ServiziApplicativiEndPointInvocazioneServizio.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.sa;

  21. import java.util.ArrayList;
  22. import java.util.List;
  23. import java.util.Map;

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

  29. import org.apache.commons.lang.StringUtils;
  30. import org.apache.struts.action.Action;
  31. import org.apache.struts.action.ActionForm;
  32. import org.apache.struts.action.ActionForward;
  33. import org.apache.struts.action.ActionMapping;
  34. import org.openspcoop2.core.commons.CoreException;
  35. import org.openspcoop2.core.commons.Filtri;
  36. import org.openspcoop2.core.commons.Liste;
  37. import org.openspcoop2.core.config.Connettore;
  38. import org.openspcoop2.core.config.Credenziali;
  39. import org.openspcoop2.core.config.InvocazioneCredenziali;
  40. import org.openspcoop2.core.config.InvocazionePorta;
  41. import org.openspcoop2.core.config.InvocazioneServizio;
  42. import org.openspcoop2.core.config.PortaApplicativa;
  43. import org.openspcoop2.core.config.PortaApplicativaServizioApplicativo;
  44. import org.openspcoop2.core.config.Property;
  45. import org.openspcoop2.core.config.ServizioApplicativo;
  46. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  47. import org.openspcoop2.core.config.constants.CredenzialeTipo;
  48. import org.openspcoop2.core.config.constants.InvocazioneServizioTipoAutenticazione;
  49. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  50. import org.openspcoop2.core.config.constants.TipologiaErogazione;
  51. import org.openspcoop2.core.config.driver.db.IDServizioApplicativoDB;
  52. import org.openspcoop2.core.constants.CostantiConnettori;
  53. import org.openspcoop2.core.constants.CostantiDB;
  54. import org.openspcoop2.core.constants.TipiConnettore;
  55. import org.openspcoop2.core.constants.TransferLengthModes;
  56. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  57. import org.openspcoop2.core.id.IDServizio;
  58. import org.openspcoop2.core.id.IDServizioApplicativo;
  59. import org.openspcoop2.core.id.IDSoggetto;
  60. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  61. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  62. import org.openspcoop2.core.registry.Soggetto;
  63. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  64. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  65. import org.openspcoop2.message.constants.ServiceBinding;
  66. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  67. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  68. import org.openspcoop2.web.ctrlstat.costanti.ConnettoreServletType;
  69. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  70. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettore;
  71. import org.openspcoop2.web.ctrlstat.plugins.servlet.ServletExtendedConnettoreUtils;
  72. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  73. import org.openspcoop2.web.ctrlstat.servlet.OggettoDialogEnum;
  74. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  75. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  76. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  77. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaHelper;
  78. import org.openspcoop2.web.ctrlstat.servlet.aps.erogazioni.ErogazioniCostanti;
  79. import org.openspcoop2.web.ctrlstat.servlet.aps.erogazioni.ErogazioniHelper;
  80. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  81. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoreStatusParams;
  82. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  83. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriHelper;
  84. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCore;
  85. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCostanti;
  86. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateCostanti;
  87. import org.openspcoop2.web.ctrlstat.servlet.pdd.PddCore;
  88. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  89. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  90. import org.openspcoop2.web.lib.mvc.Costanti;
  91. import org.openspcoop2.web.lib.mvc.DataElement;
  92. import org.openspcoop2.web.lib.mvc.ForwardParams;
  93. import org.openspcoop2.web.lib.mvc.GeneralData;
  94. import org.openspcoop2.web.lib.mvc.PageData;
  95. import org.openspcoop2.web.lib.mvc.Parameter;
  96. import org.openspcoop2.web.lib.mvc.ServletUtils;
  97. import org.openspcoop2.web.lib.mvc.TipoOperazione;
  98. import org.openspcoop2.web.lib.users.dao.PermessiUtente;

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

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

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

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

  115.         GeneralHelper generalHelper = new GeneralHelper(session);

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

  118.         try {

  119.             ServiziApplicativiHelper saHelper = new ServiziApplicativiHelper(request, pd, session);
  120.            
  121.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione
  122.             Integer parentSA = ServletUtils.getIntegerAttributeFromSession(ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT, session, request);
  123.             if(parentSA == null) parentSA = ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_NONE;
  124.             boolean useIdSogg = (parentSA!=null && parentSA.intValue() == ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_SOGGETTO);
  125.             Boolean vistaErogazioni = ServletUtils.getBooleanAttributeFromSession(ErogazioniCostanti.ASPS_EROGAZIONI_ATTRIBUTO_VISTA_EROGAZIONI, session, request).getValue();

  126.             boolean isModalitaCompleta = saHelper.isModalitaCompleta();

  127.             String nomeservizioApplicativo = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_NOME_SERVIZIO_APPLICATIVO);
  128.             String idsil = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_SERVIZIO_APPLICATIVO);
  129.             int idSilInt = Integer.parseInt(idsil);
  130.             String sbustamento = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_SBUSTAMENTO_SOAP);
  131.             String sbustamentoInformazioniProtocolloRichiesta = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_SBUSTAMENTO_INFO_PROTOCOLLO_RICHIESTA);
  132.             String getmsg = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_MESSAGE_BOX);
  133.             String getmsgUsername = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  134.             String getmsgPassword = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  135.             String changepwd = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CHANGE_PASSWORD);
  136.             String tipoCredenzialiSSLVerificaTuttiICampi = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI);
  137.             if (tipoCredenzialiSSLVerificaTuttiICampi == null) {
  138.                 tipoCredenzialiSSLVerificaTuttiICampi = ConnettoriCostanti.DEFAULT_VALUE_PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CONFIGURAZIONE_SSL_VERIFICA_TUTTI_CAMPI;
  139.             }
  140.            
  141.             String invrifRichiesta = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_INVIO_PER_RIFERIMENTO_RICHIESTA);

  142.             String risprif = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_RISPOSTA_PER_RIFERIMENTO);

  143.             String tipoauthRichiesta = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_TIPO_AUTENTICAZIONE);

  144.             String provider = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER);
  145.             if(provider == null){
  146.                 provider = "";
  147.             }
  148.             String idPorta = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_PORTA);
  149.             if(idPorta == null)
  150.                 idPorta = "";

  151.             String idAsps = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_ASPS);
  152.             if(idAsps == null)
  153.                 idAsps = "";

  154.             String endpointtype = saHelper.readEndPointType();
  155.             String tipoconn = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO);
  156.             String autenticazioneHttp = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);
  157.             String user = null;
  158.             String password = null;

  159.             String connettoreDebug = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_DEBUG);

  160.             // token policy
  161.             String autenticazioneTokenS = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  162.             boolean autenticazioneToken = ServletUtils.isCheckBoxEnabled(autenticazioneTokenS);
  163.             String tokenPolicy = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY);
  164.             boolean forcePDND = false;
  165.             boolean forceOAuth = false;

  166.             // proxy
  167.             String proxyEnabled = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  168.             String proxyHostname = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  169.             String proxyPort = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PORT);
  170.             String proxyUsername = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_USERNAME);
  171.             String proxyPassword = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PASSWORD);

  172.             // tempi risposta
  173.             String tempiRispostaEnabled = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  174.             String tempiRispostaConnectionTimeout = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  175.             String tempiRispostaReadTimeout = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  176.             String tempiRispostaTempoMedioRisposta = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);

  177.             // opzioni avanzate
  178.             String transferMode = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  179.             String transferModeChunkSize = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  180.             String redirectMode = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  181.             String redirectMaxHop = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  182.             String opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(saHelper, transferMode, redirectMode);

  183.             // http
  184.             String url = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL);
  185.             if(TipiConnettore.HTTP.toString().equals(endpointtype)){
  186.                 user = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  187.                 password = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  188.             }

  189.             // api key
  190.             String autenticazioneApiKey = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_API_KEY);
  191.             String apiKeyHeader = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_HEADER);
  192.             if(apiKeyHeader==null || StringUtils.isEmpty(apiKeyHeader)) {
  193.                 apiKeyHeader = CostantiConnettori.DEFAULT_HEADER_API_KEY;
  194.             }
  195.             String apiKeyValue = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_VALUE);
  196.             String appIdHeader = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  197.             if(appIdHeader==null || StringUtils.isEmpty(appIdHeader)) {
  198.                 appIdHeader = CostantiConnettori.DEFAULT_HEADER_APP_ID;
  199.             }
  200.             String appIdValue = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  201.             String useOAS3NamesTmp = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  202.             boolean useOAS3Names=true;
  203.             if(useOAS3NamesTmp!=null && StringUtils.isNotEmpty(useOAS3NamesTmp)) {
  204.                 useOAS3Names = ServletUtils.isCheckBoxEnabled(useOAS3NamesTmp);
  205.             }
  206.             else {
  207.                 useOAS3Names = saHelper.isAutenticazioneApiKeyUseOAS3Names(apiKeyHeader, appIdHeader);
  208.             }
  209.             String useAppIdTmp = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  210.             boolean useAppId=false;
  211.             if(useAppIdTmp!=null && StringUtils.isNotEmpty(useAppIdTmp)) {
  212.                 useAppId = ServletUtils.isCheckBoxEnabled(useAppIdTmp);
  213.             }
  214.             else {
  215.                 useAppId = saHelper.isAutenticazioneApiKeyUseAppId(appIdValue);
  216.             }
  217.            
  218.             // jms
  219.             String nome = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_NOME_CODA);
  220.             String tipo = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_CODA);
  221.             String initcont = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_INIT_CTX);
  222.             String urlpgk = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_URL_PKG);
  223.             String provurl = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PROVIDER_URL);
  224.             String connfact = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_CONNECTION_FACTORY);
  225.             String sendas = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_OGGETTO_JMS);
  226.             if(TipiConnettore.JMS.toString().equals(endpointtype)){
  227.                 user = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_USERNAME);
  228.                 password = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PASSWORD);
  229.             }

  230.             // https
  231.             String httpsurl = url;
  232.             String httpstipologia = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_SSL_TYPE);
  233.             String httpshostverifyS = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_HOST_VERIFY);
  234.             boolean httpshostverify = ServletUtils.isCheckBoxEnabled(httpshostverifyS);
  235.             String httpsTrustVerifyCertS = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS );
  236.             boolean httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  237.             String httpspath = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_LOCATION);
  238.             String httpstipo = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  239.             String httpspwd = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  240.             String httpsalgoritmo = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  241.             String httpsstatoS = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO);
  242.             boolean httpsstato = ServletUtils.isCheckBoxEnabled(httpsstatoS);
  243.             String httpskeystore = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE);
  244.             String httpspwdprivatekeytrust = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_STORE);
  245.             String httpspathkey = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  246.             String httpstipokey = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_TYPE);
  247.             String httpspwdkey = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  248.             String httpspwdprivatekey = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_KEYSTORE);
  249.             String httpsalgoritmokey = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  250.             String httpsKeyAlias = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_ALIAS_PRIVATE_KEY_KEYSTORE);
  251.             String httpsTrustStoreCRLs = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL);
  252.             String httpsTrustStoreOCSPPolicy = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  253.             String httpsKeyStoreBYOKPolicy = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  254.             if(TipiConnettore.HTTPS.toString().equals(endpointtype)){
  255.                 user = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  256.                 password = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  257.             }

  258.             // file
  259.             String requestOutputFileName = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME);
  260.             String requestOutputFileNamePermissions = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_PERMISSIONS);
  261.             String requestOutputFileNameHeaders = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS);
  262.             String requestOutputFileNameHeadersPermissions = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS);
  263.             String requestOutputParentDirCreateIfNotExists = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  264.             String requestOutputOverwriteIfExists = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE_NAME);
  265.             String responseInputMode = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  266.             String responseInputFileName = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME);
  267.             String responseInputFileNameHeaders = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS);
  268.             String responseInputDeleteAfterRead = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_DELETE_AFTER_READ);
  269.             String responseInputWaitTime = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);

  270.             //status
  271.             ConnettoreStatusParams connettoreStatusParams = ConnettoreStatusParams.fillFrom(saHelper);
  272.            
  273.             String erogazioneServizioApplicativoServerEnabledS = saHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ABILITA_USO_APPLICATIVO_SERVER);
  274.             boolean erogazioneServizioApplicativoServerEnabled = ServletUtils.isCheckBoxEnabled(erogazioneServizioApplicativoServerEnabledS);
  275.             String erogazioneServizioApplicativoServer = saHelper.getParameter(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ID_APPLICATIVO_SERVER);

  276.             String tipologia = ServletUtils.getObjectFromSession(request, session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  277.             boolean gestioneErogatori = false;
  278.             if(tipologia!=null &&
  279.                 AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  280.                 gestioneErogatori = true;
  281.             }

  282.             boolean accessoDaListaAPS = false;
  283.             String accessoDaAPSParametro = null;
  284.             // nell'erogazione vale sempre
  285.             accessoDaAPSParametro = saHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS);
  286.             if(Costanti.CHECK_BOX_ENABLED_TRUE.equals(accessoDaAPSParametro)) {
  287.                 accessoDaListaAPS = true;
  288.             }

  289.             boolean fromConfig = (parentSA!=null && (parentSA.intValue() == ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_CONFIGURAZIONE));
  290.             String idTab = saHelper.getParameter(CostantiControlStation.PARAMETRO_ID_TAB);
  291.             if(fromConfig && !saHelper.isModalitaCompleta() && StringUtils.isNotEmpty(idTab)) {
  292.                 ServletUtils.setObjectIntoSession(request, session, idTab, CostantiControlStation.PARAMETRO_ID_TAB);
  293.             }
  294.            
  295.             boolean postBackViaPost = true;
  296.            
  297.             // Preparo il menu
  298.             saHelper.makeMenu();

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

  300.             // Prendo il sil
  301.             ServiziApplicativiCore saCore = new ServiziApplicativiCore();
  302.             PddCore pddCore = new PddCore(saCore);
  303.             SoggettiCore soggettiCore = new SoggettiCore(saCore);
  304.             PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore(saCore);
  305.             PortaApplicativa pa = null;
  306.             if(StringUtils.isNotBlank(idPorta)) {
  307.                 pa = porteApplicativeCore.getPortaApplicativa(Long.parseLong(idPorta));
  308.             }

  309.             boolean isApplicativiServerEnabled = saCore.isApplicativiServerEnabled(saHelper);
  310.             if(!isApplicativiServerEnabled) {
  311.                 erogazioneServizioApplicativoServerEnabled = false;
  312.             }

  313.             // La lista degli SA viene filtrata per tipo se sono abilitati gli applicativiServer.
  314.             String filtroTipoSA = (isApplicativiServerEnabled && gestioneErogatori) ? ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER : null;

  315.             ServizioApplicativo sa = saCore.getServizioApplicativo(idSilInt);
  316.             String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(sa.getTipoSoggettoProprietario());
  317.             InvocazionePorta invocazionePorta = sa.getInvocazionePorta();
  318.             InvocazioneServizio is = sa.getInvocazioneServizio();
  319.             if(is==null) {
  320.                 throw new CoreException("ServizioApplicativo con id '"+idSilInt+"' senza InvocazioneServizio");
  321.             }
  322.             InvocazioneCredenziali cis = is.getCredenziali();
  323.             Connettore connis = is.getConnettore();
  324.             if(connis==null) {
  325.                 throw new CoreException("ServizioApplicativo con id '"+idSilInt+"' senza connettore in InvocazioneServizio");
  326.             }
  327.             List<Property> cp = connis.getPropertyList();
  328.             String tipoSA = sa.getTipo();
  329.            
  330.             String postBackElementName = saHelper.getPostBackElementName();
  331.             // Controllo se ho modificato l'azione allora ricalcolo il nome
  332.             if(postBackElementName != null ){
  333.                
  334.                 if(postBackElementName.equalsIgnoreCase(AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_ABILITA_USO_APPLICATIVO_SERVER) &&
  335.                     // se il vecchio SA era di tipo server e ripristino il default allora resetto la creazione del connettore
  336.                     ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo()) && !erogazioneServizioApplicativoServerEnabled) {
  337.                     // 1. leggo SA di default
  338.                    
  339.                     if(pa==null) {
  340.                         throw new CoreException("Porta is null");
  341.                     }
  342.                    
  343.                     IDServizioApplicativo idSA = new IDServizioApplicativo();
  344.                     idSA.setNome(pa.getServizioApplicativoDefault());
  345.                     IDSoggetto idSoggettoProprietario = new IDSoggetto();
  346.                     idSoggettoProprietario.setTipo(pa.getTipoSoggettoProprietario());
  347.                     idSoggettoProprietario.setNome(pa.getNomeSoggettoProprietario());
  348.                     idSA.setIdSoggettoProprietario(idSoggettoProprietario );
  349.                     sa = saCore.getServizioApplicativo(idSA);
  350.                     invocazionePorta = sa.getInvocazionePorta();
  351.                     is = sa.getInvocazioneServizio();
  352.                     cis = is.getCredenziali();
  353.                     connis = is.getConnettore();
  354.                     cp = connis.getPropertyList();
  355.                     tipoSA = sa.getTipo();
  356.                    
  357.                     // reset dei fields
  358.                     erogazioneServizioApplicativoServer = null;
  359.                    
  360.                     sbustamento = null;
  361.                     sbustamentoInformazioniProtocolloRichiesta = null;
  362.                     getmsg = null;
  363.                     getmsgUsername = null;
  364.                     getmsgPassword = null;
  365.                     invrifRichiesta = null;
  366.                     risprif = null;
  367.                     tipoauthRichiesta = null;
  368.                     endpointtype = saHelper.readEndPointType();
  369.                     tipoconn = null;
  370.                     autenticazioneHttp = null;
  371.                     user = null;
  372.                     password = null;
  373.                     connettoreDebug = null;

  374.                     // token policy
  375.                     autenticazioneTokenS = null;
  376.                     autenticazioneToken = ServletUtils.isCheckBoxEnabled(autenticazioneTokenS);
  377.                     tokenPolicy = null;

  378.                     // proxy
  379.                     proxyEnabled = null;
  380.                     proxyHostname = null;
  381.                     proxyPort = null;
  382.                     proxyUsername = null;
  383.                     proxyPassword = null;

  384.                     // tempi risposta
  385.                     tempiRispostaEnabled = null;
  386.                     tempiRispostaConnectionTimeout = null;
  387.                     tempiRispostaReadTimeout = null;
  388.                     tempiRispostaTempoMedioRisposta = null;

  389.                     // opzioni avanzate
  390.                     transferMode = null;
  391.                     transferModeChunkSize = null;
  392.                     redirectMode = null;
  393.                     redirectMaxHop = null;
  394.                     opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(saHelper, transferMode, redirectMode);

  395.                     // http
  396.                     url = null;

  397.                     // jms
  398.                     nome = null;
  399.                     tipo = null;
  400.                     initcont = null;
  401.                     urlpgk = null;
  402.                     provurl = null;
  403.                     connfact = null;
  404.                     sendas = null;

  405.                     // https
  406.                     httpsurl = url;
  407.                     httpstipologia = null;
  408.                     httpshostverifyS = null;
  409.                     httpshostverify = ServletUtils.isCheckBoxEnabled(httpshostverifyS);
  410.                     httpsTrustVerifyCertS=null;
  411.                     httpsTrustVerifyCert = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS;
  412.                     httpspath = null;
  413.                     httpstipo = null;
  414.                     httpspwd = null;
  415.                     httpsalgoritmo = null;
  416.                     httpsstatoS = null;
  417.                     httpsstato = ServletUtils.isCheckBoxEnabled(httpsstatoS);
  418.                     httpskeystore = null;
  419.                     httpspwdprivatekeytrust = null;
  420.                     httpspathkey = null;
  421.                     httpstipokey = null;
  422.                     httpspwdkey = null;
  423.                     httpspwdprivatekey = null;
  424.                     httpsalgoritmokey = null;
  425.                     httpsKeyAlias = null;
  426.                     httpsTrustStoreCRLs = null;
  427.                     httpsTrustStoreOCSPPolicy = null;
  428.                     httpsKeyStoreBYOKPolicy = null;

  429.                     // file
  430.                     requestOutputFileName = null;
  431.                     requestOutputFileNamePermissions = null;
  432.                     requestOutputFileNameHeaders = null;
  433.                     requestOutputFileNameHeadersPermissions = null;
  434.                     requestOutputParentDirCreateIfNotExists = null;
  435.                     requestOutputOverwriteIfExists = null;
  436.                     responseInputMode = null;
  437.                     responseInputFileName = null;
  438.                     responseInputFileNameHeaders = null;
  439.                     responseInputDeleteAfterRead = null;
  440.                     responseInputWaitTime = null;
  441.                    
  442.                     // status
  443.                     connettoreStatusParams = null;
  444.                 }
  445.                
  446.                 // Change Password basic/api
  447.                 if(postBackElementName.equalsIgnoreCase(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_CHANGE_PASSWORD) &&
  448.                     !ServletUtils.isCheckBoxEnabled(changepwd) &&
  449.                     invocazionePorta != null && invocazionePorta.sizeCredenzialiList()>0){
  450.                     getmsgPassword = invocazionePorta.getCredenziali(0).getPassword();
  451.                 }
  452.             }

  453.             boolean forceEnabled = false;
  454.             if(parentSA!=null && (parentSA.intValue() == ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_CONFIGURAZIONE)) {
  455.                 if(
  456.                         //va visualizzato comunque se già configurato: !saHelper.isModalitaStandard() &&
  457.                         ( (getmsg!=null && CostantiConfigurazione.ABILITATO.toString().equals(getmsg))
  458.                                 ||
  459.                                 (getmsg==null && is!=null && is.getGetMessage()!=null && StatoFunzionalita.ABILITATO.equals(is.getGetMessage()))
  460.                                 )
  461.                         ) {
  462.                     forceEnabled = false;
  463.                 }
  464.                 else {
  465.                     forceEnabled = true;
  466.                     if(endpointtype==null) {
  467.                         if( connis==null || connis.getTipo()==null || TipiConnettore.DISABILITATO.getNome().equals(connis.getTipo()) ) {
  468.                             endpointtype = TipiConnettore.HTTP.getNome();
  469.                         }
  470.                     }
  471.                     else if(TipiConnettore.DISABILITATO.getNome().equals(endpointtype)) {
  472.                         endpointtype = TipiConnettore.HTTP.getNome();
  473.                     }
  474.                 }
  475.             }

  476.             String nomeProtocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(sa.getTipoSoggettoProprietario());
  477.             long soggLong = -1;
  478.             // se ho fatto la add
  479.             if(useIdSogg &&
  480.                 provider != null && !provider.equals("")){
  481.                 soggLong = Long.parseLong(provider);
  482.             }

  483.             Boolean isConnettoreCustomUltimaImmagineSalvata = connis.getCustom();

  484.             List<ExtendedConnettore> listExtendedConnettore =
  485.                     ServletExtendedConnettoreUtils.getExtendedConnettore(connis, ConnettoreServletType.SERVIZIO_APPLICATIVO_INVOCAZIONE_SERVIZIO, saHelper,
  486.                             (endpointtype==null), endpointtype); // uso endpointtype per capire se è la prima volta che entro


  487.             List<Parameter> lstParm = saHelper.getTitoloSA(parentSA, provider, idAsps, idPorta);

  488.             boolean integrationManagerEnabled = !saHelper.isModalitaStandard() && saCore.isIntegrationManagerEnabled();
  489.                        
  490.             ServiceBinding serviceBinding = null;
  491.             String labelPerPorta = null;
  492.             if(parentSA!=null && (parentSA.intValue() == ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_CONFIGURAZIONE)) {

  493.                 AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(saCore);
  494.                 AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(idAsps));

  495.                 if(accessoDaListaAPS) {
  496.                     if(!isModalitaCompleta) {
  497.                         if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  498.                             labelPerPorta = ErogazioniCostanti.LABEL_ASPS_PORTE_APPLICATIVE_MODIFICA_CONNETTORE;
  499.                         } else {
  500.                             labelPerPorta = PorteDelegateCostanti.LABEL_PARAMETRO_PORTE_DELEGATE_CONNETTORE_DI+
  501.                                     saHelper.getLabelIdServizio(asps);
  502.                         }
  503.                     }
  504.                     else {
  505.                         labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE;
  506.                     }
  507.                 }
  508.                 else {
  509.                    
  510.                     labelPerPorta = porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  511.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DI,
  512.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE,
  513.                             pa);
  514.                 }

  515.                 AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(apsCore);
  516.                 AccordoServizioParteComuneSintetico apc = apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  517.                 serviceBinding = apcCore.toMessageServiceBinding(apc.getServiceBinding());
  518.                
  519.                 boolean isSoapOneWay = false;
  520.                 if(pa!=null) {
  521.                     MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa = porteApplicativeCore.getMappingErogazionePortaApplicativa(pa);
  522.                     isSoapOneWay = saHelper.isSoapOneWay(pa, mappingErogazionePortaApplicativa, asps, apc, serviceBinding);
  523.                 }
  524.                 integrationManagerEnabled = integrationManagerEnabled && isSoapOneWay;
  525.             }
  526.             else {
  527.                 labelPerPorta = ServiziApplicativiCostanti.LABEL_PARAMETRO_SERVIZI_APPLICATIVI_INVOCAZIONE_SERVIZIO_DI+nomeservizioApplicativo;
  528.             }

  529.             // Lista dei servizi applicativi per la creazione automatica
  530.             List<IDServizioApplicativoDB> listaIdSAServer = null;
  531.             if ((provider != null) && !provider.equals("")) {
  532.                 int idErogatore = Integer.parseInt(provider);

  533.                 // I servizi applicativi da visualizzare sono quelli che hanno
  534.                 // -Integration Manager (getMessage abilitato)
  535.                 // -connettore != disabilitato
  536.                 listaIdSAServer = saCore.getIdServiziApplicativiWithIdErogatore(Long.valueOf(idErogatore), filtroTipoSA, integrationManagerEnabled, true);

  537.             }
  538.            
  539.             if(accessoDaListaAPS) {
  540.                 lstParm.remove(lstParm.size()-1);
  541.             }
  542.            
  543.             lstParm.add(new Parameter(labelPerPorta,null));

  544.             // Se nomehid = null, devo visualizzare la pagina per la
  545.             // modifica dati
  546.             if(saHelper.isEditModeInProgress()){

  547.                 // setto la barra del titolo
  548.                 ServletUtils.setPageDataTitle(pd, lstParm);

  549.                 // Prendo i dati dal db solo se non sono stati passati
  550.                 // controllo se servizio applicativo appartiene a soggetto con
  551.                 // pdd esterna
  552.                 long idProprietario = sa.getIdSoggetto();
  553.                 if(saCore.isRegistroServiziLocale()){
  554.                     Soggetto soggetto = soggettiCore.getSoggettoRegistro(idProprietario);
  555.                     String nomePdd = soggetto.getPortaDominio();
  556.                     if(pddCore.isPddEsterna(nomePdd)){
  557.                         pd.setMessage("Impossibile Effettuare operazioni su Connettore.<br>Questo Servizio Applicativo appartiene ad un Soggetto associato ad una Porta di Dominio con tipo 'esterno'");
  558.                         ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  559.                         return ServletUtils.getStrutsForwardGeneralError(mapping, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,
  560.                                 ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_INVOCAZIONE_SERVIZIO);
  561.                     }
  562.                 }

  563.                 if (erogazioneServizioApplicativoServer == null && isApplicativiServerEnabled &&
  564.                     // se in configurazione ho selezionato un server
  565.                     ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(tipoSA)) {
  566.                     erogazioneServizioApplicativoServer = sa.getNome();
  567.                     erogazioneServizioApplicativoServerEnabled = true;
  568.                 }

  569.                 if (sbustamento == null &&
  570.                     is.getSbustamentoSoap()!=null) {
  571.                     sbustamento = is.getSbustamentoSoap().toString();
  572.                 }
  573.                 if (sbustamentoInformazioniProtocolloRichiesta == null &&
  574.                     is.getSbustamentoInformazioniProtocollo()!=null) {
  575.                     sbustamentoInformazioniProtocolloRichiesta = is.getSbustamentoInformazioniProtocollo().toString();
  576.                 }
  577.                 if (getmsg == null &&
  578.                     is.getGetMessage()!=null) {
  579.                     getmsg = is.getGetMessage().toString();
  580.                     if(CostantiConfigurazione.ABILITATO.toString().equals(getmsg) &&
  581.                         invocazionePorta!=null && invocazionePorta.sizeCredenzialiList()>0) {
  582.                         for (int i = 0; i < invocazionePorta.sizeCredenzialiList(); i++) {
  583.                             Credenziali c = invocazionePorta.getCredenziali(i);
  584.                             if(CredenzialeTipo.BASIC.equals(c.getTipo())) {
  585.                                 getmsgUsername = c.getUser();
  586.                                 getmsgPassword = c.getPassword();
  587.                                 tipoCredenzialiSSLVerificaTuttiICampi = c.isCertificateStrictVerification() ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED;
  588.                                 break;
  589.                             }
  590.                         }
  591.                     }
  592.                 }
  593.                
  594.                 if(!integrationManagerEnabled && CostantiConfigurazione.ABILITATO.toString().equals(getmsg)) {
  595.                     // faccio vedere I.M. anche con interfaccia standard
  596.                     integrationManagerEnabled = true;
  597.                    
  598.                     forceEnabled = false;
  599.                    
  600.                     if(erogazioneServizioApplicativoServerEnabled && ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo())) {
  601.                         if(listaIdSAServer==null) {
  602.                             listaIdSAServer = new ArrayList<>();
  603.                         }
  604.                         boolean found = false;
  605.                         for (IDServizioApplicativo idServizioApplicativo : listaIdSAServer) {
  606.                             if(idServizioApplicativo.getNome().equals(sa.getNome())) {
  607.                                 found = true;
  608.                                 break;
  609.                             }
  610.                         }
  611.                         if(!found) {
  612.                             IDServizioApplicativoDB idSA = new IDServizioApplicativoDB();
  613.                             idSA.setNome(sa.getNome());
  614.                             idSA.setIdSoggettoProprietario(new IDSoggetto(sa.getTipoSoggettoProprietario(), sa.getNomeSoggettoProprietario()));
  615.                             idSA.setId(sa.getId());
  616.                             listaIdSAServer.add(idSA);
  617.                         }
  618.                     }
  619.                    
  620.                 }

  621.                 if (invrifRichiesta == null) {
  622.                     if(is.getInvioPerRiferimento()!=null)
  623.                         invrifRichiesta = is.getInvioPerRiferimento().toString();
  624.                     if ((invrifRichiesta == null) || "".equals(invrifRichiesta)) {
  625.                         invrifRichiesta = CostantiConfigurazione.DISABILITATO.toString();
  626.                     }
  627.                 }
  628.                 if (risprif == null) {
  629.                     if(is.getRispostaPerRiferimento()!=null)
  630.                         risprif = is.getRispostaPerRiferimento().toString();
  631.                     if ((risprif == null) || "".equals(risprif)) {
  632.                         risprif = CostantiConfigurazione.DISABILITATO.toString();
  633.                     }
  634.                 }

  635.                 if ((tipoauthRichiesta == null) && (is != null) && is.getAutenticazione()!=null) {
  636.                     tipoauthRichiesta = is.getAutenticazione().getValue();
  637.                 }
  638.                 if ((user == null) && (cis != null)) {
  639.                     user = cis.getUser();
  640.                     password = cis.getPassword();
  641.                 }
  642.                 if (endpointtype == null) {
  643.                     if ((connis.getCustom()!=null && connis.getCustom()) &&
  644.                             !connis.getTipo().equals(TipiConnettore.HTTPS.toString()) &&
  645.                             !connis.getTipo().equals(TipiConnettore.FILE.toString()) &&
  646.                             !connis.getTipo().equals(TipiConnettore.STATUS.toString())) {
  647.                         endpointtype = TipiConnettore.CUSTOM.toString();
  648.                         tipoconn = connis.getTipo();
  649.                     } else
  650.                         endpointtype = connis.getTipo();
  651.                 }

  652.                 Map<String, String> props = null;
  653.                 if(is!=null && is.getConnettore()!=null)
  654.                     props = is.getConnettore().getProperties();

  655.                 if(connettoreDebug==null && props!=null){
  656.                     String v = props.get(CostantiDB.CONNETTORE_DEBUG);
  657.                     if(v!=null){
  658.                         if("true".equals(v)){
  659.                             connettoreDebug = Costanti.CHECK_BOX_ENABLED;
  660.                         }
  661.                         else{
  662.                             connettoreDebug = Costanti.CHECK_BOX_DISABLED;
  663.                         }
  664.                     }
  665.                 }

  666.                 if(proxyEnabled==null && props!=null){
  667.                     String v = props.get(CostantiDB.CONNETTORE_PROXY_TYPE);
  668.                     if(v!=null && !"".equals(v)){
  669.                         proxyEnabled = Costanti.CHECK_BOX_ENABLED_TRUE;

  670.                         // raccolgo anche altre proprietà
  671.                         v = props.get(CostantiDB.CONNETTORE_PROXY_HOSTNAME);
  672.                         if(v!=null && !"".equals(v)){
  673.                             proxyHostname = v.trim();
  674.                         }
  675.                         v = props.get(CostantiDB.CONNETTORE_PROXY_PORT);
  676.                         if(v!=null && !"".equals(v)){
  677.                             proxyPort = v.trim();
  678.                         }
  679.                         v = props.get(CostantiDB.CONNETTORE_PROXY_USERNAME);
  680.                         if(v!=null && !"".equals(v)){
  681.                             proxyUsername = v.trim();
  682.                         }
  683.                         v = props.get(CostantiDB.CONNETTORE_PROXY_PASSWORD);
  684.                         if(v!=null && !"".equals(v)){
  685.                             proxyPassword = v.trim();
  686.                         }
  687.                     }
  688.                 }

  689.                 if(tempiRispostaEnabled == null ||
  690.                         tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout)
  691.                         ||
  692.                         tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout)
  693.                         ||
  694.                         tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ){

  695.                     ConfigurazioneCore configCore = new ConfigurazioneCore(soggettiCore);
  696.                     ConfigurazioneGenerale configGenerale = configCore.getConfigurazioneControlloTraffico();

  697.                     if( props!=null ) {
  698.                         if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout) ) {
  699.                             String v = props.get(CostantiDB.CONNETTORE_CONNECTION_TIMEOUT);
  700.                             if(v!=null && !"".equals(v)){
  701.                                 tempiRispostaConnectionTimeout = v.trim();
  702.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  703.                             }
  704.                             else {
  705.                                 tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaErogazione().getConnectionTimeout().intValue()+"";
  706.                             }
  707.                         }

  708.                         if(tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout) ) {
  709.                             String v = props.get(CostantiDB.CONNETTORE_READ_CONNECTION_TIMEOUT);
  710.                             if(v!=null && !"".equals(v)){
  711.                                 tempiRispostaReadTimeout = v.trim();
  712.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  713.                             }
  714.                             else {
  715.                                 tempiRispostaReadTimeout = configGenerale.getTempiRispostaErogazione().getReadTimeout().intValue()+"";
  716.                             }
  717.                         }

  718.                         if(tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ) {
  719.                             String v = props.get(CostantiDB.CONNETTORE_TEMPO_MEDIO_RISPOSTA);
  720.                             if(v!=null && !"".equals(v)){
  721.                                 tempiRispostaTempoMedioRisposta = v.trim();
  722.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  723.                             }
  724.                             else {
  725.                                 tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaErogazione().getTempoMedioRisposta().intValue()+"";
  726.                             }
  727.                         }
  728.                     }
  729.                     else {
  730.                         if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout) ) {
  731.                             tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaErogazione().getConnectionTimeout().intValue()+"";
  732.                         }
  733.                         if(tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout) ) {
  734.                             tempiRispostaReadTimeout = configGenerale.getTempiRispostaErogazione().getReadTimeout().intValue()+"";
  735.                         }
  736.                         if(tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ) {
  737.                             tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaErogazione().getTempoMedioRisposta().intValue()+"";
  738.                         }
  739.                     }
  740.                 }

  741.                 if(transferMode==null && props!=null){
  742.                     String v = props.get(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE);
  743.                     if(v!=null && !"".equals(v)){

  744.                         transferMode = v.trim();

  745.                         if(TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode)){
  746.                             // raccolgo anche altra proprietà correlata
  747.                             v = props.get(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE_CHUNK_SIZE);
  748.                             if(v!=null && !"".equals(v)){
  749.                                 transferModeChunkSize = v.trim();
  750.                             }
  751.                         }

  752.                     }
  753.                 }

  754.                 if(redirectMode==null && props!=null){
  755.                     String v = props.get(CostantiDB.CONNETTORE_HTTP_REDIRECT_FOLLOW);
  756.                     if(v!=null && !"".equals(v)){

  757.                         if("true".equalsIgnoreCase(v.trim()) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v.trim())){
  758.                             redirectMode = CostantiConfigurazione.ABILITATO.getValue();
  759.                         }
  760.                         else{
  761.                             redirectMode = CostantiConfigurazione.DISABILITATO.getValue();
  762.                         }                  

  763.                         if(CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode)){
  764.                             // raccolgo anche altra proprietà correlata
  765.                             v = props.get(CostantiDB.CONNETTORE_HTTP_REDIRECT_MAX_HOP);
  766.                             if(v!=null && !"".equals(v)){
  767.                                 redirectMaxHop = v.trim();
  768.                             }
  769.                         }

  770.                     }
  771.                 }

  772.                 if(tokenPolicy==null && props!=null){
  773.                     String v = props.get(CostantiDB.CONNETTORE_TOKEN_POLICY);
  774.                     if(v!=null && !"".equals(v)){
  775.                         tokenPolicy = v;
  776.                         autenticazioneToken = true;
  777.                     }
  778.                 }

  779.                 opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(saHelper, transferMode, redirectMode);

  780.                 autenticazioneHttp = saHelper.getAutenticazioneHttp(autenticazioneHttp, endpointtype, user);

  781.                 if(autenticazioneApiKey==null || StringUtils.isEmpty(autenticazioneApiKey)) {
  782.                     for (int i = 0; i < connis.sizePropertyList(); i++) {
  783.                         Property singlecp = cp.get(i);
  784.                         if (singlecp.getNome().equals(CostantiDB.CONNETTORE_APIKEY_HEADER)) {
  785.                             apiKeyHeader = singlecp.getValore();
  786.                         }
  787.                         else if (singlecp.getNome().equals(CostantiDB.CONNETTORE_APIKEY)) {
  788.                             apiKeyValue = singlecp.getValore();
  789.                         }
  790.                         else if (singlecp.getNome().equals(CostantiDB.CONNETTORE_APIKEY_APPID_HEADER)) {
  791.                             appIdHeader = singlecp.getValore();
  792.                         }
  793.                         else if (singlecp.getNome().equals(CostantiDB.CONNETTORE_APIKEY_APPID)) {
  794.                             appIdValue = singlecp.getValore();
  795.                         }
  796.                     }
  797.                    
  798.                     autenticazioneApiKey = saHelper.getAutenticazioneApiKey(autenticazioneApiKey, endpointtype, apiKeyValue);
  799.                     if(ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)) {
  800.                         useOAS3Names = saHelper.isAutenticazioneApiKeyUseOAS3Names(apiKeyHeader, appIdHeader);
  801.                         useAppId = saHelper.isAutenticazioneApiKeyUseAppId(appIdValue);
  802.                     }
  803.                     else {
  804.                         apiKeyValue=null;
  805.                         apiKeyHeader=null;
  806.                         appIdHeader=null;
  807.                         appIdValue=null;
  808.                     }
  809.                 }
  810.                
  811.                 for (int i = 0; i < connis.sizePropertyList(); i++) {
  812.                     Property singlecp = cp.get(i);
  813.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_HTTP_LOCATION) &&
  814.                         url == null) {
  815.                         url = singlecp.getValore();
  816.                     }
  817.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_NOME) &&
  818.                         nome == null) {
  819.                         nome = singlecp.getValore();
  820.                     }
  821.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_TIPO) &&
  822.                         tipo == null) {
  823.                         tipo = singlecp.getValore();
  824.                     }
  825.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_CONNECTION_FACTORY) &&
  826.                         connfact == null) {
  827.                         connfact = singlecp.getValore();
  828.                     }
  829.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_SEND_AS) &&
  830.                         sendas == null) {
  831.                         sendas = singlecp.getValore();
  832.                     }
  833.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_FACTORY_INITIAL) &&
  834.                         initcont == null) {
  835.                         initcont = singlecp.getValore();
  836.                     }
  837.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_FACTORY_URL_PKG) &&
  838.                         urlpgk == null) {
  839.                         urlpgk = singlecp.getValore();
  840.                     }
  841.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_PROVIDER_URL) &&
  842.                         provurl == null) {
  843.                         provurl = singlecp.getValore();
  844.                     }
  845.                 }

  846.                 if (httpstipologia == null) {
  847.                     httpsurl = props.get(CostantiDB.CONNETTORE_HTTPS_LOCATION);
  848.                     httpstipologia = props.get(CostantiDB.CONNETTORE_HTTPS_SSL_TYPE);
  849.                     httpshostverifyS = props.get(CostantiDB.CONNETTORE_HTTPS_HOSTNAME_VERIFIER);
  850.                     if(httpshostverifyS!=null){
  851.                         httpshostverify = Boolean.valueOf(httpshostverifyS);
  852.                     }
  853.                     httpsTrustVerifyCertS = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_ALL_CERTS);
  854.                     if(httpsTrustVerifyCertS!=null){
  855.                         httpsTrustVerifyCert = !Boolean.valueOf(httpsTrustVerifyCertS);
  856.                     }
  857.                     else {
  858.                         httpsTrustVerifyCert = true; // backward compatibility
  859.                     }
  860.                     httpspath = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_LOCATION);
  861.                     httpstipo = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  862.                     httpspwd = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  863.                     httpsalgoritmo = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  864.                     httpspwdprivatekeytrust = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_PASSWORD);
  865.                     httpspathkey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  866.                     httpstipokey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_TYPE);
  867.                     httpspwdkey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  868.                     httpspwdprivatekey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_PASSWORD);
  869.                     httpsalgoritmokey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  870.                     httpsKeyAlias = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_ALIAS);
  871.                     httpsTrustStoreCRLs = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_CRLS);
  872.                     httpsTrustStoreOCSPPolicy = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  873.                     httpsKeyStoreBYOKPolicy = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  874.                     if (httpspathkey == null) {
  875.                         httpsstato = false;
  876.                         httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  877.                     } else {
  878.                         httpsstato = true;
  879.                         if (httpspathkey.equals(httpspath) &&
  880.                                 httpstipokey.equals(httpstipo) &&
  881.                                 (
  882.                                     (httpspwdkey!=null && httpspwdkey.equals(httpspwd))
  883.                                     ||
  884.                                     (httpspwdkey==null && httpspwd==null)
  885.                                 )
  886.                             )
  887.                             httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  888.                         else
  889.                             httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_RIDEFINISCI;
  890.                     }
  891.                 }

  892.                 // default
  893.                 if(httpsalgoritmo==null || "".equals(httpsalgoritmo)){
  894.                     httpsalgoritmo = TrustManagerFactory.getDefaultAlgorithm();
  895.                 }
  896.                 if(httpsalgoritmokey==null || "".equals(httpsalgoritmokey)){
  897.                     httpsalgoritmokey = KeyManagerFactory.getDefaultAlgorithm();
  898.                 }
  899.                 if(httpstipologia==null || "".equals(httpstipologia)){
  900.                     httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE;
  901.                 }
  902.                 if(httpshostverifyS==null || "".equals(httpshostverifyS)){
  903.                     httpshostverifyS = Costanti.CHECK_BOX_ENABLED_TRUE;
  904.                     httpshostverify = ServletUtils.isCheckBoxEnabled(httpshostverifyS);
  905.                 }
  906.                 if(httpsTrustVerifyCertS==null || "".equals(httpsTrustVerifyCertS)){
  907.                     httpsTrustVerifyCertS = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS ? Costanti.CHECK_BOX_ENABLED_TRUE : Costanti.CHECK_BOX_DISABLED;
  908.                     httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  909.                 }

  910.                 // file
  911.                 if(responseInputMode==null && props!=null){

  912.                     requestOutputFileName = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE);  
  913.                     requestOutputFileNamePermissions = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_PERMISSIONS);  
  914.                     requestOutputFileNameHeaders = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_HEADERS);
  915.                     requestOutputFileNameHeadersPermissions = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_HEADERS_PERMISSIONS);
  916.                     String v = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  917.                     if(v!=null && !"".equals(v) &&
  918.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  919.                         ){
  920.                         requestOutputParentDirCreateIfNotExists = Costanti.CHECK_BOX_ENABLED_TRUE;
  921.                     }                  
  922.                     v = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE);
  923.                     if(v!=null && !"".equals(v) &&
  924.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  925.                         ){
  926.                         requestOutputOverwriteIfExists = Costanti.CHECK_BOX_ENABLED_TRUE;
  927.                     }  

  928.                     v = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  929.                     if(v!=null && !"".equals(v) &&
  930.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  931.                         ){
  932.                         responseInputMode = CostantiConfigurazione.ABILITATO.getValue();
  933.                     }
  934.                     if(CostantiConfigurazione.ABILITATO.getValue().equals(responseInputMode)){                      
  935.                         responseInputFileName = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE);
  936.                         responseInputFileNameHeaders = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE_HEADERS);
  937.                         v = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE_DELETE_AFTER_READ);
  938.                         if(v!=null && !"".equals(v) &&
  939.                             ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  940.                             ){
  941.                             responseInputDeleteAfterRead = Costanti.CHECK_BOX_ENABLED_TRUE;
  942.                         }                      
  943.                         responseInputWaitTime = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);                    
  944.                     }

  945.                 }
  946.                
  947.                 // status
  948.                 connettoreStatusParams.updateFromDB(props);


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

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

  952.                 saHelper.addEndPointToDati(dati,idsil,nomeservizioApplicativo,sbustamento,sbustamentoInformazioniProtocolloRichiesta,
  953.                         getmsg,getmsgUsername,getmsgPassword,true,
  954.                         invrifRichiesta,risprif,nomeProtocollo,true,true, true,
  955.                         parentSA,serviceBinding, accessoDaAPSParametro, erogazioneServizioApplicativoServerEnabled,
  956.                         null, false,
  957.                         integrationManagerEnabled,
  958.                         TipoOperazione.CHANGE, tipoCredenzialiSSLVerificaTuttiICampi, changepwd,
  959.                         postBackViaPost);

  960.                 dati = saHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp, null,
  961.                         url, nome,
  962.                         tipo, user, password, initcont, urlpgk, provurl,
  963.                         connfact, sendas, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI, TipoOperazione.CHANGE,
  964.                         httpsurl, httpstipologia, httpshostverify,
  965.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  966.                         httpsalgoritmo, httpsstato, httpskeystore,
  967.                         httpspwdprivatekeytrust, httpspathkey,
  968.                         httpstipokey, httpspwdkey,
  969.                         httpspwdprivatekey, httpsalgoritmokey,
  970.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  971.                         tipoconn, ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT,
  972.                         nomeservizioApplicativo, idsil, idAsps, idPorta, null, null,
  973.                         null, null, true,
  974.                         isConnettoreCustomUltimaImmagineSalvata,
  975.                         proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  976.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  977.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  978.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  979.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  980.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  981.                         autenticazioneToken,tokenPolicy, forcePDND, forceOAuth,
  982.                         listExtendedConnettore, forceEnabled,
  983.                         nomeProtocollo, false, false
  984.                         , isApplicativiServerEnabled, erogazioneServizioApplicativoServerEnabled,
  985.                         erogazioneServizioApplicativoServer, ServiziApplicativiHelper.toArray(listaIdSAServer),
  986.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  987.                         connettoreStatusParams,
  988.                         postBackViaPost
  989.                         );

  990.                 dati = saHelper.addHiddenFieldsToDati(dati, provider, idAsps, idPorta);

  991.                 pd.setDati(dati);

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

  993.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,
  994.                         ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_INVOCAZIONE_SERVIZIO);
  995.             }

  996.             // Controlli sui campi immessi
  997.             boolean isOk = saHelper.servizioApplicativoEndPointCheckData(protocollo, listExtendedConnettore, sa);
  998.             if (!isOk) {

  999.                 // setto la barra del titolo
  1000.                 ServletUtils.setPageDataTitle(pd, lstParm);

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

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

  1004.                 saHelper.addEndPointToDati(dati,idsil,nomeservizioApplicativo,sbustamento,sbustamentoInformazioniProtocolloRichiesta,
  1005.                         getmsg,getmsgUsername,getmsgPassword,true,
  1006.                         invrifRichiesta,risprif,nomeProtocollo,true,true, true,
  1007.                         parentSA,serviceBinding, accessoDaAPSParametro, erogazioneServizioApplicativoServerEnabled,
  1008.                         null, false,
  1009.                         integrationManagerEnabled,
  1010.                         TipoOperazione.CHANGE, tipoCredenzialiSSLVerificaTuttiICampi, changepwd,
  1011.                         postBackViaPost);

  1012.                 dati = saHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp, null,
  1013.                         url, nome,
  1014.                         tipo, user, password, initcont, urlpgk, provurl,
  1015.                         connfact, sendas, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI, TipoOperazione.CHANGE,
  1016.                         httpsurl, httpstipologia, httpshostverify,
  1017.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  1018.                         httpsalgoritmo, httpsstato, httpskeystore,
  1019.                         httpspwdprivatekeytrust, httpspathkey,
  1020.                         httpstipokey, httpspwdkey,
  1021.                         httpspwdprivatekey, httpsalgoritmokey,
  1022.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  1023.                         tipoconn, ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT,
  1024.                         nomeservizioApplicativo, idsil, null, null, null, null,
  1025.                         null, null, true,
  1026.                         isConnettoreCustomUltimaImmagineSalvata,
  1027.                         proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  1028.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  1029.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  1030.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  1031.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  1032.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  1033.                         autenticazioneToken,tokenPolicy, forcePDND, forceOAuth,
  1034.                         listExtendedConnettore, forceEnabled,
  1035.                         nomeProtocollo, false, false, isApplicativiServerEnabled, erogazioneServizioApplicativoServerEnabled,
  1036.                         erogazioneServizioApplicativoServer, ServiziApplicativiHelper.toArray(listaIdSAServer),
  1037.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  1038.                         connettoreStatusParams,
  1039.                         postBackViaPost
  1040.                         );

  1041.                 dati = saHelper.addHiddenFieldsToDati(dati, provider, idAsps, idPorta);

  1042.                 pd.setDati(dati);

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

  1044.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,
  1045.                         ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_INVOCAZIONE_SERVIZIO);
  1046.             }

  1047.             // rileggo la vecchia configurazione dal db (puo' essere stata riletta durante la postback)
  1048.             sa = saCore.getServizioApplicativo(idSilInt);
  1049.             invocazionePorta = sa.getInvocazionePorta();
  1050.             is = sa.getInvocazioneServizio();
  1051.             cis = is.getCredenziali();
  1052.             connis = is.getConnettore();
  1053.             cp = connis.getPropertyList();

  1054.             boolean secret = false;
  1055.             String secretPassword  = null;
  1056.             String secretUser = null;
  1057.             boolean secretAppId = false;
  1058.            
  1059.             List<Object> oggettiDaAggiornare = new ArrayList<>();
  1060.             // se ho selezionato un servizio applicativo Server allora devo associarlo alla porta al posto del vecchio
  1061.             if(erogazioneServizioApplicativoServerEnabled) {
  1062.                 // solo se ho cambiato il valore del servizio server oppure ho scelto un server al posto del default
  1063.                 if(!erogazioneServizioApplicativoServer.equals(sa.getNome())) {
  1064.                    
  1065.                     // prelevo l'associazione con il vecchio servizio applicativo
  1066.                     PortaApplicativaServizioApplicativo paSAtmp = null;
  1067.                     for (PortaApplicativaServizioApplicativo paSA : pa.getServizioApplicativoList()) {
  1068.                         if(paSA.getNome().equals(sa.getNome())) {
  1069.                             paSAtmp = paSA;
  1070.                             break;
  1071.                         }
  1072.                     }

  1073.                     if(paSAtmp!= null) {
  1074.                         // se ho modificato il server che sto utilizzando lo rimuovo
  1075.                         if(ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo())){
  1076.                             pa.getServizioApplicativoList().remove(paSAtmp);    
  1077.                         } else {
  1078.                             // SA di default da conservare
  1079.                             pa.getServizioApplicativoList().remove(paSAtmp);
  1080.                             pa.setServizioApplicativoDefault(sa.getNome());
  1081.                         }
  1082.                     }

  1083.                     // nuovo SA da aggiungere
  1084.                     PortaApplicativaServizioApplicativo paSA = new PortaApplicativaServizioApplicativo();
  1085.                     paSA.setNome(erogazioneServizioApplicativoServer);
  1086.                     pa.getServizioApplicativoList().add(paSA);

  1087.                     oggettiDaAggiornare.add(pa);
  1088.                    
  1089.                     saHelper.impostaSAServerAlleConfigurazioniCheUsanoConnettoreDelMappingDiDefault(idAsps, erogazioneServizioApplicativoServer, pa, sa, oggettiDaAggiornare);
  1090.                    
  1091.                 }
  1092.             } else {
  1093.                
  1094.                 if(isApplicativiServerEnabled &&
  1095.                
  1096.                     // caso normale
  1097.                     // se avevo salvato un server e ritorno ad una configurazione di default
  1098.                     pa.getServizioApplicativoDefault() != null) {
  1099.                        
  1100.                     String oldServizioApplicativoDefault = pa.getServizioApplicativoDefault();
  1101.                     String oldNomeSA = sa.getNome();
  1102.                     String oldTipoSA = sa.getTipo();
  1103.                    
  1104.                     // prelevo l'associazione con il vecchio servizio applicativo server
  1105.                     PortaApplicativaServizioApplicativo paSAtmp = null;
  1106.                     for (PortaApplicativaServizioApplicativo paSA : pa.getServizioApplicativoList()) {
  1107.                         if(paSA.getNome().equals(oldNomeSA)) {
  1108.                             paSAtmp = paSA;
  1109.                             break;
  1110.                         }
  1111.                     }

  1112.                     if(paSAtmp!= null &&
  1113.                         // se ho modificato il server che sto utilizzando lo rimuovo
  1114.                         ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(oldTipoSA)){
  1115.                         pa.getServizioApplicativoList().remove(paSAtmp);    
  1116.                     }

  1117.                     PortaApplicativaServizioApplicativo paSA = new PortaApplicativaServizioApplicativo();
  1118.                     paSA.setNome(oldServizioApplicativoDefault);
  1119.                     pa.getServizioApplicativoList().add(paSA);
  1120.                     pa.setServizioApplicativoDefault(null);

  1121.                     oggettiDaAggiornare.add(pa);
  1122.                    
  1123.                     saHelper.impostaSADefaultAlleConfigurazioniCheUsanoConnettoreDelMappingDiDefault(idAsps, pa, sa, oggettiDaAggiornare);
  1124.                    
  1125.                     // rileggo la vecchia configurazione dal db di default
  1126.                     IDServizioApplicativo idSA = new IDServizioApplicativo();
  1127.                     idSA.setNome(oldServizioApplicativoDefault);
  1128.                     IDSoggetto idSoggettoProprietario = new IDSoggetto();
  1129.                     idSoggettoProprietario.setTipo(pa.getTipoSoggettoProprietario());
  1130.                     idSoggettoProprietario.setNome(pa.getNomeSoggettoProprietario());
  1131.                     idSA.setIdSoggettoProprietario(idSoggettoProprietario );
  1132.                     sa = saCore.getServizioApplicativo(idSA);
  1133.                     invocazionePorta = sa.getInvocazionePorta();
  1134.                     is = sa.getInvocazioneServizio();
  1135.                     cis = is.getCredenziali();
  1136.                     connis = is.getConnettore();
  1137.                     cp = connis.getPropertyList();
  1138.                    
  1139.                 }

  1140.                 // Modifico i dati del servizioApplicativo nel db
  1141.                 if(sbustamento==null){
  1142.                     is.setSbustamentoSoap(CostantiConfigurazione.DISABILITATO);
  1143.                 }else{
  1144.                     is.setSbustamentoSoap(StatoFunzionalita.toEnumConstant(sbustamento));
  1145.                 }
  1146.                 if(sbustamentoInformazioniProtocolloRichiesta==null){
  1147.                     is.setSbustamentoInformazioniProtocollo(CostantiConfigurazione.ABILITATO);
  1148.                 }else{
  1149.                     is.setSbustamentoInformazioniProtocollo(StatoFunzionalita.toEnumConstant(sbustamentoInformazioniProtocolloRichiesta));
  1150.                 }
  1151.                 is.setGetMessage(StatoFunzionalita.toEnumConstant(getmsg));
  1152.                 is.setInvioPerRiferimento(StatoFunzionalita.toEnumConstant(invrifRichiesta));
  1153.                 is.setRispostaPerRiferimento(StatoFunzionalita.toEnumConstant(risprif));
  1154.                 if (tipoauthRichiesta!=null && tipoauthRichiesta.equals(CostantiConfigurazione.INVOCAZIONE_SERVIZIO_AUTENTICAZIONE_BASIC.toString())) {
  1155.                     if (cis == null) {
  1156.                         cis = new InvocazioneCredenziali();
  1157.                     }
  1158.                     cis.setUser(user);
  1159.                     cis.setPassword(password);
  1160.                     is.setCredenziali(cis);
  1161.                     is.setAutenticazione(InvocazioneServizioTipoAutenticazione.BASIC);
  1162.                 }
  1163.                 else if(endpointtype.equals(TipiConnettore.JMS.toString())){
  1164.                     if(user!=null && password!=null){
  1165.                         if (cis == null) {
  1166.                             cis = new InvocazioneCredenziali();
  1167.                         }
  1168.                         cis.setUser(user);
  1169.                         cis.setPassword(password);
  1170.                     }
  1171.                     is.setCredenziali(cis);
  1172.                     is.setAutenticazione(InvocazioneServizioTipoAutenticazione.BASIC);
  1173.                 }
  1174.                 else {
  1175.                     is.setCredenziali(null);
  1176.                     is.setAutenticazione(InvocazioneServizioTipoAutenticazione.NONE);
  1177.                 }
  1178.                 String oldConnT = connis.getTipo();
  1179.                 if ((connis.getCustom()!=null && connis.getCustom()) &&
  1180.                         !connis.getTipo().equals(TipiConnettore.HTTPS.toString()) &&
  1181.                         !connis.getTipo().equals(TipiConnettore.FILE.toString()) &&
  1182.                         !connis.getTipo().equals(TipiConnettore.STATUS.toString()))
  1183.                     oldConnT = TipiConnettore.CUSTOM.toString();
  1184.                 saHelper.fillConnettore(connis, connettoreDebug, endpointtype, oldConnT, tipoconn, url,
  1185.                         nome, tipo, user, password,
  1186.                         initcont, urlpgk, provurl, connfact,
  1187.                         sendas, httpsurl, httpstipologia, httpshostverify,
  1188.                         httpsTrustVerifyCert, httpspath, httpstipo,
  1189.                         httpspwd, httpsalgoritmo, httpsstato,
  1190.                         httpskeystore, httpspwdprivatekeytrust,
  1191.                         httpspathkey, httpstipokey,
  1192.                         httpspwdkey, httpspwdprivatekey,
  1193.                         httpsalgoritmokey,
  1194.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  1195.                         proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  1196.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  1197.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  1198.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  1199.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  1200.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  1201.                         tokenPolicy,
  1202.                         apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  1203.                         connettoreStatusParams,
  1204.                         listExtendedConnettore);
  1205.                 is.setConnettore(connis);
  1206.                 sa.setInvocazioneServizio(is);

  1207.                 if(StatoFunzionalita.ABILITATO.equals(is.getGetMessage()) ||
  1208.                         !TipiConnettore.DISABILITATO.toString().equals(endpointtype)){
  1209.                     sa.setTipologiaErogazione(TipologiaErogazione.TRASPARENTE.getValue());
  1210.                 }
  1211.                 else{
  1212.                     sa.setTipologiaErogazione(TipologiaErogazione.DISABILITATO.getValue());
  1213.                 }

  1214.                 // rif bug#45
  1215.                 // se il connettore e' disabilitato oppure il Salvataggio in MessageBox e'
  1216.                 // disabilitato
  1217.                 // bisogna controllare che il servizio applicativo non sia in uso in
  1218.                 // porte applicative
  1219.                 StringBuilder inUsoMessage = new StringBuilder();
  1220.                 ServiziApplicativiUtilities.checkStatoConnettore(saCore, sa, connis, inUsoMessage, org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  1221.                 if(inUsoMessage.length()>0) {
  1222.                     pd.setMessage(inUsoMessage.toString());
  1223.                     ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  1224.                     return ServletUtils.getStrutsForwardGeneralError(mapping, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,
  1225.                             ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_INVOCAZIONE_SERVIZIO);
  1226.                 }

  1227.                 if(CostantiConfigurazione.ABILITATO.toString().equals(getmsg)) {
  1228.                     boolean found = false;
  1229.                     if(invocazionePorta!=null && invocazionePorta.sizeCredenzialiList()>0) {
  1230.                         for (int i = 0; i < invocazionePorta.sizeCredenzialiList(); i++) {
  1231.                             Credenziali c = invocazionePorta.getCredenziali(i);
  1232.                             if(CredenzialeTipo.BASIC.equals(c.getTipo())) {
  1233.                                 c.setUser(getmsgUsername);
  1234.                                 c.setPassword(getmsgPassword);
  1235.                                 found = true;
  1236.                                
  1237.                                 boolean encryptOldPlainPwd = !c.isCertificateStrictVerification() && saCore.isApplicativiPasswordEncryptEnabled();
  1238.                                
  1239.                                 if(ServletUtils.isCheckBoxEnabled(changepwd)) {
  1240.                                     c.setCertificateStrictVerification(false); // se è abilitata la cifratura, verrà impostata a true nel perform update
  1241.                                     if(saCore.isApplicativiPasswordEncryptEnabled()) {
  1242.                                         secret = true;
  1243.                                     }
  1244.                                 }
  1245.                                 else if(encryptOldPlainPwd) {
  1246.                                     secret = true;
  1247.                                 }
  1248.                                 else {
  1249.                                     c.setCertificateStrictVerification(ServletUtils.isCheckBoxEnabled(tipoCredenzialiSSLVerificaTuttiICampi));
  1250.                                 }
  1251.                                
  1252.                                 if(secret) {
  1253.                                     secretUser = c.getUser();
  1254.                                     secretPassword = c.getPassword();
  1255.                                     secretAppId = c.isAppId();
  1256.                                 }
  1257.                                
  1258.                             }
  1259.                         }
  1260.                     }
  1261.                     if(!found) {
  1262.                         if(invocazionePorta==null) {
  1263.                             sa.setInvocazionePorta(new InvocazionePorta());
  1264.                             invocazionePorta = sa.getInvocazionePorta();
  1265.                         }
  1266.                         Credenziali c = new Credenziali();
  1267.                         c.setTipo(CredenzialeTipo.BASIC);
  1268.                         c.setUser(getmsgUsername);
  1269.                         c.setPassword(getmsgPassword);
  1270.                        
  1271.                         c.setCertificateStrictVerification(false); // se è abilitata la cifratura, verrà impostata a true nel perform update
  1272.                         if(saCore.isApplicativiPasswordEncryptEnabled()) {
  1273.                             secret = true;
  1274.                         }
  1275.                        
  1276.                         if(secret) {
  1277.                             secretUser = c.getUser();
  1278.                             secretPassword = c.getPassword();
  1279.                             secretAppId = c.isAppId();
  1280.                         }
  1281.                                                
  1282.                         invocazionePorta.addCredenziali(c);
  1283.                     }
  1284.                 }
  1285.                 else {
  1286.                     // Fix: altrimenti rimaneva assegnate le credenziali quando si disabilitava l'integration manager
  1287.                     if(!saHelper.isModalitaCompleta() &&
  1288.                         invocazionePorta!=null) {
  1289.                         while (invocazionePorta.sizeCredenzialiList()>0) {
  1290.                             invocazionePorta.removeCredenziali(0);
  1291.                         }
  1292.                     }
  1293.                 }

  1294.                 oggettiDaAggiornare.add(sa);
  1295.             }

  1296.             String userLogin = ServletUtils.getUserLoginFromSession(session);
  1297.             if(!oggettiDaAggiornare.isEmpty())
  1298.                 saCore.performUpdateOperation(userLogin, saHelper.smista(), oggettiDaAggiornare.toArray(new Object[oggettiDaAggiornare.size()]));

  1299.             // Messaggio 'Please Copy'
  1300.             if(secret) {
  1301.                 saHelper.setSecretPleaseCopy(secretPassword, secretUser, secretAppId, ConnettoriCostanti.AUTENTICAZIONE_TIPO_BASIC, OggettoDialogEnum.EROGAZIONE, null);
  1302.             }
  1303.            
  1304.             // Preparo la lista
  1305.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);

  1306.             List<ServizioApplicativo> lista = null;
  1307.             int idLista = -1;
  1308.             switch (parentSA) {
  1309.             case ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_CONFIGURAZIONE:
  1310.                 if(accessoDaListaAPS) {
  1311.                     if(vistaErogazioni != null && vistaErogazioni.booleanValue()) {
  1312.                         ErogazioniHelper erogazioniHelper = new ErogazioniHelper(request, pd, session);
  1313.                         int idServizio = Integer.parseInt(idAsps);
  1314.                         AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(saCore);
  1315.                         AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idServizio);
  1316.                         erogazioniHelper.prepareErogazioneChange(TipoOperazione.CHANGE, asps, null);
  1317.                         ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  1318.                         return ServletUtils.getStrutsForwardEditModeFinished(mapping, ErogazioniCostanti.OBJECT_NAME_ASPS_EROGAZIONI, ForwardParams.CHANGE());
  1319.                     }

  1320.                     idLista = Liste.SERVIZI;
  1321.                     ricerca = saHelper.checkSearchParameters(idLista, ricerca);
  1322.                     if(gestioneErogatori) {
  1323.                         ricerca.addFilter(idLista, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE);
  1324.                     }
  1325.                     boolean [] permessi = new boolean[2];
  1326.                     PermessiUtente pu = ServletUtils.getUserFromSession(request, session).getPermessi();
  1327.                     permessi[0] = pu.isServizi();
  1328.                     permessi[1] = pu.isAccordiCooperazione();
  1329.                     List<AccordoServizioParteSpecifica> listaS = null;
  1330.                     AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(saCore);
  1331.                     if(apsCore.isVisioneOggettiGlobale(superUser)){
  1332.                         listaS = apsCore.soggettiServizioList(null, ricerca,permessi,session, request);
  1333.                     }else{
  1334.                         listaS = apsCore.soggettiServizioList(superUser, ricerca,permessi,session, request);
  1335.                     }
  1336.                     AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  1337.                     apsHelper.prepareServiziList(ricerca, listaS);
  1338.                 }
  1339.                 else {
  1340.                     idLista = Liste.CONFIGURAZIONE_EROGAZIONE;
  1341.                     ricerca = saHelper.checkSearchParameters(idLista, ricerca);
  1342.                     int idServizio = Integer.parseInt(idAsps);
  1343.                     AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(saCore);
  1344.                     AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idServizio);
  1345.                     IDServizio idServizio2 = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  1346.                     Long idSoggetto = asps.getIdSoggetto() != null ? asps.getIdSoggetto() : -1L;
  1347.                     List<MappingErogazionePortaApplicativa> lista2 = apsCore.mappingServiziPorteAppList(idServizio2,asps.getId(),ricerca);
  1348.                     AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  1349.                     apsHelper.prepareServiziConfigurazioneList(lista2, idAsps, idSoggetto+"", ricerca);
  1350.                 }
  1351.                 break;
  1352.             case ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_SOGGETTO:
  1353.                 idLista = Liste.SERVIZI_APPLICATIVI_BY_SOGGETTO;
  1354.                 ricerca = saHelper.checkSearchParameters(idLista, ricerca);
  1355.                 lista = saCore.soggettiServizioApplicativoList(ricerca,soggLong);
  1356.                 saHelper.prepareServizioApplicativoList(ricerca, lista, useIdSogg);
  1357.                 break;
  1358.             case ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_NONE:
  1359.             default:
  1360.                 idLista = Liste.SERVIZIO_APPLICATIVO;
  1361.                 ricerca = saHelper.checkSearchParameters(idLista, ricerca);

  1362.                 if(saCore.isVisioneOggettiGlobale(superUser)){
  1363.                     lista = saCore.soggettiServizioApplicativoList(null, ricerca);
  1364.                 }else{
  1365.                     lista = saCore.soggettiServizioApplicativoList(superUser, ricerca);
  1366.                 }
  1367.                 saHelper.prepareServizioApplicativoList(ricerca, lista, useIdSogg);
  1368.                 break;
  1369.             }

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

  1371.             ForwardParams fwP = ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_INVOCAZIONE_SERVIZIO;
  1372.             if(fromConfig && !saHelper.isModalitaCompleta()) {
  1373.                 fwP = PorteApplicativeCostanti.TIPO_OPERAZIONE_CONFIGURAZIONE;
  1374.             }

  1375.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,  fwP);

  1376.         } catch (Exception e) {
  1377.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  1378.                     ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI, ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_INVOCAZIONE_SERVIZIO);
  1379.         }

  1380.     }
  1381.    
  1382. }