SignatureC14NAlgorithm.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.core.constants.CostantiDB;
  22. import org.openspcoop2.generic_project.exception.NotFoundException;

  23. /**    
  24.  * SignatureC14NAlgorithm
  25.  *
  26.  * @author Poli Andrea (poli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public enum SignatureC14NAlgorithm {
  31.    
  32.     INCLUSIVE_C14N_10_OMITS_COMMENTS(CostantiDB.INCLUSIVE_C14N_10_OMITS_COMMENTS_URI,"Inclusive XML Canonicalization 1.0 (omits comments)"),
  33.     INCLUSIVE_C14N_10_WITH_COMMENTS(CostantiDB.INCLUSIVE_C14N_10_WITH_COMMENTS_URI,"Inclusive XML Canonicalization 1.0 (with comments)"),
  34.     INCLUSIVE_C14N_11_OMITS_COMMENTS(CostantiDB.INCLUSIVE_C14N_11_OMITS_COMMENTS_URI,"Inclusive XML Canonicalization 1.1 (omits comments)"),
  35.     INCLUSIVE_C14N_11_WITH_COMMENTS(CostantiDB.INCLUSIVE_C14N_11_WITH_COMMENTS_URI,"Inclusive XML Canonicalization 1.1 (with comments)"),
  36.     EXCLUSIVE_C14N_10_OMITS_COMMENTS(CostantiDB.EXCLUSIVE_C14N_10_OMITS_COMMENTS_URI,"Exclusive XML Canonicalization 1.0 (omits comments)"),
  37.     EXCLUSIVE_C14N_10_WITH_COMMENTS(CostantiDB.EXCLUSIVE_C14N_10_WITH_COMMENTS_URI,"Exclusive XML Canonicalization 1.0 (with comments)");
  38.    
  39.     private String uri;
  40.     private String label;
  41.     SignatureC14NAlgorithm(String uri,String label) {
  42.         this.uri = uri;
  43.         this.label = label;
  44.     }
  45.    
  46.     public String getUri() {
  47.         return this.uri;
  48.     }
  49.     public String getLabel() {
  50.         return this.label;
  51.     }
  52.    
  53.     public static SignatureC14NAlgorithm toEnumConstant(String uri){
  54.         try{
  55.             return toEnumConstant(uri,false);
  56.         }catch(NotFoundException notFound){
  57.             return null;
  58.         }
  59.     }
  60.     public static SignatureC14NAlgorithm toEnumConstant(String uri, boolean throwNotFoundException) throws NotFoundException{
  61.         SignatureC14NAlgorithm res = null;
  62.         for (SignatureC14NAlgorithm tmp : values()) {
  63.             if(tmp.getUri().equals(uri)){
  64.                 res = tmp;
  65.                 break;
  66.             }
  67.         }
  68.         if(res==null && throwNotFoundException){
  69.             throw new NotFoundException("Enum with uri ["+uri+"] not found");
  70.         }
  71.         return res;
  72.     }
  73. }