AccordiServizioParteSpecificaFruitoriAdd.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.Collections;
  23. import java.util.HashMap;
  24. import java.util.List;
  25. import java.util.Map;

  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.PortaDelegata;
  39. import org.openspcoop2.core.config.constants.CredenzialeTipo;
  40. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  41. import org.openspcoop2.core.config.constants.TipoAutenticazione;
  42. import org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal;
  43. import org.openspcoop2.core.config.constants.TipoAutorizzazione;
  44. import org.openspcoop2.core.config.driver.db.IDServizioApplicativoDB;
  45. import org.openspcoop2.core.constants.CostantiConnettori;
  46. import org.openspcoop2.core.constants.TipiConnettore;
  47. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  48. import org.openspcoop2.core.id.IDFruizione;
  49. import org.openspcoop2.core.id.IDServizio;
  50. import org.openspcoop2.core.id.IDSoggetto;
  51. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  52. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  53. import org.openspcoop2.core.registry.Connettore;
  54. import org.openspcoop2.core.registry.Fruitore;
  55. import org.openspcoop2.core.registry.Soggetto;
  56. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  57. import org.openspcoop2.core.registry.constants.FormatoSpecifica;
  58. import org.openspcoop2.core.registry.constants.StatiAccordo;
  59. import org.openspcoop2.core.registry.constants.TipologiaServizio;
  60. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  61. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  62. import org.openspcoop2.core.registry.driver.ValidazioneStatoPackageException;
  63. import org.openspcoop2.message.constants.ServiceBinding;
  64. import org.openspcoop2.protocol.engine.ProtocolFactoryManager;
  65. import org.openspcoop2.protocol.sdk.ProtocolException;
  66. import org.openspcoop2.protocol.sdk.config.ProtocolSubscription;
  67. import org.openspcoop2.protocol.sdk.constants.ConsoleOperationType;
  68. import org.openspcoop2.protocol.sdk.properties.ProtocolPropertiesUtils;
  69. import org.openspcoop2.utils.BooleanNullable;
  70. import org.openspcoop2.web.ctrlstat.core.AutorizzazioneUtilities;
  71. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  72. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  73. import org.openspcoop2.web.ctrlstat.costanti.ConnettoreServletType;
  74. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  75. import org.openspcoop2.web.ctrlstat.driver.DriverControlStationNotFound;
  76. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettore;
  77. import org.openspcoop2.web.ctrlstat.plugins.servlet.ServletExtendedConnettoreUtils;
  78. import org.openspcoop2.web.ctrlstat.servlet.ApiKeyState;
  79. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  80. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  81. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  82. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti;
  83. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoreStatusParams;
  84. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  85. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriHelper;
  86. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateCore;
  87. import org.openspcoop2.web.ctrlstat.servlet.pdd.PddCore;
  88. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCore;
  89. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCostanti;
  90. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  91. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  92. import org.openspcoop2.web.lib.mvc.Costanti;
  93. import org.openspcoop2.web.lib.mvc.DataElement;
  94. import org.openspcoop2.web.lib.mvc.ForwardParams;
  95. import org.openspcoop2.web.lib.mvc.GeneralData;
  96. import org.openspcoop2.web.lib.mvc.PageData;
  97. import org.openspcoop2.web.lib.mvc.Parameter;
  98. import org.openspcoop2.web.lib.mvc.ServletUtils;
  99. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  100. /**
  101.  * serviziFruitoriAdd
  102.  *
  103.  * @author Andrea Poli (apoli@link.it)
  104.  * @author Stefano Corallo (corallo@link.it)
  105.  * @author Sandra Giangrandi (sandra@link.it)
  106.  * @author $Author$
  107.  * @version $Rev$, $Date$
  108.  *
  109.  */
  110. public final class AccordiServizioParteSpecificaFruitoriAdd extends Action {

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

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

  114.         // Inizializzo PageData
  115.         PageData pd = new PageData();

  116.         GeneralHelper generalHelper = new GeneralHelper(session);

  117.         // Inizializzo GeneralData
  118.         GeneralData gd = generalHelper.initGeneralData(request);

  119.         String superUser =  ServletUtils.getUserLoginFromSession(session);

  120.         AccordiServizioParteSpecificaFruitoriAddStrutsBean strutsBean = new AccordiServizioParteSpecificaFruitoriAddStrutsBean();
  121.        
  122.         // Parametri Protocol Properties relativi al tipo di operazione e al tipo di visualizzazione
  123.         strutsBean.consoleOperationType = ConsoleOperationType.ADD;
  124.        
  125.         // Parametri relativi al tipo operazione
  126.         TipoOperazione tipoOp = TipoOperazione.ADD;

  127.         try {
  128.             AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  129.            
  130.             strutsBean.editMode = apsHelper.getParameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME);

  131.             strutsBean.id = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID);
  132.             strutsBean.idSoggettoFruitore = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_PROVIDER_FRUITORE);
  133.             strutsBean.correlato = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_CUSTOM_CORRELATO);

  134.             strutsBean.controlloAccessiStato = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO);
  135.            
  136.             strutsBean.fruizioneServizioApplicativo = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_FRUIZIONE_NOME_SA);
  137.             strutsBean.fruizioneRuolo = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_NOME_RUOLO);
  138.             strutsBean.fruizioneAutenticazione = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTENTICAZIONE);
  139.             strutsBean.fruizioneAutenticazioneOpzionale = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTENTICAZIONE_OPZIONALE);
  140.             String fruizioneAutenticazionePrincipalTipo = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TIPO);
  141.             strutsBean.fruizioneAutenticazionePrincipal = TipoAutenticazionePrincipal.toEnumConstant(fruizioneAutenticazionePrincipalTipo, false);
  142.             strutsBean.fruizioneAutenticazioneParametroList = apsHelper.convertFromDataElementValue_parametroAutenticazioneList(strutsBean.fruizioneAutenticazione, strutsBean.fruizioneAutenticazionePrincipal);
  143.             strutsBean.fruizioneAutorizzazione = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE);
  144.             strutsBean.fruizioneAutorizzazioneAutenticati = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_AUTENTICAZIONE);
  145.             strutsBean.fruizioneAutorizzazioneRuoli = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_RUOLI);
  146.             strutsBean.fruizioneAutorizzazioneRuoliTipologia = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_RUOLO_TIPOLOGIA);
  147.             strutsBean.fruizioneAutorizzazioneRuoliMatch = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_AUTORIZZAZIONE_RUOLO_MATCH);
  148.            
  149.             String gestioneToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  150.             String gestioneTokenPolicy = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  151.             String gestioneTokenOpzionale = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_OPZIONALE);
  152.             String gestioneTokenValidazioneInput = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  153.             String gestioneTokenIntrospection = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  154.             String gestioneTokenUserInfo = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  155.             String gestioneTokenTokenForward = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);
  156.            
  157.             String autenticazioneTokenIssuer = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_ISSUER);
  158.             String autenticazioneTokenClientId = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  159.             String autenticazioneTokenSubject = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_SUBJECT);
  160.             String autenticazioneTokenUsername = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_USERNAME);
  161.             String autenticazioneTokenEMail = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_MAIL);
  162.            
  163.             String autorizzazioneAutenticatiToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  164.             String autorizzazioneRuoliToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  165.             String autorizzazioneRuoliTipologiaToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA_TOKEN);
  166.             String autorizzazioneRuoliMatchToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_RUOLO_MATCH_TOKEN);
  167.            
  168.             String autorizzazioneToken = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  169.             String autorizzazioneTokenOptions = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  170.             String autorizzazioneScope = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  171.             String autorizzazioneScopeMatch = apsHelper.getParameter(CostantiControlStation.PARAMETRO_SCOPE_MATCH);
  172.             String scope = apsHelper.getParameter(CostantiControlStation.PARAMETRO_SCOPE);
  173.            
  174.             BinaryParameter allegatoXacmlPolicy = apsHelper.getBinaryParameter(CostantiControlStation.PARAMETRO_DOCUMENTO_SICUREZZA_XACML_POLICY);  
  175.            
  176.             String identificazioneAttributiStato = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  177.             String [] attributeAuthoritySelezionate = apsHelper.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  178.             String attributeAuthorityAttributi = apsHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  179.            
  180.             strutsBean.endpointtype = apsHelper.readEndPointType();
  181.             strutsBean.tipoconn = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO );
  182.             strutsBean.autenticazioneHttp = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);

  183.             strutsBean.connettoreDebug = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_DEBUG);
  184.            
  185.             // token policy
  186.             String autenticazioneTokenS = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  187.             strutsBean.autenticazioneToken = ServletUtils.isCheckBoxEnabled(autenticazioneTokenS);
  188.             strutsBean.tokenPolicy = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY);
  189.            
  190.             // proxy
  191.             strutsBean.proxyEnabled = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  192.             strutsBean.proxyHostname = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  193.             strutsBean.proxyPort = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PORT);
  194.             strutsBean.proxyUsername = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_USERNAME);
  195.             strutsBean.proxyPassword = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PASSWORD);

  196.             // tempi risposta
  197.             strutsBean.tempiRispostaEnabled = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  198.             strutsBean.tempiRispostaConnectionTimeout = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  199.             strutsBean.tempiRispostaReadTimeout = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  200.             strutsBean.tempiRispostaTempoMedioRisposta = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);
  201.            
  202.             // opzioni avanzate
  203.             strutsBean.transferMode = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  204.             strutsBean.transferModeChunkSize = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  205.             strutsBean.redirectMode = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  206.             strutsBean.redirectMaxHop = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  207.             strutsBean.opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(apsHelper, strutsBean.transferMode, strutsBean.redirectMode);

  208.             // http
  209.             strutsBean.url = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL  );
  210.             if(TipiConnettore.HTTP.toString().equals(strutsBean.endpointtype)){
  211.                 strutsBean.user = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  212.                 strutsBean.password = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  213.             }

  214.             // api key
  215.             strutsBean.autenticazioneApiKey = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_API_KEY);
  216.             strutsBean.apiKeyHeader = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_HEADER);
  217.             if(strutsBean.apiKeyHeader==null || StringUtils.isEmpty(strutsBean.apiKeyHeader)) {
  218.                 strutsBean.apiKeyHeader = CostantiConnettori.DEFAULT_HEADER_API_KEY;
  219.             }
  220.             strutsBean.apiKeyValue = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_VALUE);
  221.             strutsBean.appIdHeader = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  222.             if(strutsBean.appIdHeader==null || StringUtils.isEmpty(strutsBean.appIdHeader)) {
  223.                 strutsBean.appIdHeader = CostantiConnettori.DEFAULT_HEADER_APP_ID;
  224.             }
  225.             strutsBean.appIdValue = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  226.             String useOAS3NamesTmp = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  227.             strutsBean.useOAS3Names=true;
  228.             if(useOAS3NamesTmp!=null && StringUtils.isNotEmpty(useOAS3NamesTmp)) {
  229.                 strutsBean.useOAS3Names = ServletUtils.isCheckBoxEnabled(useOAS3NamesTmp);
  230.             }
  231.             else {
  232.                 strutsBean.useOAS3Names = apsHelper.isAutenticazioneApiKeyUseOAS3Names(strutsBean.apiKeyHeader, strutsBean.appIdHeader);
  233.             }
  234.             String useAppIdTmp = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  235.             strutsBean.useAppId=false;
  236.             if(useAppIdTmp!=null && StringUtils.isNotEmpty(useAppIdTmp)) {
  237.                 strutsBean.useAppId = ServletUtils.isCheckBoxEnabled(useAppIdTmp);
  238.             }
  239.             else {
  240.                 strutsBean.useAppId = apsHelper.isAutenticazioneApiKeyUseAppId(strutsBean.appIdValue);
  241.             }
  242.            
  243.             // jms
  244.             strutsBean.nome = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_NOME_CODA);
  245.             strutsBean.tipo = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_CODA);
  246.             strutsBean.initcont = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_INIT_CTX);
  247.             strutsBean.urlpgk = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_URL_PKG);
  248.             strutsBean.provurl = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PROVIDER_URL);
  249.             strutsBean.connfact = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_CONNECTION_FACTORY);
  250.             strutsBean.sendas = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_OGGETTO_JMS);
  251.             if(TipiConnettore.JMS.toString().equals(strutsBean.endpointtype)){
  252.                 strutsBean.user = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_USERNAME);
  253.                 strutsBean.password = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PASSWORD);
  254.             }

  255.             // https
  256.             strutsBean.httpsurl = strutsBean.url;
  257.             strutsBean.httpstipologia = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_SSL_TYPE );
  258.             strutsBean.httpshostverifyS = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_HOST_VERIFY);
  259.             String httpsTrustVerifyCertS = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS );
  260.             strutsBean.httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  261.             strutsBean.httpspath = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_LOCATION );
  262.             strutsBean.httpstipo = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  263.             strutsBean.httpspwd = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  264.             strutsBean.httpsalgoritmo = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  265.             strutsBean.httpsstatoS = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO);
  266.             strutsBean.httpskeystore = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE);
  267.             strutsBean.httpspwdprivatekeytrust = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_STORE);
  268.             strutsBean.httpspathkey = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  269.             strutsBean.httpstipokey = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_TYPE);
  270.             strutsBean.httpspwdkey = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  271.             strutsBean.httpspwdprivatekey = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_KEYSTORE);
  272.             strutsBean.httpsalgoritmokey = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  273.             strutsBean.httpsKeyAlias = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_ALIAS_PRIVATE_KEY_KEYSTORE);
  274.             strutsBean.httpsTrustStoreCRLs = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL);
  275.             strutsBean.httpsTrustStoreOCSPPolicy = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  276.             strutsBean.httpsKeyStoreBYOKPolicy = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  277.             if(TipiConnettore.HTTPS.toString().equals(strutsBean.endpointtype)){
  278.                 strutsBean.user = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  279.                 strutsBean.password = apsHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  280.             }
  281.            
  282.             // file
  283.             strutsBean.requestOutputFileName = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME);
  284.             strutsBean.requestOutputFileNamePermissions = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_PERMISSIONS);
  285.             strutsBean.requestOutputFileNameHeaders = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS);
  286.             strutsBean.requestOutputFileNameHeadersPermissions = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS);
  287.             strutsBean.requestOutputParentDirCreateIfNotExists = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  288.             strutsBean.requestOutputOverwriteIfExists = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE_NAME);
  289.             strutsBean.responseInputMode = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  290.             strutsBean.responseInputFileName = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME);
  291.             strutsBean.responseInputFileNameHeaders = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS);
  292.             strutsBean.responseInputDeleteAfterRead = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_DELETE_AFTER_READ);
  293.             strutsBean.responseInputWaitTime = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);

  294.             //status
  295.             ConnettoreStatusParams connettoreStatusParams = ConnettoreStatusParams.fillFrom(apsHelper);
  296.            
  297.             strutsBean.statoPackage = apsHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO_PACKAGE);

  298.             strutsBean.wsdlimpler = apsHelper.getBinaryParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_EROGATORE);
  299.             strutsBean.wsdlimplfru = apsHelper.getBinaryParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_WSDL_FRUITORE);

  300.             if(apsHelper.isMultipart()){
  301.                 strutsBean.decodeRequestValidazioneDocumenti = true;
  302.             }

  303.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore();
  304.             PddCore pddCore = new PddCore(apsCore);
  305.             SoggettiCore soggettiCore = new SoggettiCore(apsCore);
  306.             PorteDelegateCore porteDelegateCore = new PorteDelegateCore(apsCore);
  307.             ServiziApplicativiCore saCore = new ServiziApplicativiCore(apsCore);
  308.             ConfigurazioneCore confCore = new ConfigurazioneCore(apsCore);
  309.             AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(apsCore);

  310.             if(ServletUtils.isEditModeInProgress(strutsBean.editMode)){
  311.                 // primo accesso alla servlet
  312.                 strutsBean.validazioneDocumenti = true;
  313.                 if (apsHelper.isModalitaAvanzata()) {
  314.                     String tmpValidazioneDocumenti = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  315.                     if(tmpValidazioneDocumenti!=null){
  316.                         if(Costanti.CHECK_BOX_ENABLED_TRUE.equalsIgnoreCase(tmpValidazioneDocumenti) || Costanti.CHECK_BOX_ENABLED.equalsIgnoreCase(tmpValidazioneDocumenti)){
  317.                             strutsBean.validazioneDocumenti = true;
  318.                         }else{
  319.                             strutsBean.validazioneDocumenti = false;
  320.                         }
  321.                     }
  322.                 }
  323.             }else{
  324.                 if(!strutsBean.decodeRequestValidazioneDocumenti){
  325.                     String tmpValidazioneDocumenti = apsHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_VALIDAZIONE_DOCUMENTI);
  326.                     if(Costanti.CHECK_BOX_ENABLED_TRUE.equalsIgnoreCase(tmpValidazioneDocumenti) || Costanti.CHECK_BOX_ENABLED.equalsIgnoreCase(tmpValidazioneDocumenti)){
  327.                         strutsBean.validazioneDocumenti = true;
  328.                     }else{
  329.                         strutsBean.validazioneDocumenti = false;
  330.                     }
  331.                 }
  332.             }

  333.             strutsBean.httpshostverify = false;
  334.             if (strutsBean.httpshostverifyS != null && strutsBean.httpshostverifyS.equals(Costanti.CHECK_BOX_ENABLED))
  335.                 strutsBean.httpshostverify = true;
  336.             strutsBean.httpsstato = false;
  337.             if (strutsBean.httpsstatoS != null && strutsBean.httpsstatoS.equals(Costanti.CHECK_BOX_ENABLED))
  338.                 strutsBean.httpsstato = true;

  339.             long idServizioLong = Long.parseLong(strutsBean.id);

  340.             Boolean isConnettoreCustomUltimaImmagineSalvata = null;

  341.             Connettore conTmp = null;
  342.             List<ExtendedConnettore> listExtendedConnettore =
  343.                     ServletExtendedConnettoreUtils.getExtendedConnettore(conTmp, ConnettoreServletType.FRUIZIONE_ACCORDO_SERVIZIO_PARTE_SPECIFICA_ADD, apsHelper,
  344.                             null, //this.parametersPOST,
  345.                             (strutsBean.endpointtype==null), strutsBean.endpointtype); // uso endpointtype per capire se ĆØ la prima volta che entro

  346.             // prendo l'id del soggetto erogatore lo propago
  347.             // lo metto nel pd come campo hidden
  348.             PageData oldPD = ServletUtils.getPageDataFromSession(request, session);
  349.             pd.setHidden(oldPD.getHidden());

  350.             String idSoggErogatore = oldPD.getHidden(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE);

  351.             boolean postBackViaPost = true;
  352.            
  353.             // Preparo il menu
  354.             apsHelper.makeMenu();

  355.             // Prendo nome e tipo dal db

  356.             AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idServizioLong);
  357.             String nomeservizio = asps.getNome();
  358.             String tiposervizio = asps.getTipo();
  359.             Integer versioneservizio = asps.getVersione();

  360.             IDServizio idServizioObject = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  361.             idServizioObject.setUriAccordoServizioParteComune(asps.getAccordoServizioParteComune());
  362.             idServizioObject.setPortType(asps.getPortType());
  363.            
  364.             IDFruizione idFruizione = new IDFruizione();
  365.             idFruizione.setIdServizio(idServizioObject);
  366.            
  367.            
  368.             if(strutsBean.correlato == null){
  369.                 strutsBean.correlato = (TipologiaServizio.CORRELATO.equals(asps.getTipologiaServizio()) ?
  370.                         AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_CORRELATO :
  371.                             AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_NORMALE);
  372.             }

  373.             /**String profiloSoggettoFruitore = null;
  374.             //if ((this.provider != null) && !this.provider.equals("")) {
  375.             //  long idFruitore = Long.parseLong(this.provider);
  376.             //  Soggetto soggetto = soggettiCore.getSoggettoRegistro(idFruitore);
  377.             //  profiloSoggettoFruitore = soggetto.getVersioneProtocollo();
  378.             //}
  379.             //String profiloValue = profiloSoggettoFruitore;
  380.             //if(this.profilo!=null && !"".equals(this.profilo) && !"-".equals(this.profilo)){
  381.             //  profiloValue = this.profilo;
  382.             //}*/

  383.             String protocollo = apsCore.getProtocolloAssociatoTipoServizio(tiposervizio);
  384.             List<String> versioniProtocollo = apsCore.getVersioniProtocollo(protocollo);
  385.             List<String> tipiSoggettiCompatibiliAccordo = soggettiCore.getTipiSoggettiGestitiProtocollo(protocollo);

  386.             String tmpTitle = apsHelper.getLabelIdServizio(asps);

  387.             // Soggetti fruitori
  388.             // tutti i soggetti anche il soggetto attuale
  389.             // tranne quelli giĆ  registrati come fruitori
  390.             String[] soggettiList = null;
  391.             String[] soggettiListLabel = null;
  392.             List<Fruitore> fruList1 = apsCore.getSoggettiWithServizioNotFruitori(idServizioLong,true,null);
  393.             Map<String, Fruitore> mapFruitori = new HashMap<>();
  394.             List<String> keyFruitori = new ArrayList<>();
  395.             if(fruList1!=null && !fruList1.isEmpty()){
  396.                 for (Fruitore fr : fruList1) {
  397.                     String key = fr.getTipo()+""+fr.getNome();
  398.                     if(!keyFruitori.contains(key)){
  399.                         keyFruitori.add(key);
  400.                         mapFruitori.put(key, fr);
  401.                     }
  402.                 }
  403.             }
  404.             if(!keyFruitori.isEmpty()){
  405.                 Collections.sort(keyFruitori);
  406.             }
  407.            
  408.             List<String> soggettiListList = new ArrayList<>();
  409.             List<String> soggettiListLabelList = new ArrayList<>();
  410.             IDSoggetto idSoggettoSelected = null;
  411.             IDSoggetto idSoggettoFirst = null;
  412.             for (int i = 0; i < keyFruitori.size(); i++) {
  413.                 String tipoNome = keyFruitori.get(i);
  414.                 Fruitore fru = mapFruitori.get(tipoNome);
  415.                 if(tipiSoggettiCompatibiliAccordo.contains(fru.getTipo())){
  416.                     soggettiListList.add("" + fru.getId());
  417.                     soggettiListLabelList.add(apsHelper.getLabelNomeSoggetto(protocollo, fru.getTipo() , fru.getNome()));
  418.                     if(idSoggettoFirst==null) {
  419.                         idSoggettoFirst = new IDSoggetto(fru.getTipo(), fru.getNome());
  420.                     }
  421.                     if(strutsBean.idSoggettoFruitore!=null && !"".equals(strutsBean.idSoggettoFruitore)){
  422.                         long idProvider = Long.parseLong(strutsBean.idSoggettoFruitore);
  423.                         if(fru.getId()==idProvider){
  424.                             idSoggettoSelected = new IDSoggetto(fru.getTipo(), fru.getNome());
  425.                         }
  426.                     }
  427.                 }
  428.             }
  429.             if(!soggettiListList.isEmpty()){
  430.                 soggettiList = soggettiListList.toArray(new String[1]);
  431.                 soggettiListLabel = soggettiListLabelList.toArray(new String[1]);

  432.                 if(idSoggettoSelected==null &&
  433.                     idSoggettoFirst!=null){
  434.                     idSoggettoSelected = idSoggettoFirst; // prendo il primo soggetto se esiste
  435.                 }
  436.             }

  437.             idFruizione.setIdFruitore(idSoggettoSelected);

  438.             // Versioni
  439.             String[] versioniValues = new String[versioniProtocollo.size()+1];
  440.             String[] versioniLabel = new String[versioniProtocollo.size()+1];
  441.             versioniLabel[0] = "usa versione fruitore";
  442.             versioniValues[0] = "-";
  443.             for (int i = 0; i < versioniProtocollo.size(); i++) {
  444.                 String tmp = versioniProtocollo.get(i);
  445.                 versioniLabel[i+1] = tmp;
  446.                 versioniValues[i+1] = tmp;
  447.             }


  448.             // ServiziApplicativi
  449.             boolean escludiSAServer = saCore.isApplicativiServerEnabled(apsHelper);
  450.             String filtroTipoSA = escludiSAServer ? ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_CLIENT : null;
  451.            
  452.             List<String> saList = new ArrayList<>();
  453.             saList.add("-");
  454.             if(idSoggettoSelected!=null){
  455.                 String auth = strutsBean.fruizioneAutenticazione;
  456.                 if(auth==null || "".equals(auth)){
  457.                     auth = apsCore.getAutenticazione_generazioneAutomaticaPorteDelegate();
  458.                 }
  459.                 CredenzialeTipo credenziale = CredenzialeTipo.toEnumConstant(auth);
  460.                 Boolean appId = null;
  461.                 if(CredenzialeTipo.APIKEY.equals(credenziale)) {
  462.                     ApiKeyState apiKeyState =  new ApiKeyState(null);
  463.                     appId = apiKeyState.appIdSelected;
  464.                 }
  465.                 boolean bothSslAndToken = false;
  466.                 String tokenPolicy = null;
  467.                 boolean tokenPolicyOR = false;
  468.                
  469.                 List<IDServizioApplicativoDB> oldSilList = null;
  470.                 if(apsCore.isVisioneOggettiGlobale(superUser)){
  471.                     oldSilList = saCore.soggettiServizioApplicativoList(idSoggettoSelected,null,
  472.                             credenziale, appId, filtroTipoSA,
  473.                             bothSslAndToken, tokenPolicy, tokenPolicyOR);
  474.                 }
  475.                 else {
  476.                     oldSilList = saCore.soggettiServizioApplicativoList(idSoggettoSelected,superUser,
  477.                             credenziale, appId, filtroTipoSA,
  478.                             bothSslAndToken, tokenPolicy, tokenPolicyOR);
  479.                 }
  480.                 if(oldSilList!=null && !oldSilList.isEmpty()){
  481.                     for (int i = 0; i < oldSilList.size(); i++) {
  482.                         saList.add(oldSilList.get(i).getNome());        
  483.                     }
  484.                 }

  485.             }

  486.             strutsBean.protocolFactory = ProtocolFactoryManager.getInstance().getProtocolFactoryByName(protocollo);
  487.             strutsBean.consoleDynamicConfiguration =  strutsBean.protocolFactory.createDynamicConfigurationConsole();
  488.             strutsBean.registryReader = soggettiCore.getRegistryReader(strutsBean.protocolFactory);
  489.             strutsBean.configRegistryReader = soggettiCore.getConfigIntegrationReader(strutsBean.protocolFactory);
  490.            
  491.             // ID Accordo Null per default
  492.             strutsBean.consoleConfiguration = strutsBean.consoleDynamicConfiguration.getDynamicConfigFruizioneAccordoServizioParteSpecifica(strutsBean.consoleOperationType, apsHelper,
  493.                     strutsBean.registryReader, strutsBean.configRegistryReader, idFruizione  );
  494.             strutsBean.protocolProperties = apsHelper.estraiProtocolPropertiesDaRequest(strutsBean.consoleConfiguration, strutsBean.consoleOperationType);

  495.             AccordoServizioParteComuneSintetico as = apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  496.            
  497.             boolean forceHttps = false;
  498.             boolean forceHttpsClient = false;
  499.             boolean forcePDND = false;
  500.             boolean forceOAuth = false;
  501.             if(apsHelper.isProfiloModIPA(protocollo)) {
  502.                 forceHttps = apsHelper.forceHttpsProfiloModiPA();
  503.                
  504.                 BooleanNullable forceHttpsClientWrapper = BooleanNullable.NULL();
  505.                 BooleanNullable forcePDNDWrapper = BooleanNullable.NULL();
  506.                 BooleanNullable forceOAuthWrapper = BooleanNullable.NULL();
  507.                
  508.                 apsHelper.readModIConfiguration(forceHttpsClientWrapper, forcePDNDWrapper, forceOAuthWrapper,
  509.                         IDAccordoFactory.getInstance().getIDAccordoFromAccordo(as), asps.getPortType(),
  510.                         null);
  511.                
  512.                 if(forceHttpsClientWrapper.getValue()!=null) {
  513.                     forceHttpsClient = forceHttpsClientWrapper.getValue().booleanValue();
  514.                 }
  515.                 if(forcePDNDWrapper.getValue()!=null) {
  516.                     forcePDND = forcePDNDWrapper.getValue().booleanValue();
  517.                 }
  518.                 if(forceOAuthWrapper.getValue()!=null) {
  519.                     forceOAuth = forceOAuthWrapper.getValue().booleanValue();
  520.                 }
  521.                
  522.             }
  523.            
  524.             // Token Policy
  525.             List<GenericProperties> gestorePolicyTokenList = confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN, null);
  526.             String [] policyLabels = new String[gestorePolicyTokenList.size() + 1];
  527.             String [] policyValues = new String[gestorePolicyTokenList.size() + 1];
  528.            
  529.             policyLabels[0] = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  530.             policyValues[0] = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  531.            
  532.             for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  533.             GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  534.                 policyLabels[(i+1)] = genericProperties.getNome();
  535.                 policyValues[(i+1)] = genericProperties.getNome();
  536.             }
  537.            
  538.             // AttributeAuthority
  539.             List<GenericProperties> attributeAuthorityList = confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_ATTRIBUTE_AUTHORITY, null);
  540.             String [] attributeAuthorityLabels = new String[attributeAuthorityList.size()];
  541.             String [] attributeAuthorityValues = new String[attributeAuthorityList.size()];
  542.             for (int i = 0; i < attributeAuthorityList.size(); i++) {
  543.                 GenericProperties genericProperties = attributeAuthorityList.get(i);
  544.                 attributeAuthorityLabels[i] = genericProperties.getNome();
  545.                 attributeAuthorityValues[i] = genericProperties.getNome();
  546.             }
  547.            
  548.             // Se idhid = null, devo visualizzare la pagina per l'inserimento
  549.             // dati
  550.             if(ServletUtils.isEditModeInProgress(strutsBean.editMode)){
  551.                 // setto la barra del titolo
  552.                 List<Parameter> lstParm = new ArrayList<>();

  553.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  554.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FUITORI_DI  + tmpTitle,
  555.                         AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_LIST ,
  556.                         new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, ""+ strutsBean.id),
  557.                         new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, ""+ idSoggErogatore)
  558.                         ));
  559.                 lstParm.add(ServletUtils.getParameterAggiungi());

  560.                 // setto la barra del titolo
  561.                 ServletUtils.setPageDataTitle(pd, lstParm );

  562.                 // preparo i campi
  563.                 List<DataElement> dati = new ArrayList<>();
  564.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  565.                 if(soggettiListList.isEmpty()){

  566.                     pd.setMessage(AccordiServizioParteSpecificaCostanti.LABEL_AGGIUNTA_FRUITORI_COMPLETATA, Costanti.MESSAGE_TYPE_INFO);

  567.                     pd.disableEditMode();

  568.                 }

  569.                 else{
  570.                     dati = apsHelper.addHiddenFieldsToDati(tipoOp, strutsBean.id, null, null, dati);

  571.                     if (strutsBean.idSoggettoFruitore == null) {
  572.                         strutsBean.idSoggettoFruitore = "";
  573. /**                     if(strutsBean.wsdlimpler.getValue() == null)
  574. //                          strutsBean.wsdlimpler.setValue(new byte[1]);
  575. //                      if(strutsBean.wsdlimplfru.getValue() == null)
  576. //                          strutsBean.wsdlimplfru.setValue(new byte[1]); */
  577.                         strutsBean.endpointtype = AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_DISABILITATO;
  578.                         strutsBean.tipoconn = "";
  579.                         strutsBean.url = "";
  580.                         strutsBean.nome = "";
  581.                         strutsBean.tipo = ConnettoriCostanti.TIPI_CODE_JMS[0];
  582.                         strutsBean.user = "";
  583.                         strutsBean.password = "";
  584.                         strutsBean.initcont = "";
  585.                         strutsBean.urlpgk = "";
  586.                         strutsBean.provurl = "";
  587.                         strutsBean.connfact = "";
  588.                         strutsBean.sendas = ConnettoriCostanti.TIPO_SEND_AS[0];
  589.                         strutsBean.httpsurl = "";
  590.                         strutsBean.httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE;
  591.                         strutsBean.httpshostverify = true;
  592.                         strutsBean.httpsTrustVerifyCert = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS;
  593.                         strutsBean.httpspath = "";
  594.                         strutsBean.httpstipo = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TIPOLOGIA_KEYSTORE_TYPE;
  595.                         strutsBean.httpspwd = "";
  596.                         strutsBean.httpsalgoritmo = "";
  597.                         strutsBean.httpsstato = false;
  598.                         strutsBean.httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  599.                         strutsBean.httpspwdprivatekeytrust = "";
  600.                         strutsBean.httpspathkey = "";
  601.                         strutsBean.httpstipokey = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TIPOLOGIA_KEYSTORE_TYPE;
  602.                         strutsBean.httpspwdkey = "";
  603.                         strutsBean.httpspwdprivatekey = "";
  604.                         strutsBean.httpsalgoritmokey = "";

  605.                         if(apsHelper.isShowGestioneWorkflowStatoDocumenti()){
  606.                             if(strutsBean.statoPackage==null || "".equals(strutsBean.statoPackage)){
  607.                                 strutsBean.statoPackage=StatiAccordo.bozza.toString();
  608.                             }

  609.                             //Se l'ASPS riferito e' in stato operativo o finale allora setto la fruizione come operativa.
  610.                             if(asps.getStatoPackage().equals(StatiAccordo.operativo.toString()) || asps.getStatoPackage().equals(StatiAccordo.finale.toString())){
  611.                                 strutsBean.statoPackage=StatiAccordo.operativo.toString();
  612.                             }

  613.                         }else{
  614.                             strutsBean.statoPackage=StatiAccordo.finale.toString();
  615.                         }
  616.                     }
  617.                    
  618.                     if(strutsBean.fruizioneServizioApplicativo==null || "".equals(strutsBean.fruizioneServizioApplicativo))
  619.                         strutsBean.fruizioneServizioApplicativo = "-";
  620.                     if(strutsBean.fruizioneRuolo==null || "".equals(strutsBean.fruizioneRuolo))
  621.                         strutsBean.fruizioneRuolo = "-";
  622.                     if(strutsBean.fruizioneAutenticazione==null || "".equals(strutsBean.fruizioneAutenticazione))
  623.                         strutsBean.fruizioneAutenticazione = apsCore.getAutenticazione_generazioneAutomaticaPorteDelegate();
  624.                     if(strutsBean.fruizioneAutorizzazione==null || "".equals(strutsBean.fruizioneAutorizzazione)){
  625.                         String tipoAutorizzazione = apsCore.getAutorizzazione_generazioneAutomaticaPorteDelegate();
  626.                         strutsBean.fruizioneAutorizzazione = AutorizzazioneUtilities.convertToStato(tipoAutorizzazione);
  627.                         if(TipoAutorizzazione.isAuthenticationRequired(tipoAutorizzazione))
  628.                             strutsBean.fruizioneAutorizzazioneAutenticati = Costanti.CHECK_BOX_ENABLED;
  629.                         if(TipoAutorizzazione.isRolesRequired(tipoAutorizzazione))
  630.                             strutsBean.fruizioneAutorizzazioneRuoli = Costanti.CHECK_BOX_ENABLED;
  631.                         strutsBean.fruizioneAutorizzazioneRuoliTipologia = AutorizzazioneUtilities.convertToRuoloTipologia(tipoAutorizzazione).getValue();
  632.                     }
  633.                     if(gestioneToken == null) {
  634.                         gestioneToken = StatoFunzionalita.DISABILITATO.getValue();
  635.                         gestioneTokenPolicy = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  636.                         gestioneTokenOpzionale = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_OPZIONALE;
  637.                         gestioneTokenValidazioneInput = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_VALIDAZIONE_INPUT;
  638.                         gestioneTokenIntrospection = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_INTROSPECTION;
  639.                         gestioneTokenUserInfo = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_USER_INFO;
  640.                         gestioneTokenTokenForward = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TOKEN_FORWARD;
  641.                         autenticazioneTokenIssuer = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_ISSUER;
  642.                         autenticazioneTokenClientId = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_CLIENT_ID;
  643.                         autenticazioneTokenSubject = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_SUBJECT;
  644.                         autenticazioneTokenUsername = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_USERNAME;
  645.                         autenticazioneTokenEMail = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_EMAIL;
  646.                     }
  647.                     if(scope ==null || "".equals(scope))
  648.                         scope = "-";
  649.                     if(autorizzazioneScope ==null)
  650.                         autorizzazioneScope = "";
  651.    
  652.                     if(identificazioneAttributiStato==null) {
  653.                         identificazioneAttributiStato = StatoFunzionalita.DISABILITATO.getValue();
  654.                     }
  655.                    
  656.                     // default
  657.                     if(strutsBean.httpsalgoritmo==null || "".equals(strutsBean.httpsalgoritmo)){
  658.                         strutsBean.httpsalgoritmo = TrustManagerFactory.getDefaultAlgorithm();
  659.                     }
  660.                     if(strutsBean.httpsalgoritmokey==null || "".equals(strutsBean.httpsalgoritmokey)){
  661.                         strutsBean.httpsalgoritmokey = KeyManagerFactory.getDefaultAlgorithm();
  662.                     }
  663.                     if(strutsBean.httpstipologia==null || "".equals(strutsBean.httpstipologia)){
  664.                         strutsBean.httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE;
  665.                     }
  666.                     if(strutsBean.httpshostverifyS==null || "".equals(strutsBean.httpshostverifyS)){
  667.                         strutsBean.httpshostverifyS = Costanti.CHECK_BOX_ENABLED_TRUE;
  668.                         strutsBean.httpshostverify = true;
  669.                     }
  670.                     if(httpsTrustVerifyCertS==null || "".equals(httpsTrustVerifyCertS)){
  671.                         httpsTrustVerifyCertS = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS ? Costanti.CHECK_BOX_ENABLED_TRUE : Costanti.CHECK_BOX_DISABLED;
  672.                         strutsBean.httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  673.                     }

  674.                     strutsBean.autenticazioneHttp = apsHelper.getAutenticazioneHttp(strutsBean.autenticazioneHttp, strutsBean.endpointtype, strutsBean.user);

  675.                     if(strutsBean.tempiRispostaConnectionTimeout==null || "".equals(strutsBean.tempiRispostaConnectionTimeout)
  676.                             ||
  677.                             strutsBean.tempiRispostaReadTimeout==null || "".equals(strutsBean.tempiRispostaReadTimeout)
  678.                             ||
  679.                             strutsBean.tempiRispostaTempoMedioRisposta==null || "".equals(strutsBean.tempiRispostaTempoMedioRisposta) ){
  680.                        
  681.                         ConfigurazioneCore configCore = new ConfigurazioneCore(soggettiCore);
  682.                         ConfigurazioneGenerale configGenerale = configCore.getConfigurazioneControlloTraffico();
  683.                        
  684.                         if(strutsBean.tempiRispostaConnectionTimeout==null || "".equals(strutsBean.tempiRispostaConnectionTimeout) ) {
  685.                             strutsBean.tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaFruizione().getConnectionTimeout().intValue()+"";
  686.                         }
  687.                         if(strutsBean.tempiRispostaReadTimeout==null || "".equals(strutsBean.tempiRispostaReadTimeout) ) {
  688.                             strutsBean.tempiRispostaReadTimeout = configGenerale.getTempiRispostaFruizione().getReadTimeout().intValue()+"";
  689.                         }
  690.                         if(strutsBean.tempiRispostaTempoMedioRisposta==null || "".equals(strutsBean.tempiRispostaTempoMedioRisposta) ) {
  691.                             strutsBean.tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaFruizione().getTempoMedioRisposta().intValue()+"";
  692.                         }
  693.                        
  694.                     }
  695.                    
  696.                     // update della configurazione
  697.                     strutsBean.consoleDynamicConfiguration.updateDynamicConfigFruizioneAccordoServizioParteSpecifica(strutsBean.consoleConfiguration, strutsBean.consoleOperationType, apsHelper, strutsBean.protocolProperties,
  698.                             strutsBean.registryReader, strutsBean.configRegistryReader, idFruizione);


  699.                     dati = apsHelper.addServiziFruitoriToDati(dati, strutsBean.idSoggettoFruitore, strutsBean.wsdlimpler, strutsBean.wsdlimplfru, soggettiList,
  700.                             soggettiListLabel, "0", strutsBean.id, tipoOp, "", "", "", nomeservizio, tiposervizio, versioneservizio, strutsBean.correlato, strutsBean.statoPackage, strutsBean.statoPackage,asps.getStatoPackage(), null,strutsBean.validazioneDocumenti,
  701.                             strutsBean.controlloAccessiStato,
  702.                             strutsBean.fruizioneServizioApplicativo,strutsBean.fruizioneRuolo,strutsBean.fruizioneAutenticazione,strutsBean.fruizioneAutenticazioneOpzionale,strutsBean.fruizioneAutenticazionePrincipal, strutsBean.fruizioneAutenticazioneParametroList, strutsBean.fruizioneAutorizzazione,
  703.                             strutsBean.fruizioneAutorizzazioneAutenticati, strutsBean.fruizioneAutorizzazioneRuoli, strutsBean.fruizioneAutorizzazioneRuoliTipologia, strutsBean.fruizioneAutorizzazioneRuoliMatch,
  704.                             saList,apcCore.toMessageServiceBinding(as.getServiceBinding()), apcCore.formatoSpecifica2InterfaceType(as.getFormatoSpecifica()),
  705.                             null, null, null, null,
  706.                             gestioneToken, policyLabels, policyValues,
  707.                             gestioneTokenPolicy, gestioneTokenOpzionale,
  708.                             gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  709.                             autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  710.                             autorizzazioneToken, autorizzazioneTokenOptions,
  711.                             autorizzazioneScope,scope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  712.                             identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  713.                             autorizzazioneAutenticatiToken,
  714.                             autorizzazioneRuoliToken,  autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);
  715.    
  716.                     dati = apsHelper.addFruitoreToDati(TipoOperazione.ADD, versioniLabel, versioniValues, dati,null
  717.                             ,null,null,null,null,null,null,null,null,null);

  718.                     String tipoSendas = ConnettoriCostanti.TIPO_SEND_AS[0];
  719.                     String tipoJms = ConnettoriCostanti.TIPI_CODE_JMS[0];
  720.                     if (apsHelper.isModalitaAvanzata()) {
  721.                         dati = apsHelper.addEndPointToDati(dati, apcCore.toMessageServiceBinding(as.getServiceBinding()), strutsBean.connettoreDebug, strutsBean.endpointtype, strutsBean.autenticazioneHttp, null,
  722.                                 strutsBean.url, strutsBean.nome,
  723.                                 tipoJms, strutsBean.user,
  724.                                 strutsBean.password, strutsBean.initcont, strutsBean.urlpgk,
  725.                                 strutsBean.provurl, strutsBean.connfact, tipoSendas,
  726.                                 AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,tipoOp,
  727.                                 strutsBean.httpsurl, strutsBean.httpstipologia, strutsBean.httpshostverify,
  728.                                 strutsBean.httpsTrustVerifyCert, strutsBean.httpspath, strutsBean.httpstipo, strutsBean.httpspwd,
  729.                                 strutsBean.httpsalgoritmo, strutsBean.httpsstato, strutsBean.httpskeystore,
  730.                                 strutsBean.httpspwdprivatekeytrust, strutsBean.httpspathkey,
  731.                                 strutsBean.httpstipokey, strutsBean.httpspwdkey,
  732.                                 strutsBean.httpspwdprivatekey, strutsBean.httpsalgoritmokey,
  733.                                 strutsBean.httpsKeyAlias, strutsBean.httpsTrustStoreCRLs, strutsBean.httpsTrustStoreOCSPPolicy, strutsBean.httpsKeyStoreBYOKPolicy,
  734.                                 strutsBean.tipoconn, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD, null,
  735.                                 null, null, null, null, null, null, null, true,
  736.                                 isConnettoreCustomUltimaImmagineSalvata,
  737.                                 strutsBean.proxyEnabled, strutsBean.proxyHostname, strutsBean.proxyPort, strutsBean.proxyUsername, strutsBean.proxyPassword,
  738.                                 strutsBean.tempiRispostaEnabled, strutsBean.tempiRispostaConnectionTimeout, strutsBean.tempiRispostaReadTimeout, strutsBean.tempiRispostaTempoMedioRisposta,
  739.                                 strutsBean.opzioniAvanzate, strutsBean.transferMode, strutsBean.transferModeChunkSize, strutsBean.redirectMode, strutsBean.redirectMaxHop,
  740.                                 strutsBean.requestOutputFileName, strutsBean.requestOutputFileNamePermissions, strutsBean.requestOutputFileNameHeaders, strutsBean.requestOutputFileNameHeadersPermissions,
  741.                                 strutsBean.requestOutputParentDirCreateIfNotExists,strutsBean.requestOutputOverwriteIfExists,
  742.                                 strutsBean.responseInputMode, strutsBean.responseInputFileName, strutsBean.responseInputFileNameHeaders, strutsBean.responseInputDeleteAfterRead, strutsBean.responseInputWaitTime,
  743.                                 strutsBean.autenticazioneToken,strutsBean.tokenPolicy, forcePDND, forceOAuth,
  744.                                 listExtendedConnettore, false,
  745.                                 protocollo, forceHttps, forceHttpsClient, false, false, null, null,
  746.                                 strutsBean.autenticazioneApiKey, strutsBean.useOAS3Names, strutsBean.useAppId, strutsBean.apiKeyHeader, strutsBean.apiKeyValue, strutsBean.appIdHeader, strutsBean.appIdValue,
  747.                                 connettoreStatusParams,
  748.                                 postBackViaPost);
  749.                     }else{
  750.                         //spostato dentro l'helper
  751.                     }
  752.                 }

  753.                 // aggiunta campi custom
  754.                 dati = apsHelper.addProtocolPropertiesToDatiRegistry(dati, strutsBean.consoleConfiguration,strutsBean.consoleOperationType, strutsBean.protocolProperties);

  755.                 pd.setDati(dati);

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

  757.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,
  758.                         ForwardParams.ADD());
  759.             }

  760.             // Controlli sui campi immessi
  761.             boolean isOk = apsHelper.serviziFruitoriCheckData(TipoOperazione.ADD, soggettiList,
  762.                     strutsBean.id, "", "", null, "", "", strutsBean.idSoggettoFruitore,
  763.                     strutsBean.endpointtype, strutsBean.url, strutsBean.nome, strutsBean.tipo,
  764.                     strutsBean.user, strutsBean.password, strutsBean.initcont, strutsBean.urlpgk,
  765.                     strutsBean.provurl, strutsBean.connfact, strutsBean.sendas,
  766.                     strutsBean.wsdlimpler, strutsBean.wsdlimplfru, "0",
  767.                     strutsBean.httpsurl, strutsBean.httpstipologia, strutsBean.httpshostverify,
  768.                     strutsBean.httpsTrustVerifyCert, strutsBean.httpspath, strutsBean.httpstipo,
  769.                     strutsBean.httpspwd, strutsBean.httpsalgoritmo, strutsBean.httpsstato,
  770.                     strutsBean.httpskeystore, strutsBean.httpspwdprivatekeytrust,
  771.                     strutsBean.httpspathkey, strutsBean.httpstipokey,
  772.                     strutsBean.httpspwdkey, strutsBean.httpspwdprivatekey,
  773.                     strutsBean.httpsalgoritmokey,
  774.                     strutsBean.httpsKeyAlias, strutsBean.httpsTrustStoreCRLs, strutsBean.httpsTrustStoreOCSPPolicy, strutsBean.httpsKeyStoreBYOKPolicy,
  775.                     strutsBean.tipoconn,strutsBean.validazioneDocumenti,null,strutsBean.autenticazioneHttp,
  776.                     strutsBean.proxyEnabled, strutsBean.proxyHostname, strutsBean.proxyPort, strutsBean.proxyUsername, strutsBean.proxyPassword,
  777.                     strutsBean.tempiRispostaEnabled, strutsBean.tempiRispostaConnectionTimeout, strutsBean.tempiRispostaReadTimeout, strutsBean.tempiRispostaTempoMedioRisposta,
  778.                     strutsBean.opzioniAvanzate, strutsBean.transferMode, strutsBean.transferModeChunkSize, strutsBean.redirectMode, strutsBean.redirectMaxHop,
  779.                     strutsBean.requestOutputFileName, strutsBean.requestOutputFileNamePermissions, strutsBean.requestOutputFileNameHeaders, strutsBean.requestOutputFileNameHeadersPermissions,
  780.                     strutsBean.requestOutputParentDirCreateIfNotExists,strutsBean.requestOutputOverwriteIfExists,
  781.                     strutsBean.responseInputMode, strutsBean.responseInputFileName, strutsBean.responseInputFileNameHeaders, strutsBean.responseInputDeleteAfterRead, strutsBean.responseInputWaitTime,
  782.                     strutsBean.fruizioneServizioApplicativo,strutsBean.fruizioneRuolo,strutsBean.fruizioneAutenticazione,strutsBean.fruizioneAutenticazioneOpzionale,strutsBean.fruizioneAutenticazionePrincipal, strutsBean.fruizioneAutenticazioneParametroList, strutsBean.fruizioneAutorizzazione,
  783.                     strutsBean.fruizioneAutorizzazioneAutenticati, strutsBean.fruizioneAutorizzazioneRuoli, strutsBean.fruizioneAutorizzazioneRuoliTipologia, strutsBean.fruizioneAutorizzazioneRuoliMatch,
  784.                     allegatoXacmlPolicy,
  785.                     strutsBean.autenticazioneToken,strutsBean.tokenPolicy,
  786.                     strutsBean.autenticazioneApiKey, strutsBean.useOAS3Names, strutsBean.useAppId, strutsBean.apiKeyHeader, strutsBean.apiKeyValue, strutsBean.appIdHeader, strutsBean.appIdValue,
  787.                     listExtendedConnettore);

  788.             // updateDynamic
  789.             if(isOk) {
  790.                 strutsBean.consoleDynamicConfiguration.updateDynamicConfigFruizioneAccordoServizioParteSpecifica(strutsBean.consoleConfiguration, strutsBean.consoleOperationType, apsHelper, strutsBean.protocolProperties,
  791.                         strutsBean.registryReader, strutsBean.configRegistryReader, idFruizione);      
  792.             }
  793.            
  794.             // Validazione base dei parametri custom
  795.             if(isOk){
  796.                 try{
  797.                     apsHelper.validaProtocolProperties(strutsBean.consoleConfiguration, strutsBean.consoleOperationType, strutsBean.protocolProperties);
  798.                 }catch(ProtocolException e){
  799.                     ControlStationCore.getLog().error(e.getMessage(),e);
  800.                     pd.setMessage(e.getMessage());
  801.                     isOk = false;
  802.                 }
  803.             }

  804.             // Valido i parametri custom se ho gia' passato tutta la validazione prevista
  805.             if(isOk){
  806.                 try{
  807.                     //validazione campi dinamici
  808.                     strutsBean.consoleDynamicConfiguration.validateDynamicConfigFruizioneAccordoServizioParteSpecifica(strutsBean.consoleConfiguration, strutsBean.consoleOperationType, apsHelper, strutsBean.protocolProperties,
  809.                             strutsBean.registryReader, strutsBean.configRegistryReader, idFruizione);
  810.                 }catch(ProtocolException e){
  811.                     ControlStationCore.getLog().error(e.getMessage(),e);
  812.                     pd.setMessage(e.getMessage());
  813.                     isOk = false;
  814.                 }
  815.             }


  816.             if (!isOk) {
  817.                 // setto la barra del titolo
  818.                 List<Parameter> lstParm = new ArrayList<>();

  819.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  820.                 lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FUITORI_DI  + tmpTitle,
  821.                         AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_LIST ,
  822.                         new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, ""+ strutsBean.id)
  823.                         //              ,
  824.                         //                      new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, ""+ idSoggErogatore)
  825.                         ));
  826.                 lstParm.add(ServletUtils.getParameterAggiungi());

  827.                 // setto la barra del titolo
  828.                 ServletUtils.setPageDataTitle(pd, lstParm );

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

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

  832.                 // update della configurazione
  833.                 strutsBean.consoleDynamicConfiguration.updateDynamicConfigFruizioneAccordoServizioParteSpecifica(strutsBean.consoleConfiguration, strutsBean.consoleOperationType, apsHelper, strutsBean.protocolProperties,
  834.                         strutsBean.registryReader, strutsBean.configRegistryReader, idFruizione);

  835.                 dati = apsHelper.addHiddenFieldsToDati(tipoOp, strutsBean.id, null, null, dati);

  836.                 dati = apsHelper.addServiziFruitoriToDati(dati, strutsBean.idSoggettoFruitore, strutsBean.wsdlimpler, strutsBean.wsdlimplfru, soggettiList, soggettiListLabel, "0", strutsBean.id, tipoOp,
  837.                         "", "", "", nomeservizio, tiposervizio, versioneservizio, strutsBean.correlato, strutsBean.statoPackage, strutsBean.statoPackage,asps.getStatoPackage(),null,strutsBean.validazioneDocumenti,
  838.                         strutsBean.controlloAccessiStato,
  839.                         strutsBean.fruizioneServizioApplicativo,strutsBean.fruizioneRuolo,strutsBean.fruizioneAutenticazione,strutsBean.fruizioneAutenticazioneOpzionale,strutsBean.fruizioneAutenticazionePrincipal, strutsBean.fruizioneAutenticazioneParametroList, strutsBean.fruizioneAutorizzazione,
  840.                         strutsBean.fruizioneAutorizzazioneAutenticati, strutsBean.fruizioneAutorizzazioneRuoli, strutsBean.fruizioneAutorizzazioneRuoliTipologia, strutsBean.fruizioneAutorizzazioneRuoliMatch,
  841.                         saList,apcCore.toMessageServiceBinding(as.getServiceBinding()), apcCore.formatoSpecifica2InterfaceType(as.getFormatoSpecifica()),
  842.                         null, null, null, null,gestioneToken, policyLabels, policyValues,
  843.                         gestioneTokenPolicy, gestioneTokenOpzionale,
  844.                         gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  845.                         autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  846.                         autorizzazioneToken, autorizzazioneTokenOptions,
  847.                         autorizzazioneScope,scope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  848.                         identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  849.                         autorizzazioneAutenticatiToken,
  850.                         autorizzazioneRuoliToken,  autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);

  851.                 dati = apsHelper.addFruitoreToDati(tipoOp, versioniLabel, versioniValues,
  852.                         dati,null
  853.                         ,null,null,null,null,null,null,null,null,null);

  854.                 if (apsHelper.isModalitaAvanzata()) {
  855.                     dati = apsHelper.addEndPointToDati(dati, apcCore.toMessageServiceBinding(as.getServiceBinding()), strutsBean.connettoreDebug, strutsBean.endpointtype, strutsBean.autenticazioneHttp, null,
  856.                             strutsBean.url, strutsBean.nome, strutsBean.tipo, strutsBean.user,
  857.                             strutsBean.password, strutsBean.initcont, strutsBean.urlpgk,
  858.                             strutsBean.provurl, strutsBean.connfact, strutsBean.sendas,
  859.                             AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,tipoOp,
  860.                             strutsBean.httpsurl, strutsBean.httpstipologia, strutsBean.httpshostverify,
  861.                             strutsBean.httpsTrustVerifyCert, strutsBean.httpspath, strutsBean.httpstipo,
  862.                             strutsBean.httpspwd, strutsBean.httpsalgoritmo, strutsBean.httpsstato,
  863.                             strutsBean.httpskeystore, strutsBean.httpspwdprivatekeytrust,
  864.                             strutsBean.httpspathkey, strutsBean.httpstipokey,
  865.                             strutsBean.httpspwdkey, strutsBean.httpspwdprivatekey,
  866.                             strutsBean.httpsalgoritmokey,
  867.                             strutsBean.httpsKeyAlias, strutsBean.httpsTrustStoreCRLs, strutsBean.httpsTrustStoreOCSPPolicy, strutsBean.httpsKeyStoreBYOKPolicy,
  868.                             strutsBean.tipoconn, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD, null,
  869.                             null, null, null, null, null, null, null, true,
  870.                             isConnettoreCustomUltimaImmagineSalvata,
  871.                             strutsBean.proxyEnabled, strutsBean.proxyHostname, strutsBean.proxyPort, strutsBean.proxyUsername, strutsBean.proxyPassword,
  872.                             strutsBean.tempiRispostaEnabled, strutsBean.tempiRispostaConnectionTimeout, strutsBean.tempiRispostaReadTimeout, strutsBean.tempiRispostaTempoMedioRisposta,
  873.                             strutsBean.opzioniAvanzate, strutsBean.transferMode, strutsBean.transferModeChunkSize, strutsBean.redirectMode, strutsBean.redirectMaxHop,
  874.                             strutsBean.requestOutputFileName, strutsBean.requestOutputFileNamePermissions, strutsBean.requestOutputFileNameHeaders, strutsBean.requestOutputFileNameHeadersPermissions,
  875.                             strutsBean.requestOutputParentDirCreateIfNotExists,strutsBean.requestOutputOverwriteIfExists,
  876.                             strutsBean.responseInputMode, strutsBean.responseInputFileName, strutsBean.responseInputFileNameHeaders, strutsBean.responseInputDeleteAfterRead, strutsBean.responseInputWaitTime,
  877.                             strutsBean.autenticazioneToken,strutsBean.tokenPolicy, forcePDND, forceOAuth,
  878.                             listExtendedConnettore, false,
  879.                             protocollo, forceHttps, forceHttpsClient, false, false, null, null,
  880.                             strutsBean.autenticazioneApiKey, strutsBean.useOAS3Names, strutsBean.useAppId, strutsBean.apiKeyHeader, strutsBean.apiKeyValue, strutsBean.appIdHeader, strutsBean.appIdValue,
  881.                             connettoreStatusParams,
  882.                             postBackViaPost);
  883.                 }else{
  884.                     //spostato dentro l'helper
  885.                 }

  886.                 // aggiunta campi custom
  887.                 dati = apsHelper.addProtocolPropertiesToDatiRegistry(dati, strutsBean.consoleConfiguration,strutsBean.consoleOperationType, strutsBean.protocolProperties);

  888.                 pd.setDati(dati);

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

  890.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,
  891.                         ForwardParams.ADD());
  892.             }

  893.             // Inserisco il fruitore nel db
  894.             int idProv = Integer.parseInt(strutsBean.idSoggettoFruitore);

  895.             // prendo il nome e il tipo del soggetto proprietario della
  896.             // porta delegata
  897.             // che sarebbe il soggetto fruitore di questo servizio
  898.             // Soggetto Fruitore
  899.             Soggetto sogFru = soggettiCore.getSoggettoRegistro(idProv);
  900.             String nomeFruitore = sogFru.getNome();
  901.             String tipoFruitore = sogFru.getTipo();
  902.             String pdd = sogFru.getPortaDominio();


  903.             Connettore connettore = null;
  904.             if (apsHelper.isModalitaAvanzata()) {
  905.                 connettore = new Connettore();
  906.                
  907.                 apsHelper.fillConnettore(connettore, strutsBean.connettoreDebug, strutsBean.endpointtype, strutsBean.endpointtype, strutsBean.tipoconn, strutsBean.url,
  908.                         strutsBean.nome, strutsBean.tipo, strutsBean.user, strutsBean.password,
  909.                         strutsBean.initcont, strutsBean.urlpgk, strutsBean.provurl, strutsBean.connfact,
  910.                         strutsBean.sendas, strutsBean.httpsurl, strutsBean.httpstipologia, strutsBean.httpshostverify,
  911.                         strutsBean.httpsTrustVerifyCert, strutsBean.httpspath, strutsBean.httpstipo,
  912.                         strutsBean.httpspwd, strutsBean.httpsalgoritmo, strutsBean.httpsstato,
  913.                         strutsBean.httpskeystore, strutsBean.httpspwdprivatekeytrust,
  914.                         strutsBean.httpspathkey, strutsBean.httpstipokey,
  915.                         strutsBean.httpspwdkey, strutsBean.httpspwdprivatekey,
  916.                         strutsBean.httpsalgoritmokey,
  917.                         strutsBean.httpsKeyAlias, strutsBean.httpsTrustStoreCRLs, strutsBean.httpsTrustStoreOCSPPolicy, strutsBean.httpsKeyStoreBYOKPolicy,
  918.                         strutsBean.proxyEnabled, strutsBean.proxyHostname, strutsBean.proxyPort, strutsBean.proxyUsername, strutsBean.proxyPassword,
  919.                         strutsBean.tempiRispostaEnabled, strutsBean.tempiRispostaConnectionTimeout, strutsBean.tempiRispostaReadTimeout, strutsBean.tempiRispostaTempoMedioRisposta,
  920.                         strutsBean.opzioniAvanzate, strutsBean.transferMode, strutsBean.transferModeChunkSize, strutsBean.redirectMode, strutsBean.redirectMaxHop,
  921.                         strutsBean.requestOutputFileName, strutsBean.requestOutputFileNamePermissions, strutsBean.requestOutputFileNameHeaders, strutsBean.requestOutputFileNameHeadersPermissions,
  922.                         strutsBean.requestOutputParentDirCreateIfNotExists,strutsBean.requestOutputOverwriteIfExists,
  923.                         strutsBean.responseInputMode, strutsBean.responseInputFileName, strutsBean.responseInputFileNameHeaders, strutsBean.responseInputDeleteAfterRead, strutsBean.responseInputWaitTime,
  924.                         strutsBean.tokenPolicy,
  925.                         strutsBean.apiKeyHeader, strutsBean.apiKeyValue, strutsBean.appIdHeader, strutsBean.appIdValue,
  926.                         connettoreStatusParams,
  927.                         listExtendedConnettore);
  928.             }

  929.             Fruitore fruitore = new Fruitore();
  930.             fruitore.setId(Long.valueOf(idProv));
  931.             fruitore.setTipo(tipoFruitore);
  932.             fruitore.setNome(nomeFruitore);
  933.             fruitore.setConnettore(connettore);

  934.             FormatoSpecifica formato = null;
  935.             if(as!=null) {
  936.                 formato = as.getFormatoSpecifica();
  937.             }
  938.             String wsdlimplerS = strutsBean.wsdlimpler.getValue() != null ? new String(strutsBean.wsdlimpler.getValue()) : null;
  939.             fruitore.setByteWsdlImplementativoErogatore(apsCore.getInterfaceAsByteArray(formato, wsdlimplerS));
  940.             String wsdlimplfruS = strutsBean.wsdlimplfru.getValue() != null ? new String(strutsBean.wsdlimplfru.getValue()) : null;
  941.             fruitore.setByteWsdlImplementativoFruitore(apsCore.getInterfaceAsByteArray(formato, wsdlimplfruS));

  942.             AccordoServizioParteSpecifica servsp = apsCore.getAccordoServizioParteSpecifica(idServizioLong);

  943.             // stato
  944.             fruitore.setStatoPackage(strutsBean.statoPackage);

  945.             /**         Spostato sopra a livello di edit in progress            
  946.             //          //Se l'ASPS riferito e' in stato operativo o finale allora setto la fruizione come operativa.
  947.             //          if(asps.getStatoPackage().equals(StatiAccordo.operativo.toString()) || asps.getStatoPackage().equals(StatiAccordo.finale.toString())){
  948.             //              fruitore.setStatoPackage(StatiAccordo.operativo.toString());
  949.             //          }*/

  950.             // Check stato
  951.             if(apsHelper.isShowGestioneWorkflowStatoDocumenti()){

  952.                 try{
  953.                     apsCore.validaStatoFruitoreAccordoServizioParteSpecifica(fruitore, servsp);
  954.                 }catch(ValidazioneStatoPackageException validazioneException){

  955.                     // Setto messaggio di errore
  956.                     pd.setMessage(validazioneException.toString());

  957.                     // setto la barra del titolo
  958.                     List<Parameter> lstParm = new ArrayList<>();

  959.                     lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS, AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_LIST));
  960.                     lstParm.add(new Parameter(AccordiServizioParteSpecificaCostanti.LABEL_APS_FUITORI_DI  + tmpTitle,
  961.                             AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_LIST ,
  962.                             new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID, ""+ strutsBean.id)
  963.                             //                  ,
  964.                             //                          new Parameter( AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_SOGGETTO_EROGATORE, ""+ idSoggErogatore)
  965.                             ));
  966.                     lstParm.add(ServletUtils.getParameterAggiungi());

  967.                     // setto la barra del titolo
  968.                     ServletUtils.setPageDataTitle(pd, lstParm );

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

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

  972.                     // update della configurazione
  973.                     strutsBean.consoleDynamicConfiguration.updateDynamicConfigFruizioneAccordoServizioParteSpecifica(strutsBean.consoleConfiguration, strutsBean.consoleOperationType, apsHelper, strutsBean.protocolProperties,
  974.                             strutsBean.registryReader, strutsBean.configRegistryReader, idFruizione);

  975.                     dati = apsHelper.addHiddenFieldsToDati(tipoOp, strutsBean.id, null, null, dati);

  976.                     dati = apsHelper.addServiziFruitoriToDati(dati, strutsBean.idSoggettoFruitore, strutsBean.wsdlimpler, strutsBean.wsdlimplfru,
  977.                             soggettiList, soggettiListLabel, "0", strutsBean.id, tipoOp, "", "", "", nomeservizio, tiposervizio, versioneservizio, strutsBean.correlato,
  978.                             strutsBean.statoPackage, strutsBean.statoPackage,asps.getStatoPackage(),null,strutsBean.validazioneDocumenti,
  979.                             strutsBean.controlloAccessiStato,
  980.                             strutsBean.fruizioneServizioApplicativo,strutsBean.fruizioneRuolo,strutsBean.fruizioneAutenticazione,strutsBean.fruizioneAutenticazioneOpzionale,strutsBean.fruizioneAutenticazionePrincipal, strutsBean.fruizioneAutenticazioneParametroList, strutsBean.fruizioneAutorizzazione,
  981.                             strutsBean.fruizioneAutorizzazioneAutenticati, strutsBean.fruizioneAutorizzazioneRuoli, strutsBean.fruizioneAutorizzazioneRuoliTipologia, strutsBean.fruizioneAutorizzazioneRuoliMatch,
  982.                             saList,apcCore.toMessageServiceBinding(as.getServiceBinding()), apcCore.formatoSpecifica2InterfaceType(as.getFormatoSpecifica()),
  983.                             null, null, null, null,gestioneToken, policyLabels, policyValues,
  984.                             gestioneTokenPolicy, gestioneTokenOpzionale,
  985.                             gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  986.                             autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  987.                             autorizzazioneToken, autorizzazioneTokenOptions,
  988.                             autorizzazioneScope,scope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  989.                             identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  990.                             autorizzazioneAutenticatiToken,
  991.                             autorizzazioneRuoliToken,  autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);

  992.                     dati = apsHelper.addFruitoreToDati(TipoOperazione.ADD, versioniLabel, versioniValues, dati,null
  993.                             ,null,null,null,null,null,null,null,null,null);

  994.                     if (apsHelper.isModalitaAvanzata()) {
  995.                         dati = apsHelper.addEndPointToDati(dati, apcCore.toMessageServiceBinding(as.getServiceBinding()), strutsBean.connettoreDebug, strutsBean.endpointtype, strutsBean.autenticazioneHttp, null,
  996.                                 strutsBean.url, strutsBean.nome, strutsBean.tipo, strutsBean.user,
  997.                                 strutsBean.password, strutsBean.initcont, strutsBean.urlpgk,
  998.                                 strutsBean.provurl, strutsBean.connfact, strutsBean.sendas,
  999.                                 AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,tipoOp,
  1000.                                 strutsBean.httpsurl, strutsBean.httpstipologia, strutsBean.httpshostverify,
  1001.                                 strutsBean.httpsTrustVerifyCert, strutsBean.httpspath, strutsBean.httpstipo,
  1002.                                 strutsBean.httpspwd, strutsBean.httpsalgoritmo, strutsBean.httpsstato,
  1003.                                 strutsBean.httpskeystore, strutsBean.httpspwdprivatekeytrust,
  1004.                                 strutsBean.httpspathkey, strutsBean.httpstipokey,
  1005.                                 strutsBean.httpspwdkey, strutsBean.httpspwdprivatekey,
  1006.                                 strutsBean.httpsalgoritmokey,
  1007.                                 strutsBean.httpsKeyAlias, strutsBean.httpsTrustStoreCRLs, strutsBean.httpsTrustStoreOCSPPolicy, strutsBean.httpsKeyStoreBYOKPolicy,
  1008.                                 strutsBean.tipoconn,
  1009.                                 AccordiServizioParteSpecificaCostanti.SERVLET_NAME_APS_FRUITORI_ADD, null,
  1010.                                 null, null, null, null, null, null, null, true,
  1011.                                 isConnettoreCustomUltimaImmagineSalvata,
  1012.                                 strutsBean.proxyEnabled, strutsBean.proxyHostname, strutsBean.proxyPort, strutsBean.proxyUsername, strutsBean.proxyPassword,
  1013.                                 strutsBean.tempiRispostaEnabled, strutsBean.tempiRispostaConnectionTimeout, strutsBean.tempiRispostaReadTimeout, strutsBean.tempiRispostaTempoMedioRisposta,
  1014.                                 strutsBean.opzioniAvanzate, strutsBean.transferMode, strutsBean.transferModeChunkSize, strutsBean.redirectMode, strutsBean.redirectMaxHop,
  1015.                                 strutsBean.requestOutputFileName, strutsBean.requestOutputFileNamePermissions, strutsBean.requestOutputFileNameHeaders, strutsBean.requestOutputFileNameHeadersPermissions,
  1016.                                 strutsBean.requestOutputParentDirCreateIfNotExists,strutsBean.requestOutputOverwriteIfExists,
  1017.                                 strutsBean.responseInputMode, strutsBean.responseInputFileName, strutsBean.responseInputFileNameHeaders, strutsBean.responseInputDeleteAfterRead, strutsBean.responseInputWaitTime,
  1018.                                 strutsBean.autenticazioneToken,strutsBean.tokenPolicy, forcePDND, forceOAuth,
  1019.                                 listExtendedConnettore, false,
  1020.                                 protocollo, forceHttps, forceHttpsClient, false, false, null, null,
  1021.                                 strutsBean.autenticazioneApiKey, strutsBean.useOAS3Names, strutsBean.useAppId, strutsBean.apiKeyHeader, strutsBean.apiKeyValue, strutsBean.appIdHeader, strutsBean.appIdValue,
  1022.                                 connettoreStatusParams,
  1023.                                 postBackViaPost);
  1024.                     }else{
  1025.                         //spostato dentro l'helper
  1026.                     }

  1027.                     // aggiunta campi custom
  1028.                     dati = apsHelper.addProtocolPropertiesToDatiRegistry(dati, strutsBean.consoleConfiguration,strutsBean.consoleOperationType, strutsBean.protocolProperties);

  1029.                     pd.setDati(dati);

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

  1031.                     return ServletUtils.getStrutsForwardEditModeCheckError(mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,
  1032.                             ForwardParams.ADD());
  1033.                 }
  1034.             }

  1035.             //imposto properties custom
  1036.             fruitore.setProtocolPropertyList(ProtocolPropertiesUtils.toProtocolPropertiesRegistry(strutsBean.protocolProperties, strutsBean.consoleOperationType,null));

  1037.             servsp.addFruitore(fruitore);
  1038.             apsCore.setDataCreazioneFruitore(fruitore);
  1039.             apsCore.performUpdateOperation(superUser, apsHelper.smista(), servsp);

  1040.             // Prendo i dati del soggetto erogatore del servizio
  1041.             String mynomeprov = asps.getNomeSoggettoErogatore();
  1042.             String mytipoprov = asps.getTipoSoggettoErogatore();

  1043.             // creo la porta delegata in automatico
  1044.             boolean generazionePortaDelegata = true;
  1045.             /*
  1046.              * bug-fix #61 Se il soggetto (fruitore) afferisce a una porta di
  1047.              * dominio di tipo 'esterno', la porta delegata non deve essere
  1048.              * creata.
  1049.              */
  1050.             try{
  1051.                 if(pddCore.isPddEsterna(pdd)){
  1052.                     generazionePortaDelegata = false;
  1053.                 }
  1054.             }catch(DriverControlStationNotFound dNT){
  1055.                 // In singlePdD la porta di dominio e' opzionale.
  1056.                 if(!apsCore.isSinglePdD()){
  1057.                     throw dNT;
  1058.                 }
  1059.             }
  1060.             if (generazionePortaDelegata) {
  1061.                
  1062.                 List<Object> listaOggettiDaCreare = new ArrayList<>();
  1063.                
  1064.                 IDSoggetto idFruitore = new IDSoggetto(tipoFruitore, nomeFruitore);
  1065.                 IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(tiposervizio, nomeservizio, mytipoprov, mynomeprov, versioneservizio);
  1066.                 ServiceBinding serviceBinding = org.openspcoop2.core.registry.constants.ServiceBinding.REST.equals(as.getServiceBinding()) ?
  1067.                         ServiceBinding.REST : ServiceBinding.SOAP;
  1068.                 ProtocolSubscription subscriptionDefault = strutsBean.protocolFactory.createProtocolIntegrationConfiguration().
  1069.                         createDefaultSubscription(serviceBinding, idFruitore, idServizio);
  1070.                
  1071.                 PortaDelegata portaDelegata = subscriptionDefault.getPortaDelegata();
  1072.                 MappingFruizionePortaDelegata mappingFruizione = subscriptionDefault.getMapping();
  1073.                 portaDelegata.setIdSoggetto((long) idProv);

  1074.                 if(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO_PUBBLICO.equals(strutsBean.controlloAccessiStato)) {
  1075.                     strutsBean.fruizioneAutenticazione = TipoAutenticazione.DISABILITATO.getValue();
  1076.                     strutsBean.fruizioneAutenticazioneOpzionale = null;
  1077.                     strutsBean.fruizioneAutenticazionePrincipal = null;
  1078.                     strutsBean.fruizioneAutenticazioneParametroList = null;
  1079.                 }
  1080.                
  1081.                 if(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_STATO_PUBBLICO.equals(strutsBean.controlloAccessiStato)) {
  1082.                     strutsBean.fruizioneAutorizzazione = TipoAutorizzazione.DISABILITATO.getValue();
  1083.                     strutsBean.fruizioneAutorizzazioneAutenticati = null;
  1084.                     strutsBean.fruizioneAutorizzazioneRuoli = null;
  1085.                     strutsBean.fruizioneAutorizzazioneRuoliTipologia = null;
  1086.                     strutsBean.fruizioneAutorizzazioneRuoliMatch = null;
  1087.                 }
  1088.                
  1089.                 porteDelegateCore.configureControlloAccessiPortaDelegata(portaDelegata,
  1090.                         strutsBean.fruizioneAutenticazione, strutsBean.fruizioneAutenticazioneOpzionale,strutsBean.fruizioneAutenticazionePrincipal, strutsBean.fruizioneAutenticazioneParametroList,
  1091.                         strutsBean.fruizioneAutorizzazione, strutsBean.fruizioneAutorizzazioneAutenticati, strutsBean.fruizioneAutorizzazioneRuoli, strutsBean.fruizioneAutorizzazioneRuoliTipologia, strutsBean.fruizioneAutorizzazioneRuoliMatch,
  1092.                         strutsBean.fruizioneServizioApplicativo, strutsBean.fruizioneRuolo,
  1093.                         autorizzazioneAutenticatiToken,
  1094.                         autorizzazioneRuoliToken,  autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken,
  1095.                         autorizzazioneTokenOptions,
  1096.                         autorizzazioneScope,scope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  1097.                         identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi);
  1098.                
  1099.                 porteDelegateCore.configureControlloAccessiGestioneToken(portaDelegata, gestioneToken,
  1100.                         gestioneTokenPolicy, gestioneTokenOpzionale,
  1101.                         gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  1102.                         autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  1103.                         autorizzazioneTokenOptions
  1104.                         );
  1105.                            
  1106.                 // Verifico prima che la porta delegata non esista giĆ 
  1107.                 if (!porteDelegateCore.existsPortaDelegata(mappingFruizione.getIdPortaDelegata())){
  1108.                     listaOggettiDaCreare.add(portaDelegata);
  1109.                 }
  1110.                 listaOggettiDaCreare.add(mappingFruizione);
  1111.                
  1112.                 porteDelegateCore.performCreateOperation(superUser, apsHelper.smista(), listaOggettiDaCreare.toArray());
  1113.             }


  1114.             // cancello i file temporanei
  1115.             apsHelper.deleteBinaryParameters(strutsBean.wsdlimpler,strutsBean.wsdlimplfru);
  1116.             apsHelper.deleteBinaryProtocolPropertiesTmpFiles(strutsBean.protocolProperties);

  1117.             // Preparo la lista
  1118.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);

  1119.             int idLista = Liste.SERVIZI_FRUITORI;

  1120.             ricerca = apsHelper.checkSearchParameters(idLista, ricerca);

  1121.             List<Fruitore> lista = apsCore.serviziFruitoriList(Integer.parseInt(strutsBean.id), ricerca);

  1122.             apsHelper.prepareServiziFruitoriList(lista, strutsBean.id, ricerca);

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

  1124.             return ServletUtils.getStrutsForwardEditModeFinished( mapping, AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,
  1125.                     ForwardParams.ADD());

  1126.         } catch (Exception e) {
  1127.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  1128.                     AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_FRUITORI,
  1129.                     ForwardParams.ADD());
  1130.         }  
  1131.     }

  1132.    
  1133. }