ConnettoriHelper.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.web.ctrlstat.servlet.connettori;

  21. import java.io.File;
  22. import java.net.InetSocketAddress;
  23. import java.text.ParseException;
  24. import java.text.SimpleDateFormat;
  25. import java.util.ArrayList;
  26. import java.util.Arrays;
  27. import java.util.Date;
  28. import java.util.HashMap;
  29. import java.util.Iterator;
  30. import java.util.List;
  31. import java.util.Map;

  32. import javax.servlet.http.HttpServletRequest;
  33. import javax.servlet.http.HttpSession;

  34. import org.apache.commons.lang.StringEscapeUtils;
  35. import org.apache.commons.lang.StringUtils;
  36. import org.openspcoop2.core.commons.CoreException;
  37. import org.openspcoop2.core.commons.ISearch;
  38. import org.openspcoop2.core.config.Connettore;
  39. import org.openspcoop2.core.config.GenericProperties;
  40. import org.openspcoop2.core.config.InvocazioneServizio;
  41. import org.openspcoop2.core.config.PortaApplicativa;
  42. import org.openspcoop2.core.config.PortaApplicativaServizioApplicativo;
  43. import org.openspcoop2.core.config.PortaDelegata;
  44. import org.openspcoop2.core.config.RispostaAsincrona;
  45. import org.openspcoop2.core.config.ServizioApplicativo;
  46. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  47. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  48. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  49. import org.openspcoop2.core.constants.CostantiConnettori;
  50. import org.openspcoop2.core.constants.CostantiDB;
  51. import org.openspcoop2.core.constants.CostantiLabel;
  52. import org.openspcoop2.core.constants.TipiConnettore;
  53. import org.openspcoop2.core.constants.TransferLengthModes;
  54. import org.openspcoop2.core.id.IDSoggetto;
  55. import org.openspcoop2.core.mvc.properties.provider.InputValidationUtils;
  56. import org.openspcoop2.core.plugins.constants.TipoPlugin;
  57. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  58. import org.openspcoop2.core.registry.Fruitore;
  59. import org.openspcoop2.core.registry.Property;
  60. import org.openspcoop2.core.registry.Soggetto;
  61. import org.openspcoop2.core.registry.constants.StatiAccordo;
  62. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  63. import org.openspcoop2.message.constants.ServiceBinding;
  64. import org.openspcoop2.pdd.core.autenticazione.ApiKeyUtilities;
  65. import org.openspcoop2.pdd.core.connettori.ConnettoreFILE;
  66. import org.openspcoop2.pdd.core.connettori.ConnettoreFile_outputConfig;
  67. import org.openspcoop2.pdd.core.dynamic.DynamicHelperCostanti;
  68. import org.openspcoop2.pdd.core.dynamic.DynamicUtils;
  69. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  70. import org.openspcoop2.utils.UtilsException;
  71. import org.openspcoop2.utils.certificate.ArchiveLoader;
  72. import org.openspcoop2.utils.certificate.ArchiveType;
  73. import org.openspcoop2.utils.certificate.CertificateInfo;
  74. import org.openspcoop2.utils.certificate.KeystoreType;
  75. import org.openspcoop2.utils.certificate.PrincipalType;
  76. import org.openspcoop2.utils.crypt.PasswordGenerator;
  77. import org.openspcoop2.utils.crypt.PasswordVerifier;
  78. import org.openspcoop2.utils.transport.http.SSLConstants;
  79. import org.openspcoop2.utils.transport.http.SSLUtilities;
  80. import org.openspcoop2.web.ctrlstat.core.Connettori;
  81. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  82. import org.openspcoop2.web.ctrlstat.core.Utilities;
  83. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  84. import org.openspcoop2.web.ctrlstat.costanti.TipologiaConnettori;
  85. import org.openspcoop2.web.ctrlstat.dao.SoggettoCtrlStat;
  86. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationException;
  87. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettore;
  88. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettoreConverter;
  89. import org.openspcoop2.web.ctrlstat.plugins.servlet.ServletExtendedConnettoreUtils;
  90. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  91. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCostanti;
  92. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  93. import org.openspcoop2.web.ctrlstat.servlet.aps.erogazioni.ErogazioniCostanti;
  94. import org.openspcoop2.web.ctrlstat.servlet.archivi.ArchiviCostanti;
  95. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti;
  96. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCostanti;
  97. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeHelper;
  98. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateCostanti;
  99. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateHelper;
  100. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCostanti;
  101. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiHelper;
  102. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  103. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  104. import org.openspcoop2.web.lib.mvc.Costanti;
  105. import org.openspcoop2.web.lib.mvc.DataElement;
  106. import org.openspcoop2.web.lib.mvc.DataElementInfo;
  107. import org.openspcoop2.web.lib.mvc.DataElementType;
  108. import org.openspcoop2.web.lib.mvc.PageData;
  109. import org.openspcoop2.web.lib.mvc.Parameter;
  110. import org.openspcoop2.web.lib.mvc.ServletUtils;
  111. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  112. /**
  113.  * ConnettoriHelper
  114.  *
  115.  * @author Poli Andrea (apoli@link.it)
  116.  * @author $Author$
  117.  * @version $Rev$, $Date$
  118.  */
  119. public class ConnettoriHelper extends ConsoleHelper {
  120.    
  121.     private SimpleDateFormat sdfCredenziali = new SimpleDateFormat("dd/MM/yyyy HH:mm:SS");

  122.     public ConnettoriHelper(HttpServletRequest request, PageData pd,
  123.             HttpSession session) {
  124.         super(request, pd,  session);
  125.     }
  126.     public ConnettoriHelper(ControlStationCore core, HttpServletRequest request, PageData pd,
  127.             HttpSession session) {
  128.         super(core, request, pd,  session);
  129.     }
  130.    
  131.     public SimpleDateFormat getSdfCredenziali() {
  132.         return this.sdfCredenziali;
  133.     }

  134.     public String getAutenticazioneHttp(String autenticazioneHttp,String endpointtype, String user){
  135.         if((endpointtype!=null && (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())))){
  136.             if ( autenticazioneHttp==null && user!=null && !"".equals(user) ){
  137.                 autenticazioneHttp =  Costanti.CHECK_BOX_ENABLED;
  138.             }  
  139.         }
  140.         else{
  141.             autenticazioneHttp = null;
  142.         }
  143.         return autenticazioneHttp;
  144.     }
  145.    
  146.     public String getAutenticazioneApiKey(String autenticazioneApiKey,String endpointtype, String apiKeyValue){
  147.         if((endpointtype!=null && (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())))){
  148.             if ( autenticazioneApiKey==null && apiKeyValue!=null && !"".equals(apiKeyValue) ){
  149.                 autenticazioneApiKey =  Costanti.CHECK_BOX_ENABLED;
  150.             }  
  151.         }
  152.         else{
  153.             autenticazioneApiKey = null;
  154.         }
  155.         return autenticazioneApiKey;
  156.     }
  157.     public boolean isAutenticazioneApiKey(String apiKeyValue) {
  158.         return apiKeyValue!=null && StringUtils.isNotEmpty(apiKeyValue);
  159.     }
  160.     public boolean isAutenticazioneApiKeyUseAppId(String appIdValue) {
  161.         return appIdValue!=null && StringUtils.isNotEmpty(appIdValue);
  162.     }
  163.     public boolean isAutenticazioneApiKeyUseOAS3Names(String apiKeyHeader, String appIdHeader) {
  164.         if(apiKeyHeader==null || CostantiConnettori.DEFAULT_HEADER_API_KEY.equals(apiKeyHeader)) {
  165.             if(appIdHeader == null || StringUtils.isEmpty(appIdHeader)) {
  166.                 return true;
  167.             }
  168.             else {
  169.                 return CostantiConnettori.DEFAULT_HEADER_APP_ID.equals(appIdHeader);
  170.             }
  171.         }
  172.         return false;
  173.     }
  174.    
  175.     public void setTitleProprietaConnettoriCustom(PageData pd,TipoOperazione tipoOperazione,
  176.             String servlet, String id, String nomeprov, String tipoprov,String nomeservizio,String tiposervizio,
  177.             String myId, String correlato, String idSoggErogatore, String nomeservizioApplicativo,String idsil,String tipoAccordo,
  178.             String provider, String idPorta) throws Exception{
  179.        
  180.         if(tipoAccordo!=null) {
  181.             // nop
  182.         }
  183.        
  184.         boolean isModalitaCompleta = this.isModalitaCompleta();
  185.         Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, this.session, this.request).getValue();
  186.        
  187.         boolean accessoDaListaAPS = false;
  188.         String accessoDaAPSParametro = null;
  189.         // nell'erogazione vale sempre
  190.         /**if(gestioneErogatori) {*/
  191.         accessoDaAPSParametro = this.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS);
  192.         if(Costanti.CHECK_BOX_ENABLED_TRUE.equals(accessoDaAPSParametro)) {
  193.             accessoDaListaAPS = true;
  194.         }
  195.        
  196.         String azioneConnettoreIdPorta = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA);
  197.         if(azioneConnettoreIdPorta==null) {
  198.             azioneConnettoreIdPorta="";
  199.         }
  200.                
  201.         if (AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE.equals(servlet)) {
  202.             int idServizioInt = Integer.parseInt(id);
  203.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(idServizioInt);
  204.            
  205.             ServletUtils.setPageDataTitle(pd,
  206.                     // t1
  207.                     new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST),
  208.                     // t2
  209.                     new Parameter(
  210.                         "Connettore del servizio "+IDServizioFactory.getInstance().getUriFromAccordo(asps),
  211.                         AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE+
  212.                         "?"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID+"=" + id+
  213.                         "&"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO+"=" + nomeservizio +
  214.                         "&"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SERVIZIO+"=" + tiposervizio
  215.                         )
  216.                     );

  217.         }
  218.        
  219.         else if (AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE.equals(servlet)) {
  220.             int idServizioInt = Integer.parseInt(id);
  221.             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(idServizioInt);
  222.             int idServizioFruitoreInt = Integer.parseInt(myId);
  223.             Fruitore servFru = this.apsCore.getServizioFruitore(idServizioFruitoreInt);
  224.             String nomefru = servFru.getNome();
  225.             String tipofru = servFru.getTipo();
  226.             Long idSoggettoFruitore = servFru.getIdSoggetto();
  227.            
  228.             Integer parentPD = ServletUtils.getIntegerAttributeFromSession(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT, this.session, this.request);
  229.             if(parentPD == null)
  230.                 parentPD = PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_NONE;
  231.            
  232.             String tipologia = ServletUtils.getObjectFromSession(this.request, this.session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  233.             boolean gestioneFruitori = false;
  234.             if(tipologia!=null) {
  235.                 if(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_FRUIZIONE.equals(tipologia)) {
  236.                     gestioneFruitori = true;
  237.                 }
  238.             }
  239.            
  240.            
  241.             boolean viewOnlyConnettore = gestioneFruitori || (PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE==parentPD);
  242.            
  243.             PorteDelegateHelper porteDelegateHelper = new PorteDelegateHelper(this.request, this.pd, this.session);
  244.             List<Parameter> lstParm = porteDelegateHelper.getTitoloPD(PorteDelegateCostanti.ATTRIBUTO_PORTE_DELEGATE_PARENT_CONFIGURAZIONE, idSoggettoFruitore+"",id, myId);
  245.            
  246.             String protocollo = this.apsCore.getProtocolloAssociatoTipoServizio(asps.getTipo());
  247.             String fruitoreLabel = this.getLabelNomeSoggetto(protocollo, tipofru , nomefru);
  248.            
  249.             List<Parameter> lstParameteriASPSFruitoriChange = new ArrayList<>();
  250.            
  251.             Parameter pId = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, asps.getId()+"");
  252.             Parameter pIdSoggettoErogatore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, asps.getIdSoggetto()+"");
  253.             Parameter pIdFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_MY_ID, myId);
  254.             Parameter pConnettoreDaListaAPS = new Parameter(PorteDelegateCostanti.PARAMETRO_PORTE_DELEGATE_CONNETTORE_DA_LISTA_APS, accessoDaAPSParametro);
  255.             Parameter pIdProviderFruitore = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE, idSoggettoFruitore + "");
  256.             Parameter pAzioneConnettoreIdPorta = new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA, azioneConnettoreIdPorta);
  257.            
  258.             lstParameteriASPSFruitoriChange.add(pId);
  259.             lstParameteriASPSFruitoriChange.add(pIdFruitore);
  260.             lstParameteriASPSFruitoriChange.add(pIdSoggettoErogatore);
  261.             lstParameteriASPSFruitoriChange.add(pIdProviderFruitore);
  262.             lstParameteriASPSFruitoriChange.add(pConnettoreDaListaAPS);
  263.             lstParameteriASPSFruitoriChange.add(pAzioneConnettoreIdPorta);
  264.            
  265.             if(viewOnlyConnettore) {
  266.                
  267.                 String labelPerPorta = null;
  268.                 if(accessoDaListaAPS) {
  269.                     if(!isModalitaCompleta) {
  270.                         if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  271.                             labelPerPorta = ErogazioniCostanti.LABEL_ASPS_PORTE_DELEGATE_MODIFICA_CONNETTORE;
  272.                         } else {
  273.                             labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE_DI+ porteDelegateHelper.getLabelIdServizio(asps);
  274.                         }
  275.                     }
  276.                     else {
  277.                         labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE;
  278.                     }
  279.                 }
  280.                 else {
  281.                     PortaDelegata portaDelegata = this.porteDelegateCore.getPortaDelegata(Long.parseLong(azioneConnettoreIdPorta));
  282.                     labelPerPorta = this.porteDelegateCore.getLabelRegolaMappingFruizionePortaDelegata(
  283.                             PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE_DI,
  284.                             PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE,
  285.                             portaDelegata);
  286.                 }
  287.                
  288.                 Parameter pConnettore = new Parameter(labelPerPorta, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE, lstParameteriASPSFruitoriChange.toArray(new Parameter[lstParameteriASPSFruitoriChange.size()]));
  289.                 if(accessoDaListaAPS) {
  290.                     lstParm.set(lstParm.size()-1, pConnettore);
  291.                 }
  292.                 else {
  293.                     lstParm.add(pConnettore);
  294.                 }
  295.             }
  296.             else {
  297.                 lstParm.set(lstParm.size()-1, new Parameter(fruitoreLabel, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE, lstParameteriASPSFruitoriChange.toArray(new Parameter[lstParameteriASPSFruitoriChange.size()])));
  298.             }
  299.            
  300.             ServletUtils.setPageDataTitle(pd,lstParm);
  301.         }
  302.        
  303.         else if (ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT.equals(servlet)) {
  304.             int idInt = Integer.parseInt(idsil);
  305.             ServizioApplicativo sa = this.saCore.getServizioApplicativo(idInt);
  306.            
  307.            
  308.             Integer parentSA = ServletUtils.getIntegerAttributeFromSession(ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT, this.session, this.request);
  309.             if(parentSA == null) parentSA = ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_NONE;
  310.            
  311.             ServiziApplicativiHelper saHelper = new ServiziApplicativiHelper(this.request, this.pd, this.session);
  312.             List<Parameter> lstParm = saHelper.getTitoloSA(parentSA, provider, id, idPorta);
  313.            
  314.             String labelPerPorta = null;
  315.             if(parentSA!=null && (parentSA.intValue() == ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_CONFIGURAZIONE)) {
  316.                
  317.                 AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(id));
  318.                
  319.                 if(accessoDaListaAPS) {
  320.                     if(!isModalitaCompleta) {
  321.                         if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  322.                             labelPerPorta = ErogazioniCostanti.LABEL_ASPS_PORTE_APPLICATIVE_MODIFICA_CONNETTORE;
  323.                         } else {
  324.                             labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE_DI+
  325.                                 saHelper.getLabelIdServizio(asps);
  326.                         }
  327.                     }
  328.                     else {
  329.                         labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE;
  330.                     }
  331.                 }
  332.                 else {
  333.                     PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(Long.parseLong(idPorta));
  334.                     labelPerPorta = this.porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  335.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DI,
  336.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE,
  337.                             pa);
  338.                 }
  339.             }
  340.             else {
  341.                 /**labelPerPorta = ServiziApplicativiCostanti.LABEL_PARAMETRO_SERVIZI_APPLICATIVI_INVOCAZIONE_SERVIZIO_DI+nomeservizioApplicativo;*/
  342.                
  343.                 labelPerPorta = "Connettore del servizio applicativo (InvocazioneServizio) " + nomeservizioApplicativo+" del soggetto "+sa.getTipoSoggettoProprietario()+"/"+sa.getNomeSoggettoProprietario();
  344.             }
  345.            
  346.             if(accessoDaListaAPS) {
  347.                 lstParm.remove(lstParm.size()-1);
  348.             }
  349.            
  350.             List<Parameter> lstParameteriSAEndpoint = new ArrayList<>();
  351.             lstParameteriSAEndpoint.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, id));
  352.             lstParameteriSAEndpoint.add(new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER, provider));
  353.             lstParameteriSAEndpoint.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO, idsil));
  354.             lstParameteriSAEndpoint.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO,nomeservizioApplicativo ));
  355.             lstParameteriSAEndpoint.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_PORTA, idPorta ));
  356.             lstParameteriSAEndpoint.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_DATI_INVOCAZIONE,Costanti.CHECK_BOX_ENABLED_TRUE));
  357.             lstParameteriSAEndpoint.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS,accessoDaAPSParametro ));

  358.             lstParm.add(new Parameter(labelPerPorta,ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT, lstParameteriSAEndpoint.toArray(new Parameter[lstParameteriSAEndpoint.size()])));
  359.                    
  360.             ServletUtils.setPageDataTitle(pd,lstParm);
  361.         }
  362.        
  363.         else if (ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA.equals(servlet)) {
  364.             int idInt = Integer.parseInt(idsil);
  365.             ServizioApplicativo sa = this.saCore.getServizioApplicativo(idInt);

  366.             if(!this.isModalitaCompleta()) {
  367.                
  368.                 IDSoggetto idSoggettoProprietario = new IDSoggetto(sa.getTipoSoggettoProprietario(), sa.getNomeSoggettoProprietario());
  369.                 Soggetto soggettoProprietario = this.soggettiCore.getSoggettoRegistro(idSoggettoProprietario);
  370.                 String dominio = this.pddCore.isPddEsterna(soggettoProprietario.getPortaDominio()) ? SoggettiCostanti.SOGGETTO_DOMINIO_ESTERNO_VALUE : SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE;
  371.            
  372.                 List<Parameter> parametersServletSAChange = new ArrayList<>();
  373.                 Parameter pIdSA = new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID, sa.getId()+"");
  374.                 parametersServletSAChange.add(pIdSA);
  375.                 Parameter pIdSoggettoSA = new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER, sa.getIdSoggetto()+"");
  376.                 parametersServletSAChange.add(pIdSoggettoSA);
  377.                 if(dominio != null) {
  378.                     Parameter pDominio = new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_DOMINIO, dominio);
  379.                     parametersServletSAChange.add(pDominio);
  380.                 }
  381.                
  382.                 ServletUtils.setPageDataTitle(pd,
  383.                         // t1
  384.                         new Parameter(ServiziApplicativiCostanti.LABEL_APPLICATIVI, ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_LIST),
  385.                         // t2
  386.                         new Parameter(sa.getNome(), ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CHANGE, parametersServletSAChange.toArray(new Parameter[parametersServletSAChange.size()])),
  387.                         // t3
  388.                         new Parameter(          
  389.                             ServiziApplicativiCostanti.LABEL_RISPOSTA_ASINCRONA,
  390.                             ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA+
  391.                             "?"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO+"=" + nomeservizioApplicativo +
  392.                             "&"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO+"=" + idsil +
  393.                             "&"+ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER+"=" + provider
  394.                         )
  395.                         );
  396.             }
  397.             else {
  398.                 ServletUtils.setPageDataTitle(pd,
  399.                         // t1
  400.                         new Parameter(ServiziApplicativiCostanti.LABEL_SERVIZIO_APPLICATIVO, ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_LIST),
  401.                         // t2
  402.                         new Parameter(          
  403.                             "Connettore del servizio applicativo (RispostaAsincrona) " + nomeservizioApplicativo+" del soggetto "+sa.getTipoSoggettoProprietario()+"/"+sa.getNomeSoggettoProprietario(),
  404.                             ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA+
  405.                             "?"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO+"=" + nomeservizioApplicativo +
  406.                             "&"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO+"=" + idsil +
  407.                             "&"+ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER+"=" + provider
  408.                         )
  409.                         );
  410.             }

  411.         }
  412.        
  413.         else if (PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CHANGE.equals(servlet)) {
  414.             int idInt = Integer.parseInt(idsil);
  415.             ServizioApplicativo sa = this.saCore.getServizioApplicativo(idInt);
  416.                        
  417.             Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, this.session, this.request);
  418.             if(parentPA == null) parentPA = PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE;
  419.            
  420.             PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(this.request, this.pd, this.session);
  421.             List<Parameter> lstParam = porteApplicativeHelper.getTitoloPA(parentPA, sa.getIdSoggetto()+"", id);
  422.                        
  423.             String labelPerPorta = null;
  424.             if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  425.                
  426.                 AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(id));
  427.                
  428.                 if(accessoDaListaAPS) {
  429.                     if(!isModalitaCompleta) {
  430.                         if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  431.                             labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI;
  432.                         } else {
  433.                             labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_DI+
  434.                                     porteApplicativeHelper.getLabelIdServizio(asps);
  435.                         }
  436.                     }
  437.                     else {
  438.                         labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI;
  439.                     }
  440.                 }
  441.                 else {
  442.                     PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(Long.parseLong(idPorta));
  443.                     labelPerPorta = this.porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  444.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_DI,
  445.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI,
  446.                             pa);
  447.                 }
  448.             }
  449.             else {
  450.                 PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(Long.parseLong(idPorta));
  451.                 labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_DI+pa.getNome();
  452.             }

  453.             if(accessoDaListaAPS) {
  454.                 lstParam.remove(lstParam.size()-1);
  455.             }

  456.             PortaApplicativa pa = this.porteApplicativeCore.getPortaApplicativa(Long.parseLong(idPorta));
  457.             List<Parameter> lstParamsPA = new ArrayList<>();
  458.             lstParamsPA.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, provider));
  459.             lstParamsPA.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME, pa.getNome()));
  460.             lstParamsPA.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, idPorta));
  461.             lstParamsPA.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, id));
  462.             lstParamsPA.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_NOME_SA, sa.getNome()));
  463.             String idTabP = this.getParameter(CostantiControlStation.PARAMETRO_ID_CONN_TAB);
  464.             lstParamsPA.add(new Parameter(CostantiControlStation.PARAMETRO_ID_CONN_TAB, idTabP));
  465.             String connettoreAccessoGruppi = this.getParameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI);
  466.             String connettoreRegistro = this.getParameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO);
  467.             lstParamsPA.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS, accessoDaAPSParametro != null ? accessoDaAPSParametro : ""));
  468.             lstParamsPA.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI, connettoreAccessoGruppi));
  469.             lstParamsPA.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO, connettoreRegistro));
  470.             lstParamsPA.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_LISTA_CONNETTORI_MULTIPLI, "true"));

  471.             List<Parameter> lstParamsPAlist = new ArrayList<>();
  472.             lstParamsPAlist.addAll(lstParamsPA);
  473.             lstParamsPAlist.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CONFIGURAZIONE_DATI_GENERALI, Costanti.CHECK_BOX_ENABLED_TRUE));
  474.             lstParam.add(new Parameter(labelPerPorta,PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_LIST, lstParamsPAlist.toArray(new Parameter[lstParamsPAlist.size()])));
  475.            
  476.             // Label diversa in base all'operazione
  477.             PortaApplicativaServizioApplicativo oldPaSA = null;
  478.             for (PortaApplicativaServizioApplicativo paSATmp : pa.getServizioApplicativoList()) {
  479.                 if(paSATmp.getNome().equals(sa.getNome())) {
  480.                     oldPaSA = paSATmp;                  
  481.                 }
  482.             }
  483.             String oldNomeConnettore = porteApplicativeHelper.getLabelNomePortaApplicativaServizioApplicativo(oldPaSA);
  484.             String labelPagina = oldNomeConnettore;
  485.            
  486.             List<Parameter> lstParamsPAchange = new ArrayList<>();
  487.             lstParamsPAchange.addAll(lstParamsPA);
  488.             lstParamsPAchange.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CONFIGURAZIONE_CONNETTORE, Costanti.CHECK_BOX_ENABLED_TRUE));
  489.             lstParam.add(new Parameter(labelPagina,PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CHANGE, lstParamsPAchange.toArray(new Parameter[lstParamsPAchange.size()])));
  490.                    
  491.             ServletUtils.setPageDataTitle(pd,lstParam);
  492.         }
  493.        
  494.         else if (SoggettiCostanti.SERVLET_NAME_SOGGETTI_ENDPOINT.equals(servlet)) {
  495.             String protocollo = this.soggettiCore.getProtocolloAssociatoTipoSoggetto(tipoprov);
  496.             String label = this.getLabelNomeSoggetto(protocollo, tipoprov , nomeprov);

  497.             ServletUtils.setPageDataTitle(pd,
  498.                     // t1
  499.                     new Parameter(SoggettiCostanti.LABEL_SOGGETTI,SoggettiCostanti.SERVLET_NAME_SOGGETTI_LIST),
  500.                     // t2
  501.                     new Parameter("Connettore di " + label ,
  502.                         SoggettiCostanti.SERVLET_NAME_SOGGETTI_ENDPOINT+
  503.                         "?"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID+"=" + id +
  504.                         "&"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SOGGETTO+"=" + nomeprov +
  505.                         "&"+ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SOGGETTO+"=" + tipoprov
  506.                         )
  507.                     );

  508.         }

  509.         if(!TipoOperazione.LIST.equals(tipoOperazione)){
  510.             ServletUtils.appendPageDataTitle(pd,
  511.                     // t1
  512.                     new Parameter(
  513.                         ConnettoriCostanti.LABEL_CONNETTORE_PROPRIETA,
  514.                         ConnettoriCostanti.SERVLET_NAME_CONNETTORI_CUSTOM_PROPERTIES_LIST,
  515.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET,servlet),
  516.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID,id),
  517.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SOGGETTO,nomeprov),
  518.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SOGGETTO,tipoprov),
  519.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO,nomeservizio),
  520.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SERVIZIO,tiposervizio),
  521.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_CORRELATO,correlato),
  522.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_MY_ID,myId),
  523.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SOGGETTO_EROGATORE,idSoggErogatore),
  524.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO,nomeservizioApplicativo),
  525.                         new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO,idsil),
  526.                         new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_PORTA, idPorta ),
  527.                         new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS,accessoDaAPSParametro ),
  528.                         new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER, provider),
  529.                         new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA, azioneConnettoreIdPorta)
  530.                        
  531.                             )
  532.                     );
  533.            
  534.             ServletUtils.appendPageDataTitle(pd,
  535.                     ServletUtils.getParameterAggiungi());
  536.         } else {
  537.             ServletUtils.appendPageDataTitle(pd,
  538.                     // t1
  539.                     new Parameter(
  540.                         ConnettoriCostanti.LABEL_CONNETTORE_PROPRIETA,null));
  541.         }
  542.        
  543.        
  544.        
  545.     }

  546.    
  547.    
  548.    
  549.     public void prepareConnettorePropList(List<?> lista, ISearch ricerca,
  550.             int newMyId,String tipoAccordo)
  551.     throws Exception {
  552.         try {
  553.            
  554.             if(ricerca!=null) {
  555.                 // nop
  556.             }
  557.            
  558.             String servlet = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET);
  559.             String id = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID);
  560.             String nomeprov = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SOGGETTO);
  561.             String tipoprov = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SOGGETTO);
  562.             String nomeservizio = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO);
  563.             String tiposervizio = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SERVIZIO);
  564.             String myId = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_MY_ID);
  565.             if (newMyId != 0)
  566.                 myId = ""+newMyId;
  567.             String correlato = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_CORRELATO);
  568.             String idSoggErogatore = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SOGGETTO_EROGATORE);
  569.             String nomeservizioApplicativo = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO);
  570.             String idsil = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO);
  571.             String provider = this.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER);
  572.             String idPorta = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_PORTA);
  573.             if(idPorta == null)
  574.                 idPorta = "";
  575.            
  576.             String accessoDaAPSParametro = this.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS);
  577.             if(accessoDaAPSParametro == null)
  578.                 accessoDaAPSParametro = "";
  579.            
  580.             String azioneConnettoreIdPorta = this.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA);
  581.             if(azioneConnettoreIdPorta == null)
  582.                 azioneConnettoreIdPorta = "";
  583.            
  584.             ServletUtils.addListElementIntoSession(this.request, this.session, ConnettoriCostanti.OBJECT_NAME_CONNETTORI_CUSTOM_PROPERTIES,
  585.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET, servlet),
  586.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID, id),
  587.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SOGGETTO, nomeprov),
  588.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SOGGETTO, tipoprov),
  589.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO, nomeservizio),
  590.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SERVIZIO, tiposervizio),
  591.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_MY_ID, myId),
  592.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_CORRELATO, correlato),
  593.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SOGGETTO_EROGATORE, idSoggErogatore),
  594.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO, nomeservizioApplicativo),
  595.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO, idsil),
  596.                     new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER, provider),
  597.                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_PORTA, idPorta),
  598.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS, accessoDaAPSParametro),
  599.                     new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA, azioneConnettoreIdPorta));
  600.            
  601.             this.pd.setNumEntries(lista!=null ? lista.size() : 0);

  602.             // setto la barra del titolo
  603.             setTitleProprietaConnettoriCustom(this.pd, TipoOperazione.LIST, servlet, id, nomeprov, tipoprov, nomeservizio, tiposervizio,
  604.                     myId, correlato, idSoggErogatore, nomeservizioApplicativo, idsil, tipoAccordo, provider,idPorta);
  605.            
  606.             ServletUtils.disabledPageDataSearch(this.pd);
  607.            

  608.             // setto le label delle colonne
  609.             String[] labels = { ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_CUSTOM_NOME, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_CUSTOM_VALORE };
  610.             this.pd.setLabels(labels);

  611.             // preparo i dati
  612.             List<List<DataElement>> dati = new ArrayList<>();

  613.             if (lista != null) {
  614.                 Iterator<?> it = lista.iterator();

  615.                 while (it.hasNext()) {
  616.                     String nome = "";
  617.                     String valore = "";
  618.                     if (servlet.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT) ||
  619.                             servlet.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA) ||
  620.                             servlet.equals(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CHANGE)) {
  621.                         org.openspcoop2.core.config.Property cp =
  622.                             (org.openspcoop2.core.config.Property) it.next();
  623.                         nome = cp.getNome();
  624.                         valore = cp.getValore();
  625.                     } else {
  626.                         Property cp = (Property) it.next();
  627.                         nome = cp.getNome();
  628.                         valore = cp.getValore();
  629.                     }

  630.                     List<DataElement> e = new ArrayList<>();

  631.                     DataElement de = new DataElement();
  632.                     de.setValue(nome);
  633.                     de.setIdToRemove(nome);
  634.                     e.add(de);

  635.                     de = new DataElement();
  636.                     de.setValue(valore);
  637.                     e.add(de);

  638.                     dati.add(e);
  639.                 }
  640.             }

  641.             // inserisco i campi hidden
  642.             Map<String, String> hidden = new HashMap<>();
  643.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET, servlet);
  644.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID, id != null ? id : "");
  645.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SOGGETTO, nomeprov != null ? nomeprov : "");
  646.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SOGGETTO, tipoprov != null ? tipoprov : "");
  647.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO, nomeservizio != null ? nomeservizio : "");
  648.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SERVIZIO, tiposervizio != null ? tiposervizio : "");
  649.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_MY_ID, myId != null ? myId : "");
  650.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_CORRELATO, correlato != null ? correlato : "");
  651.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SOGGETTO_EROGATORE, idSoggErogatore != null ? idSoggErogatore : "");
  652.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO, nomeservizioApplicativo != null ? nomeservizioApplicativo : "");
  653.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO, idsil != null ? idsil : "");
  654.             hidden.put(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_PORTA, idPorta != null ? idPorta : "");
  655.             hidden.put(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS, accessoDaAPSParametro != null ? accessoDaAPSParametro : "");
  656.             hidden.put(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA, azioneConnettoreIdPorta != null ? azioneConnettoreIdPorta : "");

  657.             this.pd.setHidden(hidden);

  658.             this.pd.setDati(dati);
  659.             this.pd.setAddButton(true);

  660.         } catch (Exception e) {
  661.             this.logError("prepareConnettorePropList failed: " + e.getMessage(), e);
  662.             throw new CoreException(e);
  663.         }
  664.     }
  665.    
  666.     public List<DataElement> addEndPointToDati(List<DataElement> dati, ServiceBinding serviceBinding, String connettoreDebug,
  667.             String endpointtype, String autenticazioneHttp, String prefix, String url, String nome, String tipo,
  668.             String user, String password, String initcont, String urlpgk,
  669.             String provurl, String connfact, String sendas, String objectName, TipoOperazione tipoOperazione,
  670.             String httpsurl, String httpstipologia, boolean httpshostverify,
  671.             boolean httpsTrustVerifyCert, String httpspath, String httpstipo, String httpspwd,
  672.             String httpsalgoritmo, boolean httpsstato, String httpskeystore,
  673.             String httpspwdprivatekeytrust, String httpspathkey,
  674.             String httpstipokey, String httpspwdkey,
  675.             String httpspwdprivatekey, String httpsalgoritmokey,
  676.             String httpsKeyAlias, String httpsTrustStoreCRLs, String httpsTrustStoreOCSPPolicy, String httpsKeyStoreBYOKPolicy,
  677.             String tipoconn, String servletChiamante, String elem1, String elem2, String elem3,
  678.             String elem4, String elem5, String elem6, String elem7, String elem8,
  679.             boolean showSectionTitle,
  680.             Boolean isConnettoreCustomUltimaImmagineSalvata,
  681.             String proxyEnabled, String proxyHost, String proxyPort, String proxyUsername, String proxyPassword,
  682.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  683.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  684.             String requestOutputFileName, String requestOutputFileNamePermissions, String requestOutputFileNameHeaders, String requestOutputFileNameHeadersPermissions,
  685.             String requestOutputParentDirCreateIfNotExists,String requestOutputOverwriteIfExists,
  686.             String responseInputMode, String responseInputFileName, String responseInputFileNameHeaders, String responseInputDeleteAfterRead, String responseInputWaitTime,
  687.             boolean autenticazioneToken, String tokenPolicy, boolean forcePDND, boolean forceOAuth,
  688.             List<ExtendedConnettore> listExtendedConnettore, boolean forceEnabled,
  689.             String protocollo, boolean forceHttps, boolean forceHttpsClient,
  690.             boolean visualizzaSezioneSAServer, boolean servizioApplicativoServerEnabled, String servizioApplicativoServer, String[] listaSAServer,
  691.             String autenticazioneApiKey, boolean useOAS3Names, boolean useAppId, String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue,
  692.             ConnettoreStatusParams connettoreStatusParams,
  693.             boolean postBackViaPost) throws Exception {
  694.         return addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp, prefix, url, nome, tipo, user,
  695.                 password, initcont, urlpgk, provurl, connfact, sendas,
  696.                 objectName,tipoOperazione, httpsurl, httpstipologia, httpshostverify,
  697.                 httpsTrustVerifyCert, httpspath, httpstipo, httpspwd, httpsalgoritmo, httpsstato,
  698.                 httpskeystore, httpspwdprivatekeytrust, httpspathkey,
  699.                 httpstipokey, httpspwdkey,
  700.                 httpspwdprivatekey, httpsalgoritmokey,
  701.                 httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  702.                 tipoconn, servletChiamante, elem1, elem2, elem3,
  703.                 elem4, elem5, elem6, elem7, elem8, null, showSectionTitle,
  704.                 isConnettoreCustomUltimaImmagineSalvata,
  705.                 proxyEnabled, proxyHost, proxyPort, proxyUsername, proxyPassword,
  706.                 tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  707.                 opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  708.                 requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  709.                 requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  710.                 responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  711.                 autenticazioneToken, tokenPolicy, forcePDND, forceOAuth,
  712.                 listExtendedConnettore, forceEnabled,
  713.                 protocollo, forceHttps, forceHttpsClient,visualizzaSezioneSAServer, servizioApplicativoServerEnabled, servizioApplicativoServer, listaSAServer,
  714.                 autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  715.                 connettoreStatusParams,
  716.                 postBackViaPost);
  717.     }

  718.     // Controlla i dati del connettore custom
  719.     boolean connettorePropCheckData() throws CoreException {
  720.         try {
  721.             String servlet = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET);
  722.             String id = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID);
  723.             String myId = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_MY_ID);
  724.             String idsil = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO);

  725.             String nome = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME);
  726.             String valore = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_VALORE);

  727.             // Campi obbligatori
  728.             if (nome.equals("") || valore.equals("")) {
  729.                 String tmpElenco = "";
  730.                 if (nome.equals("")) {
  731.                     tmpElenco = ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_CUSTOM_NOME;
  732.                 }
  733.                 if (valore.equals("")) {
  734.                     if (tmpElenco.equals("")) {
  735.                         tmpElenco = ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_CUSTOM_VALORE;
  736.                     } else {
  737.                         tmpElenco = tmpElenco + ", "+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_CUSTOM_VALORE;
  738.                     }
  739.                 }
  740.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare: " + tmpElenco);
  741.                 return false;
  742.             }

  743.             // Controllo che non ci siano spazi nei campi di testo
  744.             if ((nome.indexOf(" ") != -1) || (valore.indexOf(" ") != -1)) {
  745.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  746.                 return false;
  747.             }
  748.            
  749.             // Lunghezza
  750.             if(this.checkLength255(nome, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_CUSTOM_NOME)==false) {
  751.                 return false;
  752.             }
  753.             if(this.checkLength4000(valore, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_CUSTOM_VALORE)==false) {
  754.                 return false;
  755.             }

  756.             // Controllo che la property non sia gia' stata
  757.             // registrata
  758.             boolean giaRegistratoProprietaNormale = false;
  759.             boolean giaRegistratoProprietaDebug = false;
  760.             if (servlet.equals(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE)) {
  761.                 AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Long.parseLong(id));
  762.                 org.openspcoop2.core.registry.Connettore connettore = asps.getConfigurazioneServizio().getConnettore();
  763.                 for (int j = 0; j < connettore.sizePropertyList(); j++) {
  764.                     Property tmpProp = connettore.getProperty(j);
  765.                     if (tmpProp.getNome().equals(nome)) {
  766.                         if(CostantiDB.CONNETTORE_DEBUG.equals(nome)){
  767.                             giaRegistratoProprietaDebug = true;
  768.                         }else{
  769.                             giaRegistratoProprietaNormale = true;
  770.                         }
  771.                         break;
  772.                     }
  773.                 }
  774.             }
  775.             if (servlet.equals(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE)) {
  776.                 int idServizioFruitoreInt = Integer.parseInt(myId);
  777.                 Fruitore servFru = this.apsCore.getServizioFruitore(idServizioFruitoreInt);
  778.                 org.openspcoop2.core.registry.Connettore connettore = servFru.getConnettore();
  779.                 for (int j = 0; j < connettore.sizePropertyList(); j++) {
  780.                     Property tmpProp = connettore.getProperty(j);
  781.                     if (tmpProp.getNome().equals(nome)) {
  782.                         if(CostantiDB.CONNETTORE_DEBUG.equals(nome)){
  783.                             giaRegistratoProprietaDebug = true;
  784.                         }else{
  785.                             giaRegistratoProprietaNormale = true;
  786.                         }
  787.                         break;
  788.                     }
  789.                 }
  790.             }
  791.             if (servlet.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT)) {
  792.                 int idSilInt = Integer.parseInt(idsil);
  793.                 ServizioApplicativo sa = this.saCore.getServizioApplicativo(idSilInt);
  794.                 InvocazioneServizio is = sa.getInvocazioneServizio();
  795.                 org.openspcoop2.core.config.Connettore connettore = is.getConnettore();
  796.                 for (int j = 0; j < connettore.sizePropertyList(); j++) {
  797.                     org.openspcoop2.core.config.Property tmpProp = connettore.getProperty(j);
  798.                     if (tmpProp.getNome().equals(nome)) {
  799.                         if(CostantiDB.CONNETTORE_DEBUG.equals(nome)){
  800.                             giaRegistratoProprietaDebug = true;
  801.                         }else{
  802.                             giaRegistratoProprietaNormale = true;
  803.                         }
  804.                         break;
  805.                     }
  806.                 }
  807.             }
  808.             if (servlet.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA)) {
  809.                 int idSilInt = Integer.parseInt(idsil);
  810.                 ServizioApplicativo sa = this.saCore.getServizioApplicativo(idSilInt);
  811.                 RispostaAsincrona ra = sa.getRispostaAsincrona();
  812.                 org.openspcoop2.core.config.Connettore connettore = ra.getConnettore();
  813.                 for (int j = 0; j < connettore.sizePropertyList(); j++) {
  814.                     org.openspcoop2.core.config.Property tmpProp = connettore.getProperty(j);
  815.                     if (tmpProp.getNome().equals(nome)) {
  816.                         if(CostantiDB.CONNETTORE_DEBUG.equals(nome)){
  817.                             giaRegistratoProprietaDebug = true;
  818.                         }else{
  819.                             giaRegistratoProprietaNormale = true;
  820.                         }
  821.                         break;
  822.                     }
  823.                 }
  824.             }
  825.             if (servlet.equals(SoggettiCostanti.SERVLET_NAME_SOGGETTI_ENDPOINT)) {
  826.                 int idInt = Integer.parseInt(id);
  827.                 SoggettoCtrlStat scs = this.soggettiCore.getSoggettoCtrlStat(idInt);
  828.                 Soggetto ss = scs.getSoggettoReg();
  829.                 org.openspcoop2.core.registry.Connettore connettore = ss.getConnettore();
  830.                 for (int j = 0; j < connettore.sizePropertyList(); j++) {
  831.                     Property tmpProp = connettore.getProperty(j);
  832.                     if (tmpProp.getNome().equals(nome)) {
  833.                         if(CostantiDB.CONNETTORE_DEBUG.equals(nome)){
  834.                             giaRegistratoProprietaDebug = true;
  835.                         }else{
  836.                             giaRegistratoProprietaNormale = true;
  837.                         }
  838.                         break;
  839.                     }
  840.                 }
  841.             }

  842.             if (giaRegistratoProprietaNormale) {
  843.                 this.pd.setMessage("La propriet&agrave; '" + nome + "' &egrave; gi&agrave; stata associata al connettore");
  844.                 return false;
  845.             }
  846.             if (giaRegistratoProprietaDebug) {
  847.                 this.pd.setMessage("La keyword '" + nome + "' non &egrave; associabile come nome ad una propriet&agrave; del connettore");
  848.                 return false;
  849.             }

  850.             return true;
  851.         } catch (Exception e) {
  852.             this.logError("connettorePropCheckData failed: " + e.getMessage(), e);
  853.             throw new CoreException(e);
  854.         }
  855.     }

  856.     public String readEndPointType() throws CoreException{
  857.         String endpointtype = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE);
  858.         String endpointtypeCheck = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_CHECK);
  859.         String endpointtypeSsl = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTPS);
  860.         return this.readEndPointType(endpointtype, endpointtypeCheck, endpointtypeSsl);
  861.     }
  862.     public String readEndPointType(String endpointtype,String endpointtypeCheck,String endpointtypeSsl){
  863.                
  864.         TipologiaConnettori tipologiaConnettori = null;
  865.         try {
  866.             tipologiaConnettori = Utilities.getTipologiaConnettori(this.core);
  867.         } catch (Exception e) {
  868.             // default
  869.             tipologiaConnettori = TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL;
  870.         }
  871.        
  872.         if(endpointtypeCheck!=null && !"".equals(endpointtypeCheck) &&
  873.             TipologiaConnettori.TIPOLOGIA_CONNETTORI_HTTP.equals(tipologiaConnettori)) {
  874.             if(ServletUtils.isCheckBoxEnabled(endpointtypeCheck)){
  875.                 if(ServletUtils.isCheckBoxEnabled(endpointtypeSsl)){
  876.                     endpointtype = TipiConnettore.HTTPS.toString();
  877.                 }
  878.                 else{
  879.                     endpointtype = TipiConnettore.HTTP.toString();
  880.                 }
  881.             }
  882.             else{
  883.                 endpointtype = TipiConnettore.DISABILITATO.toString();
  884.             }
  885.         }
  886.         return endpointtype;
  887.     }
  888.    
  889.     public List<DataElement> addOpzioniAvanzateHttpToDati(List<DataElement> dati,
  890.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  891.             boolean postBackViaPost){
  892.        
  893.         boolean showOpzioniAvanzate = this.isModalitaAvanzata()
  894.                 && ServletUtils.isCheckBoxEnabled(opzioniAvanzate);
  895.        
  896.         if(showOpzioniAvanzate){
  897.             DataElement de = new DataElement();
  898.             de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_OPZIONI_AVANZATE);
  899.             de.setType(DataElementType.TITLE);
  900.             dati.add(de);
  901.         }
  902.         else{
  903.             if(this.isModalitaAvanzata() &&
  904.                     !ServletUtils.isCheckBoxEnabled(opzioniAvanzate)){
  905.                 transferMode=null;
  906.                 transferModeChunkSize=null;
  907.                 redirectMode=null;
  908.                 redirectMaxHop=null;
  909.             }
  910.         }
  911.        
  912.         // DataTransferMode
  913.         DataElement de = new DataElement();
  914.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  915.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  916.         if(showOpzioniAvanzate){
  917.             if(transferMode==null || "".equals(transferMode)){
  918.                 transferMode = ConnettoriCostanti.DEFAULT_TIPO_DATA_TRANSFER;
  919.             }
  920.             de.setType(DataElementType.SELECT);
  921.             de.setValues(ConnettoriCostanti.TIPI_DATA_TRANSFER);
  922.             if(postBackViaPost) {
  923.                 de.setPostBack_viaPOST(true);
  924.             }
  925.             else {
  926.                 de.setPostBack(true);
  927.             }
  928.             de.setSelected(transferMode);
  929.             de.setSize(this.getSize());
  930.         }
  931.         else{
  932.             de.setType(DataElementType.HIDDEN);
  933.         }
  934.         de.setValue(transferMode);
  935.         dati.add(de);
  936.        
  937.         de = new DataElement();
  938.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  939.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  940.         if(showOpzioniAvanzate && TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode)){
  941.             de.setType(DataElementType.TEXT_EDIT);
  942.             de.setSize(this.getSize());
  943.         }
  944.         else{
  945.             de.setType(DataElementType.HIDDEN);
  946.         }
  947.         de.setValue(transferModeChunkSize);
  948.         dati.add(de);
  949.        
  950.        
  951.         // Redirect
  952.         de = new DataElement();
  953.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  954.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  955.         if(showOpzioniAvanzate){
  956.             if(redirectMode==null || "".equals(redirectMode)){
  957.                 redirectMode = ConnettoriCostanti.DEFAULT_GESTIONE_REDIRECT;
  958.             }
  959.             de.setType(DataElementType.SELECT);
  960.             de.setValues(ConnettoriCostanti.TIPI_GESTIONE_REDIRECT);
  961.             if(postBackViaPost) {
  962.                 de.setPostBack_viaPOST(true);
  963.             }
  964.             else {
  965.                 de.setPostBack(true);
  966.             }
  967.             de.setSelected(redirectMode);
  968.             de.setSize(this.getSize());
  969.         }
  970.         else{
  971.             de.setType(DataElementType.HIDDEN);
  972.         }
  973.         de.setValue(redirectMode);
  974.         dati.add(de);
  975.        
  976.         de = new DataElement();
  977.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  978.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  979.         if(showOpzioniAvanzate && CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode)){
  980.             de.setType(DataElementType.TEXT_EDIT);
  981.             de.setSize(this.getSize());
  982.         }
  983.         else{
  984.             de.setType(DataElementType.HIDDEN);
  985.         }
  986.         de.setValue(redirectMaxHop);
  987.         dati.add(de);
  988.        
  989.         return dati;
  990.     }
  991.    
  992.     public List<DataElement> addOpzioniAvanzateHttpToDatiAsHidden(List<DataElement> dati,
  993.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop){
  994.        
  995.         boolean showOpzioniAvanzate = this.isModalitaAvanzata()
  996.                 && ServletUtils.isCheckBoxEnabled(opzioniAvanzate);
  997.        
  998.         if(!showOpzioniAvanzate &&
  999.             this.isModalitaAvanzata() &&
  1000.             !ServletUtils.isCheckBoxEnabled(opzioniAvanzate)){
  1001.             transferMode=null;
  1002.             transferModeChunkSize=null;
  1003.             redirectMode=null;
  1004.             redirectMaxHop=null;
  1005.         }
  1006.        
  1007.         // DataTransferMode
  1008.         DataElement de = new DataElement();
  1009.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  1010.         de.setType(DataElementType.HIDDEN);
  1011.         de.setValue(transferMode);
  1012.         dati.add(de);
  1013.        
  1014.         de = new DataElement();
  1015.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  1016.         de.setType(DataElementType.HIDDEN);
  1017.         de.setValue(transferModeChunkSize);
  1018.         dati.add(de);
  1019.        
  1020.        
  1021.         // Redirect
  1022.         de = new DataElement();
  1023.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  1024.         de.setType(DataElementType.HIDDEN);
  1025.         de.setValue(redirectMode);
  1026.         dati.add(de);
  1027.        
  1028.         de = new DataElement();
  1029.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  1030.         de.setType(DataElementType.HIDDEN);
  1031.         de.setValue(redirectMaxHop);
  1032.         dati.add(de);
  1033.        
  1034.         return dati;
  1035.     }
  1036.    
  1037.     public List<DataElement> addTokenPolicyToDatiAsHidden(List<DataElement> dati, boolean autenticazioneToken, String tokenPolicy){
  1038.         DataElement de = new DataElement();
  1039.         de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_BEARER);
  1040.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  1041.         de.setType(DataElementType.HIDDEN);
  1042.         de.setValue(autenticazioneToken? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED);
  1043.         dati.add(de);
  1044.        
  1045.         // Token Autenticazione
  1046.         if (autenticazioneToken) {
  1047.             de = new DataElement();
  1048.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TOKEN_POLICY);
  1049.             de.setType(DataElementType.HIDDEN);
  1050.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY);
  1051.             de.setValue(tokenPolicy);
  1052.             dati.add(de);
  1053.         }
  1054.        
  1055.         return dati;
  1056.     }
  1057.    
  1058.     public List<DataElement> addProxyToDati(List<DataElement> dati,
  1059.             String proxyHostname, String proxyPort, String proxyUsername, String proxyPassword,
  1060.             boolean postBackViaPost) throws UtilsException{
  1061.        
  1062.         if(postBackViaPost) {
  1063.             // unused
  1064.         }
  1065.        
  1066.         DataElement de = new DataElement();
  1067.         de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_PROXY);
  1068.         de.setType(DataElementType.TITLE);
  1069.         dati.add(de);
  1070.        
  1071.         de = new DataElement();
  1072.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  1073.         de.setValue(proxyHostname);
  1074.         de.setType(DataElementType.TEXT_EDIT);
  1075.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  1076.         de.setSize(this.getSize());
  1077.         de.setRequired(true);
  1078.         dati.add(de);
  1079.        
  1080.         de = new DataElement();
  1081.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_PORT);
  1082.         de.setValue(proxyPort);
  1083.         de.setType(DataElementType.TEXT_EDIT);
  1084.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PORT);
  1085.         de.setSize(this.getSize());
  1086.         de.setRequired(true);
  1087.         dati.add(de);
  1088.        
  1089.         de = new DataElement();
  1090.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_USERNAME);
  1091.         de.setValue(StringEscapeUtils.escapeHtml(proxyUsername));
  1092.         de.setType(DataElementType.TEXT_EDIT);
  1093.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_USERNAME);
  1094.         de.setSize(this.getSize());
  1095.         de.setRequired(false);
  1096.         dati.add(de);
  1097.        
  1098.         de = new DataElement();
  1099.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_PASSWORD);
  1100.         de.setType(DataElementType.TEXT_EDIT);
  1101.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PASSWORD);
  1102.         this.core.getLockUtilities().lock(de, proxyPassword);
  1103.         de.setSize(this.getSize());
  1104.         de.setRequired(false);
  1105.         dati.add(de);
  1106.        
  1107.         return dati;
  1108.     }
  1109.    
  1110.     public List<DataElement> addProxyToDatiAsHidden(List<DataElement> dati,
  1111.             String proxyEnabled, String proxyHostname, String proxyPort, String proxyUsername, String proxyPassword) throws UtilsException{
  1112.        
  1113.         DataElement de = new DataElement();
  1114.         de.setValue(proxyEnabled);
  1115.         de.setType(DataElementType.HIDDEN);
  1116.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  1117.         dati.add(de);
  1118.        
  1119.         de = new DataElement();
  1120.         de.setValue(proxyHostname);
  1121.         de.setType(DataElementType.HIDDEN);
  1122.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  1123.         dati.add(de);
  1124.        
  1125.         de = new DataElement();
  1126.         de.setValue(proxyPort);
  1127.         de.setType(DataElementType.HIDDEN);
  1128.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PORT);
  1129.         dati.add(de);
  1130.        
  1131.         de = new DataElement();
  1132.         de.setValue(StringEscapeUtils.escapeHtml(proxyUsername));
  1133.         de.setType(DataElementType.HIDDEN);
  1134.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_USERNAME);
  1135.         dati.add(de);
  1136.        
  1137.         de = new DataElement();
  1138.         de.setType(DataElementType.HIDDEN);
  1139.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PASSWORD);
  1140.         this.core.getLockUtilities().lockHidden(de, proxyPassword);
  1141.         dati.add(de);
  1142.        
  1143.         return dati;
  1144.     }
  1145.    

  1146.    
  1147.     public List<DataElement> addTokenPolicy(List<DataElement> dati, String tokenPolicy, boolean forcePDND, boolean forceOAuth, TipoOperazione tipoOperazione,
  1148.             boolean postBackViaPost) throws DriverConfigurazioneException{
  1149.    
  1150.         List<String> policyFiltered = getTokenPolicyNegoziazione(forcePDND, forceOAuth,
  1151.                 true,
  1152.                 tokenPolicy, tipoOperazione);
  1153.         if(!policyFiltered.contains(tokenPolicy)) {
  1154.             tokenPolicy = null;
  1155.         }
  1156.            
  1157.         DataElement de = new DataElement();
  1158.         de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_BEARER);
  1159.         de.setType(DataElementType.TITLE);
  1160.         dati.add(de);
  1161.        
  1162.         de = new DataElement();
  1163.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TOKEN_POLICY);
  1164.         de.setType(DataElementType.SELECT);
  1165.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY);
  1166.         de.setValues(policyFiltered);
  1167.         de.setLabels(policyFiltered);
  1168.         de.setSelected(tokenPolicy);
  1169.         de.setRequired(true);
  1170.         if(postBackViaPost) {
  1171.             de.setPostBack_viaPOST(true);
  1172.         }
  1173.         else {
  1174.             de.setPostBack(true);
  1175.         }
  1176.         dati.add(de);
  1177.        
  1178.         return dati;
  1179.     }
  1180.    
  1181.     public List<DataElement> addApiKeyToDati(List<DataElement> dati, boolean useOAS3Names, boolean useAppId,
  1182.             String apiKeyHeader, String apiKeyValue,
  1183.             String appIdHeader, String appIdValue,
  1184.             boolean postBackViaPost) throws UtilsException {
  1185.                
  1186.         DataElement de = new DataElement();
  1187.         de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_API_KEY);
  1188.         de.setType(DataElementType.TITLE);
  1189.         dati.add(de);
  1190.        
  1191.         boolean useSubSections = !useOAS3Names && useAppId;
  1192.        
  1193.         // useOAS3Names            
  1194.         de = new DataElement();
  1195.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  1196.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  1197.         de.setType(DataElementType.CHECKBOX);
  1198.         de.setSelected(useOAS3Names);
  1199.         if(postBackViaPost) {
  1200.             de.setPostBack_viaPOST(true);
  1201.         }
  1202.         else {
  1203.             de.setPostBack(true);
  1204.         }
  1205.         dati.add(de);
  1206.        
  1207.         // appId                
  1208.         de = new DataElement();
  1209.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  1210.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  1211.         de.setType(DataElementType.CHECKBOX);
  1212.         de.setSelected(useAppId);
  1213.         if(postBackViaPost) {
  1214.             de.setPostBack_viaPOST(true);
  1215.         }
  1216.         else {
  1217.             de.setPostBack(true);
  1218.         }
  1219.         dati.add(de);
  1220.        

  1221.         // API KEY
  1222.         if(useSubSections) {
  1223.             de = new DataElement();
  1224.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_VALUE);
  1225.             de.setType(DataElementType.SUBTITLE);
  1226.             dati.add(de);
  1227.         }
  1228.         if(!useOAS3Names) {
  1229.             de = new DataElement();
  1230.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_HEADER);
  1231.             de.setType(DataElementType.TEXT_EDIT);
  1232.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_HEADER);
  1233.             de.setValue(apiKeyHeader);
  1234.             de.setRequired(true);
  1235.             dati.add(de);
  1236.         }
  1237.         de = new DataElement();
  1238.         de.setLabel(!useSubSections ? ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_VALUE : ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_NON_STANDARD_VALUE);
  1239.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_VALUE);
  1240.         this.core.getLockUtilities().lock(de, apiKeyValue);
  1241.         de.setRequired(true);
  1242.         dati.add(de);
  1243.        
  1244.        
  1245.        
  1246.         // APP ID
  1247.         if(useSubSections) {
  1248.             de = new DataElement();
  1249.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  1250.             de.setType(DataElementType.SUBTITLE);
  1251.             dati.add(de);
  1252.         }
  1253.         if(!useOAS3Names && useAppId) {
  1254.             de = new DataElement();
  1255.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  1256.             de.setType(DataElementType.TEXT_EDIT);
  1257.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  1258.             de.setValue(appIdHeader);
  1259.             de.setRequired(true);
  1260.             dati.add(de);
  1261.         }
  1262.         if(useAppId) {
  1263.             de = new DataElement();
  1264.             de.setLabel(!useSubSections ? ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE : ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_NON_STANDARD_VALUE);
  1265.             de.setType(DataElementType.TEXT_EDIT);
  1266.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  1267.             de.setValue(appIdValue);
  1268.             de.setRequired(true);
  1269.             dati.add(de);
  1270.         }
  1271.        
  1272.        
  1273.         return dati;
  1274.     }
  1275.     public List<DataElement> addApiKeyToDatiHidden(List<DataElement> dati, boolean useOAS3Names, boolean useAppId,
  1276.             String apiKeyHeader, String apiKeyValue,
  1277.             String appIdHeader, String appIdValue) throws UtilsException {
  1278.                
  1279.         // useOAS3Names            
  1280.         DataElement de = new DataElement();
  1281.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  1282.         de.setType(DataElementType.HIDDEN);
  1283.         de.setValue(useOAS3Names+"");
  1284.         dati.add(de);
  1285.        
  1286.         // appId                
  1287.         de = new DataElement();
  1288.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  1289.         de.setType(DataElementType.HIDDEN);
  1290.         de.setValue(useAppId+"");
  1291.         dati.add(de);
  1292.        
  1293.         // API KEY
  1294.         if(!useOAS3Names) {
  1295.             de = new DataElement();
  1296.             de.setType(DataElementType.HIDDEN);
  1297.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_HEADER);
  1298.             de.setValue(apiKeyHeader);
  1299.             dati.add(de);
  1300.         }
  1301.         de = new DataElement();
  1302.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_VALUE);
  1303.         this.core.getLockUtilities().lockHidden(de, apiKeyValue);
  1304.         dati.add(de);
  1305.        
  1306.         // APP ID
  1307.         if(!useOAS3Names) {
  1308.             de = new DataElement();
  1309.             de.setType(DataElementType.HIDDEN);
  1310.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  1311.             de.setValue(appIdHeader);
  1312.             dati.add(de);
  1313.         }
  1314.         de = new DataElement();
  1315.         de.setType(DataElementType.HIDDEN);
  1316.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  1317.         de.setValue(appIdValue);
  1318.         dati.add(de);
  1319.        
  1320.        
  1321.         return dati;
  1322.     }
  1323.    
  1324.     public boolean isTokenPolicyModeUseAuthorizationHeader(String tokenPolicy) throws DriverConfigurazioneException, DriverConfigurazioneNotFound{
  1325.         if(tokenPolicy==null || "".equals(tokenPolicy) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(tokenPolicy)) {
  1326.             return false;
  1327.         }
  1328.         GenericProperties gestorePolicyToken = this.confCore.getGenericProperties(tokenPolicy,  ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_RETRIEVE_POLICY_TOKEN, true);
  1329.         for (org.openspcoop2.core.config.Property p : gestorePolicyToken.getPropertyList()) {
  1330.             if(org.openspcoop2.pdd.core.token.Costanti.POLICY_RETRIEVE_TOKEN_FORWARD_MODE.equals(p.getNome()) &&
  1331.                 org.openspcoop2.pdd.core.token.Costanti.POLICY_RETRIEVE_TOKEN_FORWARD_MODE_RFC6750_HEADER.equals(p.getValore())) {
  1332.                 return true;
  1333.             }
  1334.         }  
  1335.         return false;
  1336.     }
  1337.    
  1338.     public List<DataElement> addTempiRispostaToDati(List<DataElement> dati,
  1339.             String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  1340.             boolean postBackViaPost){
  1341.        
  1342.         if(postBackViaPost) {
  1343.             // unused
  1344.         }
  1345.        
  1346.         DataElement de = new DataElement();
  1347.         de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_TEMPI_RISPOSTA);
  1348.         de.setType(DataElementType.TITLE);
  1349.         dati.add(de);
  1350.        
  1351.         de = new DataElement();
  1352.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  1353.         de.setNote(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_MILLISECONDI_NOTE);
  1354.         de.setValue(tempiRispostaConnectionTimeout);
  1355.         de.setType(DataElementType.TEXT_EDIT);
  1356.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  1357.         de.setSize(this.getSize());
  1358.         de.setRequired(true);
  1359.         dati.add(de);
  1360.        
  1361.         de = new DataElement();
  1362.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  1363.         de.setNote(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_MILLISECONDI_NOTE);
  1364.         de.setValue(tempiRispostaReadTimeout);
  1365.         de.setType(DataElementType.TEXT_EDIT);
  1366.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  1367.         de.setSize(this.getSize());
  1368.         de.setRequired(true);
  1369.         dati.add(de);
  1370.        
  1371.         de = new DataElement();
  1372.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);
  1373.         de.setNote(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_MILLISECONDI_NOTE);
  1374.         de.setValue(tempiRispostaTempoMedioRisposta);
  1375.         de.setType(DataElementType.TEXT_EDIT);
  1376.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);
  1377.         de.setSize(this.getSize());
  1378.         de.setRequired(true);
  1379.         dati.add(de);
  1380.        
  1381.         return dati;
  1382.     }
  1383.    
  1384.     public List<DataElement> addTempiRispostaToDatiAsHidden(List<DataElement> dati,
  1385.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta){
  1386.        
  1387.         DataElement de = new DataElement();
  1388.         de.setValue(tempiRispostaEnabled);
  1389.         de.setType(DataElementType.HIDDEN);
  1390.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  1391.         dati.add(de);
  1392.        
  1393.         de = new DataElement();
  1394.         de.setValue(tempiRispostaConnectionTimeout);
  1395.         de.setType(DataElementType.HIDDEN);
  1396.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  1397.         dati.add(de);
  1398.        
  1399.         de = new DataElement();
  1400.         de.setValue(tempiRispostaReadTimeout);
  1401.         de.setType(DataElementType.HIDDEN);
  1402.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  1403.         dati.add(de);
  1404.        
  1405.         de = new DataElement();
  1406.         de.setValue(tempiRispostaTempoMedioRisposta);
  1407.         de.setType(DataElementType.HIDDEN);
  1408.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);
  1409.         dati.add(de);
  1410.        
  1411.         return dati;
  1412.     }
  1413.    
  1414.    
  1415.     public List<DataElement> addCredenzialiToDati(List<DataElement> dati, String tipoauth, String utente, String password, String subject, String principal,
  1416.             String toCall, boolean showLabelCredenzialiAccesso, String endpointtype,boolean connettore,boolean visualizzaTipoAutenticazione,
  1417.             String prefix, boolean autenticazioneNessunaAbilitata,
  1418.             boolean postBackViaPost) throws Exception {
  1419.         return this.addCredenzialiToDati(null, dati, tipoauth, null, utente, password, subject, principal, toCall, showLabelCredenzialiAccesso, endpointtype, connettore, visualizzaTipoAutenticazione, prefix, autenticazioneNessunaAbilitata,
  1420.                 null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
  1421.                 null,
  1422.                 null,null,null,
  1423.                 null, false, false, null, null, null, null,
  1424.                 false, null,null,false,
  1425.                 false, null,
  1426.                 postBackViaPost);
  1427.     }
  1428.     public List<DataElement> addCredenzialiToDati(List<DataElement> dati, String tipoauth, String utente, String password, String subject, String principal,
  1429.             String toCall, boolean showLabelCredenzialiAccesso, String endpointtype,boolean connettore,boolean visualizzaTipoAutenticazione,
  1430.             String prefix, boolean autenticazioneNessunaAbilitata,
  1431.             String subtitleConfigurazione,
  1432.             boolean postBackViaPost) throws Exception {
  1433.         return this.addCredenzialiToDati(null, dati, tipoauth, null, utente, password, subject, principal, toCall, showLabelCredenzialiAccesso, endpointtype, connettore, visualizzaTipoAutenticazione, prefix, autenticazioneNessunaAbilitata,
  1434.                 null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,
  1435.                 null,
  1436.                 null,null,null,
  1437.                 subtitleConfigurazione, false, false, null, null, null, null,
  1438.                 false, null,null,false,
  1439.                 false, null,
  1440.                 postBackViaPost);
  1441.     }
  1442.    
  1443.     public List<DataElement> addCredenzialiToDati(TipoOperazione tipoOperazione, List<DataElement> dati, String tipoauth, String oldtipoauth, String utente, String password, String subject, String principal,
  1444.             String toCall, boolean showLabelCredenzialiAccesso, String endpointtype,boolean connettore,boolean visualizzaTipoAutenticazione,
  1445.             String prefix, boolean autenticazioneNessunaAbilitata,String tipoCredenzialiSSLSorgente, ArchiveType tipoCredenzialiSSLTipoArchivio, BinaryParameter tipoCredenzialiSSLFileCertificato, String tipoCredenzialiSSLFileCertificatoPassword,
  1446.             List<String> listaAliasEstrattiCertificato, String tipoCredenzialiSSLAliasCertificato,  String tipoCredenzialiSSLAliasCertificatoSubject, String tipoCredenzialiSSLAliasCertificatoIssuer,
  1447.             String tipoCredenzialiSSLAliasCertificatoType, String tipoCredenzialiSSLAliasCertificatoVersion, String tipoCredenzialiSSLAliasCertificatoSerialNumber, String tipoCredenzialiSSLAliasCertificatoSelfSigned,
  1448.             String tipoCredenzialiSSLAliasCertificatoNotBefore, String tipoCredenzialiSSLAliasCertificatoNotAfter, String tipoCredenzialiSSLVerificaTuttiICampi, String tipoCredenzialiSSLConfigurazioneManualeSelfSigned,
  1449.             String issuer, String tipoCredenzialiSSLStatoElaborazioneCertificato,
  1450.             String changepwd,
  1451.             String multipleApiKey, String appId, String apiKey,
  1452.             boolean visualizzaModificaCertificato, boolean visualizzaAddCertificato, String servletCredenzialiList, List<Parameter> parametersServletCredenzialiList, Integer numeroCertificati, String servletCredenzialiAdd,
  1453.             boolean credenzialiToken, String tokenPolicySA, String tokenClientIdSA, boolean tokenWithHttpsEnabledByConfigSA,
  1454.             boolean dominioEsterno, String protocollo,
  1455.             boolean postBackViaPost) throws Exception{
  1456.         return addCredenzialiToDati(tipoOperazione, dati, tipoauth, oldtipoauth, utente, password, subject, principal,
  1457.                 toCall, showLabelCredenzialiAccesso, endpointtype,connettore,visualizzaTipoAutenticazione,
  1458.                 prefix, autenticazioneNessunaAbilitata,tipoCredenzialiSSLSorgente, tipoCredenzialiSSLTipoArchivio, tipoCredenzialiSSLFileCertificato, tipoCredenzialiSSLFileCertificatoPassword,
  1459.                 listaAliasEstrattiCertificato, tipoCredenzialiSSLAliasCertificato,tipoCredenzialiSSLAliasCertificatoSubject, tipoCredenzialiSSLAliasCertificatoIssuer,
  1460.                 tipoCredenzialiSSLAliasCertificatoType, tipoCredenzialiSSLAliasCertificatoVersion, tipoCredenzialiSSLAliasCertificatoSerialNumber, tipoCredenzialiSSLAliasCertificatoSelfSigned,
  1461.                 tipoCredenzialiSSLAliasCertificatoNotBefore, tipoCredenzialiSSLAliasCertificatoNotAfter, tipoCredenzialiSSLVerificaTuttiICampi, tipoCredenzialiSSLConfigurazioneManualeSelfSigned,
  1462.                 issuer, tipoCredenzialiSSLStatoElaborazioneCertificato,
  1463.                 changepwd,
  1464.                 multipleApiKey, appId, apiKey,
  1465.                 null, visualizzaModificaCertificato, visualizzaAddCertificato, servletCredenzialiList, parametersServletCredenzialiList, numeroCertificati, servletCredenzialiAdd,
  1466.                 credenzialiToken, tokenPolicySA, tokenClientIdSA, tokenWithHttpsEnabledByConfigSA,
  1467.                 dominioEsterno, protocollo,
  1468.                 postBackViaPost);
  1469.     }
  1470.     public List<DataElement> addCredenzialiToDati(TipoOperazione tipoOperazione, List<DataElement> dati, String tipoauth, String oldtipoauth, String utente, String password, String subject, String principal,
  1471.             String toCall, boolean showLabelCredenzialiAccesso, String endpointtype,boolean connettore,boolean visualizzaTipoAutenticazione,
  1472.             String prefix, boolean autenticazioneNessunaAbilitata,String tipoCredenzialiSSLSorgente, ArchiveType tipoCredenzialiSSLTipoArchivio, BinaryParameter tipoCredenzialiSSLFileCertificato, String tipoCredenzialiSSLFileCertificatoPassword,
  1473.             List<String> listaAliasEstrattiCertificato, String tipoCredenzialiSSLAliasCertificato,  String tipoCredenzialiSSLAliasCertificatoSubject, String tipoCredenzialiSSLAliasCertificatoIssuer,
  1474.             String tipoCredenzialiSSLAliasCertificatoType, String tipoCredenzialiSSLAliasCertificatoVersion, String tipoCredenzialiSSLAliasCertificatoSerialNumber, String tipoCredenzialiSSLAliasCertificatoSelfSigned,
  1475.             String tipoCredenzialiSSLAliasCertificatoNotBefore, String tipoCredenzialiSSLAliasCertificatoNotAfter, String tipoCredenzialiSSLVerificaTuttiICampi, String tipoCredenzialiSSLConfigurazioneManualeSelfSigned,
  1476.             String issuer, String tipoCredenzialiSSLStatoElaborazioneCertificato,
  1477.             String changepwd,
  1478.             String multipleApiKey, String appId, String apiKey,
  1479.             String subtitleConfigurazione,
  1480.             boolean visualizzaModificaCertificato, boolean visualizzaAddCertificato, String servletCredenzialiList, List<Parameter> parametersServletCredenzialiList, Integer numeroCertificati, String servletCredenzialiAdd,
  1481.             boolean credenzialiToken, String tokenPolicySA, String tokenClientIdSA, boolean tokenWithHttpsEnabledByConfigSA,
  1482.             boolean dominioEsterno, String protocollo,
  1483.             boolean postBackViaPost) throws Exception{
  1484.        
  1485.         if(visualizzaModificaCertificato) {
  1486.             // nop
  1487.         }
  1488.        
  1489.         if(dati==null) {
  1490.             throw new CoreException("Param dati is null");
  1491.         }
  1492.        
  1493.         if(subtitleConfigurazione==null) {
  1494.             subtitleConfigurazione = ConnettoriCostanti.LABEL_CONFIGURAZIONE_SSL_TITLE_CONFIGURAZIONE;
  1495.         }
  1496.        
  1497.         DataElement de = null;

  1498.         if(prefix==null){
  1499.             prefix = "";
  1500.         }

  1501.         boolean tokenWithHttsSupportato = false;
  1502.         boolean tokenModIPDND = false;
  1503.         if(!connettore && dominioEsterno && protocollo!=null) {
  1504.             ProtocolFactoryManager protocolFactoryManager = ProtocolFactoryManager.getInstance();
  1505.             tokenWithHttsSupportato = protocolFactoryManager.getProtocolFactoryByName(protocollo).createProtocolConfiguration().isSupportatoAutenticazioneApplicativiHttpsConToken();
  1506.             if(tokenPolicySA!=null && StringUtils.isNotEmpty(tokenPolicySA)) {
  1507.                 tokenModIPDND = this.saCore.isPolicyGestioneTokenPDND(tokenPolicySA);
  1508.             }
  1509.         }
  1510.         if(tokenWithHttsSupportato) {
  1511.             if(ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL.equals(tipoauth) && tokenWithHttpsEnabledByConfigSA) {
  1512.                 if(tokenModIPDND) {
  1513.                     tipoauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_PDND;
  1514.                 }
  1515.                 else {
  1516.                     tipoauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_OAUTH;
  1517.                 }
  1518.             }
  1519.             else {
  1520.                 if(ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN.equals(tipoauth)){
  1521.                     if(tokenModIPDND) {
  1522.                         tipoauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_PDND;
  1523.                     }
  1524.                     else {
  1525.                         tipoauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_OAUTH;
  1526.                     }
  1527.                 }
  1528.             }
  1529.         }
  1530.        
  1531.         String[] tipoA = null;
  1532.         String[] labelTipoA = null;
  1533.         if(visualizzaTipoAutenticazione){
  1534.             if (ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT.equals(toCall) ||
  1535.                     ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA.equals(toCall)) {
  1536.                 if(TipiConnettore.HTTPS.toString().equals(endpointtype) || TipiConnettore.HTTP.toString().equals(endpointtype) ||
  1537.                         TipiConnettore.JMS.toString().equals(endpointtype) || TipiConnettore.CUSTOM.toString().equals(endpointtype)){
  1538.                     tipoA = new String[] { ConnettoriCostanti.AUTENTICAZIONE_TIPO_NESSUNA,
  1539.                             ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC };
  1540.                     if(TipiConnettore.HTTPS.toString().equals(endpointtype) || TipiConnettore.HTTP.toString().equals(endpointtype) ){
  1541.                         labelTipoA = new String[] { CostantiConfigurazione.DISABILITATO.toString(),
  1542.                                 ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC };
  1543.                     }else{
  1544.                         labelTipoA = new String[] { CostantiConfigurazione.DISABILITATO.toString(),
  1545.                                 CostantiConfigurazione.ABILITATO.toString() };
  1546.                     }
  1547.                 }else{
  1548.                     tipoA = new String[] { ConnettoriCostanti.AUTENTICAZIONE_TIPO_NESSUNA };
  1549.                     labelTipoA = new String[] { CostantiConfigurazione.DISABILITATO.toString() };
  1550.                     tipoauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_NESSUNA;
  1551.                 }
  1552.             } else {
  1553.                 boolean autenticazioneNessuna = autenticazioneNessunaAbilitata;
  1554.                 if (! (SoggettiCostanti.SERVLET_NAME_SOGGETTI_ADD.equals(toCall) ||
  1555.                         SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE.equals(toCall)) ) {
  1556.                     boolean creazioneModificaSA = ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ADD.equals(toCall) ||
  1557.                             ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CHANGE.equals(toCall);
  1558.                     if (this.isModalitaStandard() || (!this.isModalitaCompleta() && creazioneModificaSA)){
  1559.                         autenticazioneNessuna = false;
  1560.                     }
  1561.                 }
  1562.                
  1563.                 if (autenticazioneNessuna) {
  1564.                     tipoA = ConnettoriCostanti.CREDENZIALI_CON_NESSUNA_VALUES;
  1565.                     labelTipoA = ConnettoriCostanti.CREDENZIALI_CON_NESSUNA_LABELS;
  1566.                 }
  1567.                 else{
  1568.                     tipoA = ConnettoriCostanti.CREDENZIALI_VALUES;
  1569.                     labelTipoA = ConnettoriCostanti.CREDENZIALI_LABELS;
  1570.                     if(credenzialiToken) {
  1571.                         tipoA = ConnettoriCostanti.CREDENZIALI_CON_TOKEN_VALUES;
  1572.                         labelTipoA = ConnettoriCostanti.CREDENZIALI_CON_TOKEN_LABELS;
  1573.                     }
  1574.                     if(tipoauth==null){
  1575.                         tipoauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL;
  1576.                     }
  1577.                 }
  1578.             }
  1579.         }
  1580.         else {
  1581.             if(tokenWithHttsSupportato && StringUtils.isNotEmpty(protocollo) && isProfiloModIPA(protocollo)) {
  1582.                 visualizzaTipoAutenticazione = true;
  1583.                 tipoA = ConnettoriCostanti.CREDENZIALI_MODI_ESTERNO_VALUES;
  1584.                 labelTipoA = ConnettoriCostanti.CREDENZIALI_MODI_ESTERNO_LABELS;
  1585.             }
  1586.         }

  1587.         boolean showSezioneCredenziali = true;
  1588.         if(!visualizzaTipoAutenticazione){
  1589.             showSezioneCredenziali = true;
  1590.         }
  1591.         else if(tipoA.length == 1){
  1592.             showSezioneCredenziali = false;
  1593.         }

  1594.         if(showSezioneCredenziali) {
  1595.             if(showLabelCredenzialiAccesso){
  1596.                 de = new DataElement();
  1597.                 if(connettore){
  1598.                     if(TipiConnettore.HTTPS.toString().equals(endpointtype) ||  TipiConnettore.HTTP.toString().equals(endpointtype) ){
  1599.                         de.setLabel(prefix+ServiziApplicativiCostanti.LABEL_CREDENZIALI_ACCESSO_SERVIZIO_APPLICATIVO_HTTP);
  1600.                     }
  1601.                     else{
  1602.                         de.setLabel(prefix+ServiziApplicativiCostanti.LABEL_CREDENZIALI_ACCESSO_SERVIZIO_APPLICATIVO);
  1603.                     }
  1604.                 }else{
  1605.                     de.setLabel(prefix+ServiziApplicativiCostanti.LABEL_CREDENZIALI_ACCESSO_PORTA);
  1606.                 }
  1607.                 de.setType(DataElementType.TITLE);
  1608.                 dati.add(de);
  1609.             }

  1610.             de = new DataElement();
  1611.             if(tokenWithHttsSupportato && StringUtils.isNotEmpty(protocollo) && isProfiloModIPA(protocollo)) {
  1612.                 de.setLabel(CostantiLabel.MODIPA_API_PROFILO_SICUREZZA_MESSAGGIO_LABEL);
  1613.             }
  1614.             else if(showLabelCredenzialiAccesso){
  1615.                 de.setLabel(ServiziApplicativiCostanti.LABEL_TIPO_CREDENZIALE);
  1616.             }else{
  1617.                 de.setLabel(ServiziApplicativiCostanti.LABEL_CREDENZIALE_ACCESSO);
  1618.             }
  1619.             if(connettore){
  1620.                 de.setName(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_TIPO_AUTENTICAZIONE);
  1621.             }
  1622.             else{
  1623.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_TIPO_AUTENTICAZIONE);
  1624.             }
  1625.             if(visualizzaTipoAutenticazione){
  1626.                 de.setType(DataElementType.SELECT);
  1627.                 de.setLabels(labelTipoA);
  1628.                 de.setValues(tipoA);
  1629.                 de.setSelected(tipoauth);
  1630.                 if(postBackViaPost) {
  1631.                     de.setPostBack_viaPOST(true);
  1632.                 }
  1633.                 else {
  1634.                     de.setPostBack(true);
  1635.                 }
  1636.             }
  1637.             else{
  1638.                 de.setType(DataElementType.HIDDEN);
  1639.                 de.setValue(tipoauth);
  1640.             }
  1641.             dati.add(de);
  1642.            
  1643.             if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC.equals(tipoauth)) {
  1644.                 de = new DataElement();
  1645.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  1646.                 de.setValue(StringEscapeUtils.escapeHtml(utente));
  1647.                 de.setType(DataElementType.TEXT_EDIT);
  1648.                 if(connettore){
  1649.                     de.setName(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  1650.                 }
  1651.                 else{
  1652.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  1653.                 }
  1654.                 de.setSize(this.getSize());
  1655.                 de.setRequired(true);
  1656.                 dati.add(de);

  1657.                
  1658.                
  1659.                 de = new DataElement();
  1660.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  1661.                 de.setValue(StringEscapeUtils.escapeHtml(password));
  1662.                 de.setType(DataElementType.TEXT_EDIT);
  1663.                 if(connettore){
  1664.                     de.setName(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  1665.                     this.core.getLockUtilities().lock(de, password);
  1666.                 }
  1667.                 else{
  1668.                    
  1669.                     boolean change = ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CHANGE.equals(toCall) ||
  1670.                             SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE.equals(toCall);
  1671.                     boolean soggetti = SoggettiCostanti.SERVLET_NAME_SOGGETTI_ADD.equals(toCall) ||
  1672.                             SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE.equals(toCall);
  1673.                    
  1674.                     boolean passwordCifrata = ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLVerificaTuttiICampi); // tipoCredenzialiSSLVerificaTuttiICampi usata come informazione per sapere se una password e' cifrata o meno
  1675.                    
  1676.                     if(change && passwordCifrata ){
  1677.                         DataElement deCifratura = new DataElement();
  1678.                         deCifratura.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  1679.                         deCifratura.setType(DataElementType.HIDDEN);
  1680.                         deCifratura.setValue(tipoCredenzialiSSLVerificaTuttiICampi);
  1681.                         dati.add(deCifratura);
  1682.                     }
  1683.                    
  1684.                     // solo adesso posso reimpostare il change
  1685.                     if(change &&
  1686.                         !tipoauth.equals(oldtipoauth)) {
  1687.                         change = false;
  1688.                     }
  1689.                                        
  1690.                     if(change && passwordCifrata ){
  1691.                         DataElement deModifica = new DataElement();
  1692.                         deModifica.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_MODIFICA_PASSWORD);
  1693.                         deModifica.setType(DataElementType.CHECKBOX);
  1694.                         deModifica.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CHANGE_PASSWORD);
  1695.                         if(postBackViaPost) {
  1696.                             deModifica.setPostBack_viaPOST(true);
  1697.                         }
  1698.                         else {
  1699.                             deModifica.setPostBack(true);
  1700.                         }
  1701.                         deModifica.setSelected(changepwd);
  1702.                         deModifica.setSize(this.getSize());
  1703.                         dati.add(deModifica);
  1704.                        
  1705.                         de.setType(DataElementType.HIDDEN);
  1706.                         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  1707.                     }
  1708.                    
  1709.                     if( (!change) || (!passwordCifrata) || (ServletUtils.isCheckBoxEnabled(changepwd)) ){
  1710.                    
  1711.                         if(change && passwordCifrata && ServletUtils.isCheckBoxEnabled(changepwd) ){
  1712.                             de.setValue(null); // non faccio vedere una password cifrata
  1713.                             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_NUOVA_PASSWORD);
  1714.                         }
  1715.                        
  1716.                         // Nuova visualizzazione Password con bottone genera password
  1717.                         de.setType(DataElementType.CRYPT);
  1718.                         de.getPassword().setVisualizzaPasswordChiaro(true);
  1719.                         de.getPassword().setVisualizzaBottoneGeneraPassword(true);
  1720.                        
  1721.                         PasswordVerifier passwordVerifier = null;
  1722.                         boolean isBasicPasswordEnableConstraints = false;
  1723.                         int lunghezzaPasswordGenerate;
  1724.                         if ( soggetti ) {
  1725.                             lunghezzaPasswordGenerate = this.connettoriCore.getSoggettiBasicLunghezzaPasswordGenerate();
  1726.                             isBasicPasswordEnableConstraints = this.connettoriCore.isSoggettiBasicPasswordEnableConstraints();
  1727.                             if(isBasicPasswordEnableConstraints) {
  1728.                                 passwordVerifier = this.connettoriCore.getSoggettiPasswordVerifier();
  1729.                             }
  1730.                         }
  1731.                         else {
  1732.                             lunghezzaPasswordGenerate = this.connettoriCore.getApplicativiBasicLunghezzaPasswordGenerate();
  1733.                             isBasicPasswordEnableConstraints = this.connettoriCore.isApplicativiBasicPasswordEnableConstraints();
  1734.                             if(isBasicPasswordEnableConstraints) {
  1735.                                 passwordVerifier = this.connettoriCore.getApplicativiPasswordVerifier();
  1736.                             }
  1737.                         }
  1738.                         if(passwordVerifier != null) {
  1739.                             PasswordGenerator passwordGenerator = new PasswordGenerator(passwordVerifier);
  1740.                             de.getPassword().setPasswordGenerator(passwordGenerator);
  1741.                             de.setNote(passwordVerifier.help(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE));
  1742.                         }
  1743.                         de.getPassword().getPasswordGenerator().setDefaultLength(lunghezzaPasswordGenerate);
  1744.                        
  1745.                         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  1746.                        
  1747.                     }
  1748.                 }
  1749.                 de.setSize(this.getSize());
  1750.                 de.setRequired(true);
  1751.                 dati.add(de);

  1752.             }
  1753.            
  1754.             if (
  1755.                     (
  1756.                             ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL.equals(tipoauth)
  1757.                             ||
  1758.                             ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_OAUTH.equals(tipoauth)
  1759.                             ||
  1760.                             ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_PDND.equals(tipoauth)
  1761.                     )
  1762.                     && !connettore) {
  1763.                 boolean add = ( SoggettiCostanti.SERVLET_NAME_SOGGETTI_ADD.equals(toCall) ||  ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ADD.equals(toCall));
  1764.                
  1765.                 boolean visualizzaFieldCert = false;
  1766.                 boolean visualizzaDownload = false;
  1767.                 if(add) {
  1768.                     visualizzaFieldCert = StringUtils.isEmpty(tipoCredenzialiSSLAliasCertificatoSubject);
  1769.                 }
  1770.                 else {
  1771.                     visualizzaFieldCert = !tipoCredenzialiSSLStatoElaborazioneCertificato.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_NO_WIZARD)
  1772.                             && StringUtils.isEmpty(tipoCredenzialiSSLAliasCertificatoSubject);
  1773.                     visualizzaDownload = tipoCredenzialiSSLStatoElaborazioneCertificato.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_NO_WIZARD);
  1774.                 }
  1775.                 boolean aggiuntoWizardStep = false;
  1776.                 if(!add && visualizzaDownload) {
  1777.                     de = new DataElement();
  1778.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_WIZARD_STEP);
  1779.                     de.setValue(tipoCredenzialiSSLStatoElaborazioneCertificato);
  1780.                     de.setType(DataElementType.HIDDEN);
  1781.                     dati.add(de);
  1782.                     aggiuntoWizardStep = true;
  1783.                 }
  1784.                

  1785.                 /**
  1786.                 String tipoCredenzialiSSLSorgente = ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_UPLOAD_CERTIFICATO;
  1787.                 String tipoCredenzialiSSLTipoArchivio = ArchiveType.CER.name();
  1788.                 BinaryParameter tipoCredenzialiSSLFileCertificato = new BinaryParameter();
  1789.                 tipoCredenzialiSSLFileCertificato.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO);
  1790.                 List<String> listaAliasEstrattiCertificato = new ArrayList<>();
  1791.                 String tipoCredenzialiSSLFileCertificatoPassword = "";
  1792.                 String tipoCredenzialiSSLAliasCertificato = "";
  1793.                 String tipoCredenzialiSSLAliasCertificatoSubject= "";
  1794.                 String tipoCredenzialiSSLAliasCertificatoIssuer= "";
  1795.                 String tipoCredenzialiSSLAliasCertificatoType= "";
  1796.                 String tipoCredenzialiSSLAliasCertificatoVersion= "";
  1797.                 String tipoCredenzialiSSLAliasCertificatoSerialNumber= "";
  1798.                 String tipoCredenzialiSSLAliasCertificatoSelfSigned= "";
  1799.                 String tipoCredenzialiSSLAliasCertificatoNotBefore= "";
  1800.                 String tipoCredenzialiSSLAliasCertificatoNotAfter = "";
  1801.                 String tipoCredenzialiSSLVerificaTuttiICampi = "";
  1802.                 String tipoCredenzialiSSLConfigurazioneManualeSelfSigned="";
  1803.                 String issuer = "";
  1804.                 */
  1805.                
  1806.                 boolean visualizzaSceltaConfigurazione = (visualizzaFieldCert || !tipoCredenzialiSSLSorgente.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_UPLOAD_CERTIFICATO)) &&
  1807.                         !tipoCredenzialiSSLStatoElaborazioneCertificato.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_NO_WIZARD_ARCHIVI);
  1808.                
  1809.                 de = new DataElement();
  1810.                 if(dominioEsterno && StringUtils.isNotEmpty(protocollo) && isProfiloModIPA(protocollo)) {
  1811.                     de.setLabel(CostantiLabel.MODIPA_SICUREZZA_MESSAGGIO_FIRMA_APPLICATIVO_SUBTITLE_LABEL);
  1812.                 }
  1813.                 else {
  1814.                     de.setLabel(subtitleConfigurazione);
  1815.                 }
  1816.                 de.setType(DataElementType.SUBTITLE);
  1817.                 dati.add(de);
  1818.                
  1819.                 // OP-816
  1820.                 // 1. Select List - Upload Certificato / Configurazione Manuale
  1821.                 de = new DataElement();
  1822.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL);
  1823.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL);
  1824.                 if(visualizzaSceltaConfigurazione) {
  1825.                     de.setType(DataElementType.SELECT);
  1826.                     de.setLabels(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_LABELS);
  1827.                     de.setValues(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VALUES);
  1828.                     de.setSelected(tipoCredenzialiSSLSorgente);
  1829.                     if(postBackViaPost) {
  1830.                         de.setPostBack_viaPOST(true);
  1831.                     }
  1832.                     else {
  1833.                         de.setPostBack(true);
  1834.                     }
  1835.                     de.setSize(this.getSize());
  1836.                 } else {
  1837.                     de.setType(DataElementType.HIDDEN);
  1838.                     de.setValue(tipoCredenzialiSSLSorgente);
  1839.                 }
  1840.                 dati.add(de);

  1841.                 if(tipoCredenzialiSSLSorgente.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_UPLOAD_CERTIFICATO)) {
  1842.                     // 1a. Select List Tipo Archivio
  1843.                     de = new DataElement();
  1844.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  1845.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  1846.                     if(visualizzaFieldCert) {
  1847.                         de.setType(DataElementType.SELECT);
  1848.                         de.setLabels(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_LABELS);
  1849.                         de.setValues(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_VALUES);
  1850.                         de.setSelected(tipoCredenzialiSSLTipoArchivio.name());
  1851.                         de.setSize(this.getSize());
  1852.                         if(postBackViaPost) {
  1853.                             de.setPostBack_viaPOST(true);
  1854.                         }
  1855.                         else {
  1856.                             de.setPostBack(true);
  1857.                         }
  1858.                        
  1859.                         if(ArchiveType.CER.equals(tipoCredenzialiSSLTipoArchivio) || ArchiveType.JKS.equals(tipoCredenzialiSSLTipoArchivio)) {
  1860.                             DataElementInfo dInfo = new DataElementInfo(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  1861.                             if(ArchiveType.CER.equals(tipoCredenzialiSSLTipoArchivio)) {
  1862.                                 dInfo.setHeaderBody(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_INFO_CER);
  1863.                                 dInfo.setListBody(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_INFO_CER_VALUES);
  1864.                             }
  1865.                             else {
  1866.                                 dInfo.setHeaderBody(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_INFO_JKS);
  1867.                             }
  1868.                             de.setInfo(dInfo);
  1869.                         }
  1870.                        
  1871.                     } else {
  1872.                         de.setType(DataElementType.HIDDEN);
  1873.                         de.setValue(tipoCredenzialiSSLTipoArchivio.name());
  1874.                     }
  1875.                     dati.add(de);
  1876.                    
  1877.                     de = new DataElement();
  1878.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PASSWORD);
  1879.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PASSWORD);
  1880.                     de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLFileCertificatoPassword));
  1881.                     if(visualizzaFieldCert && (tipoCredenzialiSSLTipoArchivio.equals(ArchiveType.JKS) || tipoCredenzialiSSLTipoArchivio.equals(ArchiveType.PKCS12))) {
  1882.                         // 1a. Password per gli archivi JKS o PKCS12.
  1883.                         de.setType(DataElementType.TEXT_EDIT);
  1884.                         de.setSize(this.getSize());
  1885.                         if(tipoCredenzialiSSLTipoArchivio.equals(ArchiveType.JKS)) {
  1886.                             de.setRequired(this.core.isLoadCertificateWizardJksPasswordRequiredRequired());
  1887.                         }
  1888.                         else if(tipoCredenzialiSSLTipoArchivio.equals(ArchiveType.PKCS12)) {
  1889.                             de.setRequired(this.core.isLoadCertificateWizardPkcs12PasswordRequiredRequired());
  1890.                         }
  1891.                         else {
  1892.                             de.setRequired(true);
  1893.                         }
  1894.                     } else {
  1895.                         de.setType(DataElementType.HIDDEN);
  1896.                     }
  1897.                    
  1898.                     dati.add(de);
  1899.                    
  1900.                     // 1a. File Upload
  1901.                     String labelCertificato = null;
  1902.                     if(ArchiveType.CER.equals(tipoCredenzialiSSLTipoArchivio)) {
  1903.                         labelCertificato = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO;
  1904.                     }
  1905.                     else {
  1906.                         labelCertificato = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_ARCHIVIO;
  1907.                     }
  1908.                     DataElement fileDataElement = tipoCredenzialiSSLFileCertificato.getFileDataElement(labelCertificato, "", getSize());
  1909.                     fileDataElement.setRequired(true);
  1910.                     fileDataElement.setPostBack(false);
  1911.                     fileDataElement.setPostBack_viaPOST(false);
  1912.                    
  1913.                     if(!visualizzaFieldCert)
  1914.                         fileDataElement.setType(DataElementType.HIDDEN);
  1915.                    
  1916.                     dati.add(fileDataElement);
  1917.                     dati.addAll(tipoCredenzialiSSLFileCertificato.getFileNameDataElement());
  1918.                     dati.add(tipoCredenzialiSSLFileCertificato.getFileIdDataElement());
  1919.                                        
  1920.                     if(!visualizzaFieldCert && numeroCertificati <= 1) {
  1921.                         de = new DataElement();
  1922.                         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_MODIFICA);
  1923.                         de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_CAMBIA_+labelCertificato);
  1924.                         if(postBackViaPost) {
  1925.                             de.setPostBack_viaPOST(true);
  1926.                         }
  1927.                         else {
  1928.                             de.setPostBack(true);
  1929.                         }
  1930.                         // Imposto # per valorizzare la url, non viene utilizzata ma viene scatenata la post back
  1931.                         de.setUrl("#");
  1932.                         de.setType(DataElementType.LINK);
  1933.                         dati.add(de);
  1934.                     }
  1935.                    
  1936.                     // link aggiungi certificato
  1937.                     if(visualizzaDownload && visualizzaAddCertificato) {
  1938.                         de = new DataElement();
  1939.                         if(numeroCertificati == 1) {
  1940.                             de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_AGGIUNGI);
  1941.                             de.setUrl(servletCredenzialiAdd, parametersServletCredenzialiList.toArray(new Parameter[parametersServletCredenzialiList.size()]));
  1942.                         } else {
  1943.                             Boolean contaListe = ServletUtils.getContaListeFromSession(this.session);
  1944.                             if(contaListe!=null && contaListe.booleanValue()) {
  1945.                                 de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_ELENCO_CERTIFICATI +" (" + numeroCertificati + ")");
  1946.                             } else {
  1947.                                 de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_ELENCO_CERTIFICATI);
  1948.                             }
  1949.                             de.setUrl(servletCredenzialiList, parametersServletCredenzialiList.toArray(new Parameter[parametersServletCredenzialiList.size()]));
  1950.                         }
  1951.                         de.setType(DataElementType.LINK);
  1952.                         dati.add(de);
  1953.                     }
  1954.                    
  1955.                     // 1a. Eventuale Select per selezionare l'alias
  1956.                     de = new DataElement();
  1957.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO);
  1958.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO);
  1959.                     if(listaAliasEstrattiCertificato.size() > 1) {
  1960.                        
  1961.                         de.setType(DataElementType.SELECT);
  1962.                        
  1963.                         List<String> listaLabels = new ArrayList<>();
  1964.                         listaLabels.addAll(listaAliasEstrattiCertificato);
  1965.                         listaLabels.add(0, "--");
  1966.                        
  1967.                         List<String> listaValues = new ArrayList<>();
  1968.                         listaValues.addAll(listaAliasEstrattiCertificato);
  1969.                         listaValues.add(0, "");
  1970.                        
  1971.                         de.setLabels(listaLabels);
  1972.                         de.setValues(listaValues);
  1973.                         de.setSelected(tipoCredenzialiSSLAliasCertificato);
  1974.                         if(postBackViaPost) {
  1975.                             de.setPostBack_viaPOST(true);
  1976.                         }
  1977.                         else {
  1978.                             de.setPostBack(true);
  1979.                         }
  1980.                         de.setSize(this.getSize());
  1981.                         de.setRequired(true);
  1982.                        
  1983.                     } else {
  1984.                         de.setType(DataElementType.HIDDEN);
  1985.                         de.setValue(tipoCredenzialiSSLAliasCertificato);
  1986.                     }
  1987.                     dati.add(de);

  1988.                     // 1a. Pannello Recap info certificato.
  1989.                    
  1990.                     if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject) &&
  1991.                             !(dominioEsterno && StringUtils.isNotEmpty(protocollo) && isProfiloModIPA(protocollo))
  1992.                         ) {
  1993.                         de = new DataElement();
  1994.                         de.setLabel(ConnettoriCostanti.LABEL_CONFIGURAZIONE_SSL_TITLE_INFORMAZIONI_CERTIFICATO+" "+
  1995.                         tipoCredenzialiSSLAliasCertificatoType+" v"+tipoCredenzialiSSLAliasCertificatoVersion);
  1996.                         de.setType(DataElementType.SUBTITLE);
  1997.                         dati.add(de);
  1998.                     }
  1999.                    
  2000.                     // link al download
  2001.                     if(visualizzaDownload) {
  2002.                         de = new DataElement();
  2003.                        
  2004.                         String idOggetto = null;
  2005.                         String tipoOggetto = "";
  2006.                                
  2007.                         if(SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE.equals(toCall)) {
  2008.                             tipoOggetto =  ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_SOGGETTO;
  2009.                             idOggetto = this.getParameter(SoggettiCostanti.PARAMETRO_SOGGETTO_ID);
  2010.                         }
  2011.                        
  2012.                         if(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CHANGE.equals(toCall)) {
  2013.                             tipoOggetto =  ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_SERVIZIO_APPLICATIVO;
  2014.                             idOggetto = this.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID);
  2015.                         }
  2016.                        
  2017.                         de.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  2018.                                 new Parameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_ALLEGATI_ID_ACCORDO, idOggetto),
  2019.                                 new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, tipoOggetto),
  2020.                                 new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_CERTIFICATO_SSL));
  2021.                         de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_DOWNLOAD);
  2022.                         de.setType(DataElementType.LINK);
  2023.                         de.setDisabilitaAjaxStatus();
  2024.                         dati.add(de);
  2025.                     }
  2026.                    
  2027.                    
  2028.                     // 1a. Checkbox 'Verifica tutti i campi' + nota: attenzione questa opzione richiede l'aggiornamento del certificato a scadenza
  2029.                    
  2030.                     boolean verificaCompleta = false;
  2031.                     if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject)) {
  2032.                         verificaCompleta = ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLVerificaTuttiICampi);
  2033.                     }
  2034.                    
  2035.                     de = new DataElement();
  2036.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  2037.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  2038.                     if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject)) {
  2039.                         de.setType(DataElementType.CHECKBOX);
  2040.                         de.setSelected(verificaCompleta);
  2041.                         de.setSize(this.getSize());
  2042.                         de.setLabelAffiancata(true);
  2043.                         if(postBackViaPost) {
  2044.                             de.setPostBack_viaPOST(true);
  2045.                         }
  2046.                         else {
  2047.                             de.setPostBack(true);
  2048.                         }
  2049.                     }else {
  2050.                         de.setType(DataElementType.HIDDEN);
  2051.                         de.setValue(tipoCredenzialiSSLVerificaTuttiICampi);
  2052.                     }
  2053.                     dati.add(de);
  2054.                    
  2055.                     if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject) && !verificaCompleta) {
  2056.                         de = new DataElement();
  2057.                         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI_NOTE_DISABLE);
  2058.                         de.setType(DataElementType.NOTE);
  2059.                         de.setBold(true);
  2060.                         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_SOLO_SUBJECT_ISSUER);
  2061.                         de.setValue(ConnettoriCostanti.NOTE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_SOLO_SUBJECT_ISSUER);
  2062.                         dati.add(de);
  2063.                     }
  2064.                    
  2065. //                      Subject:
  2066.                     de = new DataElement();
  2067.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SUBJECT);
  2068.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SUBJECT);
  2069.                     de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLAliasCertificatoSubject));
  2070.                     if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject)) {
  2071.                         de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  2072.                         de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  2073.                     }else {
  2074.                         de.setType(DataElementType.HIDDEN);
  2075.                     }
  2076.                     de.setSize(this.getSize());
  2077.                     dati.add(de);
  2078. //                          Issuer:
  2079.                     de = new DataElement();
  2080.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_ISSUER);
  2081.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_ISSUER);
  2082.                     de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLAliasCertificatoIssuer));
  2083.                     if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoIssuer)) {
  2084.                         de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  2085.                         de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  2086.                     }else {
  2087.                         de.setType(DataElementType.HIDDEN);
  2088.                     }
  2089.                     de.setSize(this.getSize());
  2090.                     dati.add(de);
  2091. //                          Type:
  2092.                     de = new DataElement();
  2093.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_TYPE);
  2094.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_TYPE);
  2095.                     de.setValue(tipoCredenzialiSSLAliasCertificatoType);
  2096.                     de.setType(DataElementType.HIDDEN);
  2097.                     de.setSize(this.getSize());
  2098.                     dati.add(de);
  2099. //                          Version:
  2100.                     de = new DataElement();
  2101.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_VERSION);
  2102.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_VERSION);
  2103.                     de.setValue(tipoCredenzialiSSLAliasCertificatoVersion);
  2104.                     de.setType(DataElementType.HIDDEN);
  2105.                     de.setSize(this.getSize());
  2106.                     dati.add(de);
  2107. //                          Serial Number:
  2108.                     de = new DataElement();
  2109.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER);
  2110.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER);
  2111.                     de.setValue(tipoCredenzialiSSLAliasCertificatoSerialNumber);
  2112.                     if(verificaCompleta && StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSerialNumber)) {
  2113.                         de.setType(DataElementType.TEXT);
  2114.                     }else {
  2115.                         de.setType(DataElementType.HIDDEN);
  2116.                     }
  2117.                     de.setSize(this.getSize());
  2118.                     dati.add(de);
  2119.                     if(verificaCompleta && StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSerialNumber)) {
  2120.                         String hexValue = null;
  2121.                         try {
  2122.                             hexValue = CertificateInfo.formatSerialNumberHex(tipoCredenzialiSSLAliasCertificatoSerialNumber,":");
  2123.                         }catch(Throwable t) {
  2124.                             // ignore
  2125.                         }
  2126.                         if(hexValue!=null && StringUtils.isNotEmpty(hexValue)) {
  2127.                             de = new DataElement();
  2128.                             de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER_HEX);
  2129.                             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER_HEX);
  2130.                             de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER_HEX_PREFIX+hexValue);
  2131.                             de.setType(DataElementType.TEXT);
  2132.                             de.setSize(this.getSize());
  2133.                             dati.add(de);
  2134.                         }
  2135.                     }
  2136. //                          SelfSigned:
  2137.                     de = new DataElement();
  2138.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SELF_SIGNED);
  2139.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SELF_SIGNED);
  2140.                     de.setValue(tipoCredenzialiSSLAliasCertificatoSelfSigned);
  2141.                     if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSelfSigned)) {
  2142.                         de.setType(DataElementType.TEXT);
  2143.                     }else {
  2144.                         de.setType(DataElementType.HIDDEN);
  2145.                     }
  2146.                     de.setSize(this.getSize());
  2147.                     dati.add(de);
  2148. //                          NotBefore:
  2149.                     de = new DataElement();
  2150.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_BEFORE);
  2151.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_BEFORE);
  2152.                     de.setValue(tipoCredenzialiSSLAliasCertificatoNotBefore);
  2153.                     if(verificaCompleta && StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoNotBefore)) {
  2154.                         de.setType(DataElementType.TEXT);
  2155.                         // Rendi bold la data NotBefore se è una data successiva ad adesso.
  2156.                         if(this.getSdfCredenziali().parse(tipoCredenzialiSSLAliasCertificatoNotBefore).after(new Date())) {
  2157.                             de.setValoreBold();
  2158.                         }
  2159.                            
  2160.                        
  2161.                     }else {
  2162.                         de.setType(DataElementType.HIDDEN);
  2163.                     }
  2164.                     de.setSize(this.getSize());
  2165.                     dati.add(de);
  2166. //                          NotAfter:
  2167.                     de = new DataElement();
  2168.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_AFTER);
  2169.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_AFTER);
  2170.                     de.setValue(tipoCredenzialiSSLAliasCertificatoNotAfter);
  2171.                     if(verificaCompleta && StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoNotAfter)) {
  2172.                         de.setType(DataElementType.TEXT);
  2173.                         // Rendi bold e colora di Rosso la data visualizzata Not After se risulta scaduta.
  2174.                         if(this.getSdfCredenziali().parse(tipoCredenzialiSSLAliasCertificatoNotAfter).before(new Date())) {
  2175.                             de.setValoreBoldRed();
  2176.                         }
  2177.                        
  2178.                        
  2179.                     }else {
  2180.                         de.setType(DataElementType.HIDDEN);
  2181.                     }
  2182.                     de.setSize(this.getSize());
  2183.                     dati.add(de);                  
  2184.                    
  2185.                     // data element per pilotare la label del  tasto carica
  2186.                     if(!aggiuntoWizardStep) {
  2187.                         de = new DataElement();
  2188.                         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_WIZARD_STEP);
  2189.                         de.setLabel("");
  2190.                         de.setType(DataElementType.HIDDEN);
  2191.                         de.setValue(tipoCredenzialiSSLStatoElaborazioneCertificato);
  2192.                         dati.add(de);
  2193.                     }
  2194.                    
  2195.                 } else {
  2196.                    
  2197.                     // 1b  Checkbox selfSigned
  2198.                     de = new DataElement();
  2199.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_MANUALE_SELF_SIGNED);
  2200.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_MANUALE_SELF_SIGNED);
  2201.                     de.setType(DataElementType.CHECKBOX);
  2202.                     de.setSelected(ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLConfigurazioneManualeSelfSigned));
  2203.                     de.setSize(this.getSize());
  2204.                     if(postBackViaPost) {
  2205.                         de.setPostBack_viaPOST(true);
  2206.                     }
  2207.                     else {
  2208.                         de.setPostBack(true);
  2209.                     }
  2210.                     dati.add(de);
  2211.                    
  2212.                    
  2213.                     // 1b. TextArea Subject
  2214.                     de = new DataElement();
  2215.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT);
  2216.                     de.setValue(StringEscapeUtils.escapeHtml(subject));
  2217.                     de.setType(DataElementType.TEXT_AREA);
  2218.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT);
  2219.                     de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  2220.                     de.setSize(this.getSize());
  2221.                     de.setRequired(true);
  2222.                     dati.add(de);
  2223.                    
  2224.                     // 1b. TextArea Issuer
  2225.                     de = new DataElement();
  2226.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER);
  2227.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER);
  2228.                     if(!ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLConfigurazioneManualeSelfSigned)) {
  2229.                         de.setType(DataElementType.TEXT_AREA);
  2230.                         de.setValue(StringEscapeUtils.escapeHtml(issuer));
  2231.                         de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  2232.                         de.setSize(this.getSize());
  2233.                     } else {
  2234.                         de.setType(DataElementType.HIDDEN);
  2235.                         de.setValue("");
  2236.                     }
  2237.                     dati.add(de);
  2238.                 }
  2239.             }
  2240.            
  2241.             if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_APIKEY.equals(tipoauth)  && !connettore) {
  2242.                
  2243.                 boolean multipleApiKeysEnabled = ServletUtils.isCheckBoxEnabled(multipleApiKey);
  2244.                 boolean appIdModificabile = ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID_MODIFICABILE;
  2245.                
  2246.                 boolean change = ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CHANGE.equals(toCall) ||
  2247.                         SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE.equals(toCall);
  2248.                
  2249.                 boolean soggetti = SoggettiCostanti.SERVLET_NAME_SOGGETTI_CHANGE.equals(toCall);
  2250.                 boolean encryptPassword = soggetti ? this.connettoriCore.isSoggettiPasswordEncryptEnabled() : this.connettoriCore.isApplicativiPasswordEncryptEnabled();
  2251.                                
  2252.                 boolean modificaApiKey = ServletUtils.isCheckBoxEnabled(changepwd);
  2253.                 String suffixOld = "";
  2254.                 if(modificaApiKey) {
  2255.                     suffixOld = "__OLD";
  2256.                 }
  2257.                
  2258.                 boolean passwordCifrata = ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLVerificaTuttiICampi); // tipoCredenzialiSSLVerificaTuttiICampi usata come informazione per sapere se una password e' cifrata o meno
  2259.                
  2260.                 if(change && passwordCifrata ){
  2261.                     DataElement deCifratura = new DataElement();
  2262.                     deCifratura.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  2263.                     deCifratura.setType(DataElementType.HIDDEN);
  2264.                     deCifratura.setValue(tipoCredenzialiSSLVerificaTuttiICampi);
  2265.                     dati.add(deCifratura);
  2266.                 }
  2267.                
  2268.                 // solo adesso posso reimpostare a false il change
  2269.                 if(change &&
  2270.                     !tipoauth.equals(oldtipoauth)) {
  2271.                     change = false;
  2272.                 }
  2273.                
  2274.                 de = new DataElement();
  2275.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_MULTIPLE_API_KEYS+suffixOld);
  2276.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_MULTIPLE_API_KEYS);
  2277.                 if(change) {
  2278.                     de.setType(DataElementType.HIDDEN);
  2279.                     de.setValue(multipleApiKey);
  2280.                     if(!modificaApiKey) {
  2281.                         DataElement deLabel = new DataElement();
  2282.                         deLabel.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_MULTIPLE_API_KEYS);
  2283.                         deLabel.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_MULTIPLE_API_KEYS+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  2284.                         if(!multipleApiKeysEnabled) {
  2285.                             deLabel.setType(DataElementType.TEXT);
  2286.                         }
  2287.                         else {
  2288.                             deLabel.setType(DataElementType.HIDDEN); // faccio vedere sotto direttamente l'app id
  2289.                         }
  2290.                         deLabel.setValue(multipleApiKeysEnabled? CostantiConfigurazione.ABILITATO.getValue() : CostantiConfigurazione.DISABILITATO.getValue());
  2291.                         dati.add(deLabel);                      
  2292.                     }
  2293.                 }
  2294.                 else {
  2295.                     de.setType(DataElementType.CHECKBOX);
  2296.                     de.setSelected(multipleApiKeysEnabled);
  2297.                     if(postBackViaPost) {
  2298.                         de.setPostBack_viaPOST(true);
  2299.                     }
  2300.                     else {
  2301.                         de.setPostBack(true);
  2302.                     }
  2303.                 }
  2304.                 dati.add(de);
  2305.                
  2306.                 de = new DataElement();
  2307.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID+suffixOld);
  2308.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID_EMPTY_LABEL);
  2309.                 if(change) {
  2310.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID);
  2311.                 }
  2312.                 de.setValue(StringEscapeUtils.escapeHtml(appId));
  2313.                 if(multipleApiKeysEnabled) {
  2314.                     if(appIdModificabile) {
  2315.                         de.setType(DataElementType.TEXT_EDIT);
  2316.                         de.setSize(this.getSize());
  2317.                         de.setRequired(true);
  2318.                     }
  2319.                     else if(change && !modificaApiKey) {
  2320.                         de.setType(DataElementType.TEXT);
  2321.                     }
  2322.                     else {
  2323.                         de.setType(DataElementType.HIDDEN);
  2324.                     }
  2325.                 }else {
  2326.                     de.setType(DataElementType.HIDDEN);
  2327.                 }
  2328.                 dati.add(de);
  2329.                
  2330.                 if(change && !modificaApiKey && !encryptPassword && !passwordCifrata) {
  2331.                     de = new DataElement();
  2332.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  2333.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY);
  2334.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  2335.                     de.setRows(3);
  2336.                     if(multipleApiKeysEnabled) {
  2337.                         de.setValue(ApiKeyUtilities.encodeMultipleApiKey(password));
  2338.                     }
  2339.                     else {
  2340.                         de.setValue(ApiKeyUtilities.encodeApiKey(utente, password));
  2341.                     }
  2342.                     dati.add(de);
  2343.                 }
  2344.                
  2345.                 if(change) {
  2346.                     DataElement deModifica = new DataElement();
  2347.                     deModifica.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_MODIFICA_API_KEY);
  2348.                     deModifica.setType(DataElementType.CHECKBOX);
  2349.                     deModifica.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CHANGE_PASSWORD);
  2350.                     if(postBackViaPost) {
  2351.                         deModifica.setPostBack_viaPOST(true);
  2352.                     }
  2353.                     else {
  2354.                         deModifica.setPostBack(true);
  2355.                     }
  2356.                     deModifica.setSelected(changepwd);
  2357.                     deModifica.setSize(this.getSize());
  2358.                     dati.add(deModifica);
  2359.                 }
  2360.                
  2361.                 if(modificaApiKey) {
  2362.                    
  2363.                     de = new DataElement();
  2364.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_NUOVA_API_KEY);
  2365.                     de.setType(DataElementType.SUBTITLE);
  2366.                     dati.add(de);
  2367.                    
  2368.                     de = new DataElement();
  2369.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_MULTIPLE_API_KEYS);
  2370.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_MULTIPLE_API_KEYS);
  2371.                     de.setType(DataElementType.CHECKBOX);
  2372.                     de.setSelected(multipleApiKeysEnabled);
  2373.                     if(postBackViaPost) {
  2374.                         de.setPostBack_viaPOST(true);
  2375.                     }
  2376.                     else {
  2377.                         de.setPostBack(true);
  2378.                     }
  2379.                     dati.add(de);
  2380.                    
  2381.                     de = new DataElement();
  2382.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID);
  2383.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID_EMPTY_LABEL);
  2384.                     de.setValue(StringEscapeUtils.escapeHtml(appId));
  2385.                     if(multipleApiKeysEnabled) {
  2386.                         if(appIdModificabile) {
  2387.                             de.setType(DataElementType.TEXT_EDIT);
  2388.                             de.setSize(this.getSize());
  2389.                             de.setRequired(true);
  2390.                         }
  2391.                         else {
  2392.                             de.setType(DataElementType.HIDDEN);
  2393.                         }
  2394.                     }else {
  2395.                         de.setType(DataElementType.HIDDEN);
  2396.                     }
  2397.                     dati.add(de);
  2398.                                    
  2399.                 }
  2400.                
  2401.                 de = new DataElement();
  2402.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_API_KEY);
  2403.                 de.setValue(StringEscapeUtils.escapeHtml(apiKey));
  2404.                 de.setType(DataElementType.HIDDEN);
  2405.                 dati.add(de);
  2406.                
  2407.             }

  2408.             if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_PRINCIPAL.equals(tipoauth)  && !connettore) {
  2409.                 de = new DataElement();
  2410.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PRINCIPAL);
  2411.                 de.setValue(StringEscapeUtils.escapeHtml(principal));
  2412.                 de.setType(DataElementType.TEXT_EDIT);
  2413.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PRINCIPAL);
  2414.                 de.setSize(this.getSize());
  2415.                 de.setRequired(true);
  2416.                 dati.add(de);
  2417.             }
  2418.            
  2419.            
  2420.             if (!connettore &&
  2421.                     credenzialiToken &&
  2422.                     (
  2423.                             ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN.equals(tipoauth)
  2424.                             ||
  2425.                             (ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_OAUTH.equals(tipoauth))
  2426.                             ||
  2427.                             (ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_PDND.equals(tipoauth))
  2428.                             ||
  2429.                             (ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_OAUTH.equals(tipoauth))
  2430.                             ||
  2431.                             (ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_PDND.equals(tipoauth))
  2432.                     )
  2433.                 ) {
  2434.                
  2435.                 if( (ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_OAUTH.equals(tipoauth) || ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_PDND.equals(tipoauth))
  2436.                         ||
  2437.                         (dominioEsterno && StringUtils.isNotEmpty(protocollo) && isProfiloModIPA(protocollo))) {
  2438.                     de = new DataElement();
  2439.                     if(dominioEsterno && StringUtils.isNotEmpty(protocollo) && isProfiloModIPA(protocollo)) {
  2440.                         if(ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_PDND.equals(tipoauth) || ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_PDND.equals(tipoauth)) {
  2441.                             de.setLabel(CostantiLabel.MODIPA_SICUREZZA_TOKEN_FIRMA_APPLICATIVO_SUBTITLE_LABEL_PDND);
  2442.                         }
  2443.                         else {
  2444.                             de.setLabel(CostantiLabel.MODIPA_SICUREZZA_TOKEN_FIRMA_APPLICATIVO_SUBTITLE_LABEL);
  2445.                         }
  2446.                     }
  2447.                     else {
  2448.                         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_DESCR);
  2449.                     }
  2450.                     de.setType(DataElementType.SUBTITLE);
  2451.                     dati.add(de);
  2452.                 }

  2453.                 // Token Policy
  2454.                 List<GenericProperties> gestorePolicyTokenListTmp = this.confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN, null);
  2455.                 List<GenericProperties> gestorePolicyTokenList = null;
  2456.                 boolean valoreNonSelezionato = true;
  2457.                 if((ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_PDND.equals(tipoauth))
  2458.                         ||
  2459.                         (ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_PDND.equals(tipoauth))) {
  2460.                     gestorePolicyTokenList = new ArrayList<>();
  2461.                     for (GenericProperties gp : gestorePolicyTokenListTmp) {
  2462.                         if(this.confCore.isPolicyGestioneTokenPDND(gp.getNome())) {
  2463.                             gestorePolicyTokenList.add(gp);
  2464.                         }
  2465.                     }
  2466.                     if(!gestorePolicyTokenList.isEmpty()) {
  2467.                         valoreNonSelezionato = false;  
  2468.                     }
  2469.                 }
  2470.                 else if((ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_OAUTH.equals(tipoauth))
  2471.                         ||
  2472.                         (ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_OAUTH.equals(tipoauth))) {
  2473.                     gestorePolicyTokenList = new ArrayList<>();
  2474.                     for (GenericProperties gp : gestorePolicyTokenListTmp) {
  2475.                         if(!this.confCore.isPolicyGestioneTokenPDND(gp.getNome())) {
  2476.                             gestorePolicyTokenList.add(gp);
  2477.                         }
  2478.                     }
  2479.                 }
  2480.                 else {
  2481.                     gestorePolicyTokenList = gestorePolicyTokenListTmp;
  2482.                 }
  2483.                
  2484.                 String [] policyLabels = null;
  2485.                 String [] policyValues = null;
  2486.                 if(!TipoOperazione.CHANGE.equals(tipoOperazione) && valoreNonSelezionato){
  2487.                     policyLabels = new String[gestorePolicyTokenList.size() + 1];
  2488.                     policyValues = new String[gestorePolicyTokenList.size() + 1];
  2489.                    
  2490.                     policyLabels[0] = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  2491.                     policyValues[0] = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  2492.                 }
  2493.                 else {
  2494.                     policyLabels = new String[gestorePolicyTokenList.size()];
  2495.                     policyValues = new String[gestorePolicyTokenList.size()];
  2496.                 }
  2497.                
  2498.                 for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  2499.                     GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  2500.                     if(!TipoOperazione.CHANGE.equals(tipoOperazione) && valoreNonSelezionato){
  2501.                         policyLabels[(i+1)] = genericProperties.getNome();
  2502.                         policyValues[(i+1)] = genericProperties.getNome();
  2503.                     }
  2504.                     else {
  2505.                         policyLabels[i] = genericProperties.getNome();
  2506.                         policyValues[i] = genericProperties.getNome();
  2507.                     }
  2508.                 }
  2509.                
  2510.                 de = new DataElement();
  2511.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_POLICY);
  2512.                 de.setType(DataElementType.SELECT);
  2513.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_POLICY);
  2514.                 de.setSelected(tokenPolicySA);
  2515.                 de.setValues(policyValues);
  2516.                 de.setLabels(policyLabels);
  2517.                 de.setSize(this.getSize());
  2518.                 de.setRequired(true);
  2519.                 dati.add(de);
  2520.                
  2521.                 de = new DataElement();
  2522.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  2523.                 de.setValue(StringEscapeUtils.escapeHtml(tokenClientIdSA));
  2524.                 de.setType(DataElementType.TEXT_EDIT);
  2525.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  2526.                 de.setSize(this.getSize());
  2527.                 de.setRequired(true);
  2528.                 dati.add(de);
  2529.                
  2530.             }

  2531.         }  
  2532.         else{
  2533.             de = new DataElement();
  2534.             de.setType(DataElementType.HIDDEN);
  2535.             de.setName(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_TIPO_AUTENTICAZIONE);
  2536.             de.setValue(ConnettoriCostanti.AUTENTICAZIONE_TIPO_NESSUNA);
  2537.             dati.add(de);
  2538.         }
  2539.        
  2540.         return dati;
  2541.     }
  2542.    
  2543.     public List<DataElement> addEndPointToDati(List<DataElement> dati, ServiceBinding serviceBinding, String connettoreDebug,
  2544.             String endpointtype, String autenticazioneHttp,String prefix, String url, String nome, String tipo,
  2545.             String user, String password, String initcont, String urlpgk,
  2546.             String provurl, String connfact, String sendas, String objectName, TipoOperazione tipoOperazione,
  2547.             String httpsurl, String httpstipologia, boolean httpshostverify,
  2548.             boolean httpsTrustVerifyCert, String httpspath, String httpstipo, String httpspwd,
  2549.             String httpsalgoritmo, boolean httpsstato, String httpskeystore,
  2550.             String httpspwdprivatekeytrust, String httpspathkey,
  2551.             String httpstipokey, String httpspwdkey,
  2552.             String httpspwdprivatekey, String httpsalgoritmokey,
  2553.             String httpsKeyAlias, String httpsTrustStoreCRLs, String httpsTrustStoreOCSPPolicy, String httpsKeyStoreBYOKPolicy,
  2554.             String tipoconn, String servletChiamante, String elem1, String elem2, String elem3,
  2555.             String elem4, String elem5, String elem6, String elem7, String elem8,
  2556.             String stato,
  2557.             boolean showSectionTitle,
  2558.             Boolean isConnettoreCustomUltimaImmagineSalvata,
  2559.             String proxyEnabled, String proxyHost, String proxyPort, String proxyUsername, String proxyPassword,
  2560.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  2561.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  2562.             String requestOutputFileName, String requestOutputFileNamePermissions, String requestOutputFileNameHeaders, String requestOutputFileNameHeadersPermissions,
  2563.             String requestOutputParentDirCreateIfNotExists,String requestOutputOverwriteIfExists,
  2564.             String responseInputMode, String responseInputFileName, String responseInputFileNameHeaders, String responseInputDeleteAfterRead, String responseInputWaitTime,
  2565.             boolean autenticazioneToken, String tokenPolicy, boolean forcePDND, boolean forceOAuth,
  2566.             List<ExtendedConnettore> listExtendedConnettore, boolean forceEnabled,
  2567.             String protocollo, boolean forceHttps, boolean forceHttpsClient,
  2568.             boolean visualizzaSezioneSAServer, boolean servizioApplicativoServerEnabled, String servizioApplicativoServer, String[] listaSAServer,
  2569.             String autenticazioneApiKey, boolean useOAS3Names, boolean useAppId, String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue,
  2570.             ConnettoreStatusParams connettoreStatusParams,
  2571.             boolean postBackViaPost) throws Exception {

  2572.         if(forcePDND || forceOAuth) {
  2573.             autenticazioneToken = true; // force
  2574.         }
  2575.        
  2576.         if(elem8==null) {
  2577.             // nop
  2578.         }
  2579.        
  2580.         if(dati==null) {
  2581.             throw new CoreException("Param dati is null");
  2582.         }

  2583.         Boolean confPers = ServletUtils.getObjectFromSession(this.request, this.session, Boolean.class, CostantiControlStation.SESSION_PARAMETRO_GESTIONE_CONFIGURAZIONI_PERSONALIZZATE);

  2584.         TipologiaConnettori tipologiaConnettori = null;
  2585.         try {
  2586.             tipologiaConnettori = Utilities.getTipologiaConnettori(this.core);
  2587.         } catch (Exception e) {
  2588.             // default
  2589.             tipologiaConnettori = TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL;
  2590.         }

  2591.         boolean modi = this.isProfiloModIPA(protocollo);
  2592.        
  2593.         boolean fruizione = false;
  2594.         boolean forceNoSec = false;
  2595.         if(servletChiamante!=null) {
  2596.             if (servletChiamante.equals(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE) ||
  2597.                     servletChiamante.equals(SoggettiCostanti.SERVLET_NAME_SOGGETTI_ENDPOINT)) {
  2598.                 fruizione = false;
  2599.                 forceNoSec = true;
  2600.             }
  2601.             else if (servletChiamante.equals(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE)) {
  2602.                 fruizione = true;
  2603.             }
  2604.             else if (servletChiamante.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT) ||
  2605.                     servletChiamante.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA) ||
  2606.                     servletChiamante.equals(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CHANGE)) {
  2607.                 fruizione = false;
  2608.             }
  2609.         }
  2610.        
  2611.         // override tipologiaconnettori :
  2612.         // se standard allora la tipologia connettori e' sempre http
  2613.         // indipendentemente
  2614.         // dalla proprieta settata
  2615.         if (this.isModalitaStandard()) {
  2616.             tipologiaConnettori = TipologiaConnettori.TIPOLOGIA_CONNETTORI_HTTP;
  2617.         }

  2618.         if(prefix==null){
  2619.             prefix="";
  2620.         }
  2621.        
  2622.         if(showSectionTitle){
  2623.             DataElement de = new DataElement();
  2624.             de.setLabel(prefix+ConnettoriCostanti.LABEL_CONNETTORE);
  2625.             de.setType(DataElementType.TITLE);
  2626.             dati.add(de);
  2627.         }

  2628.         boolean soloConnettoriHttp = false;
  2629.         if(forceHttps) {
  2630.             if(!this.isProfiloModIPA(protocollo)) {
  2631.                 // la scelta se usare il tipo https o la configurazione jvm per https deve rimanere.
  2632.                 // viene forzata solamente l'autenticazione client nel caso si scelga un connettore https per il profilo ModI
  2633.                 endpointtype = TipiConnettore.HTTPS.toString();
  2634.             }
  2635.             else {
  2636.                 // profilo modIPA, si deve usare solamente i connettori http
  2637.                 if (!TipologiaConnettori.TIPOLOGIA_CONNETTORI_HTTP.equals(tipologiaConnettori)) {
  2638.                     soloConnettoriHttp = true;
  2639.                 }
  2640.             }
  2641.         }
  2642.        
  2643.         if(
  2644.                 // serve sempre poter sceglire un applicativo server: this.isModalitaAvanzata() &&
  2645.                 visualizzaSezioneSAServer && (listaSAServer != null && listaSAServer.length > 0)) {
  2646.             DataElement de = new DataElement();
  2647.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_ABILITA_USO_APPLICATIVO_SERVER);
  2648.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ABILITA_USO_APPLICATIVO_SERVER);
  2649.             de.setType(DataElementType.CHECKBOX);
  2650.             de.setSelected(servizioApplicativoServerEnabled);
  2651.             if(postBackViaPost) {
  2652.                 de.setPostBack_viaPOST(true);
  2653.             }
  2654.             else {
  2655.                 de.setPostBack(true);
  2656.             }
  2657.             dati.add(de);
  2658.            
  2659.             de = new DataElement();
  2660.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_ID_APPLICATIVO_SERVER);
  2661.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ID_APPLICATIVO_SERVER);
  2662.             if(servizioApplicativoServerEnabled) {
  2663.                 de.setSelected(servizioApplicativoServer);
  2664.                 de.setValues(listaSAServer);
  2665.                 de.setType(DataElementType.SELECT);
  2666.             } else {
  2667.                 de.setType(DataElementType.HIDDEN);
  2668.                 de.setValue(servizioApplicativoServer);
  2669.             }
  2670.             dati.add(de);
  2671.            
  2672.             if(servizioApplicativoServerEnabled) {
  2673.                 dati = this.addEndPointToDatiAsHidden(dati, serviceBinding, connettoreDebug,
  2674.                         endpointtype, autenticazioneHttp,
  2675.                         url, nome, tipo, user, password, initcont, urlpgk, provurl, connfact, sendas, objectName, tipoOperazione,
  2676.                         httpsurl, httpstipologia, httpshostverify,
  2677.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd, httpsalgoritmo, httpsstato,
  2678.                         httpskeystore, httpspwdprivatekeytrust, httpspathkey, httpstipokey, httpspwdkey,
  2679.                         httpspwdprivatekey, httpsalgoritmokey,
  2680.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  2681.                         tipoconn, servletChiamante, elem1, elem2, elem3, elem4, elem5, elem6, elem7, stato,
  2682.                         proxyEnabled, proxyHost, proxyPort, proxyUsername, proxyPassword,
  2683.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  2684.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  2685.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  2686.                         requestOutputParentDirCreateIfNotExists, requestOutputOverwriteIfExists,
  2687.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  2688.                         autenticazioneToken, tokenPolicy,
  2689.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  2690.                         connettoreStatusParams);
  2691.             }
  2692.         }
  2693.        
  2694.         if(!servizioApplicativoServerEnabled) {
  2695.    
  2696.             /** VISUALIZZAZIONE HTTP ONLY MODE */
  2697.    
  2698.             if (TipologiaConnettori.TIPOLOGIA_CONNETTORI_HTTP.equals(tipologiaConnettori)) {
  2699.                
  2700.                 boolean configurazioneNonVisualizzabile = false;
  2701.                
  2702.                 DataElement de = new DataElement();
  2703.                 de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_ABILITATO);
  2704.    
  2705.                 de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_CHECK);
  2706.                 if(!TipiConnettore.HTTP.toString().equals(endpointtype) &&
  2707.                         !TipiConnettore.HTTPS.toString().equals(endpointtype) &&
  2708.                         (
  2709.                                 !TipiConnettore.DISABILITATO.toString().equals(endpointtype)
  2710.                                 ||
  2711.                                 (TipiConnettore.DISABILITATO.toString().equals(endpointtype) && forceEnabled)
  2712.                         )){
  2713.                     de.setLabel(null);
  2714.                     de.setValue(CostantiControlStation.LABEL_CONFIGURAZIONE_IMPOSTATA_MODALITA_AVANZATA_SHORT_MESSAGE);
  2715.                     de.setType(DataElementType.TEXT);
  2716.                     configurazioneNonVisualizzabile = true;
  2717.                     this.pd.disableEditMode();
  2718.                     this.pd.setMessage(CostantiControlStation.LABEL_CONFIGURAZIONE_IMPOSTATA_MODALITA_AVANZATA_LONG_MESSAGE, Costanti.MESSAGE_TYPE_INFO);
  2719.                    
  2720.                     for (int i = 0; i < dati.size(); i++) {
  2721.                         DataElement deCheck = dati.get(i);
  2722.                         if(ConnettoriCostanti.PARAMETRO_CONNETTORE_ABILITA_USO_APPLICATIVO_SERVER.equals(deCheck.getName())) {
  2723.                             dati.remove(i);
  2724.                             break;
  2725.                         }
  2726.                     }
  2727.                 }
  2728.                 else if( (  (AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS.equals(objectName) && TipoOperazione.CHANGE.equals(tipoOperazione))
  2729.                         ||
  2730.                         (AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI.equals(objectName) && TipoOperazione.CHANGE.equals(tipoOperazione))
  2731.                         )
  2732.                         && StatiAccordo.finale.toString().equals(stato) && this.isShowGestioneWorkflowStatoDocumenti() ){
  2733.                     if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  2734.                         de.setType(DataElementType.HIDDEN);
  2735.                         de.setValue(Costanti.CHECK_BOX_ENABLED);
  2736.                     }
  2737.                     else{
  2738.                         de.setLabel(null);
  2739.                         de.setType(DataElementType.TEXT);
  2740.                         de.setValue(TipiConnettore.DISABILITATO.toString());
  2741.                     }
  2742.                 }else{
  2743.                     if(forceEnabled) {
  2744.                         de.setType(DataElementType.HIDDEN);
  2745.                         de.setValue(Costanti.CHECK_BOX_ENABLED);
  2746.                     }
  2747.                     else {
  2748.                         de.setType(DataElementType.CHECKBOX);
  2749.                         if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  2750.                             de.setSelected(true);
  2751.                         }
  2752.                     }
  2753.                     if(postBackViaPost) {
  2754.                         de.setPostBack_viaPOST(true);
  2755.                     }
  2756.                     else {
  2757.                         de.setPostBack(true);
  2758.                     }
  2759.                 }
  2760.                 dati.add(de);
  2761.                
  2762.                
  2763.                 de = new DataElement();
  2764.                 de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE);
  2765.                 if (endpointtype.equals(TipiConnettore.HTTP.toString())) {
  2766.                     de.setValue(TipiConnettore.HTTP.toString());
  2767.                 }
  2768.                 else if (endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  2769.                     de.setValue(TipiConnettore.HTTPS.toString());
  2770.                 }
  2771.                 else {
  2772.                     de.setValue(TipiConnettore.DISABILITATO.toString());
  2773.                 }
  2774.                 de.setType(DataElementType.HIDDEN);
  2775.                 dati.add(de);
  2776.    
  2777.                
  2778.                 de = new DataElement();
  2779.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_DEBUG);
  2780.                 de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_DEBUG);
  2781.                 de.setType(DataElementType.HIDDEN);
  2782.                 if ( ServletUtils.isCheckBoxEnabled(connettoreDebug)) {
  2783.                     de.setValue(Costanti.CHECK_BOX_ENABLED_TRUE);
  2784.                 }
  2785.                 else{
  2786.                     de.setValue(Costanti.CHECK_BOX_DISABLED_FALSE);
  2787.                 }
  2788.                 dati.add(de);
  2789.                
  2790.                
  2791.                 de = new DataElement();
  2792.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL);
  2793.                 String tmpUrl = url;
  2794.                 if(
  2795.                         (url==null || "".equals(url) || "http://".equals(url) || "https://".equals(url) )
  2796.                         &&
  2797.                         (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString()))
  2798.                     ) {
  2799.                     if(this.isProfiloModIPA(protocollo)) {
  2800.                         tmpUrl =TipiConnettore.HTTPS.toString()+"://";
  2801.                     }
  2802.                     else {
  2803.                         tmpUrl =endpointtype+"://";
  2804.                     }
  2805.                 }
  2806.                 de.setValue(tmpUrl);
  2807.                 if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  2808.                     if ( !this.isShowGestioneWorkflowStatoDocumenti() || !StatiAccordo.finale.toString().equals(stato)) {
  2809.                         de.setType(DataElementType.TEXT_AREA);
  2810.                         de.setRequired(true);
  2811.                        
  2812.                         DataElementInfo dInfoPatternFileName = new DataElementInfo(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL);
  2813.                         dInfoPatternFileName.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  2814.                         dInfoPatternFileName.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_CONNETTORE_VALORI(modi, fruizione, forceNoSec));
  2815.                         de.setInfo(dInfoPatternFileName);
  2816.                     } else {
  2817.                         de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  2818.                     }
  2819.                     de.setRows(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL_SIZE);
  2820.                 }else{
  2821.                     de.setType(DataElementType.HIDDEN);
  2822.                 }
  2823.                 de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL);
  2824.                 de.setSize(this.getSize());
  2825.                 dati.add(de);
  2826.                
  2827.                
  2828.                 if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  2829.                    
  2830.                     // Autenticazione Http
  2831.                     boolean showAutenticazioneHttpBasic = true;
  2832.                     if(autenticazioneToken) {
  2833.                         if(forcePDND || forceOAuth) {
  2834.                             if(tokenPolicy!=null && !"".equals(tokenPolicy) && !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(tokenPolicy)) {
  2835.                                 showAutenticazioneHttpBasic = !isTokenPolicyModeUseAuthorizationHeader(tokenPolicy);
  2836.                             }
  2837.                             else {
  2838.                                 showAutenticazioneHttpBasic = false;
  2839.                             }
  2840.                         }
  2841.                         else {
  2842.                             showAutenticazioneHttpBasic = !isTokenPolicyModeUseAuthorizationHeader(tokenPolicy);
  2843.                         }
  2844.                     }
  2845.                    
  2846.                     de = new DataElement();
  2847.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_HTTP);
  2848.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);
  2849.                     if(showAutenticazioneHttpBasic) {
  2850.                         de.setType(DataElementType.CHECKBOX);
  2851.                         if ( ServletUtils.isCheckBoxEnabled(autenticazioneHttp)) {
  2852.                             de.setSelected(true);
  2853.                         }
  2854.                         if(postBackViaPost) {
  2855.                             de.setPostBack_viaPOST(true);
  2856.                         }
  2857.                         else {
  2858.                             de.setPostBack(true);
  2859.                         }
  2860.                     }
  2861.                     else {
  2862.                         de.setType(DataElementType.HIDDEN);
  2863.                         de.setValue(Costanti.CHECK_BOX_DISABLED);
  2864.                         autenticazioneHttp = Costanti.CHECK_BOX_DISABLED;
  2865.                     }
  2866.                     dati.add(de);      
  2867.                    
  2868.                     // Autenticazione Token
  2869.                     de = new DataElement();
  2870.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_BEARER);
  2871.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  2872.                     if(forcePDND || forceOAuth) {
  2873.                         de.setType(DataElementType.HIDDEN);
  2874.                         de.setValue(Costanti.CHECK_BOX_ENABLED_TRUE);
  2875.                     }
  2876.                     else {
  2877.                         de.setType(DataElementType.CHECKBOX);
  2878.                         de.setSelected(autenticazioneToken);
  2879.                         if(postBackViaPost) {
  2880.                             de.setPostBack_viaPOST(true);
  2881.                         }
  2882.                         else {
  2883.                             de.setPostBack(true);
  2884.                         }
  2885.                     }
  2886.                     dati.add(de);
  2887.                    
  2888.                     if(forcePDND || forceOAuth) {
  2889.                         de = new DataElement();
  2890.                         de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_BEARER);
  2891.                         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  2892.                         de.setType(DataElementType.TEXT);
  2893.                         if(forcePDND) {
  2894.                             de.setValue(ConnettoriCostanti.LABEL_CONNETTORE_BEARER_MODI_PDND);
  2895.                         }
  2896.                         else {
  2897.                             de.setValue(ConnettoriCostanti.LABEL_CONNETTORE_BEARER_MODI_OAUTH);
  2898.                         }
  2899.                         dati.add(de);
  2900.                     }
  2901.                    
  2902.                     // ApiKey
  2903.                     de = new DataElement();
  2904.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_API_KEY);
  2905.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_API_KEY);
  2906.                     de.setType(DataElementType.CHECKBOX);
  2907.                     if ( ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)) {
  2908.                         de.setSelected(true);
  2909.                     }
  2910.                     if(postBackViaPost) {
  2911.                         de.setPostBack_viaPOST(true);
  2912.                     }
  2913.                     else {
  2914.                         de.setPostBack(true);
  2915.                     }
  2916.                     dati.add(de);
  2917.                    
  2918.                     // Https
  2919.                     de = new DataElement();
  2920.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_HTTPS);
  2921.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTPS);
  2922.                     de.setType(DataElementType.CHECKBOX);
  2923.                     if (endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  2924.                         de.setSelected(true);
  2925.                     }
  2926.                     if(postBackViaPost) {
  2927.                         de.setPostBack_viaPOST(true);
  2928.                     }
  2929.                     else {
  2930.                         de.setPostBack(true);
  2931.                     }
  2932.                     dati.add(de);
  2933.                    
  2934.                     // Proxy
  2935.                     de = new DataElement();
  2936.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_PROXY);
  2937.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  2938.                     de.setType(DataElementType.CHECKBOX);
  2939.                     if ( ServletUtils.isCheckBoxEnabled(proxyEnabled)) {
  2940.                         de.setSelected(true);
  2941.                     }
  2942.                     if(postBackViaPost) {
  2943.                         de.setPostBack_viaPOST(true);
  2944.                     }
  2945.                     else {
  2946.                         de.setPostBack(true);
  2947.                     }
  2948.                     dati.add(de);
  2949.                    
  2950.                     // TempiRisposta
  2951.                     de = new DataElement();
  2952.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  2953.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  2954.                     de.setType(DataElementType.CHECKBOX);
  2955.                     if ( ServletUtils.isCheckBoxEnabled(tempiRispostaEnabled)) {
  2956.                         de.setSelected(true);
  2957.                     }
  2958.                     if(postBackViaPost) {
  2959.                         de.setPostBack_viaPOST(true);
  2960.                     }
  2961.                     else {
  2962.                         de.setPostBack(true);
  2963.                     }
  2964.                     dati.add(de);
  2965.                    
  2966.                 }  
  2967.                
  2968.                 // Extended
  2969.                 if(!configurazioneNonVisualizzabile &&
  2970.                     listExtendedConnettore!=null && !listExtendedConnettore.isEmpty()){
  2971.                     ServletExtendedConnettoreUtils.addToDatiEnabled(dati, listExtendedConnettore);
  2972.                 }
  2973.                
  2974.                 // opzioni avanzate
  2975.                 if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  2976.                     de = new DataElement();
  2977.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE);
  2978.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE);
  2979.                     if (this.isModalitaAvanzata()) {
  2980.                         de.setType(DataElementType.CHECKBOX);
  2981.                         de.setValue(opzioniAvanzate);
  2982.                         if ( ServletUtils.isCheckBoxEnabled(opzioniAvanzate)) {
  2983.                             de.setSelected(true);
  2984.                         }
  2985.                     }else{
  2986.                         de.setType(DataElementType.HIDDEN);
  2987.                         de.setValue(Costanti.CHECK_BOX_DISABLED);
  2988.                     }
  2989.                     if(postBackViaPost) {
  2990.                         de.setPostBack_viaPOST(true);
  2991.                     }
  2992.                     else {
  2993.                         de.setPostBack(true);
  2994.                     }
  2995.                     dati.add(de);
  2996.                 }
  2997.                
  2998.                 // Http Autenticazione
  2999.                 if (ServletUtils.isCheckBoxEnabled(autenticazioneHttp)) {
  3000.                     this.addCredenzialiToDati(dati, CostantiConfigurazione.CREDENZIALE_BASIC.getValue(), user, password, password, null,
  3001.                             servletChiamante,true,endpointtype,true,false, prefix, true,
  3002.                             postBackViaPost);
  3003.                 }
  3004.                
  3005.                                
  3006.                 // Token Autenticazione
  3007.                 if (autenticazioneToken) {
  3008.                     this.addTokenPolicy(dati, tokenPolicy, forcePDND, forceOAuth, tipoOperazione,
  3009.                             postBackViaPost);
  3010.                 }
  3011.            
  3012.                
  3013.                 // ApiKey
  3014.                 if ( ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)) {
  3015.                     this.addApiKeyToDati(dati, useOAS3Names, useAppId,
  3016.                             apiKeyHeader, apiKeyValue,
  3017.                             appIdHeader, appIdValue,
  3018.                             postBackViaPost);
  3019.                 }
  3020.            
  3021.                
  3022.                 // Https
  3023.                 if (endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  3024.                     ConnettoreHTTPSUtils.addHTTPSDati(dati, httpsurl, httpstipologia, httpshostverify, httpsTrustVerifyCert, httpspath, httpstipo,
  3025.                             httpspwd, httpsalgoritmo, httpsstato, httpskeystore, httpspwdprivatekeytrust, httpspathkey,
  3026.                             httpstipokey, httpspwdkey, httpspwdprivatekey, httpsalgoritmokey,
  3027.                             httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  3028.                             stato,
  3029.                             this.core, this, this.getSize(), false, prefix,
  3030.                             forceHttpsClient,
  3031.                             modi, fruizione, forceNoSec,
  3032.                             postBackViaPost);
  3033.                 }
  3034.                
  3035.                 // Proxy
  3036.                 if (
  3037.                         (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString()))
  3038.                         &&
  3039.                         ServletUtils.isCheckBoxEnabled(proxyEnabled)
  3040.                     ) {
  3041.                     this.addProxyToDati(dati, proxyHost, proxyPort, proxyUsername, proxyPassword,
  3042.                             postBackViaPost);
  3043.                 }
  3044.                
  3045.                 // TempiRisposta
  3046.                 if (
  3047.                         (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString()))
  3048.                         &&
  3049.                         ServletUtils.isCheckBoxEnabled(tempiRispostaEnabled)
  3050.                     ) {
  3051.                     this.addTempiRispostaToDati(dati, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  3052.                             postBackViaPost);
  3053.                 }
  3054.                
  3055.                 // Extended
  3056.                 if(listExtendedConnettore!=null && !listExtendedConnettore.isEmpty()){
  3057.                     ServletExtendedConnettoreUtils.addToDatiExtendedInfo(dati, listExtendedConnettore);
  3058.                 }
  3059.                
  3060.                 // Opzioni Avanzate
  3061.                 if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())){
  3062.                     this.addOpzioniAvanzateHttpToDati(dati, opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  3063.                             postBackViaPost);
  3064.                 }
  3065.                
  3066.             } else {
  3067.    
  3068.                 /** VISUALIZZAZIONE COMPLETA CONNETTORI MODE */
  3069.    
  3070.                 List<String> connettoriList = Connettori.getList();
  3071.                 if(forceEnabled) {
  3072.                     int indexDisabled = -1;
  3073.                     for (int i = 0; i < connettoriList.size(); i++) {
  3074.                         if(TipiConnettore.DISABILITATO.getNome().equals(connettoriList.get(i))) {
  3075.                             indexDisabled = i;
  3076.                             break;
  3077.                         }
  3078.                     }
  3079.                     if(indexDisabled>=0) {
  3080.                         connettoriList.remove(indexDisabled);
  3081.                     }
  3082.                 }
  3083.                 int sizeEP = connettoriList.size();
  3084.                 if (!connettoriList.contains(TipiConnettore.HTTPS.toString()))
  3085.                     sizeEP++;
  3086.                 if (confPers!=null && confPers.booleanValue() &&
  3087.                         TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL.equals(tipologiaConnettori))
  3088.                     sizeEP++;
  3089.                 String[] tipoEP = new String[sizeEP];
  3090.                 connettoriList.toArray(tipoEP);
  3091.                 int newCount = connettoriList.size();
  3092.                 if (!connettoriList.contains(TipiConnettore.HTTPS.toString())) {
  3093.                     tipoEP[newCount] = TipiConnettore.HTTPS.toString();
  3094.                     newCount++;
  3095.                 }
  3096.                 if (confPers!=null && confPers.booleanValue() &&
  3097.                         TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL.equals(tipologiaConnettori))
  3098.                     tipoEP[newCount] = TipiConnettore.CUSTOM.toString();
  3099.                
  3100.                 DataElement de = new DataElement();
  3101.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_ENDPOINT_TYPE);
  3102.                 de.setType(DataElementType.SELECT);
  3103.                 de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE);
  3104.                 if(soloConnettoriHttp) {
  3105.                     List<String> connettoriListHttp = new ArrayList<>();
  3106.                     connettoriListHttp.add(TipiConnettore.HTTP.toString());
  3107.                     connettoriListHttp.add(TipiConnettore.HTTPS.toString());
  3108.                     de.setValues(connettoriListHttp);
  3109.                    
  3110.                     List<String> connettoriListHttpLabels = new ArrayList<>();
  3111.                     connettoriListHttpLabels.add(TipiConnettore.HTTP.getLabel());
  3112.                     connettoriListHttpLabels.add(TipiConnettore.HTTPS.getLabel());
  3113.                     de.setLabels(connettoriListHttpLabels);
  3114.                 }
  3115.                 else {
  3116.                     de.setValues(tipoEP);
  3117.                    
  3118.                     List<String> connettoriListLabels = new ArrayList<>();
  3119.                     for (String tipoConnettore : tipoEP) {
  3120.                         TipiConnettore tipoC = TipiConnettore.toEnumFromName(tipoConnettore);
  3121.                         if(tipoC!=null) {
  3122.                             connettoriListLabels.add(tipoC.getLabel());
  3123.                         }
  3124.                         else {
  3125.                             connettoriListLabels.add(tipoConnettore);
  3126.                         }
  3127.                     }
  3128.                     de.setLabels(connettoriListLabels);
  3129.                 }
  3130.                 de.setSelected(endpointtype);
  3131.                 TipiConnettore tipoC = TipiConnettore.toEnumFromName(endpointtype);
  3132.                 if(tipoC!=null) {
  3133.                     de.setNote(tipoC.getNote());
  3134.                 }
  3135.                 if(postBackViaPost) {
  3136.                     de.setPostBack_viaPOST(true);
  3137.                 }
  3138.                 else {
  3139.                     de.setPostBack(true);
  3140.                 }
  3141.                 dati.add(de);
  3142.    
  3143.                 boolean connettoreCustomHidden = (endpointtype == null || !endpointtype.equals(TipiConnettore.CUSTOM.toString()));
  3144.                 this.addCustomField(TipoPlugin.CONNETTORE,
  3145.                         null,
  3146.                         null,
  3147.                         ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE,
  3148.                         ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO,
  3149.                         ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO,
  3150.                         tipoconn, connettoreCustomHidden, dati,
  3151.                         false);                
  3152.                                
  3153.                 de = new DataElement();
  3154.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL);
  3155.                 String tmpUrl = url;
  3156.                 if(
  3157.                         (url==null || "".equals(url) || "http://".equals(url) || "https://".equals(url) )
  3158.                         &&
  3159.                         (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString()))
  3160.                     ) {
  3161.                     if(this.isProfiloModIPA(protocollo)) {
  3162.                         tmpUrl =TipiConnettore.HTTPS.toString()+"://";
  3163.                     }
  3164.                     else {
  3165.                         tmpUrl =endpointtype+"://";
  3166.                     }
  3167.                 }
  3168.                 de.setValue(tmpUrl);
  3169.                 if (TipiConnettore.HTTP.toString().equals(endpointtype) || TipiConnettore.HTTPS.toString().equals(endpointtype)){
  3170.                     if (!this.isShowGestioneWorkflowStatoDocumenti() || !StatiAccordo.finale.toString().equals(stato)) {
  3171.                         de.setType(DataElementType.TEXT_AREA);
  3172.                         de.setRequired(true);
  3173.                        
  3174.                         DataElementInfo dInfoPatternFileName = new DataElementInfo(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL);
  3175.                         dInfoPatternFileName.setHeaderBody(DynamicHelperCostanti.LABEL_CONFIGURAZIONE_INFO_TRASPORTO);
  3176.                         dInfoPatternFileName.setListBody(DynamicHelperCostanti.getLABEL_CONFIGURAZIONE_INFO_CONNETTORE_VALORI(modi, fruizione, forceNoSec));
  3177.                         de.setInfo(dInfoPatternFileName);
  3178.                     } else {
  3179.                         de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  3180.                     }
  3181.                     de.setRows(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL_SIZE);
  3182.                 }
  3183.                 else{
  3184.                     de.setType(DataElementType.HIDDEN);
  3185.                 }
  3186.                 de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL);
  3187.                 de.setSize(this.getSize());
  3188.                 dati.add(de);
  3189.                    
  3190.                 if (TipiConnettore.HTTP.toString().equals(endpointtype) || TipiConnettore.HTTPS.toString().equals(endpointtype)){
  3191.                        
  3192.                     // Autenticazione Http
  3193.                     boolean showAutenticazioneHttpBasic = true;
  3194.                     if(autenticazioneToken) {
  3195.                         if(forcePDND || forceOAuth) {
  3196.                             if(tokenPolicy!=null && !"".equals(tokenPolicy) && !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(tokenPolicy)) {
  3197.                                 showAutenticazioneHttpBasic = !isTokenPolicyModeUseAuthorizationHeader(tokenPolicy);
  3198.                             }
  3199.                             else {
  3200.                                 showAutenticazioneHttpBasic = false;
  3201.                             }
  3202.                         }
  3203.                         else {
  3204.                             showAutenticazioneHttpBasic = !isTokenPolicyModeUseAuthorizationHeader(tokenPolicy);
  3205.                         }
  3206.                     }
  3207.                    
  3208.                     de = new DataElement();
  3209.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_HTTP);
  3210.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);
  3211.                     if(showAutenticazioneHttpBasic) {
  3212.                         de.setType(DataElementType.CHECKBOX);
  3213.                         if ( ServletUtils.isCheckBoxEnabled(autenticazioneHttp)) {
  3214.                             de.setSelected(true);
  3215.                         }
  3216.                         if(postBackViaPost) {
  3217.                             de.setPostBack_viaPOST(true);
  3218.                         }
  3219.                         else {
  3220.                             de.setPostBack(true);
  3221.                         }
  3222.                     }
  3223.                     else {
  3224.                         de.setType(DataElementType.HIDDEN);
  3225.                         de.setValue(Costanti.CHECK_BOX_DISABLED);
  3226.                         autenticazioneHttp = Costanti.CHECK_BOX_DISABLED;
  3227.                     }
  3228.                     dati.add(de);      
  3229.                    
  3230.                    
  3231.                     // Autenticazione Token
  3232.                     de = new DataElement();
  3233.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_BEARER);
  3234.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  3235.                     if(forcePDND || forceOAuth) {
  3236.                         de.setType(DataElementType.HIDDEN);
  3237.                         de.setValue(Costanti.CHECK_BOX_ENABLED_TRUE);
  3238.                     }
  3239.                     else {
  3240.                         de.setType(DataElementType.CHECKBOX);
  3241.                         de.setSelected(autenticazioneToken);
  3242.                         if(postBackViaPost) {
  3243.                             de.setPostBack_viaPOST(true);
  3244.                         }
  3245.                         else {
  3246.                             de.setPostBack(true);
  3247.                         }
  3248.                     }
  3249.                     dati.add(de);
  3250.                    
  3251.                     if(forcePDND || forceOAuth) {
  3252.                         de = new DataElement();
  3253.                         de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_BEARER);
  3254.                         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO+CostantiControlStation.PARAMETRO_SUFFIX_LABEL);
  3255.                         de.setType(DataElementType.TEXT);
  3256.                         if(forcePDND) {
  3257.                             de.setValue(ConnettoriCostanti.LABEL_CONNETTORE_BEARER_MODI_PDND);
  3258.                         }
  3259.                         else {
  3260.                             de.setValue(ConnettoriCostanti.LABEL_CONNETTORE_BEARER_MODI_OAUTH);
  3261.                         }
  3262.                         dati.add(de);
  3263.                     }
  3264.                    
  3265.                     // ApiKey
  3266.                     de = new DataElement();
  3267.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_API_KEY);
  3268.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_API_KEY);
  3269.                     de.setType(DataElementType.CHECKBOX);
  3270.                     if ( ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)) {
  3271.                         de.setSelected(true);
  3272.                     }
  3273.                     if(postBackViaPost) {
  3274.                         de.setPostBack_viaPOST(true);
  3275.                     }
  3276.                     else {
  3277.                         de.setPostBack(true);
  3278.                     }
  3279.                     dati.add(de);
  3280.                    
  3281.                     // Proxy
  3282.                     de = new DataElement();
  3283.                     de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_PROXY);
  3284.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  3285.                     de.setType(DataElementType.CHECKBOX);
  3286.                     if ( ServletUtils.isCheckBoxEnabled(proxyEnabled)) {
  3287.                         de.setSelected(true);
  3288.                     }
  3289.                     if(postBackViaPost) {
  3290.                         de.setPostBack_viaPOST(true);
  3291.                     }
  3292.                     else {
  3293.                         de.setPostBack(true);
  3294.                     }
  3295.                     dati.add(de);
  3296.                    
  3297.                     // TempiRisposta
  3298.                     de = new DataElement();
  3299.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  3300.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  3301.                     de.setType(DataElementType.CHECKBOX);
  3302.                     if ( ServletUtils.isCheckBoxEnabled(tempiRispostaEnabled)) {
  3303.                         de.setSelected(true);
  3304.                     }
  3305.                     if(postBackViaPost) {
  3306.                         de.setPostBack_viaPOST(true);
  3307.                     }
  3308.                     else {
  3309.                         de.setPostBack(true);
  3310.                     }
  3311.                     dati.add(de);
  3312.                 }
  3313.                                
  3314.                 // Extended
  3315.                 if(listExtendedConnettore!=null && !listExtendedConnettore.isEmpty()){
  3316.                     ServletExtendedConnettoreUtils.addToDatiEnabled(dati, listExtendedConnettore);
  3317.                 }
  3318.                
  3319.                 // opzioni avanzate
  3320.                 if (TipiConnettore.HTTP.toString().equals(endpointtype) || TipiConnettore.HTTPS.toString().equals(endpointtype)) {
  3321.                     de = new DataElement();
  3322.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE);
  3323.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE);
  3324.                     if (this.isModalitaAvanzata()) {
  3325.                         de.setType(DataElementType.CHECKBOX);
  3326.                         de.setValue(opzioniAvanzate);
  3327.                         if ( ServletUtils.isCheckBoxEnabled(opzioniAvanzate)) {
  3328.                             de.setSelected(true);
  3329.                         }
  3330.                     }else{
  3331.                         de.setType(DataElementType.HIDDEN);
  3332.                         de.setValue(Costanti.CHECK_BOX_DISABLED);
  3333.                     }
  3334.                     if(postBackViaPost) {
  3335.                         de.setPostBack_viaPOST(true);
  3336.                     }
  3337.                     else {
  3338.                         de.setPostBack(true);
  3339.                     }
  3340.                     dati.add(de);
  3341.                 }
  3342.                
  3343.                 // Debug
  3344.                 de = new DataElement();
  3345.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_DEBUG);
  3346.                 de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_DEBUG);
  3347.                 if(this.core.isShowDebugOptionConnettore() && !TipiConnettore.DISABILITATO.toString().equals(endpointtype)){
  3348.                     de.setType(DataElementType.CHECKBOX);
  3349.                     if ( ServletUtils.isCheckBoxEnabled(connettoreDebug)) {
  3350.                         de.setSelected(true);
  3351.                     }
  3352.                     de.setInfo(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_DEBUG, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_DEBUG_INFO);
  3353.                     de.setNote(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_DEBUG_NODE);
  3354.                 }
  3355.                 else{
  3356.                     de.setType(DataElementType.HIDDEN);
  3357.                 }
  3358.                 if ( ServletUtils.isCheckBoxEnabled(connettoreDebug)) {
  3359.                     de.setValue(Costanti.CHECK_BOX_ENABLED_TRUE);
  3360.                 }
  3361.                 else{
  3362.                     de.setValue(Costanti.CHECK_BOX_DISABLED_FALSE);
  3363.                 }
  3364.                 dati.add(de);
  3365.                
  3366.                 // Autenticazione http
  3367.                 if (ServletUtils.isCheckBoxEnabled(autenticazioneHttp)) {
  3368.                     this.addCredenzialiToDati(dati, CostantiConfigurazione.CREDENZIALE_BASIC.getValue(), user, password, password, null,
  3369.                             servletChiamante,true,endpointtype,true,false, prefix, true,
  3370.                             postBackViaPost);
  3371.                 }
  3372.                
  3373.                 // Token Autenticazione
  3374.                 if (autenticazioneToken) {
  3375.                     this.addTokenPolicy(dati, tokenPolicy, forcePDND, forceOAuth, tipoOperazione,
  3376.                             postBackViaPost);
  3377.                 }
  3378.                
  3379.                 // ApiKey
  3380.                 if ( ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)) {
  3381.                     this.addApiKeyToDati(dati, useOAS3Names, useAppId,
  3382.                             apiKeyHeader, apiKeyValue,
  3383.                             appIdHeader, appIdValue,
  3384.                             postBackViaPost);
  3385.                 }
  3386.                
  3387.                 // Custom
  3388.                 boolean showProprietaCustom = false;
  3389.                 if (endpointtype != null && endpointtype.equals(TipiConnettore.CUSTOM.toString()) &&
  3390.                         !servletChiamante.equals(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_ADD) &&
  3391.                         !servletChiamante.equals(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD) &&
  3392.                         (isConnettoreCustomUltimaImmagineSalvata!=null && isConnettoreCustomUltimaImmagineSalvata)) {
  3393.                    
  3394.                     showProprietaCustom = true;
  3395.                    
  3396.                     String postBack = this.getPostBackElementName();
  3397.                     if(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE.equals(postBack) ||
  3398.                             ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO.equals(postBack) ) {
  3399.                         showProprietaCustom = false;
  3400.                     }
  3401.                 }
  3402.                 if(showProprietaCustom) {
  3403.                     de = new DataElement();
  3404.                     de.setType(DataElementType.LINK);
  3405.                     de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_PROPRIETA);
  3406.                     int numProp = 0;
  3407.                     try {
  3408.                         if (servletChiamante.equals(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_CHANGE)) {
  3409.                             de.setUrl(ConnettoriCostanti.SERVLET_NAME_CONNETTORI_CUSTOM_PROPERTIES_LIST,
  3410.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET, servletChiamante),
  3411.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID, elem1),
  3412.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO, elem2),
  3413.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SERVIZIO, elem3),
  3414.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_VERSIONE_SERVIZIO, elem4));
  3415.                             AccordoServizioParteSpecifica asps = this.apsCore.getAccordoServizioParteSpecifica(Long.parseLong(elem1));
  3416.                             org.openspcoop2.core.registry.Connettore connettore = asps.getConfigurazioneServizio().getConnettore();
  3417.                             if (connettore != null && (connettore.getCustom()!=null && connettore.getCustom()) ){
  3418.                                 for (int i = 0; i < connettore.sizePropertyList(); i++) {
  3419.                                     if(!CostantiDB.CONNETTORE_DEBUG.equals(connettore.getProperty(i).getNome())  &&
  3420.                                             !connettore.getProperty(i).getNome().startsWith(CostantiConnettori.CONNETTORE_EXTENDED_PREFIX)){
  3421.                                         numProp++;
  3422.                                     }
  3423.                                 }
  3424.                                 /** Non devo contare la proprietà debug: numProp = connettore.sizePropertyList();*/
  3425.                             }
  3426.                         }
  3427.                         else if (servletChiamante.equals(AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_CHANGE)) {
  3428.                             List<Parameter> lstParams = new ArrayList<>();
  3429.                            
  3430.                             String accessoDaAPSParametro = this.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS);
  3431.                             if(accessoDaAPSParametro != null)
  3432.                                 lstParams.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS, accessoDaAPSParametro));
  3433.                            
  3434.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET, servletChiamante));
  3435.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID, elem1));
  3436.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_MY_ID, elem2));
  3437.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SOGGETTO_EROGATORE, elem3));
  3438.                             lstParams.add(new Parameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUITORE_VIEW_CONNETTORE_MAPPING_AZIONE_ID_PORTA, elem4));
  3439.                            
  3440.                             de.setUrl(ConnettoriCostanti.SERVLET_NAME_CONNETTORI_CUSTOM_PROPERTIES_LIST, lstParams.toArray(new Parameter[lstParams.size()]));
  3441.                            
  3442.                            
  3443.                             int idServizioFruitoreInt = Integer.parseInt(elem2);
  3444.                             Fruitore servFru = this.apsCore.getServizioFruitore(idServizioFruitoreInt);
  3445.                             org.openspcoop2.core.registry.Connettore connettore = servFru.getConnettore();
  3446.                             if (connettore != null && (connettore.getCustom()!=null && connettore.getCustom()) ){
  3447.                                 for (int i = 0; i < connettore.sizePropertyList(); i++) {
  3448.                                     if(!CostantiDB.CONNETTORE_DEBUG.equals(connettore.getProperty(i).getNome())  &&
  3449.                                             !connettore.getProperty(i).getNome().startsWith(CostantiConnettori.CONNETTORE_EXTENDED_PREFIX)){
  3450.                                         numProp++;
  3451.                                     }
  3452.                                 }
  3453.                                 /** Non devo contare la proprietà debug: numProp = connettore.sizePropertyList();*/
  3454.                             }
  3455.                         }
  3456.                         else if (servletChiamante.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT) ||
  3457.                                 servletChiamante.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA)) {
  3458.                             int idSilInt = Integer.parseInt(elem2);
  3459.                             ServizioApplicativo sa = this.saCore.getServizioApplicativo(idSilInt);
  3460.                             Soggetto soggetto = this.soggettiCore.getSoggettoRegistro(new IDSoggetto(sa.getTipoSoggettoProprietario(), sa.getNomeSoggettoProprietario()));
  3461.                             List<Parameter> lstParams = new ArrayList<>();
  3462.                            
  3463.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET, servletChiamante));
  3464.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO, elem1));
  3465.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO, elem2));
  3466.                             if(elem3 != null)
  3467.                                 lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID, elem3));
  3468.                             if(elem4 != null)
  3469.                                 lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_PORTA, elem4));
  3470.                             lstParams.add(new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER, soggetto.getId()+""));
  3471.                            
  3472.                             String accessoDaAPSParametro = this.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS);
  3473.                             if(accessoDaAPSParametro != null)
  3474.                                 lstParams.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS, accessoDaAPSParametro));
  3475.    
  3476.                             de.setUrl(ConnettoriCostanti.SERVLET_NAME_CONNETTORI_CUSTOM_PROPERTIES_LIST, lstParams.toArray(new Parameter[lstParams.size()]));
  3477.                            
  3478.                             if (servletChiamante.equals(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT)) {
  3479.                                 InvocazioneServizio is = sa.getInvocazioneServizio();
  3480.                                 Connettore connettore = is.getConnettore();
  3481.                                 if(connettore!=null && (connettore.getCustom()==null || !connettore.getCustom()) ){
  3482.                                     // è cambiato il tipo
  3483.                                     de.setType(DataElementType.HIDDEN);
  3484.                                 }
  3485.                                 if (connettore != null && connettore.getCustom()!=null && connettore.getCustom().booleanValue()){
  3486.                                     for (int i = 0; i < connettore.sizePropertyList(); i++) {
  3487.                                         if(!CostantiDB.CONNETTORE_DEBUG.equals(connettore.getProperty(i).getNome())  &&
  3488.                                                 !connettore.getProperty(i).getNome().startsWith(CostantiConnettori.CONNETTORE_EXTENDED_PREFIX)){
  3489.                                             numProp++;
  3490.                                         }
  3491.                                     }
  3492.                                     /** Non devo contare la proprietà debug: numProp = connettore.sizePropertyList();*/
  3493.                                 }
  3494.                             } else {
  3495.                                 RispostaAsincrona ra = sa.getRispostaAsincrona();
  3496.                                 Connettore connettore = ra.getConnettore();
  3497.                                 if(connettore!=null && (connettore.getCustom()==null || !connettore.getCustom()) ){
  3498.                                     // è cambiato il tipo
  3499.                                     de.setType(DataElementType.HIDDEN);
  3500.                                 }
  3501.                                 if (connettore != null && connettore.getCustom()!=null && connettore.getCustom().booleanValue()){
  3502.                                     for (int i = 0; i < connettore.sizePropertyList(); i++) {
  3503.                                         if(!CostantiDB.CONNETTORE_DEBUG.equals(connettore.getProperty(i).getNome())  &&
  3504.                                                 !connettore.getProperty(i).getNome().startsWith(CostantiConnettori.CONNETTORE_EXTENDED_PREFIX)){
  3505.                                             numProp++;
  3506.                                         }
  3507.                                     }
  3508.                                     /** Non devo contare la proprietà debug: numProp = connettore.sizePropertyList(); */
  3509.                                 }
  3510.                             }
  3511.                         }
  3512.                         else if (servletChiamante.equals(PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CHANGE)) {
  3513.                             int idSilInt = Integer.parseInt(elem6);
  3514.                             ServizioApplicativo sa = this.saCore.getServizioApplicativo(idSilInt);
  3515.                             Soggetto soggetto = this.soggettiCore.getSoggettoRegistro(new IDSoggetto(sa.getTipoSoggettoProprietario(), sa.getNomeSoggettoProprietario()));
  3516.                            
  3517.                             List<Parameter> lstParams = new ArrayList<>();
  3518.                            
  3519.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET, servletChiamante));
  3520.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SERVIZIO_APPLICATIVO, sa.getNome()));
  3521.                             lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_SERVIZIO_APPLICATIVO, elem6));
  3522.                             if(elem3 != null)
  3523.                                 lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID, elem3));
  3524.                             if(elem1 != null)
  3525.                                 lstParams.add(new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID_PORTA, elem1));
  3526.                             lstParams.add(new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER, soggetto.getId()+""));
  3527.                            
  3528.                             String accessoDaAPSParametro = this.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS);
  3529.                             String connettoreAccessoGruppi = this.getParameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI);
  3530.                             String connettoreRegistro = this.getParameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO);
  3531.                            
  3532.                             lstParams.add(new Parameter(CostantiControlStation.PARAMETRO_ID_CONN_TAB, elem7));
  3533.                             lstParams.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CONFIGURAZIONE_DATI_GENERALI, Costanti.CHECK_BOX_ENABLED_TRUE));
  3534.                             lstParams.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS, accessoDaAPSParametro != null ? accessoDaAPSParametro : ""));
  3535.                             lstParams.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_GRUPPI, connettoreAccessoGruppi));
  3536.                             lstParams.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_REGISTRO, connettoreRegistro));
  3537.                             lstParams.add(new Parameter(CostantiControlStation.PARAMETRO_VERIFICA_CONNETTORE_ACCESSO_DA_LISTA_CONNETTORI_MULTIPLI, "true"));
  3538.                            
  3539.                             de.setUrl(ConnettoriCostanti.SERVLET_NAME_CONNETTORI_CUSTOM_PROPERTIES_LIST, lstParams.toArray(new Parameter[lstParams.size()]));
  3540.                            
  3541.                             InvocazioneServizio is = sa.getInvocazioneServizio();
  3542.                             Connettore connettore = is.getConnettore();
  3543.                             if(connettore==null || connettore.getCustom()==null || !connettore.getCustom().booleanValue()){
  3544.                                 // è cambiato il tipo
  3545.                                 de.setType(DataElementType.HIDDEN);
  3546.                             }
  3547.                             if (connettore != null && connettore.getCustom()!=null && connettore.getCustom().booleanValue()){
  3548.                                 for (int i = 0; i < connettore.sizePropertyList(); i++) {
  3549.                                     if(!CostantiDB.CONNETTORE_DEBUG.equals(connettore.getProperty(i).getNome())  &&
  3550.                                             !connettore.getProperty(i).getNome().startsWith(CostantiConnettori.CONNETTORE_EXTENDED_PREFIX)){
  3551.                                         numProp++;
  3552.                                     }
  3553.                                 }
  3554.                                 /** Non devo contare la proprietà debug: numProp = connettore.sizePropertyList();*/
  3555.                             }
  3556.                         }
  3557.                         else if (servletChiamante.equals(SoggettiCostanti.SERVLET_NAME_SOGGETTI_ENDPOINT)) {
  3558.                             de.setUrl(ConnettoriCostanti.SERVLET_NAME_CONNETTORI_CUSTOM_PROPERTIES_LIST,
  3559.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_SERVLET, servletChiamante),
  3560.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_ID, elem1),
  3561.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_NOME_SOGGETTO, elem2),
  3562.                                     new Parameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_TIPO_SOGGETTO, elem3));
  3563.                             int idInt = Integer.parseInt(elem1);
  3564.                             SoggettoCtrlStat scs = this.soggettiCore.getSoggettoCtrlStat(idInt);
  3565.                             Soggetto ss = scs.getSoggettoReg();
  3566.                             org.openspcoop2.core.registry.Connettore connettore = ss.getConnettore();
  3567.                             if (connettore != null && (connettore.getCustom()!=null && connettore.getCustom()) ){
  3568.                                 for (int i = 0; i < connettore.sizePropertyList(); i++) {
  3569.                                     if(!CostantiDB.CONNETTORE_DEBUG.equals(connettore.getProperty(i).getNome())  &&
  3570.                                             !connettore.getProperty(i).getNome().startsWith(CostantiConnettori.CONNETTORE_EXTENDED_PREFIX)){
  3571.                                         numProp++;
  3572.                                     }
  3573.                                 }
  3574.                                 /** Non devo contare la proprietà debug: numProp = connettore.sizePropertyList();*/
  3575.                             }
  3576.                         }
  3577.                     } catch (Exception ex) {
  3578.                         this.logError("Custom Property Exception: " + ex.getMessage(), ex);
  3579.                     }
  3580.                     de.setValue(ConnettoriCostanti.LABEL_CONNETTORE_PROPRIETA+"("+numProp+")");
  3581.                     dati.add(de);
  3582.                 }
  3583.                
  3584.                 // Https
  3585.                 if (TipiConnettore.HTTPS.toString().equals(endpointtype)) {
  3586.                     ConnettoreHTTPSUtils.addHTTPSDati(dati, httpsurl, httpstipologia, httpshostverify, httpsTrustVerifyCert, httpspath, httpstipo, httpspwd, httpsalgoritmo,
  3587.                             httpsstato, httpskeystore, httpspwdprivatekeytrust, httpspathkey, httpstipokey, httpspwdkey, httpspwdprivatekey, httpsalgoritmokey,
  3588.                             httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  3589.                             stato,
  3590.                             this.core, this, this.getSize(), false, prefix,
  3591.                             forceHttpsClient,
  3592.                             modi, fruizione, forceNoSec,
  3593.                             postBackViaPost);
  3594.                 }
  3595.    
  3596.                 // Jms
  3597.                 if (TipiConnettore.JMS.getNome().equals(endpointtype)) {
  3598.                     ConnettoreJMSUtils.addJMSDati(dati, nome, tipo, user, password, initcont, urlpgk,
  3599.                             provurl, connfact, sendas, objectName, tipoOperazione, stato,
  3600.                             this.core, this, this.getSize(),
  3601.                             postBackViaPost);
  3602.                 }
  3603.                
  3604.                 //status
  3605.                 if (TipiConnettore.STATUS.toString().equals(endpointtype)) {
  3606.                     connettoreStatusParams.addDati(dati, serviceBinding, postBackViaPost);
  3607.                 }
  3608.                
  3609.                 // FileSystem
  3610.                 if (TipiConnettore.FILE.toString().equals(endpointtype)) {
  3611.                     ConnettoreFileUtils.addFileDati(dati, this.getSize(),this,
  3612.                             requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  3613.                             requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  3614.                             responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  3615.                             modi, fruizione, forceNoSec,
  3616.                             postBackViaPost);
  3617.                 }
  3618.                
  3619.                 // Proxy
  3620.                 if (
  3621.                         (TipiConnettore.HTTP.toString().equals(endpointtype) || TipiConnettore.HTTPS.toString().equals(endpointtype))
  3622.                         &&
  3623.                         ServletUtils.isCheckBoxEnabled(proxyEnabled)
  3624.                     ) {
  3625.                     this.addProxyToDati(dati, proxyHost, proxyPort, proxyUsername, proxyPassword,
  3626.                             postBackViaPost);
  3627.                 }
  3628.                
  3629.                 // TempiRisposta
  3630.                 if (
  3631.                         (TipiConnettore.HTTP.toString().equals(endpointtype) || TipiConnettore.HTTPS.toString().equals(endpointtype))
  3632.                         &&
  3633.                         ServletUtils.isCheckBoxEnabled(tempiRispostaEnabled)
  3634.                     ) {
  3635.                     this.addTempiRispostaToDati(dati, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  3636.                             postBackViaPost);
  3637.                 }
  3638.                
  3639.                 // Extended
  3640.                 if(listExtendedConnettore!=null && !listExtendedConnettore.isEmpty()){
  3641.                     ServletExtendedConnettoreUtils.addToDatiExtendedInfo(dati, listExtendedConnettore);
  3642.                 }
  3643.                
  3644.                 // Opzioni Avanzate
  3645.                 if (TipiConnettore.HTTP.toString().equals(endpointtype) || TipiConnettore.HTTPS.toString().equals(endpointtype)){
  3646.                     this.addOpzioniAvanzateHttpToDati(dati, opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  3647.                             postBackViaPost);
  3648.                 }
  3649.    
  3650.             }
  3651.         }

  3652.         return dati;
  3653.     }
  3654.    
  3655.     public List<DataElement> addEndPointSAServerToDatiAsHidden(List<DataElement> dati, boolean servizioApplicativoServerEnabled, String servizioApplicativoServer){
  3656.         DataElement de = new DataElement();
  3657.         de.setType(DataElementType.HIDDEN);
  3658.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ABILITA_USO_APPLICATIVO_SERVER);
  3659.         de.setValue(servizioApplicativoServerEnabled + "");
  3660.         dati.add(de);
  3661.        
  3662.         de = new DataElement();
  3663.         de.setType(DataElementType.HIDDEN);
  3664.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ID_APPLICATIVO_SERVER);
  3665.         de.setValue(servizioApplicativoServer);
  3666.         dati.add(de);
  3667.        
  3668.         return dati;
  3669.     }

  3670.     public List<DataElement> addEndPointToDatiAsHidden(List<DataElement> dati, ServiceBinding serviceBinding, String connettoreDebug,
  3671.             String endpointtype, String autenticazioneHttp,
  3672.             String url, String nome, String tipo,
  3673.             String user, String password, String initcont, String urlpgk,
  3674.             String provurl, String connfact, String sendas, String objectName, TipoOperazione tipoOperazione,
  3675.             String httpsurl, String httpstipologia, boolean httpshostverify,
  3676.             boolean httpsTrustVerifyCert, String httpspath, String httpstipo, String httpspwd,
  3677.             String httpsalgoritmo, boolean httpsstato, String httpskeystore,
  3678.             String httpspwdprivatekeytrust, String httpspathkey,
  3679.             String httpstipokey, String httpspwdkey,
  3680.             String httpspwdprivatekey, String httpsalgoritmokey,
  3681.             String httpsKeyAlias, String httpsTrustStoreCRLs, String httpsTrustStoreOCSPPolicy, String httpsKeyStoreBYOKPolicy,
  3682.             String tipoconn, String servletChiamante, String elem1, String elem2, String elem3,
  3683.             String elem4, String elem5, String elem6, String elem7, String stato,
  3684.             String proxyEnabled, String proxyHost, String proxyPort, String proxyUsername, String proxyPassword,
  3685.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  3686.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  3687.             String requestOutputFileName, String requestOutputFileNamePermissions, String requestOutputFileNameHeaders, String requestOutputFileNameHeadersPermissions,
  3688.             String requestOutputParentDirCreateIfNotExists,String requestOutputOverwriteIfExists,
  3689.             String responseInputMode, String responseInputFileName, String responseInputFileNameHeaders, String responseInputDeleteAfterRead, String responseInputWaitTime,
  3690.             boolean autenticazioneToken, String tokenPolicy,
  3691.             String autenticazioneApiKey, boolean useOAS3Names, boolean useAppId, String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue,
  3692.             ConnettoreStatusParams connettoreStatusParams) throws DriverControlStationException, UtilsException {

  3693.         if(tipo!=null || servletChiamante!=null) {
  3694.             // nop
  3695.         }
  3696.         if(elem1!=null || elem2!=null || elem3!=null || elem4!=null || elem5!=null || elem6!=null || elem7!=null) {
  3697.             // nop
  3698.         }

  3699.         Boolean confPers = ServletUtils.getObjectFromSession(this.request, this.session, Boolean.class, CostantiControlStation.SESSION_PARAMETRO_GESTIONE_CONFIGURAZIONI_PERSONALIZZATE);

  3700.         TipologiaConnettori tipologiaConnettori = null;
  3701.         try {
  3702.             tipologiaConnettori = Utilities.getTipologiaConnettori(this.core);
  3703.         } catch (Exception e) {
  3704.             // default
  3705.             tipologiaConnettori = TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL;
  3706.         }

  3707.         // override tipologiaconnettori :
  3708.         // se standard allora la tipologia connettori e' sempre http
  3709.         // indipendentemente
  3710.         // dalla proprieta settata
  3711.         if (this.isModalitaStandard()) {
  3712.             tipologiaConnettori = TipologiaConnettori.TIPOLOGIA_CONNETTORI_HTTP;
  3713.         }


  3714.         DataElement de = new DataElement();
  3715.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_DEBUG);
  3716.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_DEBUG);
  3717.         de.setType(DataElementType.HIDDEN);
  3718.         if ( ServletUtils.isCheckBoxEnabled(connettoreDebug)) {
  3719.             de.setValue(Costanti.CHECK_BOX_ENABLED_TRUE);
  3720.         }
  3721.         else{
  3722.             de.setValue(Costanti.CHECK_BOX_DISABLED_FALSE);
  3723.         }
  3724.         dati.add(de);
  3725.        
  3726.        
  3727.         /** VISUALIZZAZIONE HTTP ONLY MODE */

  3728.         if (TipologiaConnettori.TIPOLOGIA_CONNETTORI_HTTP.equals(tipologiaConnettori)) {
  3729.            
  3730.             de = new DataElement();
  3731.             de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE_ABILITATO);

  3732.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_CHECK);
  3733.             if(!TipiConnettore.HTTP.toString().equals(endpointtype) &&
  3734.                     !TipiConnettore.HTTPS.toString().equals(endpointtype) &&
  3735.                     !TipiConnettore.DISABILITATO.toString().equals(endpointtype)){
  3736.                 de.setType(DataElementType.HIDDEN);
  3737.                 de.setValue(Costanti.CHECK_BOX_DISABLED);
  3738.             }
  3739.             else if( (  (AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS.equals(objectName) && TipoOperazione.CHANGE.equals(tipoOperazione))
  3740.                     ||
  3741.                     (AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI.equals(objectName) && TipoOperazione.CHANGE.equals(tipoOperazione))
  3742.                     )
  3743.                     && StatiAccordo.finale.toString().equals(stato) && this.isShowGestioneWorkflowStatoDocumenti() ){
  3744.                 if (endpointtype.equals(TipiConnettore.HTTP.toString())) {
  3745.                     de.setType(DataElementType.HIDDEN);
  3746.                     de.setValue(Costanti.CHECK_BOX_ENABLED);
  3747.                 }else{
  3748.                     de.setType(DataElementType.HIDDEN);
  3749.                     de.setLabel(TipiConnettore.DISABILITATO.toString());
  3750.                     de.setValue(Costanti.CHECK_BOX_DISABLED);
  3751.                 }
  3752.             }else{
  3753.                 de.setType(DataElementType.HIDDEN);
  3754.                 if (endpointtype.equals(TipiConnettore.HTTP.toString())) {
  3755.                     de.setValue(Costanti.CHECK_BOX_ENABLED);
  3756.                 }
  3757.             }
  3758.             dati.add(de);

  3759.             de = new DataElement();
  3760.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE);
  3761.             if (endpointtype.equals(TipiConnettore.HTTP.toString())) {
  3762.                 de.setValue(TipiConnettore.HTTP.toString());
  3763.             }
  3764.             else if (endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  3765.                 de.setValue(TipiConnettore.HTTPS.toString());
  3766.             }else {
  3767.                 de.setValue(TipiConnettore.DISABILITATO.toString());
  3768.             }
  3769.             de.setType(DataElementType.HIDDEN);
  3770.             dati.add(de);

  3771.             de = new DataElement();
  3772.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL);
  3773.             String defaultPrefixValue = "http://";
  3774.             if (endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  3775.                 defaultPrefixValue = "https://";
  3776.             }
  3777.             de.setValue((url != null) && !"".equals(url) && !"http://".equals(url) && !"https://".equals(url) ? url : defaultPrefixValue);
  3778.             de.setType(DataElementType.HIDDEN);
  3779.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL);
  3780.             dati.add(de);

  3781.         } else {

  3782.             /** VISUALIZZAZIONE COMPLETA CONNETTORI MODE */


  3783.             int sizeEP = Connettori.getList().size();
  3784.             if (!Connettori.getList().contains(TipiConnettore.HTTPS.toString()))
  3785.                 sizeEP++;
  3786.             if (confPers!=null && confPers.booleanValue() &&
  3787.                     TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL.equals(tipologiaConnettori))
  3788.                 sizeEP++;
  3789.             String[] tipoEP = new String[sizeEP];
  3790.             Connettori.getList().toArray(tipoEP);
  3791.             int newCount = Connettori.getList().size();
  3792.             if (!Connettori.getList().contains(TipiConnettore.HTTPS.toString())) {
  3793.                 tipoEP[newCount] = TipiConnettore.HTTPS.toString();
  3794.                 newCount++;
  3795.             }
  3796.             if (confPers!=null && confPers.booleanValue() &&
  3797.                     TipologiaConnettori.TIPOLOGIA_CONNETTORI_ALL.equals(tipologiaConnettori))
  3798.                 tipoEP[newCount] = TipiConnettore.CUSTOM.toString();

  3799.             de = new DataElement();
  3800.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_ENDPOINT_TYPE);
  3801.             de.setType(DataElementType.HIDDEN);
  3802.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE);
  3803.             de.setValue(endpointtype);
  3804.             dati.add(de);

  3805.             de = new DataElement();
  3806.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL);
  3807.             de.setValue(url);
  3808.             de.setType(DataElementType.HIDDEN);
  3809.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL);
  3810.             de.setSize(this.getSize());
  3811.             dati.add(de);

  3812.             de = new DataElement();
  3813.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO);
  3814.             de.setType(DataElementType.HIDDEN);
  3815.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO);
  3816.             de.setValue(tipoconn);
  3817.             dati.add(de);

  3818.         }
  3819.        
  3820.         // Https
  3821.         if (endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  3822.             ConnettoreHTTPSUtils.addHTTPSDatiAsHidden(dati, httpsurl, httpstipologia, httpshostverify, httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  3823.                     httpsalgoritmo, httpsstato, httpskeystore, httpspwdprivatekeytrust, httpspathkey, httpstipokey, httpspwdkey, httpspwdprivatekey, httpsalgoritmokey,
  3824.                     httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  3825.                     stato,
  3826.                     this.core,this.getSize());
  3827.            
  3828.         }

  3829.         if (endpointtype.equals(TipiConnettore.JMS.getNome())) {
  3830.             ConnettoreJMSUtils.addJMSDatiAsHidden(dati, nome, tipoconn, user, password, initcont, urlpgk,
  3831.                     provurl, connfact, sendas, objectName, tipoOperazione, stato,
  3832.                     this.core,this.getSize());
  3833.         }

  3834.         if (endpointtype.equals(TipiConnettore.FILE.toString())) {
  3835.             ConnettoreFileUtils.addFileDatiAsHidden(dati,
  3836.                     requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  3837.                     requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  3838.                     responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime);
  3839.            
  3840.            
  3841.         }
  3842.        
  3843.         if (endpointtype.equals(TipiConnettore.STATUS.toString())) {
  3844.             connettoreStatusParams.addDatiHidden(dati, serviceBinding);
  3845.         }
  3846.        
  3847.         // Proxy
  3848.         if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())){
  3849.             this.addProxyToDatiAsHidden(dati, proxyEnabled, proxyHost, proxyPort, proxyUsername, proxyPassword);
  3850.         }
  3851.        
  3852.         // TempiRisposta
  3853.         if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())){
  3854.             this.addTempiRispostaToDatiAsHidden(dati, tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta);
  3855.         }
  3856.        
  3857.         // Opzioni Avanzate
  3858.         if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())){
  3859.             this.addOpzioniAvanzateHttpToDatiAsHidden(dati, opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop);
  3860.         }
  3861.        
  3862.         // Token Policy
  3863.         if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())){
  3864.             this.addTokenPolicyToDatiAsHidden(dati, autenticazioneToken, tokenPolicy);
  3865.         }
  3866.    
  3867.         // Autenticazione Http
  3868.         if (endpointtype.equals(TipiConnettore.HTTP.toString()) || endpointtype.equals(TipiConnettore.HTTPS.toString())){
  3869.            
  3870.             de = new DataElement();
  3871.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);
  3872.             de.setType(DataElementType.HIDDEN);
  3873.             de.setValue(autenticazioneHttp);
  3874.             dati.add(de);
  3875.            
  3876.             if (ServletUtils.isCheckBoxEnabled(autenticazioneHttp)) {
  3877.                 de = new DataElement();
  3878.                 de.setName(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  3879.                 de.setType(DataElementType.HIDDEN);
  3880.                 de.setValue(StringEscapeUtils.escapeHtml(user));
  3881.                 dati.add(de);

  3882.                 de = new DataElement();
  3883.                 de.setName(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  3884.                 de.setType(DataElementType.HIDDEN);
  3885.                 this.core.getLockUtilities().lockHidden(de, password);
  3886.                 dati.add(de);
  3887.             }
  3888.         }
  3889.        
  3890.         // APi Key
  3891.         if ( ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)) {
  3892.             addApiKeyToDatiHidden(dati, useOAS3Names, useAppId,
  3893.                     apiKeyHeader, apiKeyValue,
  3894.                     appIdHeader, appIdValue);
  3895.         }
  3896.        
  3897.         return dati;
  3898.     }




  3899.     // Controlla i dati dell'end-point
  3900.     public boolean endPointCheckData(ServiceBinding serviceBinding, String protocollo, boolean servizioApplicativo, List<ExtendedConnettore> listExtendedConnettore) throws Exception {
  3901.         try {

  3902.             String endpointtype = this.readEndPointType();
  3903.             String tipoconn = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO);
  3904.             String autenticazioneHttp = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);
  3905.            
  3906.             String autenticazioneTokenS = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  3907.             boolean autenticazioneToken = ServletUtils.isCheckBoxEnabled(autenticazioneTokenS);
  3908.             String tokenPolicy = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY);
  3909.            
  3910.             // proxy
  3911.             String proxyEnabled = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  3912.             String proxyHostname = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  3913.             String proxyPort = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PORT);
  3914.             String proxyUsername = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_USERNAME);
  3915.             String proxyPassword = this.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PASSWORD);
  3916.            
  3917.             // tempiRisposta
  3918.             String tempiRispostaEnabled = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  3919.             String tempiRispostaConnectionTimeout = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  3920.             String tempiRispostaReadTimeout = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  3921.             String tempiRispostaTempoMedioRisposta = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);

  3922.             // opzioni avanzate
  3923.             String transferMode = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  3924.             String transferModeChunkSize = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  3925.             String redirectMode = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  3926.             String redirectMaxHop = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  3927.             String opzioniAvanzate = getOpzioniAvanzate(this,transferMode, redirectMode);
  3928.                        
  3929.             // http
  3930.             String url = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL);

  3931.             // api key
  3932.             String autenticazioneApiKey = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_API_KEY);
  3933.             String useOAS3NamesTmp = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  3934.             boolean useOAS3Names=true;
  3935.             if(useOAS3NamesTmp!=null && StringUtils.isNotEmpty(useOAS3NamesTmp)) {
  3936.                 useOAS3Names = ServletUtils.isCheckBoxEnabled(useOAS3NamesTmp);
  3937.             }
  3938.             String useAppIdTmp = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  3939.             boolean useAppId=false;
  3940.             if(useAppIdTmp!=null && StringUtils.isNotEmpty(useAppIdTmp)) {
  3941.                 useAppId = ServletUtils.isCheckBoxEnabled(useAppIdTmp);
  3942.             }
  3943.             String apiKeyHeader = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_HEADER);
  3944.             String apiKeyValue = this.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_VALUE);
  3945.             String appIdHeader = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  3946.             String appIdValue = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  3947.            
  3948.             // jms
  3949.             String nome = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_NOME_CODA);
  3950.             String tipo = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_CODA);
  3951.             String user = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_USERNAME);
  3952.             String password = this.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PASSWORD);
  3953.             String initcont = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_INIT_CTX);
  3954.             String urlpgk = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_URL_PKG);
  3955.             String provurl = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PROVIDER_URL);
  3956.             String connfact = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_CONNECTION_FACTORY);
  3957.             String sendas = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_OGGETTO_JMS);

  3958.             // https
  3959.             String httpsurl = url;
  3960.             String httpstipologia = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_SSL_TYPE);
  3961.             String httpshostverifyS = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_HOST_VERIFY);
  3962.             boolean httpshostverify = ServletUtils.isCheckBoxEnabled(httpshostverifyS);
  3963.             String httpsTrustVerifyCertS = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS );
  3964.             boolean httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  3965.             String httpspath = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_LOCATION);
  3966.             String httpstipo = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  3967.             String httpspwd = this.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  3968.             String httpsalgoritmo = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  3969.             String httpsstatoS = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO);
  3970.             boolean httpsstato = ServletUtils.isCheckBoxEnabled(httpsstatoS);
  3971.             String httpskeystore = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE);
  3972.             String httpspwdprivatekeytrust = this.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_STORE);
  3973.             String httpspathkey = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  3974.             String httpstipokey = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_TYPE);
  3975.             String httpspwdkey = this.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  3976.             String httpspwdprivatekey = this.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_KEYSTORE);
  3977.             String httpsalgoritmokey = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  3978.             String httpsKeyAlias = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_ALIAS_PRIVATE_KEY_KEYSTORE);
  3979.             String httpsTrustStoreCRLs = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL);
  3980.             String httpsTrustStoreOCSPPolicy = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  3981.             String httpsKeyStoreBYOKPolicy = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  3982.            
  3983.             if(ServletUtils.isCheckBoxEnabled(autenticazioneHttp)){
  3984.                 user = this.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  3985.                 password = this.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  3986.             }
  3987.            
  3988.             // file
  3989.             String requestOutputFileName = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME);
  3990.             String requestOutputFileNamePermissions = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_PERMISSIONS);
  3991.             String requestOutputFileNameHeaders = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS);
  3992.             String requestOutputFileNameHeadersPermissions = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS);
  3993.             String requestOutputParentDirCreateIfNotExists = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  3994.             String requestOutputOverwriteIfExists = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE_NAME);
  3995.             String responseInputMode = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  3996.             String responseInputFileName = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME);
  3997.             String responseInputFileNameHeaders = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS);
  3998.             String responseInputDeleteAfterRead = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_DELETE_AFTER_READ);
  3999.             String responseInputWaitTime = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);
  4000.            
  4001.            
  4002.             String servizioApplicativoServerEnabledS = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ABILITA_USO_APPLICATIVO_SERVER);
  4003.             boolean servizioApplicativoServerEnabled = ServletUtils.isCheckBoxEnabled(servizioApplicativoServerEnabledS);
  4004.             String servizioApplicativoServer = this.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ID_APPLICATIVO_SERVER);
  4005.            
  4006.             return endPointCheckData(serviceBinding, protocollo, servizioApplicativo, endpointtype, url, nome, tipo, user,
  4007.                     password, initcont, urlpgk, provurl, connfact, sendas,
  4008.                     httpsurl, httpstipologia, httpshostverify,
  4009.                     httpsTrustVerifyCert, httpspath, httpstipo, httpspwd, httpsalgoritmo, httpsstato,
  4010.                     httpskeystore, httpspwdprivatekeytrust, httpspathkey,
  4011.                     httpstipokey, httpspwdkey,
  4012.                     httpspwdprivatekey, httpsalgoritmokey,
  4013.                     httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  4014.                     tipoconn, autenticazioneHttp,
  4015.                     proxyEnabled,proxyHostname,proxyPort,proxyUsername,proxyPassword,
  4016.                     tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  4017.                     opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  4018.                     requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  4019.                     requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  4020.                     responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  4021.                     autenticazioneToken, tokenPolicy,
  4022.                     autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  4023.                     listExtendedConnettore,servizioApplicativoServerEnabled, servizioApplicativoServer);
  4024.            
  4025.         } catch (Exception e) {
  4026.             this.logError("endPointCheckData failed: " + e.getMessage(), e);
  4027.             throw new CoreException(e);
  4028.         }
  4029.     }

  4030.     // Controlla i dati dell'end-point
  4031.     public boolean endPointCheckData(ServiceBinding serviceBinding, String protocollo, boolean servizioApplicativo,
  4032.             String endpointtype, String url, String nome,
  4033.             String tipo, String user, String password, String initcont,
  4034.             String urlpgk, String provurl, String connfact, String sendas,
  4035.             String httpsurl, String httpstipologia, boolean httpshostverify,
  4036.             boolean httpsTrustVerifyCert, String httpspath, String httpstipo, String httpspwd,
  4037.             String httpsalgoritmo, boolean httpsstato, String httpskeystore,
  4038.             String httpspwdprivatekeytrust, String httpspathkey,
  4039.             String httpstipokey, String httpspwdkey,
  4040.             String httpspwdprivatekey, String httpsalgoritmokey,
  4041.             String httpsKeyAlias, String httpsTrustStoreCRLs, String httpsTrustStoreOCSPPolicy, String httpsKeyStoreBYOKPolicy,
  4042.             String tipoconn, String autenticazioneHttp,
  4043.             String proxyEnabled, String proxyHostname, String proxyPort, String proxyUsername, String proxyPassword,
  4044.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  4045.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  4046.             String requestOutputFileName, String requestOutputFileNamePermissions, String requestOutputFileNameHeaders, String requestOutputFileNameHeadersPermissions,
  4047.             String requestOutputParentDirCreateIfNotExists,String requestOutputOverwriteIfExists,
  4048.             String responseInputMode, String responseInputFileName, String responseInputFileNameHeaders, String responseInputDeleteAfterRead, String responseInputWaitTime,
  4049.             boolean autenticazioneToken, String tokenPolicy,
  4050.             String autenticazioneApiKey, boolean useOAS3Names, boolean useAppId, String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue,
  4051.             List<ExtendedConnettore> listExtendedConnettore,boolean servizioApplicativoServerEnabled, String servizioApplicativoServer)
  4052.                     throws CoreException {
  4053.        
  4054.         if(requestOutputParentDirCreateIfNotExists==null || requestOutputOverwriteIfExists==null || responseInputDeleteAfterRead==null) {
  4055.             // nop
  4056.         }
  4057.        
  4058.         try{
  4059.             if(!servizioApplicativoServerEnabled) {
  4060.                 if (url == null)
  4061.                     url = "";
  4062.                 if (nome == null)
  4063.                     nome = "";
  4064.                 if (tipo == null)
  4065.                     tipo = "";
  4066.                 if (user == null)
  4067.                     user = "";
  4068.                 if (password == null)
  4069.                     password = "";
  4070.                 if (initcont == null)
  4071.                     initcont = "";
  4072.                 if (urlpgk == null)
  4073.                     urlpgk = "";
  4074.                 if (provurl == null)
  4075.                     provurl = "";
  4076.                 if (connfact == null)
  4077.                     connfact = "";
  4078.                 if (sendas == null)
  4079.                     sendas = "";
  4080.                 if (httpsurl == null)
  4081.                     httpsurl = "";
  4082.                 if (httpstipologia == null)
  4083.                     httpstipologia = "";
  4084.                 if (httpspath == null)
  4085.                     httpspath = "";
  4086.                 if (httpstipo == null)
  4087.                     httpstipo = "";
  4088.                 if (httpspwd == null)
  4089.                     httpspwd = "";
  4090.                 if (httpsalgoritmo == null)
  4091.                     httpsalgoritmo = "";
  4092.                 if (httpskeystore == null)
  4093.                     httpskeystore = "";
  4094.                 if (httpspwdprivatekeytrust == null)
  4095.                     httpspwdprivatekeytrust = "";
  4096.                 if (httpspathkey == null)
  4097.                     httpspathkey = "";
  4098.                 if (httpstipokey == null)
  4099.                     httpstipokey = "";
  4100.                 if (httpspwdkey == null)
  4101.                     httpspwdkey = "";
  4102.                 if (httpspwdprivatekey == null)
  4103.                     httpspwdprivatekey = "";
  4104.                 if (httpsalgoritmokey == null)
  4105.                     httpsalgoritmokey = "";
  4106.                 if (httpsKeyAlias == null)
  4107.                     httpsKeyAlias = "";
  4108.                 if (httpsTrustStoreCRLs == null)
  4109.                     httpsTrustStoreCRLs = "";
  4110.                 if (httpsTrustStoreOCSPPolicy == null)
  4111.                     httpsTrustStoreOCSPPolicy = "";
  4112.                 if (httpsKeyStoreBYOKPolicy == null)
  4113.                     httpsKeyStoreBYOKPolicy = "";
  4114.                 if (tipoconn == null)
  4115.                     tipoconn = "";  
  4116.                 if (proxyEnabled == null)
  4117.                     proxyEnabled = "";
  4118.                 if (proxyHostname == null)
  4119.                     proxyHostname = "";
  4120.                 if (proxyPort == null)
  4121.                     proxyPort = "";
  4122.                 if (proxyUsername == null)
  4123.                     proxyUsername = "";
  4124.                 if (proxyPassword == null)
  4125.                     proxyPassword = "";
  4126.                 if (tempiRispostaEnabled == null)
  4127.                     tempiRispostaEnabled = "";
  4128.                 if (tempiRispostaConnectionTimeout == null)
  4129.                     tempiRispostaConnectionTimeout = "";
  4130.                 if (tempiRispostaReadTimeout == null)
  4131.                     tempiRispostaReadTimeout = "";
  4132.                 if (tempiRispostaTempoMedioRisposta == null)
  4133.                     tempiRispostaTempoMedioRisposta = "";
  4134.                 if (transferMode == null)
  4135.                     transferMode = "";
  4136.                 if (transferModeChunkSize == null)
  4137.                     transferModeChunkSize = "";
  4138.                 if (redirectMode == null)
  4139.                     redirectMode = "";
  4140.                 if (redirectMaxHop == null)
  4141.                     redirectMaxHop = "";            
  4142.                 if (requestOutputFileName == null)
  4143.                     requestOutputFileName = "";
  4144.                 if (requestOutputFileNamePermissions == null)
  4145.                     requestOutputFileNamePermissions = "";
  4146.                 if (requestOutputFileNameHeaders == null)
  4147.                     requestOutputFileNameHeaders = "";
  4148.                 if (requestOutputFileNameHeadersPermissions == null)
  4149.                     requestOutputFileNameHeadersPermissions = "";
  4150.                 if (responseInputFileName == null)
  4151.                     responseInputFileName = "";
  4152.                 if (responseInputFileNameHeaders == null)
  4153.                     responseInputFileNameHeaders = "";
  4154.                 if (responseInputWaitTime == null)
  4155.                     responseInputWaitTime = "";
  4156.                
  4157.                 // Controllo che non ci siano spazi nei campi di testo
  4158.                 if (
  4159.                         (nome.indexOf(" ") != -1) ||
  4160.                         (user.indexOf(" ") != -1) ||
  4161.                         (password.indexOf(" ") != -1) ||
  4162.                         (initcont.indexOf(" ") != -1) ||
  4163.                         (urlpgk.indexOf(" ") != -1) ||
  4164.                         (provurl.indexOf(" ") != -1) ||
  4165.                         (connfact.indexOf(" ") != -1) ||
  4166.                         (httpspath.indexOf(" ") != -1) ||
  4167.                         (httpspwd.indexOf(" ") != -1) ||
  4168.                         (httpsalgoritmo.indexOf(" ") != -1) ||
  4169.                         (httpskeystore.indexOf(" ") != -1) ||
  4170.                         (httpspwdprivatekeytrust.indexOf(" ") != -1) ||
  4171.                         (httpspathkey.indexOf(" ") != -1) ||
  4172.                         (httpspwdkey.indexOf(" ") != -1) ||
  4173.                         (httpspwdprivatekey.indexOf(" ") != -1) ||
  4174.                         (httpsalgoritmokey.indexOf(" ") != -1) ||
  4175.                         (httpsKeyAlias.indexOf(" ") != -1) ||
  4176.                         (tipoconn.indexOf(" ") != -1) ||
  4177.                         (proxyHostname.indexOf(" ") != -1) ||
  4178.                         (proxyPort.indexOf(" ") != -1) ||
  4179.                         (proxyUsername.indexOf(" ") != -1) ||
  4180.                         (proxyPassword.indexOf(" ") != -1) ||
  4181.                         (tempiRispostaConnectionTimeout.indexOf(" ") != -1) ||
  4182.                         (tempiRispostaReadTimeout.indexOf(" ") != -1) ||
  4183.                         (tempiRispostaTempoMedioRisposta.indexOf(" ") != -1) ||
  4184.                         (transferMode.indexOf(" ") != -1) ||
  4185.                         (transferModeChunkSize.indexOf(" ") != -1) ||
  4186.                         (redirectMode.indexOf(" ") != -1) ||
  4187.                         (redirectMaxHop.indexOf(" ") != -1) ||
  4188.                         (requestOutputFileName.indexOf(" ") != -1) ||
  4189.                         (requestOutputFileNameHeaders.indexOf(" ") != -1) ||
  4190.                         (requestOutputFileNamePermissions.indexOf(" ") != -1) ||
  4191.                         (requestOutputFileNameHeadersPermissions.indexOf(" ") != -1) ||
  4192.                         (responseInputFileName.indexOf(" ") != -1) ||
  4193.                         (responseInputFileNameHeaders.indexOf(" ") != -1) ||
  4194.                         (responseInputWaitTime.indexOf(" ") != -1)
  4195.                         ) {
  4196.                     this.pd.setMessage("Non inserire spazi nei campi di testo");
  4197.                     return false;
  4198.                 }
  4199.    
  4200.                 if(url.startsWith(" ") || url.endsWith(" ")) {
  4201.                     this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL+" non deve iniziare o terminare con uno spazio");
  4202.                     return false;
  4203.                 }
  4204.                 if(httpsurl.startsWith(" ") || httpsurl.endsWith(" ")) {
  4205.                     this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL+" non deve iniziare o terminare con uno spazio");
  4206.                     return false;
  4207.                 }
  4208.                 if(httpshostverify) {
  4209.                     // nop
  4210.                 }
  4211.                 if(url.indexOf(" ") != -1) {
  4212.                     int indexOfSpace = url.indexOf(" ");
  4213.                     int indexOfParameterSeparator = url.indexOf("?");
  4214.                     if(indexOfParameterSeparator<=0) {
  4215.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL+" non può contenere degli spazi");
  4216.                         return false;
  4217.                     }
  4218.                     else if(indexOfSpace<indexOfParameterSeparator) {
  4219.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL+" può contenere degli spazi solamente nei parametri");
  4220.                         return false;
  4221.                     }
  4222.                 }
  4223.                 if(httpsurl.indexOf(" ") != -1) {
  4224.                     int indexOfSpace = httpsurl.indexOf(" ");
  4225.                     int indexOfParameterSeparator = httpsurl.indexOf("?");
  4226.                     if(indexOfParameterSeparator<=0) {
  4227.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL+" non può contenere degli spazi");
  4228.                         return false;
  4229.                     }
  4230.                     else if(indexOfSpace<indexOfParameterSeparator) {
  4231.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL+" può contenere degli spazi solamente nei parametri");
  4232.                         return false;
  4233.                     }
  4234.                 }
  4235.                
  4236.                 if(ServletUtils.isCheckBoxEnabled(proxyEnabled)){
  4237.                    
  4238.                     if (proxyHostname == null || "".equals(proxyHostname)) {
  4239.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_HOSTNAME+" obbligatorio se si seleziona la comunicazione tramite Proxy");
  4240.                         return false;
  4241.                     }
  4242.                     if (proxyPort == null || "".equals(proxyPort)) {
  4243.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_PORT+" obbligatorio se si seleziona la comunicazione tramite Proxy");
  4244.                         return false;
  4245.                     }
  4246.                     int value = -1;
  4247.                     try{
  4248.                         value = Integer.parseInt(proxyPort);
  4249.                         if(value<1 || value>65535){
  4250.                             this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_PORT+" indicata per il Proxy deve essere un intero compreso tra 1 e  65.535");
  4251.                             return false;
  4252.                         }
  4253.                     }catch(Exception e){
  4254.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_PORT+" indicata per il Proxy deve essere un numero intero: "+e.getMessage());
  4255.                         return false;
  4256.                     }
  4257.                    
  4258.                     try{
  4259.                         new InetSocketAddress(proxyHostname,value);
  4260.                     }catch(Exception e){
  4261.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_HOSTNAME+" e "+
  4262.                                 ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_PORT+" indicati per il Proxy non sono corretti: "+e.getMessage());
  4263.                         return false;
  4264.                     }
  4265.                    
  4266.                     // Check lunghezza
  4267.                     if(!this.checkLength255(proxyHostname, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_HOSTNAME)) {
  4268.                         return false;
  4269.                     }
  4270.                     if(proxyUsername!=null && !"".equals(proxyUsername) &&
  4271.                         !this.checkLength255(proxyUsername, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_USERNAME)) {
  4272.                         return false;
  4273.                     }
  4274.                     if(proxyPassword!=null && !"".equals(proxyPassword) &&
  4275.                         !this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(proxyPassword) &&
  4276.                         !this.checkLength255(proxyPassword, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_PROXY_PASSWORD)) {
  4277.                         return false;
  4278.                     }
  4279.                 }
  4280.                
  4281.                 if(ServletUtils.isCheckBoxEnabled(tempiRispostaEnabled)){
  4282.                    
  4283.                     try{
  4284.                         int v = Integer.parseInt(tempiRispostaConnectionTimeout);
  4285.                         if(v<=0) {
  4286.                             throw new CoreException("fornire un valore maggiore di zero");
  4287.                         }
  4288.                     }catch(Exception e){
  4289.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT+" indicato nella sezione '"+
  4290.                                 ConnettoriCostanti.LABEL_CONNETTORE_TEMPI_RISPOSTA+"' deve essere un numero intero maggiore di zero");
  4291.                         return false;
  4292.                     }
  4293.                    
  4294.                     try{
  4295.                         int v = Integer.parseInt(tempiRispostaReadTimeout);
  4296.                         if(v<=0) {
  4297.                             throw new CoreException("fornire un valore maggiore di zero");
  4298.                         }
  4299.                     }catch(Exception e){
  4300.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT+" indicato nella sezione '"+
  4301.                                 ConnettoriCostanti.LABEL_CONNETTORE_TEMPI_RISPOSTA+"' deve essere un numero intero maggiore di zero");
  4302.                         return false;
  4303.                     }
  4304.                    
  4305.                     try{
  4306.                         int v = Integer.parseInt(tempiRispostaTempoMedioRisposta);
  4307.                         if(v<=0) {
  4308.                             throw new CoreException("fornire un valore maggiore di zero");
  4309.                         }
  4310.                     }catch(Exception e){
  4311.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA+" indicato nella sezione '"+
  4312.                                 ConnettoriCostanti.LABEL_CONNETTORE_TEMPI_RISPOSTA+"' deve essere un numero intero maggiore di zero");
  4313.                         return false;
  4314.                     }
  4315.                    
  4316.                 }
  4317.                
  4318.                 if(ServletUtils.isCheckBoxEnabled(opzioniAvanzate)){
  4319.                    
  4320.                     if(TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode) &&
  4321.                         transferModeChunkSize!=null && !"".equals(transferModeChunkSize)){
  4322.                         int value = -1;
  4323.                         try{
  4324.                             value = Integer.parseInt(transferModeChunkSize);
  4325.                             if(value<1){
  4326.                                 this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE+
  4327.                                         "' indicato per la modalità "+TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome()+" deve essere un numero maggiore di zero.");
  4328.                                 return false;
  4329.                             }
  4330.                         }catch(Exception e){
  4331.                             this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE+
  4332.                                     "' indicato per la modalità "+TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome()+" deve essere un numero intero: "+e.getMessage());
  4333.                             return false;
  4334.                         }
  4335.                     }
  4336.                    
  4337.                     if(CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode) &&
  4338.                         redirectMaxHop!=null && !"".equals(redirectMaxHop)){
  4339.                         int value = -1;
  4340.                         try{
  4341.                             value = Integer.parseInt(redirectMaxHop);
  4342.                             if(value<1){
  4343.                                 this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP+
  4344.                                         "' deve essere un numero maggiore di zero.");
  4345.                                 return false;
  4346.                             }
  4347.                         }catch(Exception e){
  4348.                             this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP+
  4349.                                     "' deve essere un numero intero: "+e.getMessage());
  4350.                             return false;
  4351.                         }
  4352.                     }
  4353.                    
  4354.                    
  4355.                 }
  4356.                
  4357.                 if(ServletUtils.isCheckBoxEnabled(autenticazioneHttp)){
  4358.                     if (user == null || "".equals(user)) {
  4359.                         this.pd.setMessage("Username obbligatoria per l'autenticazione http");
  4360.                         return false;
  4361.                     }
  4362.                     if (password == null || "".equals(password)) {
  4363.                         this.pd.setMessage("Password obbligatoria per l'autenticazione http");
  4364.                         return false;
  4365.                     }
  4366.                     if(!this.checkLength255(user, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME)) {
  4367.                         return false;
  4368.                     }
  4369.                     if(!this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(password) &&
  4370.                             !this.checkLength255(password, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD)) {
  4371.                         return false;
  4372.                     }
  4373.                 }
  4374.    
  4375.                 if(autenticazioneToken) {
  4376.                     if (tokenPolicy == null || "".equals(tokenPolicy) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(tokenPolicy)) {
  4377.                         this.pd.setMessage("Policy obbligatoria per l'autenticazione basata su token");
  4378.                         return false;
  4379.                     }
  4380.                    
  4381.                     List<GenericProperties> gestorePolicyTokenList = this.confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_RETRIEVE_POLICY_TOKEN, null);
  4382.                     List<String> policyValues = new ArrayList<>();
  4383.                     for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  4384.                         GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  4385.                         policyValues.add(genericProperties.getNome());
  4386.                     }
  4387.                    
  4388.                     if(!policyValues.contains(tokenPolicy)) {
  4389.                         this.pd.setMessage("Policy indicata per l'autenticazione basata su token, non esiste");
  4390.                         return false;
  4391.                     }
  4392.                 }
  4393.                
  4394.                 if(ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)){
  4395.                     String prefix = "Autenticazione API Key: ";
  4396.                     if (apiKeyValue == null || "".equals(apiKeyValue)) {
  4397.                         this.pd.setMessage(prefix+"valore non fornito");
  4398.                         return false;
  4399.                     }
  4400.                     if(apiKeyValue.startsWith(" ")) {
  4401.                         this.pd.setMessage(prefix+"valore inizia con uno spazio");
  4402.                         return false;
  4403.                     }
  4404.                     if(apiKeyValue.endsWith(" ")) {
  4405.                         this.pd.setMessage(prefix+"valore termina con uno spazio");
  4406.                         return false;
  4407.                     }
  4408.                     if(apiKeyValue.contains("\n") || apiKeyValue.contains("\r")) {
  4409.                         this.pd.setMessage(prefix+"valore contiene ritorni a capo");
  4410.                         return false;
  4411.                     }
  4412.                     if(!useOAS3Names &&
  4413.                         (apiKeyHeader == null || "".equals(apiKeyHeader))
  4414.                         ){
  4415.                         this.pd.setMessage(prefix+"header http non fornito");
  4416.                         return false;
  4417.                     }
  4418.                     if (apiKeyHeader != null && StringUtils.isNotEmpty(apiKeyHeader)) {
  4419.                         if (apiKeyHeader.contains(" ") || apiKeyHeader.contains("\n") || apiKeyHeader.contains("\r")) {
  4420.                             this.pd.setMessage(prefix+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_HEADER+" contiene spazi");
  4421.                             return false;
  4422.                         }
  4423.                         if (!this.checkLength255(apiKeyHeader, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_HEADER+" "+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_VALUE)) {
  4424.                             return false;
  4425.                         }
  4426.                     }
  4427.                     if(useAppId) {
  4428.                         if (appIdValue == null || "".equals(appIdValue)) {
  4429.                             this.pd.setMessage(prefix+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE+" non fornito");
  4430.                             return false;
  4431.                         }
  4432.                         if (appIdValue.contains(" ") || appIdValue.contains("\n") || appIdValue.contains("\r")) {
  4433.                             this.pd.setMessage(prefix+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE+" fornito contiene spazi");
  4434.                             return false;
  4435.                         }
  4436.                         if(!useOAS3Names &&
  4437.                             (appIdHeader == null || "".equals(appIdHeader))
  4438.                             ){
  4439.                             this.pd.setMessage(prefix+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER+" "+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE+" non fornito");
  4440.                             return false;
  4441.                         }
  4442.                         if (appIdHeader != null && StringUtils.isNotEmpty(appIdHeader)) {
  4443.                             if (appIdHeader.contains(" ") || appIdHeader.contains("\n") || appIdHeader.contains("\r")) {
  4444.                                 this.pd.setMessage(prefix+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER+" "+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE+" contiene spazi");
  4445.                                 return false;
  4446.                             }
  4447.                             if(!this.checkLength255(appIdHeader, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER+" "+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE)) {
  4448.                                 return false;
  4449.                             }
  4450.                         }
  4451.                     }
  4452.                 }
  4453.                
  4454.                 // Controllo che i campi "select" abbiano uno dei valori ammessi
  4455.                 if (!Connettori.contains(endpointtype) && !endpointtype.equals(TipiConnettore.CUSTOM.toString())) {
  4456.                     this.pd.setMessage("Tipo Connettore dev'essere uno tra : " + Connettori.getList());
  4457.                     return false;
  4458.                 }
  4459.    
  4460.                 List<String> tipologie = null;
  4461.                 try{
  4462.                     tipologie = SSLUtilities.getSSLSupportedProtocols();
  4463.                 }catch(Exception e){
  4464.                     ControlStationCore.logError(e.getMessage(), e);
  4465.                     tipologie = SSLUtilities.getAllSslProtocol();
  4466.                 }
  4467.                 if(!tipologie.contains(SSLConstants.PROTOCOL_TLS)){
  4468.                     tipologie.add(SSLConstants.PROTOCOL_TLS); // retrocompatibilita'
  4469.                 }
  4470.                 if(!tipologie.contains(SSLConstants.PROTOCOL_SSL)){
  4471.                     tipologie.add(SSLConstants.PROTOCOL_SSL); // retrocompatibilita'
  4472.                 }
  4473.                 if (!httpstipologia.equals("") &&
  4474.                         !tipologie.contains(httpstipologia)) {
  4475.                     this.pd.setMessage("Il campo Tipologia può assumere uno tra i seguenti valori: "+tipologie);
  4476.                     return false;
  4477.                 }
  4478.    
  4479.                 if(this.core.isConnettoriAllTypesEnabled()) {
  4480.                     if (!httpstipo.equals("") &&
  4481.                             !Utilities.contains(httpstipo, ConnettoriCostanti.TIPOLOGIE_KEYSTORE_OLD)) {
  4482.                         this.pd.setMessage("Il campo Tipo per l'Autenticazione Server può assumere uno tra i seguenti valori: "+Utilities.toString(ConnettoriCostanti.TIPOLOGIE_KEYSTORE_OLD, ","));
  4483.                         return false;
  4484.                     }
  4485.                     if (!httpstipokey.equals("") &&
  4486.                             !Utilities.contains(httpstipokey, ConnettoriCostanti.TIPOLOGIE_KEYSTORE_OLD)) {
  4487.                         this.pd.setMessage("Il campo Tipo per l'Autenticazione Client può assumere uno tra i seguenti valori: "+Utilities.toString(ConnettoriCostanti.TIPOLOGIE_KEYSTORE_OLD, ","));
  4488.                         return false;
  4489.                     }
  4490.                 }
  4491.                 else {
  4492.                     if (!httpstipo.equals("") &&
  4493.                             !Utilities.contains(httpstipo, ConnettoriCostanti.getTIPOLOGIE_KEYSTORE(true, false).toArray(new String[1]))) {
  4494.                         this.pd.setMessage("Il campo Tipo per l'Autenticazione Server può assumere uno tra i seguenti valori: "+Utilities.toString(ConnettoriCostanti.TIPOLOGIE_KEYSTORE_OLD, ","));
  4495.                         return false;
  4496.                     }
  4497.                     if (!httpstipokey.equals("") &&
  4498.                             !Utilities.contains(httpstipokey, ConnettoriCostanti.getTIPOLOGIE_KEYSTORE(false, false).toArray(new String[1]))) {
  4499.                         this.pd.setMessage("Il campo Tipo per l'Autenticazione Client può assumere uno tra i seguenti valori: "+Utilities.toString(ConnettoriCostanti.TIPOLOGIE_KEYSTORE_OLD, ","));
  4500.                         return false;
  4501.                     }
  4502.                 }
  4503.    
  4504.                 // Controllo campi obbligatori per il tipo di connettore custom
  4505.                 if (endpointtype.equals(TipiConnettore.CUSTOM.toString()) &&
  4506.                         (tipoconn == null || "".equals(tipoconn) || CostantiControlStation.PARAMETRO_TIPO_PERSONALIZZATO_VALORE_UNDEFINED.equals(tipoconn))) {
  4507.                     if(this.connettoriCore.isConfigurazionePluginsEnabled()) {
  4508.                         this.pd.setMessage("Non è stato selezionato un plugin");
  4509.                     }
  4510.                     else {
  4511.                         this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO+" obbligatorio per il tipo di connettore selezionato");
  4512.                     }
  4513.                     return false;
  4514.                 }
  4515.                 if (endpointtype.equals(TipiConnettore.CUSTOM.toString()) &&
  4516.                     !this.checkLength255(tipoconn, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO)) {
  4517.                     return false;
  4518.                 }
  4519.    
  4520.                 // Controllo campi obbligatori per il tipo di connettore http
  4521.                 if (endpointtype.equals(TipiConnettore.HTTP.toString()) && (url == null || "".equals(url))) {
  4522.                     this.pd.setMessage("Url obbligatoria per il tipo di connettore http");
  4523.                     return false;
  4524.                 }
  4525.    
  4526.                 // Se il tipo di connettore è custom, tipoconn non può essere
  4527.                 if (endpointtype.equals(TipiConnettore.CUSTOM.toString()) && (tipoconn.equals(TipiConnettore.HTTP.toString()) || tipoconn.equals(TipiConnettore.HTTPS.toString()) || tipoconn.equals(TipiConnettore.STATUS.toString()) || tipoconn.equals(TipiConnettore.JMS.toString()) || tipoconn.equals(TipiConnettore.NULL.toString()) || tipoconn.equals(TipiConnettore.NULLECHO.toString()) || tipoconn.equals(TipiConnettore.DISABILITATO.toString()) )) {
  4528.                     this.pd.setMessage(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO+" non può assumere i valori: disabilitato,http,https,jms,null,nullEcho,status");
  4529.                     return false;
  4530.                 }
  4531.    
  4532.                 // Se e' stata specificata la url, dev'essere valida
  4533.                 if (endpointtype.equals(TipiConnettore.HTTP.toString()) && !url.equals("") ){
  4534.                     try{
  4535.                         org.openspcoop2.utils.regexp.RegExpUtilities.validateUrl(url, true);
  4536.                     }catch(Exception e){
  4537.                         this.pd.setMessage("Url non correttamente formata: "+e.getMessage());
  4538.                         return false;
  4539.                     }
  4540.                     if(!this.checkLength4000(url, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL)) {
  4541.                         return false;
  4542.                     }
  4543.                     try {
  4544.                         InputValidationUtils.validateTextAreaInput(url,
  4545.                                 ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_URL);
  4546.                     }catch(Exception e){
  4547.                         this.pd.setMessage(e.getMessage());
  4548.                         return false;
  4549.                     }
  4550.                     if(this.isProfiloModIPA(protocollo) && !servizioApplicativo && this.connettoriCore.isModipaFruizioniConnettoreCheckHttps() &&
  4551.                         !httpsurl.toLowerCase().trim().startsWith("https://")) {
  4552.                         this.pd.setMessage("Il profilo richiede una url con prefisso https://");
  4553.                         return false;
  4554.                     }
  4555.                 }
  4556.    
  4557.                 // Controllo campi obbligatori per il tipo di connettore jms
  4558.                 if (endpointtype.equals(TipiConnettore.JMS.toString())) {
  4559.                     if (nome == null || "".equals(nome)) {
  4560.                         this.pd.setMessage("Nome della coda/topic obbligatorio per il tipo di connettore jms");
  4561.                         return false;
  4562.                     }
  4563.                     if (tipo == null || "".equals(tipo)) {
  4564.                         this.pd.setMessage("Tipo di coda obbligatorio per il tipo di connettore jms");
  4565.                         return false;
  4566.                     }
  4567.                     if (sendas == null || "".equals(sendas)) {
  4568.                         this.pd.setMessage("Tipo di messaggio (SendAs) obbligatorio per il tipo di connettore jms");
  4569.                         return false;
  4570.                     }
  4571.                     if (connfact == null || "".equals(connfact)) {
  4572.                         this.pd.setMessage("Connection Factory obbligatoria per il tipo di connettore jms");
  4573.                         return false;
  4574.                     }
  4575.                    
  4576.                     if(!this.checkLength255(nome, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_JMS_NOME_CODA)) {
  4577.                         return false;
  4578.                     }
  4579.                     if(!this.checkLength255(connfact, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_JMS_CONNECTION_FACTORY)) {
  4580.                         return false;
  4581.                     }
  4582.                     if(user!=null && !"".equals(user) &&
  4583.                         !this.checkLength255(user, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_JMS_USERNAME)) {
  4584.                         return false;
  4585.                     }
  4586.                     if(password!=null && !"".equals(password) &&
  4587.                         !this.checkLength255(password, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_JMS_PASSWORD)) {
  4588.                         return false;
  4589.                     }
  4590.                     if(initcont!=null && !"".equals(initcont) &&
  4591.                         !this.checkLength255(initcont, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_JMS_INIT_CTX)) {
  4592.                         return false;
  4593.                     }
  4594.                     if(urlpgk!=null && !"".equals(urlpgk) &&
  4595.                         !this.checkLength255(urlpgk, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_JMS_URL_PKG)) {
  4596.                         return false;
  4597.                     }
  4598.                     if(provurl!=null && !"".equals(provurl) &&
  4599.                         !this.checkLength255(provurl, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_JMS_PROVIDER_URL)) {
  4600.                         return false;
  4601.                     }
  4602.                 }
  4603.    
  4604.                 if (endpointtype.equals(TipiConnettore.JMS.toString()) && !Utilities.contains(tipo, ConnettoriCostanti.TIPI_CODE_JMS)) {
  4605.                     this.pd.setMessage("Tipo Jms dev'essere: "+Utilities.toString(ConnettoriCostanti.TIPI_CODE_JMS, ","));
  4606.                     return false;
  4607.                 }
  4608.                 if (endpointtype.equals(TipiConnettore.JMS.toString()) && !Utilities.contains(sendas, ConnettoriCostanti.TIPO_SEND_AS) ) {
  4609.                     this.pd.setMessage("Send As dev'essere: "+Utilities.toString(ConnettoriCostanti.TIPO_SEND_AS, ","));
  4610.                     return false;
  4611.                 }
  4612.    
  4613.                 // Controllo campi obbligatori per il tipo di connettore https
  4614.                 if (endpointtype.equals(TipiConnettore.HTTPS.toString())) {
  4615.                     if ("".equals(httpsurl)) {
  4616.                         this.pd.setMessage("Url obbligatorio per il tipo di connettore https");
  4617.                         return false;
  4618.                     }else{
  4619.                         try{
  4620.                             org.openspcoop2.utils.regexp.RegExpUtilities.validateUrl(httpsurl, true);
  4621.                         }catch(Exception e){
  4622.                             this.pd.setMessage("Url non correttamente formata: "+e.getMessage());
  4623.                             return false;
  4624.                         }
  4625.                     }
  4626.                     if(!this.checkLength4000(httpsurl, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_URL)) {
  4627.                         return false;
  4628.                     }
  4629.                     try {
  4630.                         InputValidationUtils.validateTextAreaInput(httpsurl,
  4631.                                 ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_URL);
  4632.                     }catch(Exception e){
  4633.                         this.pd.setMessage(e.getMessage());
  4634.                         return false;
  4635.                     }
  4636.                    
  4637.                     if(!httpsurl.toLowerCase().trim().startsWith("https://")) {
  4638.                         if(this.isProfiloModIPA(protocollo) && this.connettoriCore.isModipaFruizioniConnettoreCheckHttps()) {
  4639.                             this.pd.setMessage("Il profilo richiede una url con prefisso https://");
  4640.                             return false;
  4641.                         }
  4642.                         else {
  4643.                             this.pd.setMessage("Url deve possedere il prefisso https://");
  4644.                             return false;
  4645.                         }
  4646.                     }
  4647.                    
  4648.                     if(httpsTrustVerifyCert) {
  4649.                         if ("".equals(httpspath)) {
  4650.                             this.pd.setMessage("Il campo 'Path' è obbligatorio per l'Autenticazione Server");
  4651.                             return false;
  4652.                         }else{
  4653.                             try{
  4654.                                 File f = new File(httpspath);
  4655.                                 f.getAbsolutePath();
  4656.                             }catch(Exception e){
  4657.                                 this.pd.setMessage("Il campo 'Path', obbligatorio per l'Autenticazione Server, non è correttamente definito: "+e.getMessage());
  4658.                                 return false;
  4659.                             }
  4660.                         }
  4661.                         if(!this.checkLength4000(httpspath, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_LOCATION)) {
  4662.                             return false;
  4663.                         }
  4664.                         try {
  4665.                             InputValidationUtils.validateTextAreaInput(httpspath,
  4666.                                     ConnettoriCostanti.LABEL_CONNETTORE_AUTENTICAZIONE_SERVER + " - " + ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_LOCATION);
  4667.                         }catch(Exception e){
  4668.                             this.pd.setMessage(e.getMessage());
  4669.                             return false;
  4670.                         }
  4671.                         boolean isRequired = true;
  4672.                         if(KeystoreType.JKS.isType(httpstipo)) {
  4673.                             isRequired = this.core.isTruststoreJksPasswordRequired();
  4674.                         }
  4675.                         else if(KeystoreType.PKCS12.isType(httpstipo)) {
  4676.                             isRequired = this.core.isTruststorePkcs12PasswordRequired();
  4677.                         }
  4678.                         if ("".equals(httpspwd) && isRequired) {
  4679.                             this.pd.setMessage("La password del TrustStore è necessaria per l'Autenticazione Server");
  4680.                             return false;
  4681.                         }
  4682.                         if(!this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(httpspwd) &&
  4683.                                 !this.checkLength255(httpspwd, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_PASSWORD)) {
  4684.                             return false;
  4685.                         }
  4686.                        
  4687.                         if ("".equals(httpsalgoritmo)) {
  4688.                             this.pd.setMessage("Il campo 'Algoritmo' è obbligatorio per l'Autenticazione Server");
  4689.                             return false;
  4690.                         }
  4691.                         if(!this.checkLength255(httpsalgoritmo, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM)) {
  4692.                             return false;
  4693.                         }
  4694.                    
  4695.                         if(httpsTrustStoreCRLs!=null && !"".equals(httpsTrustStoreCRLs)) {
  4696.                            
  4697.                             if(!this.checkLength4000(httpsTrustStoreCRLs, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL)) {
  4698.                                 return false;
  4699.                             }
  4700.                            
  4701.                             try {
  4702.                                 InputValidationUtils.validateTextAreaInput(httpsTrustStoreCRLs,
  4703.                                         ConnettoriCostanti.LABEL_CONNETTORE_AUTENTICAZIONE_SERVER + " - " + ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL);
  4704.                             }catch(Exception e){
  4705.                                 this.pd.setMessage(e.getMessage());
  4706.                                 return false;
  4707.                             }
  4708.                            
  4709.                             httpsTrustStoreCRLs = httpsTrustStoreCRLs.trim();
  4710.                             String [] tmp = httpsTrustStoreCRLs.split(",");
  4711.                             if(tmp!=null && tmp.length>0) {
  4712.                                 for (String crl : tmp) {
  4713.                                     if(crl!=null) {
  4714.                                         crl = crl.trim();
  4715.                                         if(!"".equals(crl) && crl.contains(" ")) {
  4716.                                             this.pd.setMessage("I path inseriti nel campo '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL+"' non devono contenere spazi");
  4717.                                             return false;
  4718.                                         }
  4719.                                     }
  4720.                                 }
  4721.                             }
  4722.                            
  4723.                         }
  4724.                     }
  4725.                    
  4726.                     if (httpsstato) {
  4727.                         if (ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT.equals(httpskeystore)) {
  4728.                             boolean isRequired = true;
  4729.                             if(KeystoreType.JKS.isType(httpstipo)) {
  4730.                                 isRequired = this.core.isKeystoreJksKeyPasswordRequired();
  4731.                             }
  4732.                             else if(KeystoreType.PKCS12.isType(httpstipo)) {
  4733.                                 isRequired = this.core.isKeystorePkcs12KeyPasswordRequired();
  4734.                             }
  4735.                             if ("".equals(httpspwdprivatekeytrust) && isRequired) {
  4736.                                 this.pd.setMessage("La password della chiave privata è necessaria in caso di Autenticazione Client abilitata");
  4737.                                 return false;
  4738.                             }
  4739.                             if(!this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(httpspwdprivatekeytrust) &&
  4740.                                     !this.checkLength255(httpspwdprivatekeytrust, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_KEYSTORE)) {
  4741.                                 return false;
  4742.                             }
  4743.                            
  4744.                             if ("".equals(httpsalgoritmokey)) {
  4745.                                 this.pd.setMessage("Il campo 'Algoritmo' è obbligatorio in caso di Autenticazione Client abilitata");
  4746.                                 return false;
  4747.                             }
  4748.                             if(!this.checkLength255(httpsalgoritmokey, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM)) {
  4749.                                 return false;
  4750.                             }
  4751.                            
  4752.                         } else {
  4753.                             if ("".equals(httpspathkey)) {
  4754.                                 this.pd.setMessage("Il campo 'Path' è obbligatorio per l'Autenticazione Client, in caso di dati di accesso al KeyStore ridefiniti");
  4755.                                 return false;
  4756.                             }else{
  4757.                                 try{
  4758.                                     File f = new File(httpspathkey);
  4759.                                     f.getAbsolutePath();
  4760.                                 }catch(Exception e){
  4761.                                     this.pd.setMessage("Il campo 'Path', obbligatorio per l'Autenticazione Client in caso di dati di accesso al KeyStore ridefiniti, non è correttamente definito: "+e.getMessage());
  4762.                                     return false;
  4763.                                 }
  4764.                             }
  4765.                             if(!this.checkLength4000(httpspathkey, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_LOCATION)) {
  4766.                                 return false;
  4767.                             }
  4768.                             try {
  4769.                                 InputValidationUtils.validateTextAreaInput(httpspathkey,
  4770.                                         ConnettoriCostanti.LABEL_CONNETTORE_AUTENTICAZIONE_CLIENT + " - " + ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  4771.                             }catch(Exception e){
  4772.                                 this.pd.setMessage(e.getMessage());
  4773.                                 return false;
  4774.                             }
  4775.                            
  4776.                             boolean isRequired = true;
  4777.                             if(KeystoreType.JKS.isType(httpstipokey)) {
  4778.                                 isRequired = this.core.isKeystoreJksPasswordRequired();
  4779.                             }
  4780.                             else if(KeystoreType.PKCS12.isType(httpstipokey)) {
  4781.                                 isRequired = this.core.isKeystorePkcs12PasswordRequired();
  4782.                             }
  4783.                             if ("".equals(httpspwdkey) && isRequired) {
  4784.                                 this.pd.setMessage("La password del KeyStore è necessaria per l'Autenticazione Client, in caso di dati di accesso al KeyStore ridefiniti");
  4785.                                 return false;
  4786.                             }
  4787.                             if(!this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(httpspwdkey) &&
  4788.                                     !this.checkLength255(httpspwdkey, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_PASSWORD)) {
  4789.                                 return false;
  4790.                             }
  4791.                            
  4792.                             isRequired = true;
  4793.                             if(KeystoreType.JKS.isType(httpstipokey)) {
  4794.                                 isRequired = this.core.isKeystoreJksKeyPasswordRequired();
  4795.                             }
  4796.                             else if(KeystoreType.PKCS12.isType(httpstipokey)) {
  4797.                                 isRequired = this.core.isKeystorePkcs12KeyPasswordRequired();
  4798.                             }
  4799.                             if ("".equals(httpspwdprivatekey) && isRequired) {
  4800.                                 this.pd.setMessage("La password della chiave privata è necessaria in caso di Autenticazione Client abilitata");
  4801.                                 return false;
  4802.                             }
  4803.                             if(!this.core.getDriverBYOKUtilities().isWrappedWithAnyPolicy(httpspwdprivatekey) &&
  4804.                                     !this.checkLength255(httpspwdprivatekey, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_KEYSTORE)) {
  4805.                                 return false;
  4806.                             }
  4807.                            
  4808.                             if ("".equals(httpsalgoritmokey)) {
  4809.                                 this.pd.setMessage("Il campo 'Algoritmo' è obbligatorio per l'Autenticazione Client, in caso di dati di accesso al KeyStore ridefiniti");
  4810.                                 return false;
  4811.                             }
  4812.                             if(!this.checkLength255(httpsalgoritmokey, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM)) {
  4813.                                 return false;
  4814.                             }
  4815.                         }
  4816.                     }
  4817.                 }
  4818.                
  4819.                 // Controllo campi obbligatori per il tipo di connettore file
  4820.                 if (endpointtype.equals(TipiConnettore.FILE.toString())) {
  4821.                    
  4822.                     if ("".equals(requestOutputFileName)) {
  4823.                         this.pd.setMessage("'"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME+"' ("+
  4824.                                 ConnettoriCostanti.LABEL_CONNETTORE_REQUEST_OUTPUT+") obbligatorio per il tipo di connettore file");
  4825.                         return false;
  4826.                     }else{
  4827.                         try{
  4828.                             DynamicUtils.validate(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME, requestOutputFileName, false, false);
  4829.                         }catch(Exception e){
  4830.                             this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME+"' ("+
  4831.                                     ConnettoriCostanti.LABEL_CONNETTORE_REQUEST_OUTPUT+") non risulta corretto: "+e.getMessage());
  4832.                             return false;
  4833.                         }
  4834.                     }
  4835.                     if(!this.checkLength4000(requestOutputFileName, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME)) {
  4836.                         return false;
  4837.                     }
  4838.                     try {
  4839.                         InputValidationUtils.validateTextAreaInput(requestOutputFileName,
  4840.                                 ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME+"' ("+
  4841.                                         ConnettoriCostanti.LABEL_CONNETTORE_REQUEST_OUTPUT+")");
  4842.                     }catch(Exception e){
  4843.                         this.pd.setMessage(e.getMessage());
  4844.                         return false;
  4845.                     }
  4846.                    
  4847.                     if(StringUtils.isNotEmpty(requestOutputFileNamePermissions)) {
  4848.                         try {
  4849.                             ConnettoreFILE.validatePermission(requestOutputFileNamePermissions, new ConnettoreFile_outputConfig());
  4850.                         }catch(Exception e) {
  4851.                             this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_PERMISSIONS+"' ("+
  4852.                                     ConnettoriCostanti.LABEL_CONNETTORE_REQUEST_OUTPUT+") non risulta corretto: "+e.getMessage());
  4853.                             return false;
  4854.                         }
  4855.                        
  4856.                         if(!this.checkLength255(requestOutputFileNamePermissions, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_PERMISSIONS)) {
  4857.                             return false;
  4858.                         }
  4859.                     }
  4860.                    
  4861.                     if(requestOutputFileNameHeaders!=null && !"".equals(requestOutputFileNameHeaders)){
  4862.                         try{
  4863.                             DynamicUtils.validate(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS, requestOutputFileNameHeaders, false, false);
  4864.                         }catch(Exception e){
  4865.                             this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS+"' ("+
  4866.                                     ConnettoriCostanti.LABEL_CONNETTORE_REQUEST_OUTPUT+") non risulta corretto: "+e.getMessage());
  4867.                             return false;
  4868.                         }
  4869.                         if(!this.checkLength4000(requestOutputFileNameHeaders, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS)) {
  4870.                             return false;
  4871.                         }      
  4872.                         try {
  4873.                             InputValidationUtils.validateTextAreaInput(requestOutputFileNameHeaders,
  4874.                                     ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS+"' ("+
  4875.                                             ConnettoriCostanti.LABEL_CONNETTORE_REQUEST_OUTPUT+")");
  4876.                         }catch(Exception e){
  4877.                             this.pd.setMessage(e.getMessage());
  4878.                             return false;
  4879.                         }
  4880.                     }
  4881.                    
  4882.                     if(StringUtils.isNotEmpty(requestOutputFileNameHeadersPermissions)) {
  4883.                         if(requestOutputFileNameHeaders!=null && !"".equals(requestOutputFileNameHeaders)){
  4884.                             try {
  4885.                                 ConnettoreFILE.validatePermission(requestOutputFileNameHeadersPermissions, new ConnettoreFile_outputConfig());
  4886.                             }catch(Exception e) {
  4887.                                 this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS+"' ("+
  4888.                                         ConnettoriCostanti.LABEL_CONNETTORE_REQUEST_OUTPUT+") non risulta corretto: "+e.getMessage());
  4889.                                 return false;
  4890.                             }
  4891.                             if(!this.checkLength255(requestOutputFileNameHeadersPermissions, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS)) {
  4892.                                 return false;
  4893.                             }
  4894.                         }
  4895.                         else {
  4896.                             this.pd.setMessage("Non è possibile configurare il parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS
  4897.                                     +"' senza configurare anche il parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS+"' ("+
  4898.                                     ConnettoriCostanti.LABEL_CONNETTORE_REQUEST_OUTPUT+")");
  4899.                             return false;
  4900.                         }
  4901.                     }
  4902.                    
  4903.                     if(CostantiConfigurazione.ABILITATO.getValue().equals(responseInputMode)){
  4904.                        
  4905.                         if ("".equals(responseInputFileName)) {
  4906.                             this.pd.setMessage("'"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME+"' ("+
  4907.                                     ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT+") obbligatorio per il tipo di connettore file");
  4908.                             return false;
  4909.                         }else{
  4910.                             try{
  4911.                                 DynamicUtils.validate(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME, responseInputFileName, false, false);
  4912.                             }catch(Exception e){
  4913.                                 this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME+"' ("+
  4914.                                         ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT+") non risulta corretto: "+e.getMessage());
  4915.                                 return false;
  4916.                             }
  4917.                         }
  4918.                         if(!this.checkLength4000(responseInputFileName, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME)) {
  4919.                             return false;
  4920.                         }
  4921.                         try {
  4922.                             InputValidationUtils.validateTextAreaInput(responseInputFileName,
  4923.                                     ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME+"' ("+
  4924.                                             ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT+")");
  4925.                         }catch(Exception e){
  4926.                             this.pd.setMessage(e.getMessage());
  4927.                             return false;
  4928.                         }
  4929.                        
  4930.                         if(responseInputFileNameHeaders!=null && !"".equals(responseInputFileNameHeaders)){
  4931.                             try{
  4932.                                 DynamicUtils.validate(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS, responseInputFileNameHeaders, false, false);
  4933.                             }catch(Exception e){
  4934.                                 this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS+"' ("+
  4935.                                         ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT+") non risulta corretto: "+e.getMessage());
  4936.                                 return false;
  4937.                             }
  4938.                             if(!this.checkLength4000(responseInputFileNameHeaders, ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS)) {
  4939.                                 return false;
  4940.                             }
  4941.                             try {
  4942.                                 InputValidationUtils.validateTextAreaInput(responseInputFileNameHeaders,
  4943.                                         ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS+"' ("+
  4944.                                                 ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT+")");
  4945.                             }catch(Exception e){
  4946.                                 this.pd.setMessage(e.getMessage());
  4947.                                 return false;
  4948.                             }
  4949.                         }
  4950.                        
  4951.                         if(responseInputWaitTime!=null && !"".equals(responseInputWaitTime)){
  4952.                             int value = -1;
  4953.                             try{
  4954.                                 value = Integer.parseInt(responseInputWaitTime);
  4955.                                 if(value<1){
  4956.                                     this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME+
  4957.                                             "' ("+
  4958.                                         ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT+") deve essere un numero maggiore di zero.");
  4959.                                     return false;
  4960.                                 }
  4961.                             }catch(Exception e){
  4962.                                 this.pd.setMessage("Il valore indicato nel parametro '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME+
  4963.                                         "' ("+
  4964.                                     ConnettoriCostanti.LABEL_CONNETTORE_RESPONSE_INPUT+") deve essere un numero intero: "+e.getMessage());
  4965.                                 return false;
  4966.                             }
  4967.                         }
  4968.                        
  4969.                     }
  4970.                 }
  4971.                
  4972.                 if (endpointtype.equals(TipiConnettore.STATUS.toString()) && ConnettoreStatusParams.check(this, serviceBinding, this.pd).getParsingErrors()) {
  4973.                         return false;
  4974.                 }
  4975.                
  4976.                
  4977.                 try{
  4978.                     ServletExtendedConnettoreUtils.checkInfo(listExtendedConnettore);
  4979.                 }catch(Exception e){
  4980.                     this.pd.setMessage(e.getMessage());
  4981.                     return false;
  4982.                 }
  4983.                
  4984.             } else {
  4985.                 if(StringUtils.isBlank(servizioApplicativoServer)) {
  4986.                     this.pd.setMessage("Il campo '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_ID_APPLICATIVO_SERVER
  4987.                             + "' &egrave; quando si abilita il campo '"+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_ABILITA_USO_APPLICATIVO_SERVER+"'.");
  4988.                     return false;
  4989.                 }
  4990.             }
  4991.            
  4992.             return true;            
  4993.         } catch (Exception e) {
  4994.             this.logError("endPointCheckData failed: " + e.getMessage(), e);
  4995.             throw new CoreException(e);
  4996.         }
  4997.     }


  4998.     public void fillConnettore(org.openspcoop2.core.registry.Connettore connettore,
  4999.             String connettoreDebug,
  5000.             String tipoConnettore, String oldtipo, String tipoconn, String httpUrl, String jmsNome,
  5001.             String jmsTipo, String user, String pwd,
  5002.             String jmsNfInitial, String jmsNfUrlPkg, String jmsNpUrl,
  5003.             String jmsConnectionFactory, String jmsSendAs,
  5004.             String httpsurl, String httpstipologia, boolean httpshostverify,
  5005.             boolean httpsTrustVerifyCert, String httpspath, String httpstipo, String httpspwd,
  5006.             String httpsalgoritmo, boolean httpsstato, String httpskeystore,
  5007.             String httpspwdprivatekeytrust, String httpspathkey,
  5008.             String httpstipokey, String httpspwdkey,
  5009.             String httpspwdprivatekey, String httpsalgoritmokey,
  5010.             String httpsKeyAlias, String httpsTrustStoreCRLs, String httpsTrustStoreOCSPPolicy, String httpsKeyStoreBYOKPolicy,
  5011.             String proxyEnabled, String proxyHost, String proxyPort, String proxyUsername, String proxyPassword,
  5012.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  5013.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  5014.             String requestOutputFileName, String requestOutputFileNamePermissions, String requestOutputFileNameHeaders, String requestOutputFileNameHeadersPermissions,
  5015.             String requestOutputParentDirCreateIfNotExists,String requestOutputOverwriteIfExists,
  5016.             String responseInputMode, String responseInputFileName, String responseInputFileNameHeaders, String responseInputDeleteAfterRead, String responseInputWaitTime,
  5017.             String tokenPolicy,
  5018.             String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue,
  5019.             ConnettoreStatusParams connettoreStatusParams,
  5020.             List<ExtendedConnettore> listExtendedConnettore)
  5021.                     throws CoreException {
  5022.         try {
  5023.            
  5024.             // azzero proprieta esistenti precedentemente
  5025.             // (se il connettore è custom lo faccio solo se prima
  5026.             // non era custom)
  5027.             if (!tipoConnettore.equals(TipiConnettore.CUSTOM.toString()) ||
  5028.                     !tipoConnettore.equals(oldtipo)) {
  5029.                 while(connettore.sizePropertyList()>0)
  5030.                     connettore.removeProperty(0);
  5031.             }
  5032.            
  5033.             String debugValue = null;
  5034.             if(ServletUtils.isCheckBoxEnabled(connettoreDebug)){
  5035.                 debugValue = Costanti.CHECK_BOX_ENABLED_TRUE;
  5036.             }
  5037.             else{
  5038.                 debugValue = Costanti.CHECK_BOX_DISABLED_FALSE;
  5039.             }
  5040.             boolean found = false;
  5041.             for (int i = 0; i < connettore.sizePropertyList(); i++) {
  5042.                 Property pCheck = connettore.getProperty(i);
  5043.                 if(CostantiDB.CONNETTORE_DEBUG.equals(pCheck.getNome())){
  5044.                     pCheck.setValore(debugValue);
  5045.                     found = true;
  5046.                     break;
  5047.                 }
  5048.             }
  5049.             if(!found){
  5050.                 Property p = new Property();
  5051.                 p.setNome(CostantiDB.CONNETTORE_DEBUG);
  5052.                 p.setValore(debugValue);
  5053.                 connettore.addProperty(p);
  5054.             }

  5055.             org.openspcoop2.core.registry.Property prop = null;

  5056.             if (tipoConnettore.equals(TipiConnettore.CUSTOM.toString()))
  5057.                 connettore.setTipo(tipoconn);
  5058.             else
  5059.                 connettore.setTipo(tipoConnettore);
  5060.             // Inizializzo a false... Poi eventualmente lo setto a true
  5061.             connettore.setCustom(false);
  5062.             if (tipoConnettore.equals(TipiConnettore.HTTP.getNome())) {
  5063.                
  5064.                 prop = new org.openspcoop2.core.registry.Property();
  5065.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_LOCATION);
  5066.                 prop.setValore(httpUrl);
  5067.                 connettore.addProperty(prop);
  5068.                
  5069.                 if(user!=null){
  5070.                     prop = new org.openspcoop2.core.registry.Property();
  5071.                     prop.setNome(CostantiDB.CONNETTORE_USER);
  5072.                     prop.setValore(user);
  5073.                     connettore.addProperty(prop);
  5074.                 }
  5075.                
  5076.                 if(pwd!=null){
  5077.                     prop = new org.openspcoop2.core.registry.Property();
  5078.                     prop.setNome(CostantiDB.CONNETTORE_PWD);
  5079.                     prop.setValore(pwd);
  5080.                     connettore.addProperty(prop);
  5081.                 }

  5082.             } else if (tipoConnettore.equals(TipiConnettore.JMS.getNome())) {
  5083.                 ConnettoreJMSUtils.fillConnettoreRegistry(connettore, jmsNome, jmsTipo, user, pwd,
  5084.                         jmsNfInitial, jmsNfUrlPkg, jmsNpUrl, jmsConnectionFactory, jmsSendAs);
  5085.             } else if (tipoConnettore.equals(TipiConnettore.NULL.getNome())) {
  5086.                 // nessuna proprieta per connettore null
  5087.             } else if (tipoConnettore.equals(TipiConnettore.NULLECHO.getNome())) {
  5088.                 // nessuna proprieta per connettore nullEcho
  5089.             } else if (tipoConnettore.equals(TipiConnettore.STATUS.getNome())) {
  5090.                 connettoreStatusParams.fillConnettoreRegistry(connettore);
  5091.             } else if (tipoConnettore.equals(TipiConnettore.HTTPS.getNome())) {
  5092.                 ConnettoreHTTPSUtils.fillConnettoreRegistry(connettore, httpsurl, httpstipologia, httpshostverify, httpsTrustVerifyCert, httpspath,
  5093.                         httpstipo, httpspwd, httpsalgoritmo, httpsstato, httpskeystore, httpspwdprivatekeytrust,
  5094.                         httpspathkey, httpstipokey, httpspwdkey, httpspwdprivatekey, httpsalgoritmokey,
  5095.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  5096.                         user, pwd);
  5097.             } else if (tipoConnettore.equals(TipiConnettore.FILE.getNome())) {
  5098.                 ConnettoreFileUtils.fillConnettoreRegistry(connettore,
  5099.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  5100.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  5101.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime);
  5102.             } else if (tipoConnettore.equals(TipiConnettore.CUSTOM.toString())) {
  5103.                 connettore.setCustom(true);
  5104.             } else if (!tipoConnettore.equals(TipiConnettore.DISABILITATO.getNome()) &&
  5105.                     !tipoConnettore.equals(TipiConnettore.CUSTOM.toString())) {
  5106.                 Property [] cp = this.connettoriCore.getPropertiesConnettore(tipoConnettore);
  5107.                 List<Property> cps = new ArrayList<>();
  5108.                 if(cp!=null && cp.length>0){
  5109.                     cps.addAll(Arrays.asList(cp));
  5110.                 }
  5111.                 connettore.setPropertyList(cps);
  5112.             }
  5113.            
  5114.             // ApiKey
  5115.             addAutenticazioneApiKey(connettore,
  5116.                     apiKeyHeader, apiKeyValue, appIdHeader, appIdValue);
  5117.            
  5118.             // Proxy
  5119.             if(ServletUtils.isCheckBoxEnabled(proxyEnabled)){
  5120.                
  5121.                 prop = new org.openspcoop2.core.registry.Property();
  5122.                 prop.setNome(CostantiDB.CONNETTORE_PROXY_TYPE);
  5123.                 prop.setValore(CostantiConnettori.CONNETTORE_HTTP_PROXY_TYPE_VALUE_HTTP);
  5124.                 connettore.addProperty(prop);
  5125.                
  5126.                 if(proxyHost!=null && !"".equals(proxyHost)){
  5127.                     prop = new org.openspcoop2.core.registry.Property();
  5128.                     prop.setNome(CostantiDB.CONNETTORE_PROXY_HOSTNAME);
  5129.                     prop.setValore(proxyHost);
  5130.                     connettore.addProperty(prop);
  5131.                 }
  5132.                
  5133.                 if(proxyPort!=null && !"".equals(proxyPort)){
  5134.                     prop = new org.openspcoop2.core.registry.Property();
  5135.                     prop.setNome(CostantiDB.CONNETTORE_PROXY_PORT);
  5136.                     prop.setValore(proxyPort);
  5137.                     connettore.addProperty(prop);
  5138.                 }
  5139.                
  5140.                 if(proxyUsername!=null && !"".equals(proxyUsername)){
  5141.                     prop = new org.openspcoop2.core.registry.Property();
  5142.                     prop.setNome(CostantiDB.CONNETTORE_PROXY_USERNAME);
  5143.                     prop.setValore(proxyUsername);
  5144.                     connettore.addProperty(prop);
  5145.                 }
  5146.                
  5147.                 if(proxyPassword!=null && !"".equals(proxyPassword)){
  5148.                     prop = new org.openspcoop2.core.registry.Property();
  5149.                     prop.setNome(CostantiDB.CONNETTORE_PROXY_PASSWORD);
  5150.                     prop.setValore(proxyPassword);
  5151.                     connettore.addProperty(prop);
  5152.                 }
  5153.                
  5154.             }
  5155.            
  5156.             // TempiRisposta
  5157.             if(ServletUtils.isCheckBoxEnabled(tempiRispostaEnabled)){
  5158.                
  5159.                 if(tempiRispostaConnectionTimeout!=null && !"".equals(tempiRispostaConnectionTimeout)){
  5160.                     prop = new org.openspcoop2.core.registry.Property();
  5161.                     prop.setNome(CostantiDB.CONNETTORE_CONNECTION_TIMEOUT);
  5162.                     prop.setValore(tempiRispostaConnectionTimeout);
  5163.                     connettore.addProperty(prop);
  5164.                 }
  5165.                
  5166.                 if(tempiRispostaReadTimeout!=null && !"".equals(tempiRispostaReadTimeout)){
  5167.                     prop = new org.openspcoop2.core.registry.Property();
  5168.                     prop.setNome(CostantiDB.CONNETTORE_READ_CONNECTION_TIMEOUT);
  5169.                     prop.setValore(tempiRispostaReadTimeout);
  5170.                     connettore.addProperty(prop);
  5171.                 }
  5172.                
  5173.                 if(tempiRispostaTempoMedioRisposta!=null && !"".equals(tempiRispostaTempoMedioRisposta)){
  5174.                     prop = new org.openspcoop2.core.registry.Property();
  5175.                     prop.setNome(CostantiDB.CONNETTORE_TEMPO_MEDIO_RISPOSTA);
  5176.                     prop.setValore(tempiRispostaTempoMedioRisposta);
  5177.                     connettore.addProperty(prop);
  5178.                 }
  5179.                
  5180.             }
  5181.            
  5182.             // OpzioniAvanzate
  5183.             if(ServletUtils.isCheckBoxEnabled(opzioniAvanzate)){
  5184.                 // li devo impostare anche in caso di HIDDEN
  5185.             }
  5186.                
  5187.             if(TransferLengthModes.CONTENT_LENGTH.getNome().equals(transferMode) ||
  5188.                     TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode)){
  5189.                
  5190.                 // nel caso di default non devo creare la proprietà
  5191.                 prop = new org.openspcoop2.core.registry.Property();
  5192.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE);
  5193.                 prop.setValore(transferMode);
  5194.                 connettore.addProperty(prop);
  5195.                
  5196.             }
  5197.            
  5198.             if(TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode) &&
  5199.                 transferModeChunkSize!=null && !"".equals(transferModeChunkSize)){
  5200.                 prop = new org.openspcoop2.core.registry.Property();
  5201.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE_CHUNK_SIZE);
  5202.                 prop.setValore(transferModeChunkSize);
  5203.                 connettore.addProperty(prop);
  5204.             }
  5205.            
  5206.             if(CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode) ||
  5207.                     CostantiConfigurazione.DISABILITATO.getValue().equals(redirectMode)){
  5208.                
  5209.                 // nel caso di default non devo creare la proprietà
  5210.                 prop = new org.openspcoop2.core.registry.Property();
  5211.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_REDIRECT_FOLLOW);
  5212.                 prop.setValore(redirectMode);
  5213.                 connettore.addProperty(prop);
  5214.                
  5215.             }
  5216.            
  5217.             if(CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode) &&
  5218.                 redirectMaxHop!=null && !"".equals(redirectMaxHop)){
  5219.                 prop = new org.openspcoop2.core.registry.Property();
  5220.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_REDIRECT_MAX_HOP);
  5221.                 prop.setValore(redirectMaxHop);
  5222.                 connettore.addProperty(prop);
  5223.             }
  5224.            
  5225.             if(tokenPolicy!=null && !"".equals(tokenPolicy) && !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(tokenPolicy)) {
  5226.                 prop = new org.openspcoop2.core.registry.Property();
  5227.                 prop.setNome(CostantiDB.CONNETTORE_TOKEN_POLICY);
  5228.                 prop.setValore(tokenPolicy);
  5229.                 connettore.addProperty(prop);
  5230.             }
  5231.                
  5232.            
  5233.             // Extended
  5234.             ExtendedConnettoreConverter.fillExtendedInfoIntoConnettore(listExtendedConnettore, connettore);

  5235.         } catch (Exception e) {
  5236.             this.logError("Exception: " + e.getMessage(), e);
  5237.             throw new CoreException(e);
  5238.         }

  5239.     }
  5240.    
  5241.     public void addAutenticazioneApiKey(org.openspcoop2.core.registry.Connettore connettore,
  5242.             String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue) {
  5243.         if(this.isAutenticazioneApiKey(apiKeyValue)) {
  5244.             org.openspcoop2.core.registry.Property prop = new org.openspcoop2.core.registry.Property();
  5245.             prop.setNome(CostantiDB.CONNETTORE_APIKEY);
  5246.             prop.setValore(apiKeyValue);
  5247.             connettore.addProperty(prop);
  5248.            
  5249.             if(apiKeyHeader!=null && !"".equals(apiKeyHeader)){
  5250.                 prop = new org.openspcoop2.core.registry.Property();
  5251.                 prop.setNome(CostantiDB.CONNETTORE_APIKEY_HEADER);
  5252.                 prop.setValore(apiKeyHeader);
  5253.                 connettore.addProperty(prop);
  5254.             }
  5255.            
  5256.             if(this.isAutenticazioneApiKeyUseAppId(appIdValue)) {
  5257.                 prop = new org.openspcoop2.core.registry.Property();
  5258.                 prop.setNome(CostantiDB.CONNETTORE_APIKEY_APPID);
  5259.                 prop.setValore(appIdValue);
  5260.                 connettore.addProperty(prop);
  5261.                
  5262.                 if(appIdHeader!=null && !"".equals(appIdHeader)){
  5263.                     prop = new org.openspcoop2.core.registry.Property();
  5264.                     prop.setNome(CostantiDB.CONNETTORE_APIKEY_APPID_HEADER);
  5265.                     prop.setValore(appIdHeader);
  5266.                     connettore.addProperty(prop);
  5267.                 }
  5268.             }
  5269.         }
  5270.     }


  5271.     public void fillConnettore(org.openspcoop2.core.config.Connettore connettore,
  5272.             String connettoreDebug,
  5273.             String tipoConnettore, String oldtipo, String tipoconn, String httpUrl, String jmsNome,
  5274.             String jmsTipo, String jmsUser, String jmsPwd,
  5275.             String jmsNfInitial, String jmsNfUrlPkg, String jmsNpUrl,
  5276.             String jmsConnectionFactory, String jmsSendAs,
  5277.             String httpsurl, String httpstipologia, boolean httpshostverify,
  5278.             boolean httpsTrustVerifyCert, String httpspath, String httpstipo, String httpspwd,
  5279.             String httpsalgoritmo, boolean httpsstato, String httpskeystore,
  5280.             String httpspwdprivatekeytrust, String httpspathkey,
  5281.             String httpstipokey, String httpspwdkey,
  5282.             String httpspwdprivatekey, String httpsalgoritmokey,
  5283.             String httpsKeyAlias, String httpsTrustStoreCRLs, String httpsTrustStoreOCSPPolicy, String httpsKeyStoreBYOKPolicy,
  5284.             String proxyEnabled, String proxyHost, String proxyPort, String proxyUsername, String proxyPassword,
  5285.             String tempiRispostaEnabled, String tempiRispostaConnectionTimeout, String tempiRispostaReadTimeout, String tempiRispostaTempoMedioRisposta,
  5286.             String opzioniAvanzate, String transferMode, String transferModeChunkSize, String redirectMode, String redirectMaxHop,
  5287.             String requestOutputFileName, String requestOutputFileNamePermissions, String requestOutputFileNameHeaders, String requestOutputFileNameHeadersPermissions,
  5288.             String requestOutputParentDirCreateIfNotExists,String requestOutputOverwriteIfExists,
  5289.             String responseInputMode, String responseInputFileName, String responseInputFileNameHeaders, String responseInputDeleteAfterRead, String responseInputWaitTime,
  5290.             String tokenPolicy,
  5291.             String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue,
  5292.             ConnettoreStatusParams connettoreStatusParams,
  5293.             List<ExtendedConnettore> listExtendedConnettore)
  5294.                     throws CoreException {
  5295.         try {
  5296.            
  5297.             // azzero proprieta esistenti precedentemente
  5298.             // (se il connettore è custom lo faccio solo se prima
  5299.             // non era custom)
  5300.             if (!tipoConnettore.equals(TipiConnettore.CUSTOM.toString()) ||
  5301.                     !tipoConnettore.equals(oldtipo)) {
  5302.                 while(connettore.sizePropertyList()>0)
  5303.                     connettore.removeProperty(0);
  5304.             }

  5305.            
  5306.             String debugValue = null;
  5307.             if(ServletUtils.isCheckBoxEnabled(connettoreDebug)){
  5308.                 debugValue = Costanti.CHECK_BOX_ENABLED_TRUE;
  5309.             }
  5310.             else{
  5311.                 debugValue = Costanti.CHECK_BOX_DISABLED_FALSE;
  5312.             }
  5313.             boolean found = false;
  5314.             for (int i = 0; i < connettore.sizePropertyList(); i++) {
  5315.                 org.openspcoop2.core.config.Property pCheck = connettore.getProperty(i);
  5316.                 if(CostantiDB.CONNETTORE_DEBUG.equals(pCheck.getNome())){
  5317.                     pCheck.setValore(debugValue);
  5318.                     found = true;
  5319.                     break;
  5320.                 }
  5321.             }
  5322.             if(!found){
  5323.                 org.openspcoop2.core.config.Property p = new org.openspcoop2.core.config.Property();
  5324.                 p.setNome(CostantiDB.CONNETTORE_DEBUG);
  5325.                 p.setValore(debugValue);
  5326.                 connettore.addProperty(p);
  5327.             }
  5328.            
  5329.             org.openspcoop2.core.config.Property prop = null;

  5330.             if (tipoConnettore.equals(TipiConnettore.CUSTOM.toString()))
  5331.                 connettore.setTipo(tipoconn);
  5332.             else
  5333.                 connettore.setTipo(tipoConnettore);
  5334.             // Inizializzo a false... Poi eventualmente lo setto a true
  5335.             connettore.setCustom(false);
  5336.             if (tipoConnettore.equals(TipiConnettore.HTTP.getNome())) {
  5337.                 prop = new org.openspcoop2.core.config.Property();
  5338.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_LOCATION);
  5339.                 prop.setValore(httpUrl);
  5340.                 connettore.addProperty(prop);

  5341.             } else if (tipoConnettore.equals(TipiConnettore.JMS.getNome())) {
  5342.                 ConnettoreJMSUtils.fillConnettoreConfig(connettore, jmsNome, jmsTipo, jmsUser, jmsPwd,
  5343.                         jmsNfInitial, jmsNfUrlPkg, jmsNpUrl, jmsConnectionFactory, jmsSendAs);
  5344.             } else if (tipoConnettore.equals(TipiConnettore.NULL.getNome())) {
  5345.                 // nessuna proprieta per connettore null
  5346.             } else if (tipoConnettore.equals(TipiConnettore.NULLECHO.getNome())) {
  5347.                 // nessuna proprieta per connettore nullEcho
  5348.             } else if (tipoConnettore.equals(TipiConnettore.STATUS.getNome())) {
  5349.                 connettoreStatusParams.fillConnettoreConfig(connettore);
  5350.             } else if (tipoConnettore.equals(TipiConnettore.HTTPS.getNome())) {
  5351.                 ConnettoreHTTPSUtils.fillConnettoreConfig(connettore, httpsurl, httpstipologia, httpshostverify, httpsTrustVerifyCert, httpspath, httpstipo,
  5352.                         httpspwd, httpsalgoritmo, httpsstato, httpskeystore, httpspwdprivatekeytrust, httpspathkey, httpstipokey,
  5353.                         httpspwdkey, httpspwdprivatekey, httpsalgoritmokey,
  5354.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy);
  5355.             } else if (tipoConnettore.equals(TipiConnettore.FILE.getNome())) {
  5356.                 ConnettoreFileUtils.fillConnettoreConfig(connettore,
  5357.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  5358.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  5359.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime);
  5360.             } else if (tipoConnettore.equals(TipiConnettore.CUSTOM.toString())) {
  5361.                 connettore.setCustom(true);
  5362.             }else if (!tipoConnettore.equals(TipiConnettore.DISABILITATO.getNome()) &&
  5363.                     !tipoConnettore.equals(TipiConnettore.CUSTOM.toString())) {
  5364.                 org.openspcoop2.core.config.Property [] cp = this.connettoriCore.getPropertiesConnettoreConfig(tipoConnettore);
  5365.                 List<org.openspcoop2.core.config.Property> cps = new ArrayList<>();
  5366.                 if(cp!=null && cp.length>0){
  5367.                     cps.addAll(Arrays.asList(cp));
  5368.                 }
  5369.                 connettore.setPropertyList(cps);
  5370.             }
  5371.            
  5372.             // ApiKey
  5373.             addAutenticazioneApiKey(connettore,
  5374.                     apiKeyHeader, apiKeyValue, appIdHeader, appIdValue);
  5375.            
  5376.             // Proxy
  5377.             if(ServletUtils.isCheckBoxEnabled(proxyEnabled)){
  5378.                
  5379.                 prop = new org.openspcoop2.core.config.Property();
  5380.                 prop.setNome(CostantiDB.CONNETTORE_PROXY_TYPE);
  5381.                 prop.setValore(CostantiConnettori.CONNETTORE_HTTP_PROXY_TYPE_VALUE_HTTP);
  5382.                 connettore.addProperty(prop);
  5383.                
  5384.                 if(proxyHost!=null && !"".equals(proxyHost)){
  5385.                     prop = new org.openspcoop2.core.config.Property();
  5386.                     prop.setNome(CostantiDB.CONNETTORE_PROXY_HOSTNAME);
  5387.                     prop.setValore(proxyHost);
  5388.                     connettore.addProperty(prop);
  5389.                 }
  5390.                
  5391.                 if(proxyPort!=null && !"".equals(proxyPort)){
  5392.                     prop = new org.openspcoop2.core.config.Property();
  5393.                     prop.setNome(CostantiDB.CONNETTORE_PROXY_PORT);
  5394.                     prop.setValore(proxyPort);
  5395.                     connettore.addProperty(prop);
  5396.                 }
  5397.                
  5398.                 if(proxyUsername!=null && !"".equals(proxyUsername)){
  5399.                     prop = new org.openspcoop2.core.config.Property();
  5400.                     prop.setNome(CostantiDB.CONNETTORE_PROXY_USERNAME);
  5401.                     prop.setValore(proxyUsername);
  5402.                     connettore.addProperty(prop);
  5403.                 }
  5404.                
  5405.                 if(proxyPassword!=null && !"".equals(proxyPassword)){
  5406.                     prop = new org.openspcoop2.core.config.Property();
  5407.                     prop.setNome(CostantiDB.CONNETTORE_PROXY_PASSWORD);
  5408.                     prop.setValore(proxyPassword);
  5409.                     connettore.addProperty(prop);
  5410.                 }
  5411.                
  5412.             }
  5413.            
  5414.             // TempiRisposta
  5415.             if(ServletUtils.isCheckBoxEnabled(tempiRispostaEnabled)){
  5416.                
  5417.                 if(tempiRispostaConnectionTimeout!=null && !"".equals(tempiRispostaConnectionTimeout)){
  5418.                     prop = new org.openspcoop2.core.config.Property();
  5419.                     prop.setNome(CostantiDB.CONNETTORE_CONNECTION_TIMEOUT);
  5420.                     prop.setValore(tempiRispostaConnectionTimeout);
  5421.                     connettore.addProperty(prop);
  5422.                 }
  5423.                
  5424.                 if(tempiRispostaReadTimeout!=null && !"".equals(tempiRispostaReadTimeout)){
  5425.                     prop = new org.openspcoop2.core.config.Property();
  5426.                     prop.setNome(CostantiDB.CONNETTORE_READ_CONNECTION_TIMEOUT);
  5427.                     prop.setValore(tempiRispostaReadTimeout);
  5428.                     connettore.addProperty(prop);
  5429.                 }
  5430.                
  5431.                 if(tempiRispostaTempoMedioRisposta!=null && !"".equals(tempiRispostaTempoMedioRisposta)){
  5432.                     prop = new org.openspcoop2.core.config.Property();
  5433.                     prop.setNome(CostantiDB.CONNETTORE_TEMPO_MEDIO_RISPOSTA);
  5434.                     prop.setValore(tempiRispostaTempoMedioRisposta);
  5435.                     connettore.addProperty(prop);
  5436.                 }
  5437.                
  5438.             }
  5439.            
  5440.             // OpzioniAvanzate
  5441.             if(ServletUtils.isCheckBoxEnabled(opzioniAvanzate)){
  5442.                 //li devo impostare anche in caso di HIDDEN
  5443.             }
  5444.                
  5445.             if(TransferLengthModes.CONTENT_LENGTH.getNome().equals(transferMode) ||
  5446.                     TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode)){
  5447.                
  5448.                 // nel caso di default non devo creare la proprietà
  5449.                 prop = new org.openspcoop2.core.config.Property();
  5450.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE);
  5451.                 prop.setValore(transferMode);
  5452.                 connettore.addProperty(prop);
  5453.                
  5454.             }
  5455.            
  5456.             if(TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode) &&
  5457.                 transferModeChunkSize!=null && !"".equals(transferModeChunkSize)){
  5458.                 prop = new org.openspcoop2.core.config.Property();
  5459.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE_CHUNK_SIZE);
  5460.                 prop.setValore(transferModeChunkSize);
  5461.                 connettore.addProperty(prop);
  5462.             }
  5463.            
  5464.             if(CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode) ||
  5465.                     CostantiConfigurazione.DISABILITATO.getValue().equals(redirectMode)){
  5466.                
  5467.                 // nel caso di default non devo creare la proprietà
  5468.                 prop = new org.openspcoop2.core.config.Property();
  5469.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_REDIRECT_FOLLOW);
  5470.                 prop.setValore(redirectMode);
  5471.                 connettore.addProperty(prop);
  5472.                
  5473.             }
  5474.            
  5475.             if(CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode) &&
  5476.                 redirectMaxHop!=null && !"".equals(redirectMaxHop)){
  5477.                 prop = new org.openspcoop2.core.config.Property();
  5478.                 prop.setNome(CostantiDB.CONNETTORE_HTTP_REDIRECT_MAX_HOP);
  5479.                 prop.setValore(redirectMaxHop);
  5480.                 connettore.addProperty(prop);
  5481.             }
  5482.            
  5483.             if(tokenPolicy!=null && !"".equals(tokenPolicy) && !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(tokenPolicy)) {
  5484.                 prop = new org.openspcoop2.core.config.Property();
  5485.                 prop.setNome(CostantiDB.CONNETTORE_TOKEN_POLICY);
  5486.                 prop.setValore(tokenPolicy);
  5487.                 connettore.addProperty(prop);
  5488.             }
  5489.                
  5490.            
  5491.             // Extended
  5492.             ExtendedConnettoreConverter.fillExtendedInfoIntoConnettore(listExtendedConnettore, connettore);

  5493.         } catch (Exception e) {
  5494.             this.logError("Exception: " + e.getMessage(), e);
  5495.             throw new CoreException(e);
  5496.         }

  5497.     }
  5498.    
  5499.     public void addAutenticazioneApiKey(org.openspcoop2.core.config.Connettore connettore,
  5500.             String apiKeyHeader, String apiKeyValue, String appIdHeader, String appIdValue) {
  5501.         if(this.isAutenticazioneApiKey(apiKeyValue)) {
  5502.             org.openspcoop2.core.config.Property prop = new org.openspcoop2.core.config.Property();
  5503.             prop.setNome(CostantiDB.CONNETTORE_APIKEY);
  5504.             prop.setValore(apiKeyValue);
  5505.             connettore.addProperty(prop);
  5506.            
  5507.             if(apiKeyHeader!=null && !"".equals(apiKeyHeader)){
  5508.                 prop = new org.openspcoop2.core.config.Property();
  5509.                 prop.setNome(CostantiDB.CONNETTORE_APIKEY_HEADER);
  5510.                 prop.setValore(apiKeyHeader);
  5511.                 connettore.addProperty(prop);
  5512.             }
  5513.            
  5514.             if(this.isAutenticazioneApiKeyUseAppId(appIdValue)) {
  5515.                 prop = new org.openspcoop2.core.config.Property();
  5516.                 prop.setNome(CostantiDB.CONNETTORE_APIKEY_APPID);
  5517.                 prop.setValore(appIdValue);
  5518.                 connettore.addProperty(prop);
  5519.                
  5520.                 if(appIdHeader!=null && !"".equals(appIdHeader)){
  5521.                     prop = new org.openspcoop2.core.config.Property();
  5522.                     prop.setNome(CostantiDB.CONNETTORE_APIKEY_APPID_HEADER);
  5523.                     prop.setValore(appIdHeader);
  5524.                     connettore.addProperty(prop);
  5525.                 }
  5526.             }
  5527.         }
  5528.     }

  5529.     public static String getOpzioniAvanzate(ConsoleHelper helper,String transfer_mode, String redirect_mode) throws Exception{

  5530.         String opzioniAvanzate = helper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE);
  5531.         return getOpzioniAvanzate(opzioniAvanzate, transfer_mode, redirect_mode);
  5532.        
  5533.     }
  5534.     public static String getOpzioniAvanzate(String opzioniAvanzate,String transfer_mode, String redirect_mode){
  5535.        
  5536.         if(opzioniAvanzate!=null && !"".equals(opzioniAvanzate)){
  5537.             return opzioniAvanzate;
  5538.         }
  5539.        
  5540.         if(opzioniAvanzate==null || "".equals(opzioniAvanzate)){
  5541.             opzioniAvanzate = Costanti.CHECK_BOX_DISABLED;
  5542.         }
  5543.         if( (transfer_mode!=null && !"".equals(transfer_mode)) || (redirect_mode!=null && !"".equals(redirect_mode)) ){
  5544.             opzioniAvanzate = Costanti.CHECK_BOX_ENABLED;
  5545.         }
  5546.         return opzioniAvanzate;
  5547.     }
  5548.    
  5549.     public boolean credenzialiCheckData(TipoOperazione tipoOp, boolean oldPasswordCifrata, boolean encryptEnabled, PasswordVerifier passwordVerifier) throws CoreException{
  5550.        
  5551.         if(oldPasswordCifrata) {
  5552.             // nop
  5553.         }
  5554.        
  5555.         String tipoauth = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_TIPO_AUTENTICAZIONE);
  5556.         if (tipoauth == null) {
  5557.             tipoauth = ConnettoriCostanti.DEFAULT_AUTENTICAZIONE_TIPO;
  5558.         }
  5559.         String utente = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  5560.         String password = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  5561.         String subject = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT);
  5562.         String principal = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PRINCIPAL);
  5563.         String appId = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID);
  5564.        
  5565.         String tokenPolicy = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_POLICY);
  5566.         String tokenClientId = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  5567.         @SuppressWarnings("unused")
  5568.         boolean tokenByPDND = ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_PDND.equals(tipoauth) || ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_PDND.equals(tipoauth);
  5569.         boolean tokenWithHttpsEnabledByConfigSA = ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_PDND.equals(tipoauth) || ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL_E_TOKEN_OAUTH.equals(tipoauth);
  5570.         if(tokenWithHttpsEnabledByConfigSA) {
  5571.             tipoauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL;
  5572.         }
  5573.         boolean tokenModiPDNDOauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_PDND.equals(tipoauth) || ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN_OAUTH.equals(tipoauth);
  5574.         if(tokenModiPDNDOauth) {
  5575.             tipoauth = ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN;
  5576.         }
  5577.        
  5578.         if (tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC)) {
  5579.            
  5580.             boolean validaPassword = false;
  5581.             if(TipoOperazione.ADD.equals(tipoOp) || !encryptEnabled) {
  5582.                 validaPassword = true;
  5583.             }
  5584.             else {
  5585.                 String changePwd = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CHANGE_PASSWORD);
  5586.                 if(ServletUtils.isCheckBoxEnabled(changePwd)) {
  5587.                     validaPassword = true;
  5588.                 }
  5589.             }
  5590.            
  5591.             boolean passwordEmpty = false;
  5592.             if(validaPassword &&
  5593.                 (password==null || password.equals(""))
  5594.                 ){
  5595.                 passwordEmpty = true;
  5596.             }
  5597.            
  5598.             if(utente.equals("") || passwordEmpty){
  5599.                 String tmpElenco = "";
  5600.                 if (utente.equals("")) {
  5601.                     tmpElenco = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME;
  5602.                 }
  5603.                 if (passwordEmpty) {
  5604.                     if (tmpElenco.equals("")) {
  5605.                         tmpElenco = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD;
  5606.                     } else {
  5607.                         tmpElenco = tmpElenco + ", "+ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD;
  5608.                     }
  5609.                 }
  5610.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare: " + tmpElenco);
  5611.                 return false;
  5612.             }
  5613.             if(!this.checkLength255(utente, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME)) {
  5614.                 return false;
  5615.             }
  5616.             if(!this.checkLength255(password, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD)) {
  5617.                 return false;
  5618.             }
  5619.            
  5620.             if (tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC) && ((utente.indexOf(" ") != -1) || (validaPassword && password.indexOf(" ") != -1))) {
  5621.                 this.pd.setMessage("Non inserire spazi nei campi di testo");
  5622.                 return false;
  5623.             }
  5624.            
  5625.             if(validaPassword &&
  5626.                 passwordVerifier!=null){
  5627.                 StringBuilder motivazioneErrore = new StringBuilder();
  5628.                 if(!passwordVerifier.validate(utente, password, motivazioneErrore)){
  5629.                     this.pd.setMessage(motivazioneErrore.toString());
  5630.                     return false;
  5631.                 }
  5632.             }
  5633.         }
  5634.        
  5635.         if (tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL)){
  5636.             String tipoCredenzialiSSLSorgente = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL);
  5637.             if(tipoCredenzialiSSLSorgente == null) {
  5638.                 tipoCredenzialiSSLSorgente = ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_CONFIGURAZIONE_MANUALE;
  5639.             }
  5640.             String tipoCredenzialiSSLConfigurazioneManualeSelfSigned= this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_MANUALE_SELF_SIGNED);
  5641.            
  5642.             if(tipoCredenzialiSSLSorgente.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_CONFIGURAZIONE_MANUALE)) {
  5643.                 if (subject.equals("")) {
  5644.                     this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare il "+ ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT);
  5645.                     return false;
  5646.                 }
  5647.                
  5648.                 if(!this.checkLengthSubject_SSL_Principal(subject, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT)) {
  5649.                     return false;
  5650.                 }
  5651.                
  5652.                 try{
  5653.                     org.openspcoop2.utils.certificate.CertificateUtils.validaPrincipal(subject, PrincipalType.SUBJECT);
  5654.                 }catch(Exception e){
  5655.                     this.pd.setMessage("Le credenziali di tipo ssl  possiedono un subject non valido: "+e.getMessage());
  5656.                     return false;
  5657.                 }
  5658.                
  5659.                 // se non e' selfsigned validare anche l'issuer
  5660.                 if(!ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLConfigurazioneManualeSelfSigned)) {
  5661.                     String issuer = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER);
  5662.                    
  5663.                     // e' opzionale!
  5664. /**                 if (issuer.equals("")) {
  5665. //                      this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare il "+ ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER);
  5666. //                      return false;
  5667. //                  }*/
  5668.                    
  5669.                     if(!this.checkLengthSubject_SSL_Principal(issuer, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER)) {
  5670.                         return false;
  5671.                     }
  5672.                    
  5673.                     if(StringUtils.isNotEmpty(issuer)) {
  5674.                         try{
  5675.                             org.openspcoop2.utils.certificate.CertificateUtils.validaPrincipal(issuer, PrincipalType.ISSUER);
  5676.                         }catch(Exception e){
  5677.                             this.pd.setMessage("Le credenziali di tipo ssl possiedono un issuer non valido: "+e.getMessage());
  5678.                             return false;
  5679.                         }
  5680.                     }
  5681.                 }
  5682.             } else {
  5683.                
  5684.                
  5685.                 String tipoCredenzialiSSLWizardStep = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_WIZARD_STEP);
  5686.                 boolean validaFieldCert = tipoOp.equals(TipoOperazione.ADD) || !tipoCredenzialiSSLWizardStep.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_NO_WIZARD);
  5687.                
  5688.                 String tipoCredenzialiSSLTipoArchivioS = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  5689.                 org.openspcoop2.utils.certificate.ArchiveType tipoCredenzialiSSLTipoArchivio= null;
  5690.                 if(tipoCredenzialiSSLTipoArchivioS == null) {
  5691.                     tipoCredenzialiSSLTipoArchivio = org.openspcoop2.utils.certificate.ArchiveType.CER;
  5692.                 } else {
  5693.                     tipoCredenzialiSSLTipoArchivio = org.openspcoop2.utils.certificate.ArchiveType.valueOf(tipoCredenzialiSSLTipoArchivioS);
  5694.                 }
  5695.                 BinaryParameter tipoCredenzialiSSLFileCertificato = this.getBinaryParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO);
  5696.                
  5697.                 if(validaFieldCert) {
  5698.                     if(tipoCredenzialiSSLFileCertificato.getValue() == null || tipoCredenzialiSSLFileCertificato.getValue().length == 0) {
  5699.                         this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare il " + ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO);
  5700.                         return false;
  5701.                     }
  5702.                    
  5703.                     // validazione certificato caricato
  5704.                     if(tipoCredenzialiSSLTipoArchivio.equals(ArchiveType.CER)) {
  5705.                         try {
  5706.                             ArchiveLoader.load(tipoCredenzialiSSLFileCertificato.getValue());
  5707.                         }catch(UtilsException e) {
  5708.                             this.pd.setMessage("Il Certificato selezionato non &egrave; valido: "+e.getMessage());
  5709.                             return false;
  5710.                         }
  5711.                     } else {
  5712.                         String tipoCredenzialiSSLFileCertificatoPassword = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PASSWORD);
  5713.                         if(StringUtils.isEmpty(tipoCredenzialiSSLFileCertificatoPassword)) {
  5714.                             boolean required = true;
  5715.                             if(KeystoreType.JKS.isType(tipoCredenzialiSSLTipoArchivio.name())) {
  5716.                                 required = this.core.isLoadCertificateWizardJksPasswordRequiredRequired();
  5717.                             }
  5718.                             else if(KeystoreType.PKCS12.isType(tipoCredenzialiSSLTipoArchivio.name())) {
  5719.                                 required = this.core.isLoadCertificateWizardPkcs12PasswordRequiredRequired();
  5720.                             }
  5721.                             if(required) {
  5722.                                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare la " + ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PASSWORD);
  5723.                                 return false;
  5724.                             }
  5725.                         }
  5726.                         List<String> listaAliasEstrattiCertificato = new ArrayList<>();
  5727.                         try {
  5728.                             listaAliasEstrattiCertificato = ArchiveLoader.readAliases(tipoCredenzialiSSLTipoArchivio, tipoCredenzialiSSLFileCertificato.getValue(), tipoCredenzialiSSLFileCertificatoPassword);
  5729.                         }catch(UtilsException e) {
  5730.                             this.pd.setMessage("Il Certificato selezionato non &egrave; valido: "+e.getMessage());
  5731.                             return false;
  5732.                         }
  5733.                         String tipoCredenzialiSSLAliasCertificato = this.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO);
  5734.                        
  5735.                         if(StringUtils.isEmpty(tipoCredenzialiSSLAliasCertificato)) {
  5736.                             this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare un " + ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO);
  5737.                             return false;
  5738.                         }
  5739.                        
  5740.                         if(!listaAliasEstrattiCertificato.contains(tipoCredenzialiSSLAliasCertificato)) {
  5741.                             this.pd.setMessage("L'" + ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO + " indicato non &egrave; presente all'interno del file caricato.");
  5742.                             return false;
  5743.                         }
  5744.                        
  5745.                         try {
  5746.                             ArchiveLoader.load(tipoCredenzialiSSLTipoArchivio, tipoCredenzialiSSLFileCertificato.getValue(), tipoCredenzialiSSLAliasCertificato, tipoCredenzialiSSLFileCertificatoPassword);
  5747.                         }catch(UtilsException e) {
  5748.                             this.pd.setMessage("Il Certificato selezionato non &egrave; valido: "+e.getMessage());
  5749.                             return false;
  5750.                         }
  5751.                     }
  5752.                 }
  5753.             }
  5754.         }
  5755.        
  5756.         if (tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_APIKEY)) {
  5757.             boolean appIdModificabile = ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID_MODIFICABILE ;
  5758.             if(appIdModificabile && ServletUtils.isCheckBoxEnabled(appId)) {
  5759.                 if(utente.equals("")) {
  5760.                     String tmpElenco = "";
  5761.                     if (utente.equals("")) {
  5762.                         tmpElenco = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID;
  5763.                     }
  5764.                     this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare: " + tmpElenco);
  5765.                     return false;
  5766.                 }
  5767.                 if(!this.checkLengthSubject_SSL_Principal(utente, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_APP_ID)) {
  5768.                     return false;
  5769.                 }
  5770.             }
  5771.         }
  5772.        
  5773.         if (tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_PRINCIPAL) ) {
  5774.             if(principal.equals("")) {
  5775.                 String tmpElenco = "";
  5776.                 if (principal.equals("")) {
  5777.                     tmpElenco = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PRINCIPAL;
  5778.                 }
  5779.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare: " + tmpElenco);
  5780.                 return false;
  5781.             }
  5782.             if(!this.checkLengthSubject_SSL_Principal(principal, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PRINCIPAL)) {
  5783.                 return false;
  5784.             }
  5785.         }
  5786.        
  5787.         if (tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN) || tokenWithHttpsEnabledByConfigSA ) {
  5788.            
  5789.             StringBuilder sb = new StringBuilder();
  5790.            
  5791.             if(tokenPolicy==null || StringUtils.isEmpty(tokenPolicy) || CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(tokenPolicy)) {
  5792.                 sb.append(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_POLICY);
  5793.             }

  5794.             if(tokenClientId==null || StringUtils.isEmpty(tokenClientId)) {
  5795.                 if(sb.length()>0) {
  5796.                     sb.append(", ");
  5797.                 }
  5798.                 sb.append(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  5799.             }
  5800.             if(sb.length()>0) {
  5801.                 this.pd.setMessage("Dati incompleti. &Egrave; necessario indicare: " + sb.toString());
  5802.                 return false;
  5803.             }
  5804.            
  5805.             if(!this.checkLengthSubject_SSL_Principal(tokenClientId, ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_TOKEN_CLIENT_ID)) {
  5806.                 return false;
  5807.             }
  5808.         }
  5809.                
  5810.         if (!tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC) &&
  5811.                 !tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL) &&
  5812.                 !tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_PRINCIPAL) &&
  5813.                 !tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_APIKEY) &&
  5814.                 !tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN) &&
  5815.                 !tipoauth.equals(ConnettoriCostanti.AUTENTICAZIONE_TIPO_NESSUNA)) {
  5816.             this.pd.setMessage("Tipo dev'essere "+
  5817.                     ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC+", "+
  5818.                     ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL+" o "+
  5819.                     ConnettoriCostanti.AUTENTICAZIONE_TIPO_PRINCIPAL+" o "+
  5820.                     ConnettoriCostanti.AUTENTICAZIONE_TIPO_APIKEY+" o "+
  5821.                     ConnettoriCostanti.AUTENTICAZIONE_TIPO_TOKEN+" o "+
  5822.                     ConnettoriCostanti.AUTENTICAZIONE_TIPO_NESSUNA);
  5823.             return false;
  5824.         }
  5825.        
  5826.         return true;
  5827.     }
  5828.    
  5829.     public List<DataElement> addConnettoreDefaultRidefinitoToDati(List<DataElement> dati, TipoOperazione tipoOp, String modalita, String[] modalitaValues, String[] modalitaLabels, boolean servletRidefinito, String servletConnettore, Parameter[] parametriServletConnettore) {
  5830.        
  5831.         if(tipoOp!=null) {
  5832.             // nop
  5833.         }
  5834.        
  5835.         DataElement de = new DataElement();
  5836.         de.setLabel(ConnettoriCostanti.LABEL_CONNETTORE);
  5837.         de.setType(DataElementType.TITLE);
  5838.         dati.add(de);
  5839.        
  5840.         de = new DataElement();
  5841.         de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_MODALITA);
  5842.         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_MODALITA);
  5843.         de.setType(DataElementType.SELECT);
  5844.         de.setValues(modalitaValues);
  5845.         de.setLabels(modalitaLabels);
  5846.         de.setPostBack(true);
  5847.         de.setSelected(modalita);
  5848.         dati.add(de);
  5849.        
  5850.         // link visualizza
  5851.         if(servletRidefinito && modalita.equals(ConnettoriCostanti.VALUE_PARAMETRO_MODALITA_CONNETTORE_RIDEFINITO)) {
  5852.             de = new DataElement();
  5853.             de.setType(DataElementType.LINK);
  5854.             de.setName(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_PROPRIETA);
  5855.             de.setUrl(servletConnettore, parametriServletConnettore);
  5856.             ServletUtils.setDataElementVisualizzaLabel(de);
  5857.             dati.add(de);  
  5858.         }
  5859.        
  5860.         return dati;
  5861.     }
  5862.    
  5863.     public boolean connettoreDefaultRidefinitoCheckData(TipoOperazione tipoOp, String modalita) {
  5864.        
  5865.         if(tipoOp!=null) {
  5866.             // nop
  5867.         }
  5868.        
  5869.         if (StringUtils.isEmpty(modalita)) {
  5870.             this.pd.setMessage("Il campo "+ConnettoriCostanti.LABEL_PARAMETRO_CONNETTORE_MODALITA+" non pu&ograve; essere vuoto");
  5871.             return false;
  5872.         }
  5873.        
  5874.         return true;
  5875.     }
  5876.    
  5877.     public List<DataElement> addCredenzialiCertificatiToDati(List<DataElement> dati, TipoOperazione tipoOperazione, String idCredenziale, String tipoauth, String subject, String toCall,
  5878.             String tipoCredenzialiSSLSorgente, ArchiveType tipoCredenzialiSSLTipoArchivio, BinaryParameter tipoCredenzialiSSLFileCertificato, String tipoCredenzialiSSLFileCertificatoPassword,
  5879.             List<String> listaAliasEstrattiCertificato, String tipoCredenzialiSSLAliasCertificato,  String tipoCredenzialiSSLAliasCertificatoSubject, String tipoCredenzialiSSLAliasCertificatoIssuer,
  5880.             String tipoCredenzialiSSLAliasCertificatoType, String tipoCredenzialiSSLAliasCertificatoVersion, String tipoCredenzialiSSLAliasCertificatoSerialNumber, String tipoCredenzialiSSLAliasCertificatoSelfSigned,
  5881.             String tipoCredenzialiSSLAliasCertificatoNotBefore, String tipoCredenzialiSSLAliasCertificatoNotAfter, String tipoCredenzialiSSLVerificaTuttiICampi, String tipoCredenzialiSSLConfigurazioneManualeSelfSigned,
  5882.             String issuer, String tipoCredenzialiSSLStatoElaborazioneCertificato, String promuoviCertificato,
  5883.             boolean visualizzaPromuoviCertificato, String aggiornaCertificatoCaricato, String servletCredenzialiChange, List<Parameter> parametersServletCredenzialiChange) throws DriverControlStationException, ParseException {

  5884.         if(servletCredenzialiChange!=null && parametersServletCredenzialiChange!=null) {
  5885.             // nop
  5886.         }
  5887.        
  5888.         DataElement de = null;
  5889.        
  5890.         de = new DataElement();
  5891.         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CREDENZIALI_ID);
  5892.         de.setType(DataElementType.HIDDEN);
  5893.         de.setValue(idCredenziale);
  5894.         dati.add(de);

  5895.         // Titolo Sezione Certificato
  5896.         de = new DataElement();
  5897.         de.setLabel(ConnettoriCostanti.LABEL_CONFIGURAZIONE_SSL_TITLE_INFORMAZIONI_CERTIFICATO);
  5898.         de.setType(DataElementType.TITLE);
  5899.         dati.add(de);
  5900.        

  5901.         // tipoAutenticazione Hidden forzato ad https
  5902.         de = new DataElement();
  5903.         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_TIPO_AUTENTICAZIONE);
  5904.         de.setType(DataElementType.HIDDEN);
  5905.         de.setValue(tipoauth);
  5906.         dati.add(de);
  5907.        
  5908.         de = new DataElement();
  5909.         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_MULTI_AGGIORNA);
  5910.         de.setType(DataElementType.HIDDEN);
  5911.         de.setValue(aggiornaCertificatoCaricato);
  5912.         dati.add(de);
  5913.        
  5914.         if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL.equals(tipoauth)) {
  5915.             boolean add = ( SoggettiCostanti.SERVLET_NAME_SOGGETTI_CREDENZIALI_ADD.equals(toCall)
  5916.                     ||  ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CREDENZIALI_ADD.equals(toCall));
  5917.            
  5918.             boolean visualizzaFieldCert = false;
  5919.             boolean visualizzaDownload = false;
  5920.             if(add) {
  5921.                 visualizzaFieldCert = StringUtils.isEmpty(tipoCredenzialiSSLAliasCertificatoSubject);
  5922.             }
  5923.             else {
  5924.                 visualizzaFieldCert = !tipoCredenzialiSSLStatoElaborazioneCertificato.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_NO_WIZARD)
  5925.                         && StringUtils.isEmpty(tipoCredenzialiSSLAliasCertificatoSubject);
  5926.                 visualizzaDownload = tipoCredenzialiSSLStatoElaborazioneCertificato.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_NO_WIZARD);
  5927.             }
  5928.             boolean aggiuntoWizardStep = false;
  5929.             if(!add && visualizzaDownload) {
  5930.                 de = new DataElement();
  5931.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_WIZARD_STEP);
  5932.                 de.setValue(tipoCredenzialiSSLStatoElaborazioneCertificato);
  5933.                 de.setType(DataElementType.HIDDEN);
  5934.                 dati.add(de);
  5935.                 aggiuntoWizardStep = true;
  5936.             }
  5937.            

  5938.             /**
  5939.             String tipoCredenzialiSSLSorgente = ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_UPLOAD_CERTIFICATO;
  5940.             String tipoCredenzialiSSLTipoArchivio = ArchiveType.CER.name();
  5941.             BinaryParameter tipoCredenzialiSSLFileCertificato = new BinaryParameter();
  5942.             tipoCredenzialiSSLFileCertificato.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO);
  5943.             List<String> listaAliasEstrattiCertificato = new ArrayList<>();
  5944.             String tipoCredenzialiSSLFileCertificatoPassword = "";
  5945.             String tipoCredenzialiSSLAliasCertificato = "";
  5946.             String tipoCredenzialiSSLAliasCertificatoSubject= "";
  5947.             String tipoCredenzialiSSLAliasCertificatoIssuer= "";
  5948.             String tipoCredenzialiSSLAliasCertificatoType= "";
  5949.             String tipoCredenzialiSSLAliasCertificatoVersion= "";
  5950.             String tipoCredenzialiSSLAliasCertificatoSerialNumber= "";
  5951.             String tipoCredenzialiSSLAliasCertificatoSelfSigned= "";
  5952.             String tipoCredenzialiSSLAliasCertificatoNotBefore= "";
  5953.             String tipoCredenzialiSSLAliasCertificatoNotAfter = "";
  5954.             String tipoCredenzialiSSLVerificaTuttiICampi = "";
  5955.             String tipoCredenzialiSSLConfigurazioneManualeSelfSigned="";
  5956.             String issuer = "";
  5957.             */
  5958.            
  5959.             String subtitleConfigurazione = ConnettoriCostanti.LABEL_CONFIGURAZIONE_SSL_TITLE_CONFIGURAZIONE;
  5960.            
  5961.             de = new DataElement();
  5962.             de.setLabel(subtitleConfigurazione);
  5963.             de.setType(DataElementType.SUBTITLE);
  5964.             dati.add(de);
  5965.            
  5966.             // OP-816
  5967.             // 1. Hidden - valorizzato come Upload Certificato
  5968.             de = new DataElement();
  5969.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL);
  5970.             de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL);
  5971.             de.setType(DataElementType.HIDDEN);
  5972.             de.setValue(tipoCredenzialiSSLSorgente);
  5973.             dati.add(de);

  5974.             if(tipoCredenzialiSSLSorgente.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_UPLOAD_CERTIFICATO)) {
  5975.                 // 1a. Select List Tipo Archivio
  5976.                 de = new DataElement();
  5977.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  5978.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  5979.                 if(visualizzaFieldCert) {
  5980.                     de.setType(DataElementType.SELECT);
  5981.                     de.setLabels(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_LABELS);
  5982.                     de.setValues(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_VALUES);
  5983.                     de.setSelected(tipoCredenzialiSSLTipoArchivio.name());
  5984.                     de.setSize(this.getSize());
  5985.                     de.setPostBack(true);
  5986.                    
  5987.                     if(ArchiveType.CER.equals(tipoCredenzialiSSLTipoArchivio) || ArchiveType.JKS.equals(tipoCredenzialiSSLTipoArchivio)) {
  5988.                         DataElementInfo dInfo = new DataElementInfo(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  5989.                         if(ArchiveType.CER.equals(tipoCredenzialiSSLTipoArchivio)) {
  5990.                             dInfo.setHeaderBody(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_INFO_CER);
  5991.                             dInfo.setListBody(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_INFO_CER_VALUES);
  5992.                         }
  5993.                         else {
  5994.                             dInfo.setHeaderBody(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO_INFO_JKS);
  5995.                         }
  5996.                         de.setInfo(dInfo);
  5997.                     }
  5998.                    
  5999.                 } else {
  6000.                     de.setType(DataElementType.HIDDEN);
  6001.                     de.setValue(tipoCredenzialiSSLTipoArchivio.name());
  6002.                 }
  6003.                 dati.add(de);
  6004.                
  6005.                 de = new DataElement();
  6006.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PASSWORD);
  6007.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PASSWORD);
  6008.                 de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLFileCertificatoPassword));
  6009.                 if(visualizzaFieldCert && (tipoCredenzialiSSLTipoArchivio.equals(ArchiveType.JKS) || tipoCredenzialiSSLTipoArchivio.equals(ArchiveType.PKCS12))) {
  6010.                     // 1a. Password per gli archivi JKS o PKCS12.
  6011.                     de.setType(DataElementType.TEXT_EDIT);
  6012.                     de.setSize(this.getSize());
  6013.                     de.setRequired(true);
  6014.                 } else {
  6015.                     de.setType(DataElementType.HIDDEN);
  6016.                 }
  6017.                
  6018.                 dati.add(de);
  6019.                
  6020.                 // 1a. File Upload
  6021.                 String labelCertificato = null;
  6022.                 if(ArchiveType.CER.equals(tipoCredenzialiSSLTipoArchivio)) {
  6023.                     labelCertificato = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO;
  6024.                 }
  6025.                 else {
  6026.                     labelCertificato = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_ARCHIVIO;
  6027.                 }
  6028.                 DataElement fileDataElement = tipoCredenzialiSSLFileCertificato.getFileDataElement(labelCertificato, "", getSize());
  6029.                 fileDataElement.setRequired(true);
  6030.                 fileDataElement.setPostBack(false);
  6031.                
  6032.                 if(!visualizzaFieldCert)
  6033.                     fileDataElement.setType(DataElementType.HIDDEN);
  6034.                
  6035.                 dati.add(fileDataElement);
  6036.                 dati.addAll(tipoCredenzialiSSLFileCertificato.getFileNameDataElement());
  6037.                 dati.add(tipoCredenzialiSSLFileCertificato.getFileIdDataElement());
  6038.                                    
  6039.                 if(!visualizzaFieldCert) {
  6040.                     de = new DataElement();
  6041.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_MODIFICA);
  6042.                     de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_CAMBIA_+labelCertificato);
  6043.                     de.setPostBack(true);
  6044.                     // Imposto # per valorizzare la url, non viene utilizzata ma viene scatenata la post back
  6045.                     de.setUrl("#");
  6046.                     de.setType(DataElementType.LINK);
  6047.                     dati.add(de);
  6048.                 }
  6049.                
  6050.                 // link promuovi certificato
  6051.                 if(!visualizzaFieldCert && visualizzaPromuoviCertificato &&
  6052.                     tipoOperazione.equals(TipoOperazione.CHANGE)) {
  6053.                     de = new DataElement();
  6054.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_PROMUOVI);
  6055.                     de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_PROMUOVI);
  6056.                     de.setPostBack(true);
  6057.                     // Imposto # per valorizzare la url, non viene utilizzata ma viene scatenata la post back
  6058.                     de.setUrl("#");
  6059. /**                     de.setUrl(servletCredenzialiChange, parametersServletCredenzialiChange.toArray(new Parameter[parametersServletCredenzialiChange.size()]));*/
  6060.                     de.setType(DataElementType.LINK);
  6061.                     dati.add(de);
  6062.                 }
  6063.                
  6064.                 // 1a. Eventuale Select per selezionare l'alias
  6065.                 de = new DataElement();
  6066.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO);
  6067.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO);
  6068.                 if(listaAliasEstrattiCertificato.size() > 1) {
  6069.                    
  6070.                     de.setType(DataElementType.SELECT);
  6071.                    
  6072.                     List<String> listaLabels = new ArrayList<>();
  6073.                     listaLabels.addAll(listaAliasEstrattiCertificato);
  6074.                     listaLabels.add(0, "--");
  6075.                    
  6076.                     List<String> listaValues = new ArrayList<>();
  6077.                     listaValues.addAll(listaAliasEstrattiCertificato);
  6078.                     listaValues.add(0, "");
  6079.                    
  6080.                     de.setLabels(listaLabels);
  6081.                     de.setValues(listaValues);
  6082.                     de.setSelected(tipoCredenzialiSSLAliasCertificato);
  6083.                     de.setPostBack(true);
  6084.                     de.setSize(this.getSize());
  6085.                     de.setRequired(true);
  6086.                    
  6087.                 } else {
  6088.                     de.setType(DataElementType.HIDDEN);
  6089.                     de.setValue(tipoCredenzialiSSLAliasCertificato);
  6090.                 }
  6091.                 dati.add(de);

  6092.                 // 1a. Pannello Recap info certificato.
  6093.                
  6094.                 if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject)) {
  6095.                     de = new DataElement();
  6096.                     de.setLabel(ConnettoriCostanti.LABEL_CONFIGURAZIONE_SSL_TITLE_INFORMAZIONI_CERTIFICATO+" "+
  6097.                     tipoCredenzialiSSLAliasCertificatoType+" v"+tipoCredenzialiSSLAliasCertificatoVersion);
  6098.                     de.setType(DataElementType.SUBTITLE);
  6099.                     dati.add(de);
  6100.                 }
  6101.                
  6102.                 // link al download
  6103.                 if(visualizzaDownload) {
  6104.                     de = new DataElement();
  6105.                    
  6106.                     String idOggetto = null;
  6107.                     String tipoOggetto = "";
  6108.                            
  6109.                     if(SoggettiCostanti.SERVLET_NAME_SOGGETTI_CREDENZIALI_CHANGE.equals(toCall)) {
  6110.                         tipoOggetto =  ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_SOGGETTO;
  6111.                         idOggetto = this.getParameter(SoggettiCostanti.PARAMETRO_SOGGETTO_ID);
  6112.                     }
  6113.                    
  6114.                     if(ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CREDENZIALI_CHANGE.equals(toCall)) {
  6115.                         tipoOggetto =  ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_SERVIZIO_APPLICATIVO;
  6116.                         idOggetto = this.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID);
  6117.                     }
  6118.                    
  6119.                     de.setUrl(ArchiviCostanti.SERVLET_NAME_DOCUMENTI_EXPORT,
  6120.                             new Parameter(AccordiServizioParteComuneCostanti.PARAMETRO_APC_ALLEGATI_ID_ACCORDO, idOggetto),
  6121.                             new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO, tipoOggetto),
  6122.                             new Parameter(ArchiviCostanti.PARAMETRO_ARCHIVI_ALLEGATO_TIPO_ACCORDO_TIPO_DOCUMENTO, ArchiviCostanti.PARAMETRO_VALORE_ARCHIVI_ALLEGATO_TIPO_DOCUMENTO_CERTIFICATO_SSL),
  6123.                             new Parameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CREDENZIALI_ID, idCredenziale));
  6124.                    
  6125.                     de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_DOWNLOAD);
  6126.                     de.setType(DataElementType.LINK);
  6127.                     de.setDisabilitaAjaxStatus();
  6128.                     dati.add(de);
  6129.                 }
  6130.                                
  6131.                 // 1a. Checkbox 'Verifica tutti i campi' + nota: attenzione questa opzione richiede l'aggiornamento del certificato a scadenza
  6132.                
  6133.                 boolean verificaCompleta = false;
  6134.                 if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject)) {
  6135.                     verificaCompleta = ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLVerificaTuttiICampi);
  6136.                 }
  6137.                
  6138.                 de = new DataElement();
  6139.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  6140.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  6141.                 if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject)) {
  6142.                     de.setType(DataElementType.CHECKBOX);
  6143.                     de.setSelected(verificaCompleta);
  6144.                     de.setSize(this.getSize());
  6145.                     de.setLabelAffiancata(true);
  6146.                     de.setPostBack(true);
  6147.                 }else {
  6148.                     de.setType(DataElementType.HIDDEN);
  6149.                     de.setValue(tipoCredenzialiSSLVerificaTuttiICampi);
  6150.                 }
  6151.                 dati.add(de);

  6152.                 if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject) && !verificaCompleta) {
  6153.                     de = new DataElement();
  6154.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI_NOTE_DISABLE);
  6155.                     de.setType(DataElementType.NOTE);
  6156.                     de.setBold(true);
  6157.                     de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_SOLO_SUBJECT_ISSUER);
  6158.                     de.setValue(ConnettoriCostanti.NOTE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_SOLO_SUBJECT_ISSUER);
  6159.                     dati.add(de);
  6160.                 }
  6161.                
  6162. //                      Subject:
  6163.                 de = new DataElement();
  6164.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SUBJECT);
  6165.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SUBJECT);
  6166.                 de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLAliasCertificatoSubject));
  6167.                 if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSubject)) {
  6168.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6169.                     de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  6170.                 }else {
  6171.                     de.setType(DataElementType.HIDDEN);
  6172.                 }
  6173.                 de.setSize(this.getSize());
  6174.                 dati.add(de);
  6175. //                          Issuer:
  6176.                 de = new DataElement();
  6177.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_ISSUER);
  6178.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_ISSUER);
  6179.                 de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLAliasCertificatoIssuer));
  6180.                 if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoIssuer)) {
  6181.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  6182.                     de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  6183.                 }else {
  6184.                     de.setType(DataElementType.HIDDEN);
  6185.                 }
  6186.                 de.setSize(this.getSize());
  6187.                 dati.add(de);
  6188. //                          Type:
  6189.                 de = new DataElement();
  6190.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_TYPE);
  6191.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_TYPE);
  6192.                 de.setValue(tipoCredenzialiSSLAliasCertificatoType);
  6193.                 de.setType(DataElementType.HIDDEN);
  6194.                 de.setSize(this.getSize());
  6195.                 dati.add(de);
  6196. //                          Version:
  6197.                 de = new DataElement();
  6198.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_VERSION);
  6199.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_VERSION);
  6200.                 de.setValue(tipoCredenzialiSSLAliasCertificatoVersion);
  6201.                 de.setType(DataElementType.HIDDEN);
  6202.                 de.setSize(this.getSize());
  6203.                 dati.add(de);
  6204. //                          Serial Number:
  6205.                 de = new DataElement();
  6206.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER);
  6207.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER);
  6208.                 de.setValue(tipoCredenzialiSSLAliasCertificatoSerialNumber);
  6209.                 if(verificaCompleta && StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSerialNumber)) {
  6210.                     de.setType(DataElementType.TEXT);
  6211.                 }else {
  6212.                     de.setType(DataElementType.HIDDEN);
  6213.                 }
  6214.                 de.setSize(this.getSize());
  6215.                 dati.add(de);
  6216.                 if(verificaCompleta && StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSerialNumber)) {
  6217.                     String hexValue = null;
  6218.                     try {
  6219.                         hexValue = CertificateInfo.formatSerialNumberHex(tipoCredenzialiSSLAliasCertificatoSerialNumber,":");
  6220.                     }catch(Throwable t) {
  6221.                         // ignore
  6222.                     }
  6223.                     if(hexValue!=null && StringUtils.isNotEmpty(hexValue)) {
  6224.                         de = new DataElement();
  6225.                         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER_HEX);
  6226.                         de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER_HEX);
  6227.                         de.setValue(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER_HEX_PREFIX+hexValue);
  6228.                         de.setType(DataElementType.TEXT);
  6229.                         de.setSize(this.getSize());
  6230.                         dati.add(de);
  6231.                     }
  6232.                 }
  6233. //                          SelfSigned:
  6234.                 de = new DataElement();
  6235.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SELF_SIGNED);
  6236.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SELF_SIGNED);
  6237.                 de.setValue(tipoCredenzialiSSLAliasCertificatoSelfSigned);
  6238.                 if(StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoSelfSigned)) {
  6239.                     de.setType(DataElementType.TEXT);
  6240.                 }else {
  6241.                     de.setType(DataElementType.HIDDEN);
  6242.                 }
  6243.                 de.setSize(this.getSize());
  6244.                 dati.add(de);
  6245. //                          NotBefore:
  6246.                 de = new DataElement();
  6247.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_BEFORE);
  6248.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_BEFORE);
  6249.                 de.setValue(tipoCredenzialiSSLAliasCertificatoNotBefore);
  6250.                 if(verificaCompleta && StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoNotBefore)) {
  6251.                     de.setType(DataElementType.TEXT);
  6252.                     // Rendi bold la data NotBefore se è una data successiva ad adesso.
  6253.                     if(this.getSdfCredenziali().parse(tipoCredenzialiSSLAliasCertificatoNotBefore).after(new Date())) {
  6254.                         de.setValoreBold();
  6255.                     }
  6256.                        
  6257.                    
  6258.                 }else {
  6259.                     de.setType(DataElementType.HIDDEN);
  6260.                 }
  6261.                 de.setSize(this.getSize());
  6262.                 dati.add(de);
  6263. //                          NotAfter:
  6264.                 de = new DataElement();
  6265.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_AFTER);
  6266.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_AFTER);
  6267.                 de.setValue(tipoCredenzialiSSLAliasCertificatoNotAfter);
  6268.                 if(verificaCompleta && StringUtils.isNotEmpty(tipoCredenzialiSSLAliasCertificatoNotAfter)) {
  6269.                     de.setType(DataElementType.TEXT);
  6270.                     // Rendi bold e colora di Rosso la data visualizzata Not After se risulta scaduta.
  6271.                     if(this.getSdfCredenziali().parse(tipoCredenzialiSSLAliasCertificatoNotAfter).before(new Date())) {
  6272.                         de.setValoreBoldRed();
  6273.                     }
  6274.                    
  6275.                    
  6276.                 }else {
  6277.                     de.setType(DataElementType.HIDDEN);
  6278.                 }
  6279.                 de.setSize(this.getSize());
  6280.                 dati.add(de);

  6281.                 // checkbox promuovi certificato
  6282.                 if(!visualizzaFieldCert &&
  6283.                     visualizzaPromuoviCertificato &&
  6284.                     tipoOperazione.equals(TipoOperazione.ADD)) {
  6285.                     de = new DataElement();
  6286.                     de.setLabelAffiancata(true);
  6287.                     de.setLabel("");
  6288.                     de.setNote(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_LINK_PROMUOVI);
  6289.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PROMUOVI);
  6290.                     de.setValue(promuoviCertificato);
  6291.                     de.setType(DataElementType.CHECKBOX);
  6292.                     dati.add(de);
  6293.                 }
  6294.                
  6295.                 // data element per pilotare la label del  tasto carica
  6296.                 if(!aggiuntoWizardStep) {
  6297.                     de = new DataElement();
  6298.                     de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_WIZARD_STEP);
  6299.                     de.setLabel("");
  6300.                     de.setType(DataElementType.HIDDEN);
  6301.                     de.setValue(tipoCredenzialiSSLStatoElaborazioneCertificato);
  6302.                     dati.add(de);
  6303.                 }
  6304.                
  6305.             } else {
  6306.                
  6307.                 // 1b  Checkbox selfSigned
  6308.                 de = new DataElement();
  6309.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_MANUALE_SELF_SIGNED);
  6310.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_MANUALE_SELF_SIGNED);
  6311.                 de.setType(DataElementType.CHECKBOX);
  6312.                 de.setSelected(ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLConfigurazioneManualeSelfSigned));
  6313.                 de.setSize(this.getSize());
  6314.                 de.setPostBack(true);
  6315.                 dati.add(de);
  6316.                
  6317.                
  6318.                 // 1b. TextArea Subject
  6319.                 de = new DataElement();
  6320.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT);
  6321.                 de.setValue(StringEscapeUtils.escapeHtml(subject));
  6322.                 de.setType(DataElementType.TEXT_AREA);
  6323.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT);
  6324.                 de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  6325.                 de.setSize(this.getSize());
  6326.                 de.setRequired(true);
  6327.                 dati.add(de);
  6328.                
  6329.                 // 1b. TextArea Issuer
  6330.                 de = new DataElement();
  6331.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER);
  6332.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER);
  6333.                 if(!ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLConfigurazioneManualeSelfSigned)) {
  6334.                     de.setType(DataElementType.TEXT_AREA);
  6335.                     de.setValue(StringEscapeUtils.escapeHtml(issuer));
  6336.                     de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  6337.                     de.setSize(this.getSize());
  6338.                 } else {
  6339.                     de.setType(DataElementType.HIDDEN);
  6340.                     de.setValue("");
  6341.                 }
  6342.                 dati.add(de);
  6343.             }
  6344.         }
  6345.        
  6346.         return dati;
  6347.     }
  6348.    
  6349.     public List<DataElement> addCredenzialiCertificatiToDatiAsHidden(List<DataElement> dati, TipoOperazione tipoOperazione, String idCredenziale, String tipoauth, String subject, String toCall,
  6350.             String tipoCredenzialiSSLSorgente, ArchiveType tipoCredenzialiSSLTipoArchivio, BinaryParameter tipoCredenzialiSSLFileCertificato, String tipoCredenzialiSSLFileCertificatoPassword,
  6351.             List<String> listaAliasEstrattiCertificato, String tipoCredenzialiSSLAliasCertificato,  String tipoCredenzialiSSLAliasCertificatoSubject, String tipoCredenzialiSSLAliasCertificatoIssuer,
  6352.             String tipoCredenzialiSSLAliasCertificatoType, String tipoCredenzialiSSLAliasCertificatoVersion, String tipoCredenzialiSSLAliasCertificatoSerialNumber, String tipoCredenzialiSSLAliasCertificatoSelfSigned,
  6353.             String tipoCredenzialiSSLAliasCertificatoNotBefore, String tipoCredenzialiSSLAliasCertificatoNotAfter, String tipoCredenzialiSSLVerificaTuttiICampi, String tipoCredenzialiSSLConfigurazioneManualeSelfSigned,
  6354.             String issuer, String tipoCredenzialiSSLStatoElaborazioneCertificato, String promuoviCertificato,
  6355.             boolean visualizzaPromuoviCertificato, String servletCredenzialiChange, List<Parameter> parametersServletCredenzialiChange) {

  6356.         if(tipoOperazione!=null || toCall!=null || listaAliasEstrattiCertificato!=null || promuoviCertificato!=null || visualizzaPromuoviCertificato ||
  6357.                 servletCredenzialiChange!=null || parametersServletCredenzialiChange!=null) {
  6358.             // nop
  6359.         }
  6360.        
  6361.         DataElement de = null;
  6362.        
  6363.         de = new DataElement();
  6364.         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CREDENZIALI_ID);
  6365.         de.setType(DataElementType.HIDDEN);
  6366.         de.setValue(idCredenziale);
  6367.         dati.add(de);

  6368.         // tipoAutenticazione Hidden forzato ad https
  6369.         de = new DataElement();
  6370.         de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_TIPO_AUTENTICAZIONE);
  6371.         de.setType(DataElementType.HIDDEN);
  6372.         de.setValue(tipoauth);
  6373.         dati.add(de);
  6374.        
  6375.         if (ConnettoriCostanti.AUTENTICAZIONE_TIPO_SSL.equals(tipoauth)) {
  6376.             // OP-816
  6377.             // 1. Hidden - valorizzato come Upload Certificato
  6378.             de = new DataElement();
  6379.             de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL);
  6380.             de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL);
  6381.             de.setType(DataElementType.HIDDEN);
  6382.             de.setValue(tipoCredenzialiSSLSorgente);
  6383.             dati.add(de);

  6384.             if(tipoCredenzialiSSLSorgente.equals(ConnettoriCostanti.VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_UPLOAD_CERTIFICATO)) {
  6385.                 // 1a. Select List Tipo Archivio
  6386.                 de = new DataElement();
  6387.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  6388.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_TIPO_ARCHIVIO);
  6389.                 de.setType(DataElementType.HIDDEN);
  6390.                 de.setValue(tipoCredenzialiSSLTipoArchivio.name());
  6391.                 dati.add(de);
  6392.                
  6393.                 de = new DataElement();
  6394.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PASSWORD);
  6395.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO_PASSWORD);
  6396.                 de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLFileCertificatoPassword));
  6397.                 de.setType(DataElementType.HIDDEN);
  6398.                 dati.add(de);
  6399.                
  6400.                 // 1a. File Upload
  6401.                 String labelCertificato = null;
  6402.                 if(ArchiveType.CER.equals(tipoCredenzialiSSLTipoArchivio)) {
  6403.                     labelCertificato = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_CERTIFICATO;
  6404.                 }
  6405.                 else {
  6406.                     labelCertificato = ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_FILE_ARCHIVIO;
  6407.                 }
  6408.                 DataElement fileDataElement = tipoCredenzialiSSLFileCertificato.getFileDataElement(labelCertificato, "", getSize());
  6409.                 fileDataElement.setRequired(true);
  6410.                 fileDataElement.setPostBack(false);
  6411.                 fileDataElement.setType(DataElementType.HIDDEN);
  6412.                 dati.add(fileDataElement);
  6413.                 dati.addAll(tipoCredenzialiSSLFileCertificato.getFileNameDataElement());
  6414.                 dati.add(tipoCredenzialiSSLFileCertificato.getFileIdDataElement());
  6415.                                    
  6416.                 // 1a. Eventuale Select per selezionare l'alias
  6417.                 de = new DataElement();
  6418.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO);
  6419.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO);
  6420.                 de.setType(DataElementType.HIDDEN);
  6421.                 de.setValue(tipoCredenzialiSSLAliasCertificato);
  6422.                 dati.add(de);

  6423.                 // 1a. Pannello Recap info certificato.

  6424.                 // 1a. Checkbox 'Verifica tutti i campi' + nota: attenzione questa opzione richiede l'aggiornamento del certificato a scadenza
  6425.                 de = new DataElement();
  6426.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  6427.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  6428.                 de.setType(DataElementType.HIDDEN);
  6429.                 de.setValue(tipoCredenzialiSSLVerificaTuttiICampi);
  6430.                 dati.add(de);
  6431.                
  6432.                 //                      Subject:
  6433.                 de = new DataElement();
  6434.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SUBJECT);
  6435.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SUBJECT);
  6436.                 de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLAliasCertificatoSubject));
  6437.                 de.setType(DataElementType.HIDDEN);
  6438.                 de.setSize(this.getSize());
  6439.                 dati.add(de);
  6440. //                          Issuer:
  6441.                 de = new DataElement();
  6442.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_ISSUER);
  6443.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_ISSUER);
  6444.                 de.setValue(StringEscapeUtils.escapeHtml(tipoCredenzialiSSLAliasCertificatoIssuer));
  6445.                 de.setType(DataElementType.HIDDEN);
  6446.                 de.setSize(this.getSize());
  6447.                 dati.add(de);
  6448. //                          Type:
  6449.                 de = new DataElement();
  6450.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_TYPE);
  6451.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_TYPE);
  6452.                 de.setValue(tipoCredenzialiSSLAliasCertificatoType);
  6453.                 de.setType(DataElementType.HIDDEN);
  6454.                 de.setSize(this.getSize());
  6455.                 dati.add(de);
  6456. //                          Version:
  6457.                 de = new DataElement();
  6458.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_VERSION);
  6459.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_VERSION);
  6460.                 de.setValue(tipoCredenzialiSSLAliasCertificatoVersion);
  6461.                 de.setType(DataElementType.HIDDEN);
  6462.                 de.setSize(this.getSize());
  6463.                 dati.add(de);
  6464. //                          Serial Number:
  6465.                 de = new DataElement();
  6466.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER);
  6467.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SERIAL_NUMBER);
  6468.                 de.setValue(tipoCredenzialiSSLAliasCertificatoSerialNumber);
  6469.                 de.setType(DataElementType.HIDDEN);
  6470.                 de.setSize(this.getSize());
  6471.                 dati.add(de);
  6472. //                          SelfSigned:
  6473.                 de = new DataElement();
  6474.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SELF_SIGNED);
  6475.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_SELF_SIGNED);
  6476.                 de.setValue(tipoCredenzialiSSLAliasCertificatoSelfSigned);
  6477.                 de.setType(DataElementType.HIDDEN);
  6478.                 de.setSize(this.getSize());
  6479.                 dati.add(de);
  6480. //                          NotBefore:
  6481.                 de = new DataElement();
  6482.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_BEFORE);
  6483.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_BEFORE);
  6484.                 de.setValue(tipoCredenzialiSSLAliasCertificatoNotBefore);
  6485.                 de.setType(DataElementType.HIDDEN);
  6486.                 de.setSize(this.getSize());
  6487.                 dati.add(de);
  6488. //                          NotAfter:
  6489.                 de = new DataElement();
  6490.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_AFTER);
  6491.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_ALIAS_CERTIFICATO_NOT_AFTER);
  6492.                 de.setValue(tipoCredenzialiSSLAliasCertificatoNotAfter);
  6493.                 de.setType(DataElementType.HIDDEN);
  6494.                 de.setSize(this.getSize());
  6495.                 dati.add(de);
  6496.                                
  6497.                 // data element per pilotare la label del  tasto carica
  6498.                 de = new DataElement();
  6499.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_WIZARD_STEP);
  6500.                 de.setLabel("");
  6501.                 de.setType(DataElementType.HIDDEN);
  6502.                 de.setValue(tipoCredenzialiSSLStatoElaborazioneCertificato);
  6503.                 dati.add(de);
  6504.                
  6505.             } else {
  6506.                
  6507.                 // 1b  Checkbox selfSigned
  6508.                 de = new DataElement();
  6509.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_MANUALE_SELF_SIGNED);
  6510.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_MANUALE_SELF_SIGNED);
  6511.                 de.setType(DataElementType.HIDDEN);
  6512.                 de.setSelected(ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLConfigurazioneManualeSelfSigned));
  6513.                 de.setSize(this.getSize());
  6514.                 de.setPostBack(true);
  6515.                 dati.add(de);
  6516.                
  6517.                
  6518.                 // 1b. TextArea Subject
  6519.                 de = new DataElement();
  6520.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT);
  6521.                 de.setValue(StringEscapeUtils.escapeHtml(subject));
  6522.                 de.setType(DataElementType.HIDDEN);
  6523.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_SUBJECT);
  6524.                 de.setRows(CostantiControlStation.LABEL_PARAMETRO_TEXT_AREA_SIZE);
  6525.                 de.setSize(this.getSize());
  6526.                 de.setRequired(true);
  6527.                 dati.add(de);
  6528.                
  6529.                 // 1b. TextArea Issuer
  6530.                 de = new DataElement();
  6531.                 de.setLabel(ConnettoriCostanti.LABEL_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER);
  6532.                 de.setName(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_ISSUER);
  6533.                 de.setValue(StringEscapeUtils.escapeHtml(issuer));
  6534.                 de.setType(DataElementType.HIDDEN);
  6535.                 dati.add(de);
  6536.             }
  6537.         }
  6538.        
  6539.         return dati;
  6540.     }
  6541.    
  6542.     public String getLabelCredenzialeCertificato(String subject) {
  6543.         if(subject!=null) {
  6544.             int length = 60;
  6545.            
  6546.             if(subject.length() > length) {
  6547.                 subject = subject.substring(0, length - 3) + "...";
  6548.             }
  6549.         }
  6550.                
  6551.         return subject;
  6552.     }
  6553. }