EncryptionSymmetricKeyWrapAlgorithm.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.  * EncryptionSymmetricKeyWrapAlgorithm
  24.  *
  25.  * @author Poli Andrea (poli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public enum EncryptionSymmetricKeyWrapAlgorithm {

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