AccordiServizioParteSpecificaPorteApplicativeAdd.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.aps;

  21. import java.util.ArrayList;
  22. import java.util.Arrays;
  23. import java.util.List;
  24. import java.util.Map;
  25. import java.util.Properties;

  26. import javax.net.ssl.KeyManagerFactory;
  27. import javax.net.ssl.TrustManagerFactory;
  28. import javax.servlet.http.HttpServletRequest;
  29. import javax.servlet.http.HttpServletResponse;
  30. import javax.servlet.http.HttpSession;

  31. import org.apache.commons.lang.StringUtils;
  32. import org.apache.struts.action.Action;
  33. import org.apache.struts.action.ActionForm;
  34. import org.apache.struts.action.ActionForward;
  35. import org.apache.struts.action.ActionMapping;
  36. import org.openspcoop2.core.commons.Liste;
  37. import org.openspcoop2.core.config.GenericProperties;
  38. import org.openspcoop2.core.config.Property;
  39. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  40. import org.openspcoop2.core.config.constants.PortaApplicativaAzioneIdentificazione;
  41. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  42. import org.openspcoop2.core.config.constants.TipoAutenticazione;
  43. import org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal;
  44. import org.openspcoop2.core.config.constants.TipoAutorizzazione;
  45. import org.openspcoop2.core.config.driver.db.IDServizioApplicativoDB;
  46. import org.openspcoop2.core.constants.CostantiConnettori;
  47. import org.openspcoop2.core.constants.TipiConnettore;
  48. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  49. import org.openspcoop2.core.id.IDAccordo;
  50. import org.openspcoop2.core.id.IDServizio;
  51. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  52. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  53. import org.openspcoop2.core.registry.Connettore;
  54. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  55. import org.openspcoop2.core.registry.constants.CredenzialeTipo;
  56. import org.openspcoop2.core.registry.constants.PddTipologia;
  57. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  58. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  59. import org.openspcoop2.core.registry.driver.db.IDSoggettoDB;
  60. import org.openspcoop2.message.constants.ServiceBinding;
  61. import org.openspcoop2.utils.BooleanNullable;
  62. import org.openspcoop2.web.ctrlstat.core.AutorizzazioneUtilities;
  63. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  64. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  65. import org.openspcoop2.web.ctrlstat.costanti.ConnettoreServletType;
  66. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  67. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationException;
  68. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettore;
  69. import org.openspcoop2.web.ctrlstat.plugins.servlet.ServletExtendedConnettoreUtils;
  70. import org.openspcoop2.web.ctrlstat.servlet.ApiKeyState;
  71. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  72. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  73. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  74. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti;
  75. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoreStatusParams;
  76. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  77. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriHelper;
  78. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCore;
  79. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCostanti;
  80. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeHelper;
  81. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCore;
  82. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCostanti;
  83. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiHelper;
  84. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  85. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  86. import org.openspcoop2.web.lib.mvc.Costanti;
  87. import org.openspcoop2.web.lib.mvc.DataElement;
  88. import org.openspcoop2.web.lib.mvc.ForwardParams;
  89. import org.openspcoop2.web.lib.mvc.GeneralData;
  90. import org.openspcoop2.web.lib.mvc.PageData;
  91. import org.openspcoop2.web.lib.mvc.Parameter;
  92. import org.openspcoop2.web.lib.mvc.ServletUtils;
  93. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  94. /**
  95.  * AccordiServizioParteSpecificaPorteApplicativeAdd
  96.  *
  97.  * @author Andrea Poli (apoli@link.it)
  98.  * @author Giuliano Pintori (pintori@link.it)
  99.  * @author $Author$
  100.  * @version $Rev$, $Date$
  101.  *
  102.  */
  103. public final class AccordiServizioParteSpecificaPorteApplicativeAdd extends Action {

  104.     @Override
  105.     public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

  106.         HttpSession session = request.getSession(true);

  107.         // Inizializzo PageData
  108.         PageData pd = new PageData();

  109.         GeneralHelper generalHelper = new GeneralHelper(session);
  110.        
  111.         String userLogin = ServletUtils.getUserLoginFromSession(session);  

  112.         // Inizializzo GeneralData
  113.         GeneralData gd = generalHelper.initGeneralData(request);

  114.         try {
  115.             AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  116.            
  117.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte delegate
  118.             Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, session, request);
  119.             if(parentPA == null) parentPA = PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE;
  120.            
  121.             String idAsps = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID);
  122.             String idSoggettoErogatoreDelServizio = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  123.             if ((idSoggettoErogatoreDelServizio == null) || idSoggettoErogatoreDelServizio.equals("")) {
  124.                 PageData oldPD = ServletUtils.getPageDataFromSession(request, session);

  125.                 idSoggettoErogatoreDelServizio = oldPD.getHidden(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);
  126.             }
  127.             String[] azioni = apsHelper.getParameterValues(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_AZIONI);
  128.            
  129.             String nome = apsHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME);
  130.             String nomeGruppo = apsHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_NOME_GRUPPO);
  131.            
  132.             String modeCreazione = apsHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MODE_CREAZIONE);
  133.             String modeCreazioneConnettore = apsHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MODE_CREAZIONE_CONNETTORE);
  134.             String identificazione = apsHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_IDENTIFICAZIONE);
  135.             String mappingPA = apsHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MAPPING);

  136.             String controlloAccessiStato = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO);
  137.            
  138.             String erogazioneRuolo = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_RUOLO);
  139.             String erogazioneAutenticazione = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTENTICAZIONE);
  140.             String erogazioneAutenticazioneOpzionale = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTENTICAZIONE_OPZIONALE);
  141.             String erogazioneAutenticazionePrincipalTipo = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TIPO);
  142.             TipoAutenticazionePrincipal erogazioneAutenticazionePrincipal = TipoAutenticazionePrincipal.toEnumConstant(erogazioneAutenticazionePrincipalTipo, false);
  143.             List<String> erogazioneAutenticazioneParametroList = apsHelper.convertFromDataElementValue_parametroAutenticazioneList(erogazioneAutenticazione, erogazioneAutenticazionePrincipal);
  144.             String erogazioneAutorizzazione = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE);
  145.             String erogazioneAutorizzazioneAutenticati = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_AUTENTICAZIONE);
  146.             String erogazioneAutorizzazioneRuoli = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_RUOLI);
  147.             String erogazioneAutorizzazioneRuoliTipologia = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_RUOLO_TIPOLOGIA);
  148.             String erogazioneAutorizzazioneRuoliMatch = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_RUOLO_MATCH);
  149.             String erogazioneSoggettoAutenticato = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_SOGGETTO_AUTENTICATO);

  150.             String erogazioneServizioApplicativoServerEnabledS = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ABILITA_USO_APPLICATIVO_SERVER);
  151.             boolean erogazioneServizioApplicativoServerEnabled = ServletUtils.isCheckBoxEnabled(erogazioneServizioApplicativoServerEnabledS);
  152.             String erogazioneServizioApplicativoServer = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_APPLICATIVO_SERVER);
  153.              
  154.             String nomeSA = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_SA);
  155.            
  156.             String gestioneToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  157.             String gestioneTokenPolicy = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  158.             String gestioneTokenOpzionale = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_OPZIONALE);
  159.             String gestioneTokenValidazioneInput = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  160.             String gestioneTokenIntrospection = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  161.             String gestioneTokenUserInfo = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  162.             String gestioneTokenForward = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  163.            
  164.             String autenticazioneTokenIssuer = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_ISSUER);
  165.             String autenticazioneTokenClientId = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  166.             String autenticazioneTokenSubject = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_SUBJECT);
  167.             String autenticazioneTokenUsername = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_USERNAME);
  168.             String autenticazioneTokenEMail = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_MAIL);
  169.            
  170.             String autorizzazioneAutenticatiToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  171.             String autorizzazioneRuoliToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  172.             String autorizzazioneRuoliTipologiaToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA_TOKEN);
  173.             String autorizzazioneRuoliMatchToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_RUOLO_MATCH_TOKEN);
  174.            
  175.             String autorizzazioneToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  176.             String autorizzazioneTokenOptions = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  177.             String autorizzazioneScope = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  178.             String autorizzazioneScopeMatch = apsHelper.getParameter(CostantiControlStation.PARAMETRO_SCOPE_MATCH);
  179.             String scope = apsHelper.getParameter(CostantiControlStation.PARAMETRO_SCOPE);
  180.            
  181.             BinaryParameter allegatoXacmlPolicy = apsHelper.getBinaryParameter(CostantiControlStation.PARAMETRO_DOCUMENTO_SICUREZZA_XACML_POLICY);
  182.            
  183.             String identificazioneAttributiStato = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  184.             String [] attributeAuthoritySelezionate = apsHelper.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  185.             String attributeAuthorityAttributi = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  186.            
  187.             Properties parametersPOST = null;
  188.            
  189.             String endpointtype = apsHelper.readEndPointType();
  190.             String tipoconn = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO );
  191.             String autenticazioneHttp = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);

  192.             String connettoreDebug = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_DEBUG);

  193.             // token policy
  194.             String autenticazioneTokenS = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  195.             boolean autenticazioneToken = ServletUtils.isCheckBoxEnabled(autenticazioneTokenS);
  196.             String tokenPolicy = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY);
  197.             boolean forcePDND = false;
  198.             boolean forceOAuth = false;
  199.            
  200.             // proxy
  201.             String proxyEnabled = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  202.             String proxyHostname = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  203.             String proxyPort = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PORT);
  204.             String proxyUsername = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_USERNAME);
  205.             String proxyPassword = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PASSWORD);

  206.             // tempi risposta
  207.             String tempiRispostaEnabled = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  208.             String tempiRispostaConnectionTimeout = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  209.             String tempiRispostaReadTimeout = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  210.             String tempiRispostaTempoMedioRisposta = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);
  211.            
  212.             // opzioni avanzate
  213.             String transferMode = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  214.             String transferModeChunkSize = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  215.             String redirectMode = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  216.             String redirectMaxHop = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  217.             String opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(apsHelper, transferMode, redirectMode);

  218.             String user= null;
  219.             String password =null;
  220.            
  221.             // http
  222.             String url = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL  );
  223.             if(TipiConnettore.HTTP.toString().equals(endpointtype)){
  224.                 user = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  225.                 password = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  226.             }

  227.             // api key
  228.             String autenticazioneApiKey = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_API_KEY);
  229.             String apiKeyHeader = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_HEADER);
  230.             if(apiKeyHeader==null || StringUtils.isEmpty(apiKeyHeader)) {
  231.                 apiKeyHeader = CostantiConnettori.DEFAULT_HEADER_API_KEY;
  232.             }
  233.             String apiKeyValue = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_VALUE);
  234.             String appIdHeader = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  235.             if(appIdHeader==null || StringUtils.isEmpty(appIdHeader)) {
  236.                 appIdHeader = CostantiConnettori.DEFAULT_HEADER_APP_ID;
  237.             }
  238.             String appIdValue = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  239.             String useOAS3NamesTmp = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  240.             boolean useOAS3Names=true;
  241.             if(useOAS3NamesTmp!=null && StringUtils.isNotEmpty(useOAS3NamesTmp)) {
  242.                 useOAS3Names = ServletUtils.isCheckBoxEnabled(useOAS3NamesTmp);
  243.             }
  244.             else {
  245.                 useOAS3Names = apsHelper.isAutenticazioneApiKeyUseOAS3Names(apiKeyHeader, appIdHeader);
  246.             }
  247.             String useAppIdTmp = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  248.             boolean useAppId=false;
  249.             if(useAppIdTmp!=null && StringUtils.isNotEmpty(useAppIdTmp)) {
  250.                 useAppId = ServletUtils.isCheckBoxEnabled(useAppIdTmp);
  251.             }
  252.             else {
  253.                 useAppId = apsHelper.isAutenticazioneApiKeyUseAppId(appIdValue);
  254.             }
  255.            
  256.             // jms
  257.             String nomeCodaJms = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_NOME_CODA);
  258.             String tipoJms = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_CODA);
  259.             String initcont = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_INIT_CTX);
  260.             String urlpgk = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_URL_PKG);
  261.             String provurl = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PROVIDER_URL);
  262.             String connfact = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_CONNECTION_FACTORY);
  263.             String tipoSendas = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_OGGETTO_JMS);
  264.             if(TipiConnettore.JMS.toString().equals(endpointtype)){
  265.                 user = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_USERNAME);
  266.                 password = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PASSWORD);
  267.             }

  268.             // https
  269.             String httpsurl = url;
  270.             String httpstipologia = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_SSL_TYPE );
  271.             String httpshostverifyS = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_HOST_VERIFY);
  272.             String httpsTrustVerifyCertS = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS );
  273.             boolean httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  274.             String httpspath = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_LOCATION );
  275.             String httpstipo = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  276.             String httpspwd = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  277.             String httpsalgoritmo = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  278.             String httpsstatoS = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO);
  279.             String httpskeystore = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE);
  280.             String httpspwdprivatekeytrust = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_STORE);
  281.             String httpspathkey = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  282.             String httpstipokey = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_TYPE);
  283.             String httpspwdkey = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  284.             String httpspwdprivatekey = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_KEYSTORE);
  285.             String httpsalgoritmokey = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  286.             String httpsKeyAlias = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_ALIAS_PRIVATE_KEY_KEYSTORE);
  287.             String httpsTrustStoreCRLs = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL);
  288.             String httpsTrustStoreOCSPPolicy = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  289.             String httpsKeyStoreBYOKPolicy = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  290.             if(TipiConnettore.HTTPS.toString().equals(endpointtype)){
  291.                 user = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  292.                 password = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  293.             }
  294.            
  295.             // file
  296.             String requestOutputFileName = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME);
  297.             String requestOutputFileNamePermissions = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_PERMISSIONS);
  298.             String requestOutputFileNameHeaders = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS);
  299.             String requestOutputFileNameHeadersPermissions = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS);
  300.             String requestOutputParentDirCreateIfNotExists = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  301.             String requestOutputOverwriteIfExists = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE_NAME);
  302.             String responseInputMode = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  303.             String responseInputFileName = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME);
  304.             String responseInputFileNameHeaders = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS);
  305.             String responseInputDeleteAfterRead = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_DELETE_AFTER_READ);
  306.             String responseInputWaitTime = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);
  307.            
  308.             // status
  309.             ConnettoreStatusParams connettoreStatusParams = ConnettoreStatusParams.fillFrom(apsHelper);

  310.             boolean httpshostverify = false;
  311.             if (httpshostverifyS != null && httpshostverifyS.equals(Costanti.CHECK_BOX_ENABLED))
  312.                 httpshostverify = true;
  313.             boolean httpsstato = false;
  314.             if (httpsstatoS != null && httpsstatoS.equals(Costanti.CHECK_BOX_ENABLED))
  315.                 httpsstato = true;

  316.             Boolean isConnettoreCustomUltimaImmagineSalvata = null;
  317.            
  318.             boolean forceEnableConnettore = false;
  319.             if( (!apsHelper.isModalitaCompleta())) {
  320.                 forceEnableConnettore = true;
  321.             }

  322.             String tipologia = ServletUtils.getObjectFromSession(request, session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  323.             boolean gestioneErogatori = false;
  324.             if(tipologia!=null &&
  325.                 AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  326.                 gestioneErogatori = true;
  327.             }
  328.            
  329.             PddTipologia pddTipologiaSoggettoAutenticati = null;
  330.             if(gestioneErogatori) {
  331.                 pddTipologiaSoggettoAutenticati = PddTipologia.ESTERNO;
  332.             }
  333.            
  334.             boolean postBackViaPost = true;
  335.            
  336.             Connettore conTmp = null;
  337.             List<ExtendedConnettore> listExtendedConnettore =
  338.                     ServletExtendedConnettoreUtils.getExtendedConnettore(conTmp, ConnettoreServletType.ACCORDO_SERVIZIO_PARTE_SPECIFICA_PORTA_APPLICATIVA_ADD, apsHelper,
  339.                             parametersPOST, (endpointtype==null), endpointtype); // uso endpointtype per capire se è la prima volta che entro


  340.             PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(request, pd, session);

  341.             // Preparo il menu
  342.             apsHelper.makeMenu();

  343.             PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore();
  344.             SoggettiCore soggettiCore = new SoggettiCore(porteApplicativeCore);
  345.             AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(porteApplicativeCore);
  346.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(porteApplicativeCore);
  347.             ServiziApplicativiCore saCore = new ServiziApplicativiCore(porteApplicativeCore);
  348.             ConfigurazioneCore confCore = new ConfigurazioneCore(porteApplicativeCore);
  349.             int idServizio = Integer.parseInt(idAsps);
  350.             AccordoServizioParteSpecifica asps  = apsCore.getAccordoServizioParteSpecifica(idServizio);
  351.             IDServizio idServizio2 = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  352.             int soggInt = idSoggettoErogatoreDelServizio!=null ? Integer.parseInt(idSoggettoErogatoreDelServizio) : -1;
  353.            
  354.             boolean isApplicativiServerEnabled = apsCore.isApplicativiServerEnabled(apsHelper);
  355.             // La lista degli SA viene filtrata per tipo se sono abilitati gli applicativiServer.
  356.             String tipoSA = (isApplicativiServerEnabled && gestioneErogatori) ? ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER : null;
  357.            
  358.             AccordiServizioParteSpecificaPorteApplicativeMappingInfo mappingInfo = AccordiServizioParteSpecificaUtilities.getMappingInfo(mappingPA, asps, apsCore);
  359.             MappingErogazionePortaApplicativa mappingSelezionato = mappingInfo.getMappingSelezionato();
  360.             MappingErogazionePortaApplicativa mappingDefault = mappingInfo.getMappingDefault();
  361.             String mappingLabel = mappingInfo.getMappingLabel();
  362.             String[] listaMappingLabels = mappingInfo.getListaMappingLabels();
  363.             String[] listaMappingValues = mappingInfo.getListaMappingValues();
  364.             List<String> azioniOccupate = mappingInfo.getAzioniOccupate();
  365.             String nomeNuovaConfigurazione = mappingInfo.getNomeNuovaConfigurazione();
  366.             boolean paMappingSelezionatoMulti = mappingInfo.isPaMappingSelezionatoMulti();

  367.             // Prendo nome, tipo e pdd del soggetto
  368.             String tipoSoggettoProprietario = null;
  369.             if(porteApplicativeCore.isRegistroServiziLocale()){
  370.                 org.openspcoop2.core.registry.Soggetto soggetto = soggettiCore.getSoggettoRegistro(soggInt);
  371.                 tipoSoggettoProprietario = soggetto.getTipo();
  372.             }else{
  373.                 org.openspcoop2.core.config.Soggetto soggetto = soggettiCore.getSoggetto(soggInt);
  374.                 tipoSoggettoProprietario = soggetto.getTipo();
  375.             }

  376.             AccordoServizioParteComuneSintetico as = null;
  377.             ServiceBinding serviceBinding = null;
  378.             IDAccordo idAccordo = null;
  379.             if (asps != null) {
  380.                 idAccordo = IDAccordoFactory.getInstance().getIDAccordoFromUri(asps.getAccordoServizioParteComune());
  381.                 as = apcCore.getAccordoServizioSintetico(idAccordo);
  382.                 serviceBinding = apcCore.toMessageServiceBinding(as.getServiceBinding());
  383.             }
  384.            
  385.             // Prendo le azioni  disponibili
  386.             boolean addTrattinoSelezioneNonEffettuata = false;
  387.             int sogliaAzioni = addTrattinoSelezioneNonEffettuata ? 1 : 0;
  388.             Map<String,String> azioniS = porteApplicativeCore.getAzioniConLabel(asps, as, addTrattinoSelezioneNonEffettuata, true, azioniOccupate);
  389.             String[] azioniDisponibiliList = null;
  390.             String[] azioniDisponibiliLabelList = null;
  391.             if(azioniS!=null && azioniS.size()>0) {
  392.                 azioniDisponibiliList = new String[azioniS.size()];
  393.                 azioniDisponibiliLabelList = new String[azioniS.size()];
  394.                 int i = 0;
  395.                 for (String string : azioniS.keySet()) {
  396.                     azioniDisponibiliList[i] = string;
  397.                     azioniDisponibiliLabelList[i] = azioniS.get(string);
  398.                     i++;
  399.                 }
  400.             }
  401.            
  402.             String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(tipoSoggettoProprietario);
  403.             List<String> tipiSoggettiCompatibiliAccordo = soggettiCore.getTipiSoggettiGestitiProtocollo(protocollo);
  404.             boolean erogazioneIsSupportatoAutenticazioneSoggetti = soggettiCore.isSupportatoAutenticazioneSoggetti(protocollo);

  405.             String postBackElementName = apsHelper.getPostBackElementName();

  406.             boolean initConnettore = false;
  407.             // Controllo se ho modificato l'azione allora ricalcolo il nome
  408.             if(postBackElementName != null ){
  409.                 if(postBackElementName.equalsIgnoreCase(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MODE_CREAZIONE_CONNETTORE) &&
  410.                     // devo resettare il connettore
  411.                     ServletUtils.isCheckBoxEnabled(modeCreazioneConnettore)) {
  412.                     initConnettore = true;
  413.                 }
  414.                
  415.                 if(postBackElementName.equalsIgnoreCase(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ABILITA_USO_APPLICATIVO_SERVER)){
  416.                     erogazioneServizioApplicativoServer = null;
  417.                     // devo resettare il connettore se passo da SA Server a Default
  418.                     if(!erogazioneServizioApplicativoServerEnabled) {
  419.                         initConnettore = true;
  420.                     }
  421.                 }
  422.             }

  423.             // Lista dei servizi applicativi per la creazione automatica
  424.             List<IDServizioApplicativoDB> listaIdSA = null;
  425.             if ((idSoggettoErogatoreDelServizio != null) && !idSoggettoErogatoreDelServizio.equals("")) {
  426.                 long idErogatore = Long.parseLong(idSoggettoErogatoreDelServizio);
  427.                
  428.                 // I servizi applicativi da visualizzare sono quelli che hanno
  429.                 // -Integration Manager (getMessage abilitato)
  430.                 // -connettore != disabilitato
  431.                 listaIdSA = saCore.getIdServiziApplicativiWithIdErogatore(idErogatore, tipoSA, true, true);

  432.             }
  433.             String [] saSoggetti = ServiziApplicativiHelper.toArray(listaIdSA);
  434.        
  435.            
  436.             List<String> soggettiAutenticati = new ArrayList<>();
  437.             List<String> soggettiAutenticatiLabel = new ArrayList<>();
  438.             // lista soggetti autenticati per la creazione automatica
  439.             CredenzialeTipo credenziale =  null;
  440.             Boolean appIdSoggetti = null;
  441.             if((erogazioneAutenticazione !=null && !"".equals(erogazioneAutenticazione)) && erogazioneIsSupportatoAutenticazioneSoggetti) {
  442.                 TipoAutenticazione tipoAutenticazione = TipoAutenticazione.toEnumConstant(erogazioneAutenticazione);
  443.                 credenziale = !tipoAutenticazione.equals(TipoAutenticazione.DISABILITATO) ? CredenzialeTipo.toEnumConstant(erogazioneAutenticazione) : null;
  444.                 if(CredenzialeTipo.APIKEY.equals(credenziale)) {
  445.                     ApiKeyState apiKeyState =  new ApiKeyState(null);
  446.                     appIdSoggetti = apiKeyState.appIdSelected;
  447.                 }
  448.             }
  449.            
  450.             List<IDSoggettoDB> listSoggettiCompatibili = null;
  451.              
  452.             if(apsCore.isVisioneOggettiGlobale(userLogin)){
  453.                 listSoggettiCompatibili = soggettiCore.getSoggettiFromTipoAutenticazione(tipiSoggettiCompatibiliAccordo, null, credenziale, appIdSoggetti, pddTipologiaSoggettoAutenticati );
  454.             }else{
  455.                 listSoggettiCompatibili = soggettiCore.getSoggettiFromTipoAutenticazione(tipiSoggettiCompatibiliAccordo, userLogin, credenziale, appIdSoggetti, pddTipologiaSoggettoAutenticati);
  456.             }
  457.            
  458.             if(listSoggettiCompatibili != null && !listSoggettiCompatibili.isEmpty() ) {
  459.                
  460.                 soggettiAutenticati.add("-"); // elemento nullo di default
  461.                 soggettiAutenticatiLabel.add("-");
  462.                 for (IDSoggettoDB soggetto : listSoggettiCompatibili) {
  463.                     soggettiAutenticati.add(soggetto.getTipo() + "/"+ soggetto.getNome());
  464.                     soggettiAutenticatiLabel.add(apsHelper.getLabelNomeSoggetto(protocollo, soggetto.getTipo(), soggetto.getNome()));
  465.                    
  466.                 }
  467.             }

  468.             List<Parameter> lstParm = porteApplicativeHelper.getTitoloPA(parentPA, idSoggettoErogatoreDelServizio, idAsps);
  469.            
  470.             // Token Policy
  471.             List<GenericProperties> gestorePolicyTokenList = confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN, null);
  472.             String [] policyLabels = new String[gestorePolicyTokenList.size() + 1];
  473.             String [] policyValues = new String[gestorePolicyTokenList.size() + 1];
  474.            
  475.             policyLabels[0] = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  476.             policyValues[0] = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  477.            
  478.             for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  479.             GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  480.                 policyLabels[(i+1)] = genericProperties.getNome();
  481.                 policyValues[(i+1)] = genericProperties.getNome();
  482.             }
  483.            
  484.             // AttributeAuthority
  485.             List<GenericProperties> attributeAuthorityList = confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_ATTRIBUTE_AUTHORITY, null);
  486.             String [] attributeAuthorityLabels = new String[attributeAuthorityList.size()];
  487.             String [] attributeAuthorityValues = new String[attributeAuthorityList.size()];
  488.             for (int i = 0; i < attributeAuthorityList.size(); i++) {
  489.                 GenericProperties genericProperties = attributeAuthorityList.get(i);
  490.                 attributeAuthorityLabels[i] = genericProperties.getNome();
  491.                 attributeAuthorityValues[i] = genericProperties.getNome();
  492.             }

  493.             lstParm.add(ServletUtils.getParameterAggiungi());

  494.             // Se idhid = null, devo visualizzare la pagina per l'inserimento
  495.             // dati
  496.             if (apsHelper.isEditModeInProgress()) {
  497.                 // setto la barra del titolo
  498.                 ServletUtils.setPageDataTitle(pd,lstParm);

  499.                 // preparo i campi
  500.                 List<DataElement> dati = new ArrayList<>();
  501.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  502.                 if(azioniDisponibiliList==null || azioniDisponibiliList.length<= sogliaAzioni) {
  503.                     // si controlla 1 poiche' c'e' il trattino nelle azioni disponibili
  504.                    
  505.                     pd.setMessage(porteApplicativeHelper.getLabelAllAzioniConfigurate(serviceBinding), Costanti.MESSAGE_TYPE_INFO);

  506.                     pd.disableEditMode();
  507.                    
  508.                 }
  509.                 else {
  510.                
  511.                     if(azioni == null) {
  512.                         azioni = new String[0];
  513.                     }
  514.    
  515.                     if(nome == null) {
  516.                         // nome mapping calcolato in base al numero id configurazioni non di default presenti
  517.                         nome = nomeNuovaConfigurazione;
  518.    
  519.                         if(identificazione == null)
  520.                             identificazione = PortaApplicativaAzioneIdentificazione.DELEGATED_BY.toString();
  521.                     }
  522.                    
  523.                     if(modeCreazione == null)
  524.                         modeCreazione = PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_EREDITA;
  525.                    
  526.                     if(modeCreazioneConnettore == null) {
  527.                         modeCreazioneConnettore = Costanti.CHECK_BOX_DISABLED;
  528.                     }
  529.    
  530.                     if(mappingPA==null) {
  531.                         mappingPA = listaMappingValues[listaMappingValues.length-1]; // sono ordinati all'incontrario
  532.                     }
  533.                    
  534.                     if(erogazioneRuolo==null || "".equals(erogazioneRuolo))
  535.                         erogazioneRuolo = "-";
  536.                     if(erogazioneAutenticazione==null || "".equals(erogazioneAutenticazione)) {
  537.                         erogazioneAutenticazione = apsCore.getAutenticazione_generazioneAutomaticaPorteApplicative();
  538.                        
  539.                         soggettiAutenticati = new ArrayList<>();
  540.                         soggettiAutenticatiLabel = new ArrayList<>();
  541.                         if(erogazioneIsSupportatoAutenticazioneSoggetti) {
  542.                             TipoAutenticazione tipoAutenticazione = TipoAutenticazione.toEnumConstant(erogazioneAutenticazione);
  543.                             credenziale = !tipoAutenticazione.equals(TipoAutenticazione.DISABILITATO) ? CredenzialeTipo.toEnumConstant(erogazioneAutenticazione) : null;
  544.                         }
  545.                          
  546.                         if(apsCore.isVisioneOggettiGlobale(userLogin)){
  547.                             listSoggettiCompatibili = soggettiCore.getSoggettiFromTipoAutenticazione(tipiSoggettiCompatibiliAccordo, null, credenziale, appIdSoggetti, pddTipologiaSoggettoAutenticati );
  548.                         }else{
  549.                             listSoggettiCompatibili = soggettiCore.getSoggettiFromTipoAutenticazione(tipiSoggettiCompatibiliAccordo, userLogin, credenziale, appIdSoggetti, pddTipologiaSoggettoAutenticati);
  550.                         }
  551.                        
  552.                         if(listSoggettiCompatibili != null && !listSoggettiCompatibili.isEmpty() ) {
  553.                             soggettiAutenticati.add("-"); // elemento nullo di default
  554.                             soggettiAutenticatiLabel.add("-");
  555.                             for (IDSoggettoDB soggetto : listSoggettiCompatibili) {
  556.                                 soggettiAutenticati.add(soggetto.getTipo() + "/"+ soggetto.getNome());
  557.                                 soggettiAutenticatiLabel.add(apsHelper.getLabelNomeSoggetto(protocollo, soggetto.getTipo(), soggetto.getNome()));
  558.                             }
  559.                         }
  560.                     }
  561.                     if(erogazioneAutorizzazione==null || "".equals(erogazioneAutorizzazione)){
  562.                         String tipoAutorizzazione = apsCore.getAutorizzazione_generazioneAutomaticaPorteApplicative();
  563.                         erogazioneAutorizzazione = AutorizzazioneUtilities.convertToStato(tipoAutorizzazione);
  564.                         if(TipoAutorizzazione.isAuthenticationRequired(tipoAutorizzazione))
  565.                             erogazioneAutorizzazioneAutenticati = Costanti.CHECK_BOX_ENABLED;
  566.                         if(TipoAutorizzazione.isRolesRequired(tipoAutorizzazione))
  567.                             erogazioneAutorizzazioneRuoli = Costanti.CHECK_BOX_ENABLED;
  568.                         erogazioneAutorizzazioneRuoliTipologia = AutorizzazioneUtilities.convertToRuoloTipologia(tipoAutorizzazione).getValue();
  569.                     }
  570.                     if(gestioneToken == null) {
  571.                         gestioneToken = StatoFunzionalita.DISABILITATO.getValue();
  572.                         gestioneTokenPolicy = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  573.                         gestioneTokenOpzionale = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_OPZIONALE;
  574.                         gestioneTokenValidazioneInput = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_VALIDAZIONE_INPUT;
  575.                         gestioneTokenIntrospection = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_INTROSPECTION;
  576.                         gestioneTokenUserInfo = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_USER_INFO;
  577.                         gestioneTokenForward = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TOKEN_FORWARD;
  578.                         autenticazioneTokenIssuer = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_ISSUER;
  579.                         autenticazioneTokenClientId = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_CLIENT_ID;
  580.                         autenticazioneTokenSubject = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_SUBJECT;
  581.                         autenticazioneTokenUsername = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_USERNAME;
  582.                         autenticazioneTokenEMail = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_EMAIL;
  583.                     }
  584.                     if(scope ==null || "".equals(scope))
  585.                         scope = "-";
  586.                     if(autorizzazioneScope ==null)
  587.                         autorizzazioneScope = "";
  588.                     if(identificazioneAttributiStato==null) {
  589.                         identificazioneAttributiStato = StatoFunzionalita.DISABILITATO.getValue();
  590.                     }
  591.                     // solo in modalita' nuova
  592.                     if(initConnettore) {
  593.                         tipoconn = "";
  594.                         url = "";
  595.                         nomeCodaJms = "";
  596.                         user = "";
  597.                         password = "";
  598.                         initcont = "";
  599.                         urlpgk = "";
  600.                         provurl = "";
  601.                         connfact = "";
  602.                         httpsurl = "";
  603.                         httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE;
  604.                         httpshostverifyS = Costanti.CHECK_BOX_ENABLED_TRUE;
  605.                         httpshostverify = true;
  606.                         httpsTrustVerifyCert = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS;
  607.                         httpspath = "";
  608.                         httpstipo = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TIPOLOGIA_KEYSTORE_TYPE;
  609.                         httpspwd = "";
  610.                         httpsstato = false;
  611.                         httpskeystore = AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_DEFAULT;
  612.                         httpspwdprivatekeytrust = "";
  613.                         httpspathkey = "";
  614.                         httpstipokey =ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TIPOLOGIA_KEYSTORE_TYPE;
  615.                         httpspwdkey = "";
  616.                         httpspwdprivatekey = "";
  617.                        
  618.                         if(endpointtype==null) {
  619.                             if(!apsHelper.isModalitaCompleta()) {
  620.                                 endpointtype = TipiConnettore.HTTP.getNome();
  621.                             }
  622.                             else {
  623.                                 endpointtype = AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_DISABILITATO;
  624.                             }
  625.                         }
  626.                                                
  627.                         tipoSendas = ConnettoriCostanti.TIPO_SEND_AS[0];
  628.                         tipoJms = ConnettoriCostanti.TIPI_CODE_JMS[0];

  629.                         autenticazioneHttp = apsHelper.getAutenticazioneHttp(autenticazioneHttp, endpointtype, user);
  630.                        
  631.                         apiKeyHeader = null;
  632.                         apiKeyValue = null;
  633.                         appIdHeader = null;
  634.                         appIdValue = null;
  635.                        
  636.                         tempiRispostaEnabled=null;
  637.                         ConfigurazioneCore configCore = new ConfigurazioneCore(soggettiCore);
  638.                         ConfigurazioneGenerale configGenerale = configCore.getConfigurazioneControlloTraffico();
  639.                         tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaErogazione().getConnectionTimeout().intValue()+"";
  640.                         tempiRispostaReadTimeout = configGenerale.getTempiRispostaErogazione().getReadTimeout().intValue()+"";
  641.                         tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaErogazione().getTempoMedioRisposta().intValue()+"";
  642.                            
  643.                     }
  644.                    
  645.                     // default (da inizializzare cmq)
  646.                     if (TipiConnettore.HTTPS.toString().equals(endpointtype)) {
  647.                         if(httpsalgoritmo==null || "".equals(httpsalgoritmo)){
  648.                             httpsalgoritmo = TrustManagerFactory.getDefaultAlgorithm();
  649.                         }
  650.                         if(httpsalgoritmokey==null || "".equals(httpsalgoritmokey)){
  651.                             httpsalgoritmokey = KeyManagerFactory.getDefaultAlgorithm();
  652.                         }
  653.                         if(httpstipologia==null || "".equals(httpstipologia)){
  654.                             httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE;
  655.                         }
  656.                         if(httpshostverifyS==null || "".equals(httpshostverifyS)){
  657.                             httpshostverifyS = Costanti.CHECK_BOX_ENABLED_TRUE;
  658.                             httpshostverify = ServletUtils.isCheckBoxEnabled(httpshostverifyS);
  659.                         }
  660.                         if(httpsTrustVerifyCertS==null || "".equals(httpsTrustVerifyCertS)){
  661.                             httpsTrustVerifyCertS = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS ? Costanti.CHECK_BOX_ENABLED_TRUE : Costanti.CHECK_BOX_DISABLED;
  662.                             httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  663.                         }
  664.                     }
  665.                    
  666.                     // Devo cmq rileggere i valori se non definiti
  667.                     if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout)
  668.                             ||
  669.                             tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout)
  670.                             ||
  671.                             tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ){
  672.                         ConfigurazioneCore configCore = new ConfigurazioneCore(soggettiCore);
  673.                         ConfigurazioneGenerale configGenerale = configCore.getConfigurazioneControlloTraffico();
  674.                         if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout) ) {
  675.                             tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaErogazione().getConnectionTimeout().intValue()+"";
  676.                         }
  677.                         if(tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout) ) {
  678.                             tempiRispostaReadTimeout = configGenerale.getTempiRispostaErogazione().getReadTimeout().intValue()+"";
  679.                         }
  680.                         if(tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ) {
  681.                             tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaErogazione().getTempoMedioRisposta().intValue()+"";
  682.                         }
  683.                     }
  684.                    
  685.    
  686.                     dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.ADD, idAsps, null, null, dati);
  687.                     dati = apsHelper.addConfigurazioneErogazioneToDati(TipoOperazione.ADD, dati, nome, nomeGruppo, azioni, azioniDisponibiliList, azioniDisponibiliLabelList, idAsps, idSoggettoErogatoreDelServizio,
  688.                             identificazione, asps, as, serviceBinding, modeCreazione, modeCreazioneConnettore, listaMappingLabels, listaMappingValues,
  689.                             mappingPA, mappingLabel, paMappingSelezionatoMulti, nomeSA, saSoggetti,
  690.                             controlloAccessiStato,
  691.                             erogazioneAutenticazione, erogazioneAutenticazioneOpzionale, erogazioneAutenticazionePrincipal, erogazioneAutenticazioneParametroList,
  692.                             erogazioneIsSupportatoAutenticazioneSoggetti, erogazioneAutorizzazione, erogazioneAutorizzazioneAutenticati,
  693.                             erogazioneAutorizzazioneRuoli, erogazioneRuolo, erogazioneAutorizzazioneRuoliTipologia, erogazioneAutorizzazioneRuoliMatch,soggettiAutenticati,soggettiAutenticatiLabel,erogazioneSoggettoAutenticato,
  694.                             gestioneToken, policyLabels, policyValues,
  695.                             gestioneTokenPolicy, gestioneTokenOpzionale,
  696.                             gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward,
  697.                             autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  698.                             autorizzazioneToken,autorizzazioneTokenOptions,
  699.                             autorizzazioneScope,scope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  700.                             identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  701.                             autorizzazioneAutenticatiToken,
  702.                             autorizzazioneRuoliToken, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  703.                    
  704. //                  apsHelper.isModalitaCompleta()?null:(generaPACheckSoggetto?AccordiServizioParteSpecificaCostanti.LABEL_APS_APPLICATIVO_INTERNO_PREFIX : AccordiServizioParteSpecificaCostanti.LABEL_APS_APPLICATIVO_ESTERNO_PREFIX)
  705.                    
  706.                     if(ServletUtils.isCheckBoxEnabled(modeCreazioneConnettore)) {
  707.                         dati = apsHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp,
  708.                                 null, //(apsHelper.isModalitaCompleta() || !multitenant)?null:AccordiServizioParteSpecificaCostanti.LABEL_APS_APPLICATIVO_INTERNO_PREFIX ,
  709.                                 url, nomeCodaJms,
  710.                                 tipoJms, user,
  711.                                 password, initcont, urlpgk,
  712.                                 provurl, connfact, tipoSendas,
  713.                                 AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,TipoOperazione.ADD,
  714.                                 httpsurl, httpstipologia, httpshostverify,
  715.                                 httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  716.                                 httpsalgoritmo, httpsstato, httpskeystore,
  717.                                 httpspwdprivatekeytrust, httpspathkey,
  718.                                 httpstipokey, httpspwdkey,
  719.                                 httpspwdprivatekey, httpsalgoritmokey,
  720.                                 httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  721.                                 tipoconn, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_PORTE_APPLICATIVE_ADD, null, null,
  722.                                 null, null, null, null, null, null, true,
  723.                                 isConnettoreCustomUltimaImmagineSalvata,
  724.                                 proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  725.                                 tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  726.                                 opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  727.                                 requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  728.                                 requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  729.                                 responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  730.                                 autenticazioneToken, tokenPolicy, forcePDND, forceOAuth,
  731.                                 listExtendedConnettore, forceEnableConnettore,
  732.                                 protocollo,false,false, isApplicativiServerEnabled, erogazioneServizioApplicativoServerEnabled,
  733.                                 erogazioneServizioApplicativoServer, saSoggetti,
  734.                                 autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  735.                                 connettoreStatusParams,
  736.                                 postBackViaPost);
  737.                     }
  738.                 }
  739.                    
  740.                 pd.setDati(dati);

  741.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  742.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,
  743.                         ForwardParams.ADD());

  744.             }

  745.             // Controlli sui campi immessi
  746.             boolean isOk = apsHelper.configurazioneErogazioneCheckData(TipoOperazione.ADD, nome, nomeGruppo, azioni, asps, azioniOccupate,modeCreazione,null,erogazioneIsSupportatoAutenticazioneSoggetti, mappingInfo);
  747.             // controllo endpoint
  748.             if(isOk && ServletUtils.isCheckBoxEnabled(modeCreazioneConnettore)) {
  749.                 isOk = apsHelper.endPointCheckData(serviceBinding, protocollo, true,
  750.                         endpointtype, url, nome, tipoJms,
  751.                         user, password, initcont, urlpgk, provurl, connfact,
  752.                         tipoSendas, httpsurl, httpstipologia, httpshostverify,
  753.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd, httpsalgoritmo, httpsstato,
  754.                         httpskeystore, httpspwdprivatekeytrust, httpspathkey,
  755.                         httpstipokey, httpspwdkey,
  756.                         httpspwdprivatekey, httpsalgoritmokey,
  757.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  758.                         tipoconn,autenticazioneHttp,
  759.                         proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  760.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  761.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  762.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  763.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  764.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  765.                         autenticazioneToken, tokenPolicy,
  766.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  767.                         listExtendedConnettore,erogazioneServizioApplicativoServerEnabled,
  768.                         erogazioneServizioApplicativoServer);
  769.             }
  770.            
  771.            
  772.             if (!isOk) {
  773.                 // setto la barra del titolo
  774.                 ServletUtils.setPageDataTitle(pd,lstParm);

  775.                 // preparo i campi
  776.                 List<DataElement> dati = new ArrayList<>();

  777.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  778.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.ADD, idAsps, null, null, dati);

  779.                 dati = apsHelper.addConfigurazioneErogazioneToDati(TipoOperazione.ADD, dati, nome, nomeGruppo, azioni, azioniDisponibiliList, azioniDisponibiliLabelList, idAsps, idSoggettoErogatoreDelServizio,
  780.                         identificazione, asps, as, serviceBinding, modeCreazione, modeCreazioneConnettore, listaMappingLabels, listaMappingValues,
  781.                         mappingPA, mappingLabel, paMappingSelezionatoMulti, nomeSA, saSoggetti,
  782.                         controlloAccessiStato,
  783.                         erogazioneAutenticazione, erogazioneAutenticazioneOpzionale, erogazioneAutenticazionePrincipal, erogazioneAutenticazioneParametroList,
  784.                         erogazioneIsSupportatoAutenticazioneSoggetti, erogazioneAutorizzazione, erogazioneAutorizzazioneAutenticati,
  785.                         erogazioneAutorizzazioneRuoli, erogazioneRuolo, erogazioneAutorizzazioneRuoliTipologia, erogazioneAutorizzazioneRuoliMatch,soggettiAutenticati,soggettiAutenticatiLabel,erogazioneSoggettoAutenticato,
  786.                         gestioneToken, policyLabels, policyValues,
  787.                         gestioneTokenPolicy, gestioneTokenOpzionale,
  788.                         gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward,
  789.                         autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  790.                         autorizzazioneToken,autorizzazioneTokenOptions,
  791.                         autorizzazioneScope,scope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  792.                         identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  793.                         autorizzazioneAutenticatiToken,
  794.                         autorizzazioneRuoliToken, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  795.                
  796.                 if(ServletUtils.isCheckBoxEnabled(modeCreazioneConnettore)) {
  797.                     dati = apsHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp,
  798.                             null, //(apsHelper.isModalitaCompleta() || !multitenant)?null:AccordiServizioParteSpecificaCostanti.LABEL_APS_APPLICATIVO_INTERNO_PREFIX ,
  799.                             url, nomeCodaJms,
  800.                             tipoJms, user,
  801.                             password, initcont, urlpgk,
  802.                             provurl, connfact, tipoSendas,
  803.                             AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,TipoOperazione.ADD,
  804.                             httpsurl, httpstipologia, httpshostverify,
  805.                             httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  806.                             httpsalgoritmo, httpsstato, httpskeystore,
  807.                             httpspwdprivatekeytrust, httpspathkey,
  808.                             httpstipokey, httpspwdkey,
  809.                             httpspwdprivatekey, httpsalgoritmokey,
  810.                             httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  811.                             tipoconn, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_PORTE_APPLICATIVE_ADD, null, null,
  812.                             null, null, null, null, null, null, true,
  813.                             isConnettoreCustomUltimaImmagineSalvata,
  814.                             proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  815.                             tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  816.                             opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  817.                             requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  818.                             requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  819.                             responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  820.                             autenticazioneToken, tokenPolicy, forcePDND, forceOAuth,
  821.                             listExtendedConnettore, forceEnableConnettore,
  822.                             protocollo,false,false, isApplicativiServerEnabled, erogazioneServizioApplicativoServerEnabled,
  823.                             erogazioneServizioApplicativoServer, saSoggetti,
  824.                             autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  825.                             connettoreStatusParams,
  826.                             postBackViaPost);
  827.                 }

  828.                 pd.setDati(dati);

  829.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  830.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,
  831.                         ForwardParams.ADD());
  832.             }

  833.             if(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MODO_CREAZIONE_NUOVA.equals(modeCreazione)
  834.                     && CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO_PUBBLICO.equals(controlloAccessiStato)) {
  835.                
  836.                 erogazioneAutenticazione = TipoAutenticazione.DISABILITATO.getValue();
  837.                 erogazioneAutenticazioneOpzionale = null;
  838.                 erogazioneAutenticazionePrincipal = null;
  839.                 erogazioneAutenticazioneParametroList = null;
  840.                
  841.                 erogazioneAutorizzazione = TipoAutorizzazione.DISABILITATO.getValue();
  842.                 erogazioneAutorizzazioneAutenticati = null;
  843.                 erogazioneAutorizzazioneRuoli = null;
  844.                 erogazioneAutorizzazioneRuoliTipologia = null;
  845.                 erogazioneAutorizzazioneRuoliMatch = null;
  846.                
  847.             }
  848.                        
  849.             if (apsHelper.isProfiloModIPA(protocollo) && asps != null) {
  850.                 BooleanNullable forceHttpsClientWrapper = BooleanNullable.NULL();
  851.                 BooleanNullable forcePDNDWrapper = BooleanNullable.NULL();
  852.                 BooleanNullable forceOAuthWrapper = BooleanNullable.NULL();
  853.                
  854.                 List<String> azioniList = null;
  855.                 if(azioni!=null && azioni.length>0) {
  856.                     azioniList = Arrays.asList(azioni);
  857.                 }
  858.                 apsHelper.readModIConfiguration(forceHttpsClientWrapper, forcePDNDWrapper, forceOAuthWrapper,
  859.                         idAccordo,asps.getPortType(),
  860.                         azioniList);
  861.                
  862.                 boolean forceDisableOptional = false;
  863.                 if(forceHttpsClientWrapper.getValue()!=null) {
  864.                     forceDisableOptional = forceHttpsClientWrapper.getValue().booleanValue();
  865.                 }
  866.                 if(forcePDNDWrapper.getValue()!=null) {
  867.                     forcePDND = forcePDNDWrapper.getValue().booleanValue();
  868.                 }
  869.                 if(forceOAuthWrapper.getValue()!=null) {
  870.                     forceOAuth = forceOAuthWrapper.getValue().booleanValue();
  871.                 }
  872.                
  873.                 erogazioneAutenticazioneOpzionale = forceDisableOptional ? Costanti.CHECK_BOX_DISABLED : Costanti.CHECK_BOX_ENABLED;
  874.                 if(!forceDisableOptional) {
  875.                     erogazioneAutorizzazione = AutorizzazioneUtilities.STATO_DISABILITATO;
  876.                 }
  877.                
  878.                 if(forcePDND || forceOAuth) {
  879.                    
  880.                     gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  881.                    
  882.                     if(forcePDND) {
  883.                         List<String> tokenPolicies = apsHelper.getTokenPolicyGestione(true, false,
  884.                                 false, // alla posizione 0 NON viene aggiunto -
  885.                                 gestioneTokenPolicy, TipoOperazione.ADD);
  886.                         if(tokenPolicies!=null && !tokenPolicies.isEmpty() &&
  887.                             (gestioneTokenPolicy==null || StringUtils.isEmpty(gestioneTokenPolicy))
  888.                             ){
  889.                             gestioneTokenPolicy = tokenPolicies.get(0);  // dovrebbe già essere stata selezionata prima
  890.                         }
  891.                     }
  892.                     else {
  893.                         List<String> tokenPolicies = apsHelper.getTokenPolicyGestione(false, true,
  894.                                 false, // alla posizione 0 NON viene aggiunto -
  895.                                 gestioneTokenPolicy, TipoOperazione.ADD);
  896.                         if(tokenPolicies!=null && !tokenPolicies.isEmpty() &&
  897.                             (gestioneTokenPolicy==null || StringUtils.isEmpty(gestioneTokenPolicy))
  898.                         ){
  899.                             gestioneTokenPolicy = tokenPolicies.get(0);  // dovrebbe già essere stata selezionata prima
  900.                         }
  901.                     }
  902.                    
  903.                     gestioneTokenOpzionale = StatoFunzionalita.DISABILITATO.getValue();
  904.                    
  905.                     if(gestioneTokenPolicy!=null && StringUtils.isNotEmpty(gestioneTokenPolicy) &&
  906.                             !CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(gestioneTokenPolicy)) {
  907.                         GenericProperties gp = confCore.getGenericProperties(gestioneTokenPolicy, CostantiConfigurazione.GENERIC_PROPERTIES_TOKEN_TIPOLOGIA_VALIDATION, false);
  908.                         if(gp!=null && gp.sizePropertyList()>0) {
  909.                             for (Property p : gp.getPropertyList()) {
  910.                                 if(org.openspcoop2.pdd.core.token.Costanti.POLICY_VALIDAZIONE_STATO.equals(p.getNome())) {
  911.                                     if("true".equalsIgnoreCase(p.getValore())) {
  912.                                         gestioneTokenValidazioneInput = StatoFunzionalita.ABILITATO.getValue();
  913.                                     }
  914.                                     else {
  915.                                         gestioneTokenValidazioneInput = StatoFunzionalita.DISABILITATO.getValue();
  916.                                     }
  917.                                 }
  918.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_INTROSPECTION_STATO.equals(p.getNome())) {
  919.                                     if("true".equalsIgnoreCase(p.getValore())) {
  920.                                         gestioneTokenIntrospection = StatoFunzionalita.ABILITATO.getValue();
  921.                                     }
  922.                                     else {
  923.                                         gestioneTokenIntrospection = StatoFunzionalita.DISABILITATO.getValue();
  924.                                     }
  925.                                 }
  926.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_USER_INFO_STATO.equals(p.getNome())) {
  927.                                     if("true".equalsIgnoreCase(p.getValore())) {
  928.                                         gestioneTokenUserInfo = StatoFunzionalita.ABILITATO.getValue();
  929.                                     }
  930.                                     else {
  931.                                         gestioneTokenUserInfo = StatoFunzionalita.DISABILITATO.getValue();
  932.                                     }
  933.                                 }
  934.                                 else if(org.openspcoop2.pdd.core.token.Costanti.POLICY_TOKEN_FORWARD_STATO.equals(p.getNome())) {
  935.                                     if("true".equalsIgnoreCase(p.getValore())) {
  936.                                         gestioneTokenForward = StatoFunzionalita.ABILITATO.getValue();
  937.                                     }
  938.                                     else {
  939.                                         gestioneTokenForward = StatoFunzionalita.DISABILITATO.getValue();
  940.                                     }
  941.                                 }
  942.                             }
  943.                         }
  944.                     }
  945.                 }
  946.             }
  947.            
  948.             AccordiServizioParteSpecificaUtilities.addAccordoServizioParteSpecificaPorteApplicative(mappingDefault,
  949.                     mappingSelezionato,
  950.                     nome, nomeGruppo, azioni, modeCreazione, modeCreazioneConnettore,
  951.                     endpointtype, tipoconn, autenticazioneHttp,
  952.                     connettoreDebug,
  953.                     url,
  954.                     nomeCodaJms, tipoJms,
  955.                     initcont, urlpgk, provurl, connfact, tipoSendas,
  956.                     user, password,
  957.                     httpsurl, httpstipologia, httpshostverify,
  958.                     httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  959.                     httpsalgoritmo, httpsstato, httpskeystore,
  960.                     httpspwdprivatekeytrust, httpspathkey,
  961.                     httpstipokey, httpspwdkey,
  962.                     httpspwdprivatekey, httpsalgoritmokey,
  963.                     httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  964.                     proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  965.                     tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  966.                     opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  967.                     requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  968.                     requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  969.                     responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  970.                     autenticazioneToken, tokenPolicy,
  971.                     listExtendedConnettore,
  972.                     erogazioneAutenticazione, erogazioneAutenticazioneOpzionale, erogazioneAutenticazionePrincipal, erogazioneAutenticazioneParametroList,
  973.                     erogazioneAutorizzazione, erogazioneAutorizzazioneAutenticati, erogazioneAutorizzazioneRuoli, erogazioneAutorizzazioneRuoliTipologia, erogazioneAutorizzazioneRuoliMatch,
  974.                     nomeSA, erogazioneRuolo, erogazioneSoggettoAutenticato,
  975.                     autorizzazioneAutenticatiToken,
  976.                     autorizzazioneRuoliToken, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken,
  977.                     autorizzazioneTokenOptions,
  978.                     autorizzazioneScope, scope, autorizzazioneScopeMatch,allegatoXacmlPolicy,
  979.                     gestioneToken,
  980.                     gestioneTokenPolicy,  gestioneTokenOpzionale,  
  981.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenForward,
  982.                     autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  983.                     asps,
  984.                     protocollo, userLogin,
  985.                     apsCore, apsHelper,erogazioneServizioApplicativoServer,
  986.                     identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  987.                     apiKeyHeader, apiKeyValue, appIdHeader, appIdValue, connettoreStatusParams);
  988.            
  989.            
  990.             // Preparo la lista
  991.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);

  992.             int idLista = Liste.CONFIGURAZIONE_EROGAZIONE;

  993.             ricerca = porteApplicativeHelper.checkSearchParameters(idLista, ricerca);

  994.             if(asps==null) {
  995.                 throw new DriverControlStationException("Asps is null");
  996.             }
  997.             List<MappingErogazionePortaApplicativa> lista = apsCore.mappingServiziPorteAppList(idServizio2,asps.getId(), ricerca);

  998.             apsHelper.prepareServiziConfigurazioneList(lista, idAsps, null, ricerca);
  999.            
  1000.             // reset posizione tab
  1001.             if(!apsHelper.isModalitaCompleta())
  1002.                 ServletUtils.setObjectIntoSession(request, session, "0", CostantiControlStation.PARAMETRO_ID_TAB);  

  1003.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  1004.            
  1005.             ForwardParams fwP = apsHelper.isModalitaCompleta() ? ForwardParams.ADD() : AccordiServizioParteSpecificaCostanti.TIPO_OPERAZIONE_CONFIGURAZIONE;
  1006.             // Forward control to the specified success URI
  1007.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,
  1008.                     fwP);

  1009.         } catch (Exception e) {
  1010.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  1011.                     AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,
  1012.                     ForwardParams.ADD());
  1013.         }  
  1014.     }
  1015. }