Enums.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.core.config.rs.server.api.impl;

  21. import java.util.HashMap;
  22. import java.util.Map;

  23. import org.openspcoop2.core.config.constants.TipoAutenticazione;
  24. import org.openspcoop2.core.config.constants.TipoGestioneCORS;
  25. import org.openspcoop2.core.config.rs.server.model.ContestoEnum;
  26. import org.openspcoop2.core.config.rs.server.model.FonteEnum;
  27. import org.openspcoop2.core.config.rs.server.model.FormatoRestEnum;
  28. import org.openspcoop2.core.config.rs.server.model.FormatoSoapEnum;
  29. import org.openspcoop2.core.config.rs.server.model.RateLimitingChiaveEnum;
  30. import org.openspcoop2.core.config.rs.server.model.RuoloAllegatoAPI;
  31. import org.openspcoop2.core.config.rs.server.model.RuoloAllegatoAPIImpl;
  32. import org.openspcoop2.core.config.rs.server.model.TipoApiEnum;
  33. import org.openspcoop2.core.config.rs.server.model.TipoAutenticazioneEnum;
  34. import org.openspcoop2.core.config.rs.server.model.TipoAutenticazionePrincipal;
  35. import org.openspcoop2.core.config.rs.server.model.TipoGestioneCorsEnum;
  36. import org.openspcoop2.core.config.rs.server.model.TipoSpecificaLivelloServizioEnum;
  37. import org.openspcoop2.core.config.rs.server.model.TipoSpecificaSemiformaleEnum;
  38. import org.openspcoop2.core.config.rs.server.model.TipoSpecificaSicurezzaEnum;
  39. import org.openspcoop2.core.controllo_traffico.constants.TipoFiltroApplicativo;
  40. import org.openspcoop2.core.registry.constants.CredenzialeTipo;
  41. import org.openspcoop2.core.registry.constants.FormatoSpecifica;
  42. import org.openspcoop2.core.registry.constants.ProfiloCollaborazione;
  43. import org.openspcoop2.core.registry.constants.RuoliDocumento;
  44. import org.openspcoop2.core.registry.constants.RuoloContesto;
  45. import org.openspcoop2.core.registry.constants.RuoloTipologia;
  46. import org.openspcoop2.core.registry.constants.ScopeContesto;
  47. import org.openspcoop2.core.registry.constants.TipiDocumentoLivelloServizio;
  48. import org.openspcoop2.core.registry.constants.TipiDocumentoSemiformale;
  49. import org.openspcoop2.core.registry.constants.TipiDocumentoSicurezza;
  50. import org.openspcoop2.message.constants.ServiceBinding;
  51. import org.openspcoop2.protocol.manifest.constants.InterfaceType;
  52. import org.openspcoop2.utils.service.beans.ProfiloCollaborazioneEnum;

  53. /**
  54.  * Enums
  55.  *
  56.  * @author $Author$
  57.  * @version $Rev$, $Date$
  58.  *
  59.  */
  60. public class Enums {
  61.    
  62.     public static final <E extends Enum<E>> E fromValue(Class<E> enumClass, String value) {
  63.    
  64.         E[] constants = enumClass.getEnumConstants();
  65.         if  (constants == null)
  66.             throw new IllegalArgumentException("La classe passata non รจ un'enumerazione");
  67.        
  68.         for ( E e : constants) {
  69.             if (String.valueOf(e.toString()).equals(value.trim())) {
  70.                 return e;
  71.             }
  72.         }
  73.        
  74.         return null;
  75.     }
  76.    

  77.     //RuoloAllegatoAPIImpl -> RuoiliDocumento
  78.     //public static final Map<RuoloAllegatoAPIImpl,RuoliDocumento>
  79.    
  80.     public static final Map<FonteEnum, RuoloTipologia> ruoloTipologiaFromRest = new HashMap<FonteEnum, RuoloTipologia>();
  81.     static {
  82.         Enums.ruoloTipologiaFromRest.put(FonteEnum.ESTERNA, RuoloTipologia.ESTERNO);
  83.         Enums.ruoloTipologiaFromRest.put(FonteEnum.QUALSIASI, RuoloTipologia.QUALSIASI);
  84.         Enums.ruoloTipologiaFromRest.put(FonteEnum.REGISTRO, RuoloTipologia.INTERNO);
  85.     }
  86.     public static final Map<FonteEnum, org.openspcoop2.core.config.constants.RuoloTipologia> ruoloTipologiaConfigFromRest = new HashMap<FonteEnum, org.openspcoop2.core.config.constants.RuoloTipologia>();
  87.     static {
  88.         Enums.ruoloTipologiaConfigFromRest.put(FonteEnum.ESTERNA, org.openspcoop2.core.config.constants.RuoloTipologia.ESTERNO);
  89.         Enums.ruoloTipologiaConfigFromRest.put(FonteEnum.QUALSIASI, org.openspcoop2.core.config.constants.RuoloTipologia.QUALSIASI);
  90.         Enums.ruoloTipologiaConfigFromRest.put(FonteEnum.REGISTRO, org.openspcoop2.core.config.constants.RuoloTipologia.INTERNO);
  91.     }
  92.    
  93.    
  94.     public static final Map<TipoAutenticazioneEnum, TipoAutenticazione> tipoAutenticazioneFromRest = new HashMap<TipoAutenticazioneEnum, TipoAutenticazione>();
  95.     static {
  96.         Enums.tipoAutenticazioneFromRest.put(TipoAutenticazioneEnum.DISABILITATO, TipoAutenticazione.DISABILITATO);
  97.         Enums.tipoAutenticazioneFromRest.put(TipoAutenticazioneEnum.HTTP_BASIC, TipoAutenticazione.BASIC);
  98.         Enums.tipoAutenticazioneFromRest.put(TipoAutenticazioneEnum.HTTPS, TipoAutenticazione.SSL);
  99.         Enums.tipoAutenticazioneFromRest.put(TipoAutenticazioneEnum.PRINCIPAL, TipoAutenticazione.PRINCIPAL);
  100.         Enums.tipoAutenticazioneFromRest.put(TipoAutenticazioneEnum.API_KEY, TipoAutenticazione.APIKEY);
  101.     }
  102.    
  103.     public static final Map<TipoAutenticazionePrincipal, org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal> tipoAutenticazionePrincipalFromRest = new HashMap<>();
  104.     static {
  105.         Enums.tipoAutenticazionePrincipalFromRest.put(TipoAutenticazionePrincipal.CONTAINER, org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal.CONTAINER);
  106.         Enums.tipoAutenticazionePrincipalFromRest.put(TipoAutenticazionePrincipal.FORM_BASED, org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal.FORM);
  107.         Enums.tipoAutenticazionePrincipalFromRest.put(TipoAutenticazionePrincipal.HEADER_BASED, org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal.HEADER);
  108.         Enums.tipoAutenticazionePrincipalFromRest.put(TipoAutenticazionePrincipal.IP_ADDRESS, org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal.INDIRIZZO_IP);
  109.         // TODO: aggiungere all'API
  110.         Enums.tipoAutenticazionePrincipalFromRest.put(TipoAutenticazionePrincipal.IP_ADDRESS_FORWARDED_FOR, org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal.INDIRIZZO_IP_X_FORWARDED_FOR);
  111.         Enums.tipoAutenticazionePrincipalFromRest.put(TipoAutenticazionePrincipal.URL_BASED, org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal.URL);
  112.         Enums.tipoAutenticazionePrincipalFromRest.put(TipoAutenticazionePrincipal.TOKEN, org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal.TOKEN);
  113.     }
  114.    
  115.     public static final <T1,T2> Map<T1,T2> dualizeMap(Map<T2,T1> map) {
  116.         HashMap<T1,T2> ret = new HashMap<T1,T2>();
  117.        
  118.         map.forEach( (t2, t1) -> ret.put(t1, t2));
  119.        
  120.         return ret;
  121.     }
  122.    
  123.    
  124.     public static final Map<TipoApiEnum,ServiceBinding> serviceBindingFromTipo = new HashMap<TipoApiEnum,ServiceBinding>();
  125.     static {
  126.         Enums.serviceBindingFromTipo.put(TipoApiEnum.REST, ServiceBinding.REST);
  127.         Enums.serviceBindingFromTipo.put(TipoApiEnum.SOAP, ServiceBinding.SOAP);
  128.     }
  129.    
  130.    
  131.     public static final Map<FormatoSoapEnum,FormatoSpecifica> formatoSpecificaFromSoap = new HashMap<FormatoSoapEnum,FormatoSpecifica>();
  132.     static {
  133.         Enums.formatoSpecificaFromSoap.put(FormatoSoapEnum._1, FormatoSpecifica.WSDL_11);
  134.     }
  135.    
  136.    
  137.     public static final Map<FormatoSpecifica,FormatoSoapEnum> formatoSoapFromSpecifica = new HashMap<FormatoSpecifica,FormatoSoapEnum>();
  138.     static {
  139.         Enums.formatoSpecificaFromSoap.forEach( (soapenum, fspec) -> Enums.formatoSoapFromSpecifica.put(fspec,soapenum) );
  140.     }
  141.    
  142.    
  143.     public static final Map<FormatoRestEnum,FormatoSpecifica> formatoSpecificaFromRest = new HashMap<FormatoRestEnum,FormatoSpecifica>();
  144.     static {
  145.         Enums.formatoSpecificaFromRest.put(FormatoRestEnum.OPENAPI3_0, FormatoSpecifica.OPEN_API_3);
  146.         Enums.formatoSpecificaFromRest.put(FormatoRestEnum.SWAGGER2_0, FormatoSpecifica.SWAGGER_2);
  147.         Enums.formatoSpecificaFromRest.put(FormatoRestEnum.WADL, FormatoSpecifica.WADL);
  148.     }
  149.    
  150.    
  151.     public static final Map<FormatoSpecifica,FormatoRestEnum> formatoRestFromSpecifica = new HashMap<FormatoSpecifica,FormatoRestEnum>();
  152.     static {
  153.         Enums.formatoSpecificaFromRest.forEach( (fr, fs) -> Enums.formatoRestFromSpecifica.put(fs, fr));
  154.     }
  155.        

  156.     public static final Map<FormatoSpecifica,InterfaceType> interfaceTypeFromFormatoSpecifica = new HashMap<FormatoSpecifica,InterfaceType>();
  157.     static {
  158.         Enums.interfaceTypeFromFormatoSpecifica.put(FormatoSpecifica.OPEN_API_3, InterfaceType.OPEN_API_3);
  159.         Enums.interfaceTypeFromFormatoSpecifica.put(FormatoSpecifica.SWAGGER_2, InterfaceType.SWAGGER_2);
  160.         Enums.interfaceTypeFromFormatoSpecifica.put(FormatoSpecifica.WADL, InterfaceType.WADL);
  161.         Enums.interfaceTypeFromFormatoSpecifica.put(FormatoSpecifica.WSDL_11, InterfaceType.WSDL_11);
  162.     }
  163.    
  164.    
  165.     public static final Map<RuoloAllegatoAPI,RuoliDocumento> ruoliDocumentoFromApi = new HashMap<RuoloAllegatoAPI,RuoliDocumento>();
  166.     static {
  167.         Enums.ruoliDocumentoFromApi.put(RuoloAllegatoAPI.ALLEGATO, RuoliDocumento.allegato);
  168.         Enums.ruoliDocumentoFromApi.put(RuoloAllegatoAPI.SPECIFICASEMIFORMALE, RuoliDocumento.specificaSemiformale);
  169.     }
  170.    
  171.    
  172.     public static final Map<RuoliDocumento,RuoloAllegatoAPI> ruoliApiFromDocumento = new HashMap<RuoliDocumento,RuoloAllegatoAPI>();
  173.     static {
  174.         Enums.ruoliDocumentoFromApi.forEach( (ra,rd) -> Enums.ruoliApiFromDocumento.put(rd, ra));
  175.     }
  176.    
  177.     public static final Map<RuoloAllegatoAPIImpl,RuoliDocumento> ruoliDocumentoFromApiImpl = new HashMap<RuoloAllegatoAPIImpl,RuoliDocumento>();
  178.     static {
  179.         Enums.ruoliDocumentoFromApiImpl.put(RuoloAllegatoAPIImpl.ALLEGATO, RuoliDocumento.allegato);
  180.         Enums.ruoliDocumentoFromApiImpl.put(RuoloAllegatoAPIImpl.SPECIFICASEMIFORMALE, RuoliDocumento.specificaSemiformale);
  181.         Enums.ruoliDocumentoFromApiImpl.put(RuoloAllegatoAPIImpl.SPECIFICASICUREZZA, RuoliDocumento.specificaSicurezza);
  182.         Enums.ruoliDocumentoFromApiImpl.put(RuoloAllegatoAPIImpl.SPECIFICALIVELLOSERVIZIO, RuoliDocumento.specificaLivelloServizio);
  183.     }
  184.    
  185.    
  186.    
  187.     public static final Map<RuoliDocumento,RuoloAllegatoAPIImpl> ruoliApiImplFromDocumento = new HashMap<RuoliDocumento,RuoloAllegatoAPIImpl>();
  188.     static {
  189.         Enums.ruoliDocumentoFromApiImpl.forEach( (ra,rd) -> Enums.ruoliApiImplFromDocumento.put(rd, ra));
  190.     }


  191.    
  192.     public static final Map<TipoSpecificaSemiformaleEnum,TipiDocumentoSemiformale> tipoDocumentoSemiFormaleFromSpecifica = new HashMap<TipoSpecificaSemiformaleEnum,TipiDocumentoSemiformale>();
  193.     static {
  194.         Enums.tipoDocumentoSemiFormaleFromSpecifica.put(TipoSpecificaSemiformaleEnum.HTML, TipiDocumentoSemiformale.HTML);
  195.         Enums.tipoDocumentoSemiFormaleFromSpecifica.put(TipoSpecificaSemiformaleEnum.JSON, TipiDocumentoSemiformale.JSON);
  196.         Enums.tipoDocumentoSemiFormaleFromSpecifica.put(TipoSpecificaSemiformaleEnum.LINGUAGGIO_NATURALE, TipiDocumentoSemiformale.LINGUAGGIO_NATURALE);
  197.         Enums.tipoDocumentoSemiFormaleFromSpecifica.put(TipoSpecificaSemiformaleEnum.UML, TipiDocumentoSemiformale.UML);
  198.         Enums.tipoDocumentoSemiFormaleFromSpecifica.put(TipoSpecificaSemiformaleEnum.XML, TipiDocumentoSemiformale.XML);
  199.         Enums.tipoDocumentoSemiFormaleFromSpecifica.put(TipoSpecificaSemiformaleEnum.XSD, TipiDocumentoSemiformale.XSD);
  200.         Enums.tipoDocumentoSemiFormaleFromSpecifica.put(TipoSpecificaSemiformaleEnum.YAML, TipiDocumentoSemiformale.YAML);
  201.     }
  202.    
  203.     public static final Map<TipoSpecificaLivelloServizioEnum,TipiDocumentoLivelloServizio> tipoDocumentoLivelloServizioFromSpecifica = new HashMap<TipoSpecificaLivelloServizioEnum,TipiDocumentoLivelloServizio>();
  204.     static {
  205.         Enums.tipoDocumentoLivelloServizioFromSpecifica.put(TipoSpecificaLivelloServizioEnum.WS_AGREEMENT, TipiDocumentoLivelloServizio.WSAGREEMENT);
  206.         Enums.tipoDocumentoLivelloServizioFromSpecifica.put(TipoSpecificaLivelloServizioEnum.WSLA, TipiDocumentoLivelloServizio.WSLA);
  207.     }
  208.    
  209.     public static final Map<TipoSpecificaSicurezzaEnum,TipiDocumentoSicurezza> tipoDocumentoSicurezzaFromSpecifica = new HashMap<TipoSpecificaSicurezzaEnum,TipiDocumentoSicurezza>();
  210.     static {
  211.         Enums.tipoDocumentoSicurezzaFromSpecifica.put(TipoSpecificaSicurezzaEnum.WS_POLICY, TipiDocumentoSicurezza.WSPOLICY);
  212.         Enums.tipoDocumentoSicurezzaFromSpecifica.put(TipoSpecificaSicurezzaEnum.XACML_POLICY, TipiDocumentoSicurezza.XACML_POLICY);
  213.         Enums.tipoDocumentoSicurezzaFromSpecifica.put(TipoSpecificaSicurezzaEnum.LINGUAGGIO_NATURALE, TipiDocumentoSicurezza.LINGUAGGIO_NATURALE);
  214.     }
  215.    
  216.    
  217.     public static final Map<ProfiloCollaborazioneEnum,ProfiloCollaborazione> profiloCollaborazioneFromApiEnum = new HashMap<ProfiloCollaborazioneEnum,ProfiloCollaborazione>();
  218.     static {
  219.         Enums.profiloCollaborazioneFromApiEnum.put(ProfiloCollaborazioneEnum.ASINCRONOASIMMETRICO, ProfiloCollaborazione.ASINCRONO_ASIMMETRICO);
  220.         Enums.profiloCollaborazioneFromApiEnum.put(ProfiloCollaborazioneEnum.ASINCRONOSIMMETRICO, ProfiloCollaborazione.ASINCRONO_SIMMETRICO);
  221.         Enums.profiloCollaborazioneFromApiEnum.put(ProfiloCollaborazioneEnum.ONEWAY, ProfiloCollaborazione.ONEWAY);
  222.         Enums.profiloCollaborazioneFromApiEnum.put(ProfiloCollaborazioneEnum.SINCRONO, ProfiloCollaborazione.SINCRONO);
  223.     }
  224.    
  225.    
  226.     public static final Map<ProfiloCollaborazione,ProfiloCollaborazioneEnum> profiloCollaborazioneApiFromRegistro = new HashMap<ProfiloCollaborazione,ProfiloCollaborazioneEnum>();
  227.     static {
  228.         Enums.profiloCollaborazioneFromApiEnum.forEach( (a,r) -> Enums.profiloCollaborazioneApiFromRegistro.put(r, a));
  229.     }


  230.     public static final Map<ContestoEnum,ScopeContesto> apiContestoToRegistroContesto = new HashMap<>();
  231.     static {
  232.         Enums.apiContestoToRegistroContesto.put(ContestoEnum.EROGAZIONE,ScopeContesto.PORTA_APPLICATIVA);
  233.         Enums.apiContestoToRegistroContesto.put(ContestoEnum.FRUIZIONE,ScopeContesto.PORTA_DELEGATA);
  234.         Enums.apiContestoToRegistroContesto.put(ContestoEnum.QUALSIASI,ScopeContesto.QUALSIASI);
  235.     }
  236.    
  237.    
  238.     public static final Map<ScopeContesto,ContestoEnum> registroContestoToApiContesto = new HashMap<>();
  239.     static {
  240.         Enums.apiContestoToRegistroContesto.forEach( (ac,rc) -> Enums.registroContestoToApiContesto.put(rc, ac));
  241.     }
  242.    
  243.    
  244.     public static RuoloContesto apiContestoToRegistroContesto(ContestoEnum c) {
  245.         switch(c) {
  246.         case EROGAZIONE:    return RuoloContesto.PORTA_APPLICATIVA;
  247.         case FRUIZIONE:     return RuoloContesto.PORTA_DELEGATA;
  248.         case QUALSIASI:     return RuoloContesto.QUALSIASI;
  249.         default: throw new IllegalArgumentException("Contesto di configurazione ruoli sconosciuto: " + c.toString());
  250.         }
  251.     }


  252.     public static ContestoEnum registroContestoToApiContesto(RuoloContesto c) {
  253.         switch(c) {
  254.         case PORTA_APPLICATIVA: return ContestoEnum.EROGAZIONE;
  255.         case PORTA_DELEGATA: return ContestoEnum.FRUIZIONE;
  256.         case QUALSIASI: return ContestoEnum.QUALSIASI;
  257.         default: throw new IllegalArgumentException("Contesto di registro ruoli sconosciuto: " + c.toString());
  258.         }
  259.     }


  260.     public static FonteEnum registroTipologiaToApiFonte(RuoloTipologia tipo) {
  261.         switch (tipo) {
  262.         case ESTERNO: return FonteEnum.ESTERNA;
  263.         case INTERNO: return FonteEnum.REGISTRO;
  264.         case QUALSIASI: return FonteEnum.QUALSIASI;
  265.         default: throw new IllegalArgumentException("TipologiaRuolo sconociuta: " + tipo.toString());
  266.         }
  267.     }


  268.     public static RuoloTipologia apiFonteToRegistroTipologia(FonteEnum fonte) {
  269.         switch (fonte) {
  270.         case ESTERNA: return RuoloTipologia.ESTERNO;
  271.         case REGISTRO: return RuoloTipologia.INTERNO;
  272.         case QUALSIASI: return RuoloTipologia.QUALSIASI;
  273.         default: throw new IllegalArgumentException("Fonte del ruolo sconosciuta: " + fonte.toString());
  274.         }
  275.     }
  276.    
  277.    

  278.     public static final Map<TipoGestioneCorsEnum,TipoGestioneCORS> tipoGestioneCorsFromRest = new HashMap<TipoGestioneCorsEnum,TipoGestioneCORS>();
  279.     static {
  280.         Enums.tipoGestioneCorsFromRest.put(TipoGestioneCorsEnum.APPLICATIVO, TipoGestioneCORS.TRASPARENTE);
  281.         Enums.tipoGestioneCorsFromRest.put(TipoGestioneCorsEnum.GATEWAY, TipoGestioneCORS.GATEWAY);
  282.     }
  283.    
  284.    
  285.     public static final Map<RateLimitingChiaveEnum,TipoFiltroApplicativo> tipoFiltroApplicativo = new HashMap<RateLimitingChiaveEnum,TipoFiltroApplicativo>();
  286.     static {
  287.         tipoFiltroApplicativo.put(RateLimitingChiaveEnum.CONTENT_BASED, TipoFiltroApplicativo.CONTENT_BASED);
  288.         tipoFiltroApplicativo.put(RateLimitingChiaveEnum.FORM_BASED, TipoFiltroApplicativo.FORM_BASED);
  289.         tipoFiltroApplicativo.put(RateLimitingChiaveEnum.HEADER_BASED, TipoFiltroApplicativo.HEADER_BASED);
  290.         tipoFiltroApplicativo.put(RateLimitingChiaveEnum.PLUGIN_BASED, TipoFiltroApplicativo.PLUGIN_BASED);
  291.         tipoFiltroApplicativo.put(RateLimitingChiaveEnum.SOAP_ACTION_BASED, TipoFiltroApplicativo.SOAPACTION_BASED);
  292.         tipoFiltroApplicativo.put(RateLimitingChiaveEnum.INDIRIZZO_IP, TipoFiltroApplicativo.INDIRIZZO_IP);
  293.         tipoFiltroApplicativo.put(RateLimitingChiaveEnum.INDIRIZZO_IP_FORWARDED, TipoFiltroApplicativo.INDIRIZZO_IP_FORWARDED);
  294.         tipoFiltroApplicativo.put(RateLimitingChiaveEnum.URL_BASED, TipoFiltroApplicativo.URLBASED);
  295.     }
  296.    
  297.     public static final Map<TipoFiltroApplicativo,RateLimitingChiaveEnum> rateLimitingChiaveEnum = new HashMap<TipoFiltroApplicativo,RateLimitingChiaveEnum>();
  298.     static {
  299.         tipoFiltroApplicativo.forEach( (a,r) -> rateLimitingChiaveEnum.put(r, a));
  300.     }
  301.    
  302.     public static final Map<TipoAutenticazioneEnum, CredenzialeTipo> credenzialeTipoFromTipoAutenticazione = new HashMap<TipoAutenticazioneEnum, CredenzialeTipo>();
  303.     static {
  304.         credenzialeTipoFromTipoAutenticazione.put(TipoAutenticazioneEnum.HTTP_BASIC, CredenzialeTipo.BASIC);
  305.         credenzialeTipoFromTipoAutenticazione.put(TipoAutenticazioneEnum.HTTPS,  CredenzialeTipo.SSL);
  306.         credenzialeTipoFromTipoAutenticazione.put(TipoAutenticazioneEnum.PRINCIPAL, CredenzialeTipo.PRINCIPAL);
  307.         credenzialeTipoFromTipoAutenticazione.put(TipoAutenticazioneEnum.API_KEY, CredenzialeTipo.APIKEY);
  308.     }

  309.     public static final TipoAutenticazione toTipoAutenticazione(TipoAutenticazioneEnum authn) {
  310.         if (authn == null) return null;
  311.        
  312.         switch(authn) {
  313.         case DISABILITATO: return TipoAutenticazione.DISABILITATO;
  314.         case HTTP_BASIC: return TipoAutenticazione.BASIC;
  315.         case HTTPS: return TipoAutenticazione.SSL;
  316.         case PRINCIPAL: return TipoAutenticazione.PRINCIPAL;
  317.         case API_KEY: return TipoAutenticazione.APIKEY;
  318.         default: return null;
  319.         }
  320.        
  321.     }
  322.    
  323. }