EncryptionAlgorithm.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.security.message.constants;

  21. import org.openspcoop2.generic_project.exception.NotFoundException;

  22. /**    
  23.  * EncryptionAlgorithm
  24.  *
  25.  * @author Poli Andrea (poli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public enum EncryptionAlgorithm {

  30.     TRIPLEDES("http://www.w3.org/2001/04/xmlenc#tripledes-cbc"),
  31.     AES_128("http://www.w3.org/2001/04/xmlenc#aes128-cbc"),
  32.     AES_192("http://www.w3.org/2001/04/xmlenc#aes192-cbc"),
  33.     AES_256("http://www.w3.org/2001/04/xmlenc#aes256-cbc"),
  34.     AES_128_GCM("http://www.w3.org/2009/xmlenc11#aes128-gcm"),
  35.     AES_192_GCM("http://www.w3.org/2009/xmlenc11#aes192-gcm"),
  36.     AES_256_GCM("http://www.w3.org/2009/xmlenc11#aes256-gcm"),
  37.     SEED_128("http://www.w3.org/2007/05/xmldsig-more#seed128-cbc"),
  38.     CAMELLIA_128("http://www.w3.org/2001/04/xmldsig-more#camellia128-cbc"),
  39.     CAMELLIA_192("http://www.w3.org/2001/04/xmldsig-more#camellia192-cbc"),
  40.     CAMELLIA_256("http://www.w3.org/2001/04/xmldsig-more#camellia256-cbc");
  41.    
  42.     private String uri;
  43.     EncryptionAlgorithm(String uri) {
  44.         this.uri = uri;
  45.     }
  46.    
  47.     public String getUri() {
  48.         return this.uri;
  49.     }
  50.    
  51.     public static EncryptionAlgorithm toEnumConstant(String uri){
  52.         try{
  53.             return toEnumConstant(uri,false);
  54.         }catch(NotFoundException notFound){
  55.             return null;
  56.         }
  57.     }
  58.     public static EncryptionAlgorithm toEnumConstant(String uri, boolean throwNotFoundException) throws NotFoundException{
  59.         EncryptionAlgorithm res = null;
  60.         for (EncryptionAlgorithm tmp : values()) {
  61.             if(tmp.getUri().equals(uri)){
  62.                 res = tmp;
  63.                 break;
  64.             }
  65.         }
  66.         if(res==null && throwNotFoundException){
  67.             throw new NotFoundException("Enum with uri ["+uri+"] not found");
  68.         }
  69.         return res;
  70.     }
  71. }