ServiziApplicativiEndPointRispostaAsincrona.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.PortaApplicativa;
  42. import org.openspcoop2.core.config.Property;
  43. import org.openspcoop2.core.config.RispostaAsincrona;
  44. import org.openspcoop2.core.config.ServizioApplicativo;
  45. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  46. import org.openspcoop2.core.config.constants.CredenzialeTipo;
  47. import org.openspcoop2.core.config.constants.InvocazioneServizioTipoAutenticazione;
  48. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  49. import org.openspcoop2.core.constants.CostantiConnettori;
  50. import org.openspcoop2.core.constants.CostantiDB;
  51. import org.openspcoop2.core.constants.TipiConnettore;
  52. import org.openspcoop2.core.constants.TransferLengthModes;
  53. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  54. import org.openspcoop2.core.id.IDServizio;
  55. import org.openspcoop2.core.id.IDSoggetto;
  56. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  57. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  58. import org.openspcoop2.core.registry.Soggetto;
  59. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  60. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  61. import org.openspcoop2.message.constants.ServiceBinding;
  62. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  63. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  64. import org.openspcoop2.web.ctrlstat.costanti.ConnettoreServletType;
  65. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettore;
  66. import org.openspcoop2.web.ctrlstat.plugins.servlet.ServletExtendedConnettoreUtils;
  67. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  68. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  69. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  70. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  71. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaHelper;
  72. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  73. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoreStatusParams;
  74. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  75. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriHelper;
  76. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCore;
  77. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCostanti;
  78. import org.openspcoop2.web.ctrlstat.servlet.pdd.PddCore;
  79. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  80. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  81. import org.openspcoop2.web.lib.mvc.Costanti;
  82. import org.openspcoop2.web.lib.mvc.DataElement;
  83. import org.openspcoop2.web.lib.mvc.GeneralData;
  84. import org.openspcoop2.web.lib.mvc.PageData;
  85. import org.openspcoop2.web.lib.mvc.Parameter;
  86. import org.openspcoop2.web.lib.mvc.ServletUtils;
  87. import org.openspcoop2.web.lib.mvc.TipoOperazione;
  88. import org.openspcoop2.web.lib.users.dao.PermessiUtente;

  89. /**
  90.  * servizioApplicativoEndPointRisposta
  91.  *
  92.  * @author Andrea Poli (apoli@link.it)
  93.  * @author Stefano Corallo (corallo@link.it)
  94.  * @author Sandra Giangrandi (sandra@link.it)
  95.  * @author $Author$
  96.  * @version $Rev$, $Date$
  97.  *
  98.  */
  99. public final class ServiziApplicativiEndPointRispostaAsincrona extends Action {

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

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

  103.         // Inizializzo PageData
  104.         PageData pd = new PageData();

  105.         GeneralHelper generalHelper = new GeneralHelper(session);

  106.         // Inizializzo GeneralData
  107.         GeneralData gd = generalHelper.initGeneralData(request);
  108.        
  109.         try {
  110.             ServiziApplicativiHelper saHelper = new ServiziApplicativiHelper(request, pd, session);
  111.            
  112.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione
  113.             Integer parentSA = ServletUtils.getIntegerAttributeFromSession(ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT, session, request);
  114.             if(parentSA == null) parentSA = ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_NONE;
  115.             boolean useIdSogg = (parentSA!=null && parentSA.intValue() == ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_SOGGETTO);
  116.            
  117.             String nomeservizioApplicativo = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_NOME_SERVIZIO_APPLICATIVO);
  118.             String idsil = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_SERVIZIO_APPLICATIVO);
  119.             int idSilInt = Integer.parseInt(idsil);
  120.             String sbustamento = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_SBUSTAMENTO_SOAP);
  121.             String sbustamentoInformazioniProtocolloRichiesta = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_SBUSTAMENTO_INFO_PROTOCOLLO_RICHIESTA);
  122.             String getmsg = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_MESSAGE_BOX);
  123.             String getmsgUsername = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  124.             String getmsgPassword = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  125.            
  126.             String invrifRichiesta = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_INVIO_PER_RIFERIMENTO_RICHIESTA);
  127.            
  128.             String risprif = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_RISPOSTA_PER_RIFERIMENTO);
  129.            
  130.             String tipoauthRichiesta = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_TIPO_AUTENTICAZIONE);
  131.            
  132.             String provider = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER);
  133.             if(provider == null){
  134.                 provider = "";
  135.             }
  136.             String idPorta = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_PORTA);
  137.             if(idPorta == null)
  138.                 idPorta = "";
  139.            
  140.             String idAsps = saHelper.getParameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID_ASPS);
  141.             if(idAsps == null)
  142.                 idAsps = "";
  143.            
  144.             String endpointtype = saHelper.readEndPointType();
  145.             String tipoconn = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO);
  146.             String autenticazioneHttp = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);
  147.             String user = null;
  148.             String password = null;
  149.            
  150.             String connettoreDebug = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_DEBUG);

  151.             // token policy
  152.             String autenticazioneTokenS = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  153.             boolean autenticazioneToken = ServletUtils.isCheckBoxEnabled(autenticazioneTokenS);
  154.             String tokenPolicy = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY);
  155.             boolean forcePDND = false;
  156.             boolean forceOAuth = false;
  157.                        
  158.             // proxy
  159.             String proxyEnabled = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  160.             String proxyHostname = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  161.             String proxyPort = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PORT);
  162.             String proxyUsername = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_USERNAME);
  163.             String proxyPassword = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PASSWORD);
  164.                
  165.             // tempi risposta
  166.             String tempiRispostaEnabled = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  167.             String tempiRispostaConnectionTimeout = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  168.             String tempiRispostaReadTimeout = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  169.             String tempiRispostaTempoMedioRisposta = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);
  170.            
  171.             // opzioni avanzate
  172.             String transferMode = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  173.             String transferModeChunkSize = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  174.             String redirectMode = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  175.             String redirectMaxHop = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  176.             String opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(saHelper, transferMode, redirectMode);
  177.            
  178.             // http
  179.             String url = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL);
  180.             if(TipiConnettore.HTTP.toString().equals(endpointtype)){
  181.                 user = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  182.                 password = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  183.             }
  184.            
  185.             // api key
  186.             String autenticazioneApiKey = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_API_KEY);
  187.             String apiKeyHeader = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_HEADER);
  188.             if(apiKeyHeader==null || StringUtils.isEmpty(apiKeyHeader)) {
  189.                 apiKeyHeader = CostantiConnettori.DEFAULT_HEADER_API_KEY;
  190.             }
  191.             String apiKeyValue = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_VALUE);
  192.             String appIdHeader = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  193.             if(appIdHeader==null || StringUtils.isEmpty(appIdHeader)) {
  194.                 appIdHeader = CostantiConnettori.DEFAULT_HEADER_APP_ID;
  195.             }
  196.             String appIdValue = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  197.             String useOAS3NamesTmp = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  198.             boolean useOAS3Names=true;
  199.             if(useOAS3NamesTmp!=null && StringUtils.isNotEmpty(useOAS3NamesTmp)) {
  200.                 useOAS3Names = ServletUtils.isCheckBoxEnabled(useOAS3NamesTmp);
  201.             }
  202.             else {
  203.                 useOAS3Names = saHelper.isAutenticazioneApiKeyUseOAS3Names(apiKeyHeader, appIdHeader);
  204.             }
  205.             String useAppIdTmp = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  206.             boolean useAppId=false;
  207.             if(useAppIdTmp!=null && StringUtils.isNotEmpty(useAppIdTmp)) {
  208.                 useAppId = ServletUtils.isCheckBoxEnabled(useAppIdTmp);
  209.             }
  210.             else {
  211.                 useAppId = saHelper.isAutenticazioneApiKeyUseAppId(appIdValue);
  212.             }
  213.            
  214.             // jms
  215.             String nome = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_NOME_CODA);
  216.             String tipo = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_CODA);
  217.             String initcont = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_INIT_CTX);
  218.             String urlpgk = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_URL_PKG);
  219.             String provurl = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PROVIDER_URL);
  220.             String connfact = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_CONNECTION_FACTORY);
  221.             String sendas = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_OGGETTO_JMS);
  222.             if(TipiConnettore.JMS.toString().equals(endpointtype)){
  223.                 user = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_USERNAME);
  224.                 password = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PASSWORD);
  225.             }
  226.            
  227.             // https
  228.             String httpsurl = url;
  229.             String httpstipologia = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_SSL_TYPE);
  230.             String httpshostverifyS = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_HOST_VERIFY);
  231.             boolean httpshostverify = ServletUtils.isCheckBoxEnabled(httpshostverifyS);
  232.             String httpsTrustVerifyCertS = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS );
  233.             boolean httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  234.             String httpspath = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_LOCATION);
  235.             String httpstipo = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  236.             String httpspwd = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  237.             String httpsalgoritmo = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  238.             String httpsstatoS = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO);
  239.             boolean httpsstato = ServletUtils.isCheckBoxEnabled(httpsstatoS);
  240.             String httpskeystore = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE);
  241.             String httpspwdprivatekeytrust = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_STORE);
  242.             String httpspathkey = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  243.             String httpstipokey = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_TYPE);
  244.             String httpspwdkey = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  245.             String httpspwdprivatekey = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_KEYSTORE);
  246.             String httpsalgoritmokey = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  247.             String httpsKeyAlias = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_ALIAS_PRIVATE_KEY_KEYSTORE);
  248.             String httpsTrustStoreCRLs = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL);
  249.             String httpsTrustStoreOCSPPolicy = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  250.             String httpsKeyStoreBYOKPolicy = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  251.             if(TipiConnettore.HTTPS.toString().equals(endpointtype)){
  252.                 user = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  253.                 password = saHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  254.             }
  255.            
  256.             // file
  257.             String requestOutputFileName = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME);
  258.             String requestOutputFileNamePermissions = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_PERMISSIONS);
  259.             String requestOutputFileNameHeaders = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS);
  260.             String requestOutputFileNameHeadersPermissions = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS);
  261.             String requestOutputParentDirCreateIfNotExists = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  262.             String requestOutputOverwriteIfExists = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE_NAME);
  263.             String responseInputMode = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  264.             String responseInputFileName = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME);
  265.             String responseInputFileNameHeaders = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS);
  266.             String responseInputDeleteAfterRead = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_DELETE_AFTER_READ);
  267.             String responseInputWaitTime = saHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);
  268.            
  269.             //status
  270.             ConnettoreStatusParams connettoreStatusParams = ConnettoreStatusParams.fillFrom(saHelper);
  271.            
  272.             String tipologia = ServletUtils.getObjectFromSession(request, session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  273.             @SuppressWarnings("unused")
  274.             boolean gestioneErogatori = false;
  275.             if(tipologia!=null &&
  276.                 AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  277.                 gestioneErogatori = true;
  278.             }

  279.             boolean accessoDaListaAPS = false;
  280.             String accessoDaAPSParametro = null;
  281.             // nell'erogazione vale sempre
  282.             accessoDaAPSParametro = saHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DA_LISTA_APS);
  283.             if(Costanti.CHECK_BOX_ENABLED_TRUE.equals(accessoDaAPSParametro)) {
  284.                 accessoDaListaAPS = true;
  285.             }
  286.            
  287.             boolean erogazioneServizioApplicativoServerEnabled = false;
  288.            
  289.             boolean postBackViaPost = true;
  290.            
  291.             // Preparo il menu
  292.             saHelper.makeMenu();
  293.            
  294.             String superUser = ServletUtils.getUserLoginFromSession(session);

  295.             // Prendo il sil
  296.             ServiziApplicativiCore saCore = new ServiziApplicativiCore();
  297.             ServizioApplicativo sa = saCore.getServizioApplicativo(idSilInt);
  298.             SoggettiCore soggettiCore = new SoggettiCore(saCore);
  299.             PddCore pddCore = new PddCore(saCore);
  300.             String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(sa.getTipoSoggettoProprietario());
  301.             InvocazionePorta invocazionePorta = sa.getInvocazionePorta();
  302.             RispostaAsincrona ra = sa.getRispostaAsincrona();
  303.             if(ra==null) {
  304.                 throw new CoreException("ServizioApplicativo con id '"+idSilInt+"' senza RispostaAsincrona");
  305.             }
  306.             InvocazioneCredenziali cra = ra.getCredenziali();
  307.             Connettore connra = ra.getConnettore();
  308.             if(connra==null) {
  309.                 throw new CoreException("ServizioApplicativo con id '"+idSilInt+"' senza connettore in RispostaAsincrona");
  310.             }
  311.             List<Property> cp = connra.getPropertyList();
  312.            
  313.             boolean forceEnabled = false;
  314.             if(parentSA!=null && (parentSA.intValue() == ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_CONFIGURAZIONE)) {
  315.                 if(
  316.                         //va visualizzato comunque se già configurato:!saHelper.isModalitaStandard() &&
  317.                         ( (getmsg!=null && CostantiConfigurazione.ABILITATO.toString().equals(getmsg))
  318.                                 ||
  319.                           (getmsg==null && ra!=null && ra.getGetMessage()!=null && StatoFunzionalita.ABILITATO.equals(ra.getGetMessage()))
  320.                         )
  321.                     ) {
  322.                     forceEnabled = false;
  323.                 }
  324.                 else {
  325.                     forceEnabled = true;
  326.                     if(endpointtype==null) {
  327.                         if( connra==null || connra.getTipo()==null || TipiConnettore.DISABILITATO.getNome().equals(connra.getTipo()) ) {
  328.                             endpointtype = TipiConnettore.HTTP.getNome();
  329.                         }
  330.                     }
  331.                     else if(TipiConnettore.DISABILITATO.getNome().equals(endpointtype)) {
  332.                         endpointtype = TipiConnettore.HTTP.getNome();
  333.                     }
  334.                 }
  335.             }
  336.            
  337.             String nomeProtocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(sa.getTipoSoggettoProprietario());
  338.            
  339.             long soggLong = -1;
  340.             // se ho fatto la add
  341.             if(useIdSogg &&
  342.                 provider != null && !provider.equals("")){
  343.                 soggLong = Long.parseLong(provider);
  344.             }

  345.             Boolean isConnettoreCustomUltimaImmagineSalvata = connra.getCustom();
  346.            
  347.             List<ExtendedConnettore> listExtendedConnettore =
  348.                     ServletExtendedConnettoreUtils.getExtendedConnettore(connra, ConnettoreServletType.SERVIZIO_APPLICATIVO_RISPOSTA_ASINCRONA, saHelper,
  349.                             (endpointtype==null), endpointtype); // uso endpointtype per capire se è la prima volta che entro
  350.            
  351.            
  352.             List<Parameter> lstParm = saHelper.getTitoloSA(parentSA, provider, idAsps, idPorta);
  353.             if(!saHelper.isModalitaCompleta()) {
  354.                 IDSoggetto idSoggettoProprietario = new IDSoggetto(sa.getTipoSoggettoProprietario(), sa.getNomeSoggettoProprietario());
  355.                 Soggetto soggettoProprietario = soggettiCore.getSoggettoRegistro(idSoggettoProprietario);
  356.                 String dominio = pddCore.isPddEsterna(soggettoProprietario.getPortaDominio()) ? SoggettiCostanti.SOGGETTO_DOMINIO_ESTERNO_VALUE : SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE;
  357.            
  358.                 List<Parameter> parametersServletSAChange = new ArrayList<>();
  359.                 Parameter pIdSA = new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_ID, sa.getId()+"");
  360.                 parametersServletSAChange.add(pIdSA);
  361.                 Parameter pIdSoggettoSA = new Parameter(ServiziApplicativiCostanti.PARAMETRO_SERVIZI_APPLICATIVI_PROVIDER, sa.getIdSoggetto()+"");
  362.                 parametersServletSAChange.add(pIdSoggettoSA);
  363.                 if(dominio != null) {
  364.                     Parameter pDominio = new Parameter(SoggettiCostanti.PARAMETRO_SOGGETTO_DOMINIO, dominio);
  365.                     parametersServletSAChange.add(pDominio);
  366.                 }
  367.                
  368.                 lstParm.add(new Parameter(sa.getNome(), ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_CHANGE, parametersServletSAChange.toArray(new Parameter[parametersServletSAChange.size()])));
  369.             }
  370.            
  371.             boolean integrationManagerEnabled = !saHelper.isModalitaStandard() && saCore.isIntegrationManagerEnabled();
  372.            
  373.             ServiceBinding serviceBinding = null;
  374.             String labelPerPorta = null;
  375.             if(parentSA!=null && (parentSA.intValue() == ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_CONFIGURAZIONE)) {
  376.                
  377.                 PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore(saCore);
  378.                 PortaApplicativa pa = null;    
  379.                
  380.                 if(accessoDaListaAPS) {
  381.                     labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE;
  382.                 }
  383.                 else {
  384.                     pa = porteApplicativeCore.getPortaApplicativa(Long.parseLong(idPorta));
  385.                     labelPerPorta = porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  386.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DI,
  387.                             PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE,
  388.                             pa);
  389.                 }
  390.                
  391.                 AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(soggettiCore);
  392.                 AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(Integer.parseInt(idAsps));
  393.                 AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(apsCore);
  394.                 AccordoServizioParteComuneSintetico apc = apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  395.                 serviceBinding = apcCore.toMessageServiceBinding(apc.getServiceBinding());
  396.                
  397.                 boolean isSoapOneWay = false;
  398.                 if(pa!=null) {
  399.                     MappingErogazionePortaApplicativa mappingErogazionePortaApplicativa = porteApplicativeCore.getMappingErogazionePortaApplicativa(pa);
  400.                     isSoapOneWay = saHelper.isSoapOneWay(pa, mappingErogazionePortaApplicativa, asps, apc, serviceBinding);
  401.                 }
  402.                 integrationManagerEnabled = integrationManagerEnabled && isSoapOneWay;
  403.             }
  404.             else {
  405.                 labelPerPorta = ServiziApplicativiCostanti.LABEL_PARAMETRO_SERVIZI_APPLICATIVI_RISPOSTA_ASINCRONA_DI+nomeservizioApplicativo;
  406.                 if(!saHelper.isModalitaCompleta()) {
  407.                     labelPerPorta = ServiziApplicativiCostanti.LABEL_RISPOSTA_ASINCRONA;
  408.                 }
  409.             }
  410.            
  411.             if(accessoDaListaAPS) {
  412.                 lstParm.remove(lstParm.size()-1);
  413.             }
  414.             lstParm.add(new Parameter(labelPerPorta,null));
  415.            
  416.             // Se nomehid = null, devo visualizzare la pagina per la
  417.             // modifica dati
  418.             if(saHelper.isEditModeInProgress()){
  419.                
  420.                 // setto la barra del titolo
  421.                 ServletUtils.setPageDataTitle(pd, lstParm);
  422.                
  423.                 // Prendo i dati dal db solo se non sono stati passati
  424.                 if (sbustamento == null &&
  425.                     ra.getSbustamentoSoap()!=null) {
  426.                     sbustamento = ra.getSbustamentoSoap().toString();
  427.                 }
  428.                 if (sbustamentoInformazioniProtocolloRichiesta == null &&
  429.                     ra.getSbustamentoInformazioniProtocollo()!=null) {
  430.                     sbustamentoInformazioniProtocolloRichiesta = ra.getSbustamentoInformazioniProtocollo().toString();
  431.                 }
  432.                 if (getmsg == null &&
  433.                     ra.getGetMessage()!=null) {
  434.                     getmsg = ra.getGetMessage().toString();
  435.                     if(CostantiConfigurazione.ABILITATO.toString().equals(getmsg) &&
  436.                         invocazionePorta!=null && invocazionePorta.sizeCredenzialiList()>0) {
  437.                         for (int i = 0; i < invocazionePorta.sizeCredenzialiList(); i++) {
  438.                             Credenziali c = invocazionePorta.getCredenziali(i);
  439.                             if(CredenzialeTipo.BASIC.equals(c.getTipo())) {
  440.                                 getmsgUsername = c.getUser();
  441.                                 getmsgPassword = c.getPassword();
  442.                                 break;
  443.                             }
  444.                         }
  445.                     }
  446.                 }
  447.                
  448.                 if(!integrationManagerEnabled && CostantiConfigurazione.ABILITATO.toString().equals(getmsg)) {
  449.                     // faccio vedere I.M. anche con interfaccia standard
  450.                     integrationManagerEnabled = true;
  451.                 }
  452.                
  453.                 if (invrifRichiesta == null) {
  454.                     if(ra.getInvioPerRiferimento()!=null)
  455.                         invrifRichiesta = ra.getInvioPerRiferimento().toString();
  456.                     if ((invrifRichiesta == null) || "".equals(invrifRichiesta)) {
  457.                         invrifRichiesta = CostantiConfigurazione.DISABILITATO.toString();
  458.                     }
  459.                 }
  460.                 if (risprif == null) {
  461.                     if(ra.getRispostaPerRiferimento()!=null)
  462.                         risprif = ra.getRispostaPerRiferimento().toString();
  463.                     if ((risprif == null) || "".equals(risprif)) {
  464.                         risprif = CostantiConfigurazione.DISABILITATO.toString();
  465.                     }
  466.                 }
  467.                
  468.                 if ((tipoauthRichiesta == null) && (ra != null) && ra.getAutenticazione()!=null) {
  469.                     tipoauthRichiesta = ra.getAutenticazione().getValue();
  470.                 }
  471.                 if ((tipoauthRichiesta == null) || "".equals(tipoauthRichiesta)) {
  472.                     tipoauthRichiesta = CostantiConfigurazione.INVOCAZIONE_SERVIZIO_AUTENTICAZIONE_NONE.toString();
  473.                 }
  474.                 if ((user == null) && (cra != null)) {
  475.                     user = cra.getUser();
  476.                     password = cra.getPassword();
  477.                 }
  478.                 if (endpointtype == null) {
  479.                     if ((connra.getCustom()!=null && connra.getCustom()) &&
  480.                             !connra.getTipo().equals(TipiConnettore.HTTPS.toString()) &&
  481.                             !connra.getTipo().equals(TipiConnettore.FILE.toString()) &&
  482.                             !connra.getTipo().equals(TipiConnettore.STATUS.toString()) ) {
  483.                         endpointtype = TipiConnettore.CUSTOM.toString();
  484.                         tipoconn = connra.getTipo();
  485.                     } else
  486.                         endpointtype = connra.getTipo();
  487.                 }
  488.                
  489.                 Map<String, String> props = null;
  490.                 if(ra!=null && ra.getConnettore()!=null)
  491.                     props = ra.getConnettore().getProperties();
  492.                
  493.                 if(connettoreDebug==null && props!=null){
  494.                     String v = props.get(CostantiDB.CONNETTORE_DEBUG);
  495.                     if(v!=null){
  496.                         if("true".equals(v)){
  497.                             connettoreDebug = Costanti.CHECK_BOX_ENABLED;
  498.                         }
  499.                         else{
  500.                             connettoreDebug = Costanti.CHECK_BOX_DISABLED;
  501.                         }
  502.                     }
  503.                 }
  504.                
  505.                 if(proxyEnabled==null && props!=null){
  506.                     String v = props.get(CostantiDB.CONNETTORE_PROXY_TYPE);
  507.                     if(v!=null && !"".equals(v)){
  508.                         proxyEnabled = Costanti.CHECK_BOX_ENABLED_TRUE;
  509.                        
  510.                         // raccolgo anche altre proprietà
  511.                         v = props.get(CostantiDB.CONNETTORE_PROXY_HOSTNAME);
  512.                         if(v!=null && !"".equals(v)){
  513.                             proxyHostname = v.trim();
  514.                         }
  515.                         v = props.get(CostantiDB.CONNETTORE_PROXY_PORT);
  516.                         if(v!=null && !"".equals(v)){
  517.                             proxyPort = v.trim();
  518.                         }
  519.                         v = props.get(CostantiDB.CONNETTORE_PROXY_USERNAME);
  520.                         if(v!=null && !"".equals(v)){
  521.                             proxyUsername = v.trim();
  522.                         }
  523.                         v = props.get(CostantiDB.CONNETTORE_PROXY_PASSWORD);
  524.                         if(v!=null && !"".equals(v)){
  525.                             proxyPassword = v.trim();
  526.                         }
  527.                     }
  528.                 }
  529.                
  530.                 if(tempiRispostaEnabled == null ||
  531.                         tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout)
  532.                         ||
  533.                         tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout)
  534.                         ||
  535.                         tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ){
  536.                    
  537.                     ConfigurazioneCore configCore = new ConfigurazioneCore(soggettiCore);
  538.                     ConfigurazioneGenerale configGenerale = configCore.getConfigurazioneControlloTraffico();
  539.                    
  540.                     if(props!=null) {
  541.                         if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout) ) {
  542.                             String v = props.get(CostantiDB.CONNETTORE_CONNECTION_TIMEOUT);
  543.                             if(v!=null && !"".equals(v)){
  544.                                 tempiRispostaConnectionTimeout = v.trim();
  545.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  546.                             }
  547.                             else {
  548.                                 tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaErogazione().getConnectionTimeout().intValue()+"";
  549.                             }
  550.                         }
  551.                            
  552.                         if(tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout) ) {
  553.                             String v = props.get(CostantiDB.CONNETTORE_READ_CONNECTION_TIMEOUT);
  554.                             if(v!=null && !"".equals(v)){
  555.                                 tempiRispostaReadTimeout = v.trim();
  556.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  557.                             }
  558.                             else {
  559.                                 tempiRispostaReadTimeout = configGenerale.getTempiRispostaErogazione().getReadTimeout().intValue()+"";
  560.                             }
  561.                         }
  562.                        
  563.                         if(tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ) {
  564.                             String v = props.get(CostantiDB.CONNETTORE_TEMPO_MEDIO_RISPOSTA);
  565.                             if(v!=null && !"".equals(v)){
  566.                                 tempiRispostaTempoMedioRisposta = v.trim();
  567.                                 tempiRispostaEnabled =  Costanti.CHECK_BOX_ENABLED_TRUE;
  568.                             }
  569.                             else {
  570.                                 tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaErogazione().getTempoMedioRisposta().intValue()+"";
  571.                             }
  572.                         }
  573.                     }
  574.                     else {
  575.                         if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout) ) {
  576.                             tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaErogazione().getConnectionTimeout().intValue()+"";
  577.                         }
  578.                         if(tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout) ) {
  579.                             tempiRispostaReadTimeout = configGenerale.getTempiRispostaErogazione().getReadTimeout().intValue()+"";
  580.                         }
  581.                         if(tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ) {
  582.                             tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaErogazione().getTempoMedioRisposta().intValue()+"";
  583.                         }
  584.                     }
  585.                 }
  586.                
  587.                 if(transferMode==null && props!=null){
  588.                     String v = props.get(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE);
  589.                     if(v!=null && !"".equals(v)){
  590.                        
  591.                         transferMode = v.trim();
  592.                        
  593.                         if(TransferLengthModes.TRANSFER_ENCODING_CHUNKED.getNome().equals(transferMode)){
  594.                             // raccolgo anche altra proprietà correlata
  595.                             v = props.get(CostantiDB.CONNETTORE_HTTP_DATA_TRANSFER_MODE_CHUNK_SIZE);
  596.                             if(v!=null && !"".equals(v)){
  597.                                 transferModeChunkSize = v.trim();
  598.                             }
  599.                         }
  600.                        
  601.                     }
  602.                 }
  603.                
  604.                 if(redirectMode==null && props!=null){
  605.                     String v = props.get(CostantiDB.CONNETTORE_HTTP_REDIRECT_FOLLOW);
  606.                     if(v!=null && !"".equals(v)){
  607.                        
  608.                         if("true".equalsIgnoreCase(v.trim()) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v.trim())){
  609.                             redirectMode = CostantiConfigurazione.ABILITATO.getValue();
  610.                         }
  611.                         else{
  612.                             redirectMode = CostantiConfigurazione.DISABILITATO.getValue();
  613.                         }                  
  614.                        
  615.                         if(CostantiConfigurazione.ABILITATO.getValue().equals(redirectMode)){
  616.                             // raccolgo anche altra proprietà correlata
  617.                             v = props.get(CostantiDB.CONNETTORE_HTTP_REDIRECT_MAX_HOP);
  618.                             if(v!=null && !"".equals(v)){
  619.                                 redirectMaxHop = v.trim();
  620.                             }
  621.                         }
  622.                        
  623.                     }
  624.                 }
  625.                
  626.                 if(tokenPolicy==null && props!=null){
  627.                     String v = props.get(CostantiDB.CONNETTORE_TOKEN_POLICY);
  628.                     if(v!=null && !"".equals(v)){
  629.                         tokenPolicy = v;
  630.                         autenticazioneToken = true;
  631.                     }
  632.                 }
  633.                
  634.                 opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(saHelper, transferMode, redirectMode);
  635.                
  636.                 autenticazioneHttp = saHelper.getAutenticazioneHttp(autenticazioneHttp, endpointtype, user);
  637.                
  638.                 if(autenticazioneApiKey==null || StringUtils.isEmpty(autenticazioneApiKey)) {
  639.                     for (int i = 0; i < connra.sizePropertyList(); i++) {
  640.                         Property singlecp = cp.get(i);
  641.                         if (singlecp.getNome().equals(CostantiDB.CONNETTORE_APIKEY_HEADER)) {
  642.                             apiKeyHeader = singlecp.getValore();
  643.                         }
  644.                         else if (singlecp.getNome().equals(CostantiDB.CONNETTORE_APIKEY)) {
  645.                             apiKeyValue = singlecp.getValore();
  646.                         }
  647.                         else if (singlecp.getNome().equals(CostantiDB.CONNETTORE_APIKEY_APPID_HEADER)) {
  648.                             appIdHeader = singlecp.getValore();
  649.                         }
  650.                         else if (singlecp.getNome().equals(CostantiDB.CONNETTORE_APIKEY_APPID)) {
  651.                             appIdValue = singlecp.getValore();
  652.                         }
  653.                     }
  654.                    
  655.                     autenticazioneApiKey = saHelper.getAutenticazioneApiKey(autenticazioneApiKey, endpointtype, apiKeyValue);
  656.                     if(ServletUtils.isCheckBoxEnabled(autenticazioneApiKey)) {
  657.                         useOAS3Names = saHelper.isAutenticazioneApiKeyUseOAS3Names(apiKeyHeader, appIdHeader);
  658.                         useAppId = saHelper.isAutenticazioneApiKeyUseAppId(appIdValue);
  659.                     }
  660.                     else {
  661.                         apiKeyValue=null;
  662.                         apiKeyHeader=null;
  663.                         appIdHeader=null;
  664.                         appIdValue=null;
  665.                     }
  666.                 }
  667.                
  668.                 for (int i = 0; i < connra.sizePropertyList(); i++) {
  669.                     Property singlecp = cp.get(i);
  670.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_HTTP_LOCATION) &&
  671.                         url == null) {
  672.                         url = singlecp.getValore();
  673.                     }
  674.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_NOME) &&
  675.                         nome == null) {
  676.                         nome = singlecp.getValore();
  677.                     }
  678.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_TIPO) &&
  679.                         tipo == null) {
  680.                         tipo = singlecp.getValore();
  681.                     }
  682.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_CONNECTION_FACTORY) &&
  683.                         connfact == null) {
  684.                         connfact = singlecp.getValore();
  685.                     }
  686.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_SEND_AS) &&
  687.                         sendas == null) {
  688.                         sendas = singlecp.getValore();
  689.                     }
  690.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_FACTORY_INITIAL) &&
  691.                         initcont == null) {
  692.                         initcont = singlecp.getValore();
  693.                     }
  694.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_FACTORY_URL_PKG) &&
  695.                         urlpgk == null) {
  696.                         urlpgk = singlecp.getValore();
  697.                     }
  698.                     if (singlecp.getNome().equals(CostantiDB.CONNETTORE_JMS_CONTEXT_JAVA_NAMING_PROVIDER_URL) &&
  699.                         provurl == null) {
  700.                         provurl = singlecp.getValore();
  701.                     }
  702.                 }

  703.                 if (httpstipologia == null) {
  704.                     httpsurl = props.get(CostantiDB.CONNETTORE_HTTPS_LOCATION);
  705.                     httpstipologia = props.get(CostantiDB.CONNETTORE_HTTPS_SSL_TYPE);
  706.                     httpshostverifyS = props.get(CostantiDB.CONNETTORE_HTTPS_HOSTNAME_VERIFIER);
  707.                     if(httpshostverifyS!=null){
  708.                         httpshostverify = Boolean.valueOf(httpshostverifyS);
  709.                     }
  710.                     httpsTrustVerifyCertS = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_ALL_CERTS);
  711.                     if(httpsTrustVerifyCertS!=null){
  712.                         httpsTrustVerifyCert = !Boolean.valueOf(httpsTrustVerifyCertS);
  713.                     }
  714.                     else {
  715.                         httpsTrustVerifyCert = true; // backward compatibility
  716.                     }
  717.                     httpspath = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_LOCATION);
  718.                     httpstipo = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  719.                     httpspwd = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  720.                     httpsalgoritmo = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  721.                     httpspwdprivatekeytrust = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_PASSWORD);
  722.                     httpspathkey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  723.                     httpstipokey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_TYPE);
  724.                     httpspwdkey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  725.                     httpspwdprivatekey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_PASSWORD);
  726.                     httpsalgoritmokey = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  727.                     httpsKeyAlias = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_ALIAS);
  728.                     httpsTrustStoreCRLs = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_CRLS);
  729.                     httpsTrustStoreOCSPPolicy = props.get(CostantiDB.CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  730.                     httpsKeyStoreBYOKPolicy = props.get(CostantiDB.CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  731.                     if (httpspathkey == null) {
  732.                         httpsstato = false;
  733.                         httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  734.                     } else {
  735.                         httpsstato = true;
  736.                         if (httpspathkey.equals(httpspath) &&
  737.                                 httpstipokey.equals(httpstipo) &&
  738.                                 (
  739.                                     (httpspwdkey!=null && httpspwdkey.equals(httpspwd))
  740.                                     ||
  741.                                     (httpspwdkey==null && httpspwd==null)
  742.                                 )
  743.                             )
  744.                             httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_DEFAULT;
  745.                         else
  746.                             httpskeystore = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE_RIDEFINISCI;
  747.                     }
  748.                 }
  749.                
  750.                 // default
  751.                 if(httpsalgoritmo==null || "".equals(httpsalgoritmo)){
  752.                     httpsalgoritmo = TrustManagerFactory.getDefaultAlgorithm();
  753.                 }
  754.                 if(httpsalgoritmokey==null || "".equals(httpsalgoritmokey)){
  755.                     httpsalgoritmokey = KeyManagerFactory.getDefaultAlgorithm();
  756.                 }
  757.                 if(httpstipologia==null || "".equals(httpstipologia)){
  758.                     httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE;
  759.                 }
  760.                 if(httpshostverifyS==null || "".equals(httpshostverifyS)){
  761.                     httpshostverifyS = Costanti.CHECK_BOX_ENABLED_TRUE;
  762.                     httpshostverify = ServletUtils.isCheckBoxEnabled(httpshostverifyS);
  763.                 }
  764.                 if(httpsTrustVerifyCertS==null || "".equals(httpsTrustVerifyCertS)){
  765.                     httpsTrustVerifyCertS = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS ? Costanti.CHECK_BOX_ENABLED_TRUE : Costanti.CHECK_BOX_DISABLED;
  766.                     httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  767.                 }
  768.                
  769.                 // file
  770.                 if(responseInputMode==null && props!=null){
  771.                    
  772.                     requestOutputFileName = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE);  
  773.                     requestOutputFileNamePermissions = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_PERMISSIONS);  
  774.                     requestOutputFileNameHeaders = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_HEADERS);  
  775.                     requestOutputFileNameHeadersPermissions = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_FILE_HEADERS_PERMISSIONS);
  776.                     String v = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  777.                     if(v!=null && !"".equals(v) &&
  778.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  779.                         ){
  780.                         requestOutputParentDirCreateIfNotExists = Costanti.CHECK_BOX_ENABLED_TRUE;
  781.                     }                  
  782.                     v = props.get(CostantiDB.CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE);
  783.                     if(v!=null && !"".equals(v) &&
  784.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  785.                         ){
  786.                         requestOutputOverwriteIfExists = Costanti.CHECK_BOX_ENABLED_TRUE;
  787.                     }  
  788.                    
  789.                     v = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  790.                     if(v!=null && !"".equals(v) &&
  791.                         ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  792.                         ){
  793.                         responseInputMode = CostantiConfigurazione.ABILITATO.getValue();
  794.                     }
  795.                     if(CostantiConfigurazione.ABILITATO.getValue().equals(responseInputMode)){                      
  796.                         responseInputFileName = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE);
  797.                         responseInputFileNameHeaders = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE_HEADERS);
  798.                         v = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_FILE_DELETE_AFTER_READ);
  799.                         if(v!=null && !"".equals(v) &&
  800.                             ("true".equalsIgnoreCase(v) || CostantiConfigurazione.ABILITATO.getValue().equalsIgnoreCase(v) )
  801.                             ){
  802.                             responseInputDeleteAfterRead = Costanti.CHECK_BOX_ENABLED_TRUE;
  803.                         }                      
  804.                         responseInputWaitTime = props.get(CostantiDB.CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);                    
  805.                     }
  806.                    
  807.                 }
  808.                
  809.                
  810.                 // preparo i campi
  811.                 List<DataElement> dati = new ArrayList<>();

  812.                 dati.add(ServletUtils.getDataElementForEditModeFinished());
  813.                
  814.                 saHelper.addEndPointToDati(dati,idsil,nomeservizioApplicativo,sbustamento,sbustamentoInformazioniProtocolloRichiesta,
  815.                         getmsg,getmsgUsername,getmsgPassword,true,
  816.                         invrifRichiesta,risprif,nomeProtocollo,true,false,true,
  817.                         parentSA,serviceBinding, accessoDaAPSParametro, erogazioneServizioApplicativoServerEnabled,
  818.                         null, false,
  819.                         integrationManagerEnabled,
  820.                         TipoOperazione.CHANGE, null,null,
  821.                         postBackViaPost);
  822.                
  823.                 dati = saHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp, null,
  824.                         url, nome,
  825.                         tipo, user, password, initcont, urlpgk, provurl,
  826.                         connfact, sendas, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI, TipoOperazione.CHANGE,
  827.                         httpsurl, httpstipologia, httpshostverify,
  828.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  829.                         httpsalgoritmo, httpsstato, httpskeystore,
  830.                         httpspwdprivatekeytrust, httpspathkey,
  831.                         httpstipokey, httpspwdkey,
  832.                         httpspwdprivatekey, httpsalgoritmokey,
  833.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  834.                         tipoconn, ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA,
  835.                         nomeservizioApplicativo, idsil, null, null, null, null,
  836.                         null, null, true,
  837.                         isConnettoreCustomUltimaImmagineSalvata,
  838.                         proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  839.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  840.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  841.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  842.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  843.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  844.                         autenticazioneToken,tokenPolicy, forcePDND, forceOAuth,
  845.                         listExtendedConnettore, forceEnabled,
  846.                         nomeProtocollo, false, false
  847.                         , false, erogazioneServizioApplicativoServerEnabled, null, null,
  848.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  849.                         connettoreStatusParams,
  850.                         postBackViaPost
  851.                         );
  852.                
  853.                 dati = saHelper.addHiddenFieldsToDati(dati, provider, idAsps, idPorta);
  854.                
  855.                 dati = saHelper.addHiddenFieldsToDati(TipoOperazione.CHANGE, null, null, idPorta, idAsps, dati);

  856.                 pd.setDati(dati);

  857.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  858.                
  859.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,
  860.                         ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_RISPOSTA_ASINCRONA);
  861.             }

  862.             // Controlli sui campi immessi
  863.             boolean isOk = saHelper.servizioApplicativoEndPointCheckData(protocollo, listExtendedConnettore, sa);
  864.             if (!isOk) {
  865.                
  866.                 // setto la barra del titolo
  867.                 ServletUtils.setPageDataTitle(pd, lstParm);

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

  870.                 dati.add(ServletUtils.getDataElementForEditModeFinished());
  871.                
  872.                 saHelper.addEndPointToDati(dati,idsil,nomeservizioApplicativo,sbustamento,sbustamentoInformazioniProtocolloRichiesta,
  873.                         getmsg,getmsgUsername,getmsgPassword,true,
  874.                         invrifRichiesta,risprif,nomeProtocollo,true,false,true,
  875.                         parentSA,serviceBinding, accessoDaAPSParametro, erogazioneServizioApplicativoServerEnabled,
  876.                         null, false,
  877.                         integrationManagerEnabled,
  878.                         TipoOperazione.CHANGE, null,null,
  879.                         postBackViaPost);
  880.                
  881.                 dati = saHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp, null,
  882.                         url, nome,
  883.                         tipo, "", "", initcont, urlpgk, provurl, connfact,
  884.                         sendas, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI, TipoOperazione.CHANGE,
  885.                         httpsurl, httpstipologia, httpshostverify,
  886.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  887.                         httpsalgoritmo, httpsstato, httpskeystore,
  888.                         httpspwdprivatekeytrust, httpspathkey,
  889.                         httpstipokey, httpspwdkey,
  890.                         httpspwdprivatekey, httpsalgoritmokey,
  891.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  892.                         tipoconn, ServiziApplicativiCostanti.SERVLET_NAME_SERVIZI_APPLICATIVI_ENDPOINT_RISPOSTA,
  893.                         nomeservizioApplicativo, idsil, null, null, null, null,
  894.                         null, null, true,
  895.                         isConnettoreCustomUltimaImmagineSalvata,
  896.                         proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  897.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  898.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  899.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  900.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  901.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  902.                         autenticazioneToken,tokenPolicy, forcePDND, forceOAuth,
  903.                         listExtendedConnettore, forceEnabled,
  904.                         nomeProtocollo, false, false
  905.                         , false, erogazioneServizioApplicativoServerEnabled, null, null,
  906.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  907.                         connettoreStatusParams,
  908.                         postBackViaPost
  909.                         );
  910.                
  911.                 dati = saHelper.addHiddenFieldsToDati(dati, provider, idAsps, idPorta);
  912.                
  913.                 dati = saHelper.addHiddenFieldsToDati(TipoOperazione.CHANGE, null, null, idPorta, idAsps, dati);

  914.                 pd.setDati(dati);

  915.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  916.                
  917.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,
  918.                         ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_RISPOSTA_ASINCRONA);
  919.             }

  920.             // Modifico i dati del servizioApplicativo nel db
  921.             if(sbustamento==null){
  922.                 ra.setSbustamentoSoap(CostantiConfigurazione.DISABILITATO);
  923.             }else{
  924.                 ra.setSbustamentoSoap(StatoFunzionalita.toEnumConstant(sbustamento));
  925.             }
  926.             if(sbustamentoInformazioniProtocolloRichiesta==null){
  927.                 ra.setSbustamentoInformazioniProtocollo(CostantiConfigurazione.ABILITATO);
  928.             }else{
  929.                 ra.setSbustamentoInformazioniProtocollo(StatoFunzionalita.toEnumConstant(sbustamentoInformazioniProtocolloRichiesta));
  930.             }
  931.             ra.setGetMessage(StatoFunzionalita.toEnumConstant(getmsg));
  932.             ra.setInvioPerRiferimento(StatoFunzionalita.toEnumConstant(invrifRichiesta));
  933.             ra.setRispostaPerRiferimento(StatoFunzionalita.toEnumConstant(risprif));
  934.             if (tipoauthRichiesta!=null && tipoauthRichiesta.equals(CostantiConfigurazione.INVOCAZIONE_SERVIZIO_AUTENTICAZIONE_BASIC.toString())) {
  935.                 if (cra == null) {
  936.                     cra = new InvocazioneCredenziali();
  937.                 }
  938.                 cra.setUser(user);
  939.                 cra.setPassword(password);
  940.                 ra.setCredenziali(cra);
  941.                 ra.setAutenticazione(InvocazioneServizioTipoAutenticazione.BASIC);
  942.             }
  943.             else if(endpointtype.equals(TipiConnettore.JMS.toString())){
  944.                 if(user!=null && password!=null){
  945.                     if (cra == null) {
  946.                         cra = new InvocazioneCredenziali();
  947.                     }
  948.                     cra.setUser(user);
  949.                     cra.setPassword(password);
  950.                 }
  951.                 ra.setCredenziali(cra);
  952.                 ra.setAutenticazione(InvocazioneServizioTipoAutenticazione.BASIC);
  953.             }
  954.             else {
  955.                 ra.setCredenziali(null);
  956.                 ra.setAutenticazione(InvocazioneServizioTipoAutenticazione.NONE);
  957.             }
  958.             String oldConnT = connra.getTipo();
  959.             if ((connra.getCustom()!=null && connra.getCustom()) &&
  960.                     !connra.getTipo().equals(TipiConnettore.HTTPS.toString()) &&
  961.                     !connra.getTipo().equals(TipiConnettore.FILE.toString()) &&
  962.                     !connra.getTipo().equals(TipiConnettore.STATUS.toString()))
  963.                 oldConnT = TipiConnettore.CUSTOM.toString();
  964.             saHelper.fillConnettore(connra, connettoreDebug, endpointtype, oldConnT, tipoconn, url,
  965.                     nome, tipo, user, password,
  966.                     initcont, urlpgk, provurl, connfact,
  967.                     sendas, httpsurl, httpstipologia, httpshostverify,
  968.                     httpsTrustVerifyCert, httpspath, httpstipo,
  969.                     httpspwd, httpsalgoritmo, httpsstato,
  970.                     httpskeystore, httpspwdprivatekeytrust,
  971.                     httpspathkey, httpstipokey,
  972.                     httpspwdkey, httpspwdprivatekey,
  973.                     httpsalgoritmokey,
  974.                     httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  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.                     tokenPolicy,
  982.                     apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  983.                     connettoreStatusParams,
  984.                     listExtendedConnettore);
  985.             ra.setConnettore(connra);
  986.             sa.setRispostaAsincrona(ra);

  987.             if(CostantiConfigurazione.ABILITATO.toString().equals(getmsg)) {
  988.                 boolean found = false;
  989.                 if(invocazionePorta!=null && invocazionePorta.sizeCredenzialiList()>0) {
  990.                     for (int i = 0; i < invocazionePorta.sizeCredenzialiList(); i++) {
  991.                         Credenziali c = invocazionePorta.getCredenziali(i);
  992.                         if(CredenzialeTipo.BASIC.equals(c.getTipo())) {
  993.                             c.setUser(getmsgUsername);
  994.                             c.setPassword(getmsgPassword);
  995.                             found = true;
  996.                         }
  997.                     }
  998.                 }
  999.                 if(!found) {
  1000.                     if(invocazionePorta==null) {
  1001.                         sa.setInvocazionePorta(new InvocazionePorta());
  1002.                         invocazionePorta = sa.getInvocazionePorta();
  1003.                     }
  1004.                     Credenziali c = new Credenziali();
  1005.                     c.setTipo(CredenzialeTipo.BASIC);
  1006.                     c.setUser(getmsgUsername);
  1007.                     c.setPassword(getmsgPassword);
  1008.                     invocazionePorta.addCredenziali(c);
  1009.                 }
  1010.             }
  1011.            
  1012.             String userLogin = ServletUtils.getUserLoginFromSession(session);
  1013.            
  1014.             saCore.performUpdateOperation(userLogin, saHelper.smista(), sa);

  1015.             // Preparo la lista
  1016.             ConsoleSearch ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);
  1017.            
  1018.             List<ServizioApplicativo> lista = null;
  1019.             int idLista = -1;
  1020.             switch (parentSA) {
  1021.             case ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_CONFIGURAZIONE:
  1022.                 if(accessoDaListaAPS) {
  1023.                     idLista = Liste.SERVIZI;
  1024.                     ricerca = saHelper.checkSearchParameters(idLista, ricerca);
  1025.                     if(gestioneErogatori) {
  1026.                         ricerca.addFilter(idLista, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE);
  1027.                     }
  1028.                     boolean [] permessi = new boolean[2];
  1029.                     PermessiUtente pu = ServletUtils.getUserFromSession(request, session).getPermessi();
  1030.                     permessi[0] = pu.isServizi();
  1031.                     permessi[1] = pu.isAccordiCooperazione();
  1032.                     List<AccordoServizioParteSpecifica> listaS = null;
  1033.                     AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(saCore);
  1034.                     if(apsCore.isVisioneOggettiGlobale(superUser)){
  1035.                         listaS = apsCore.soggettiServizioList(null, ricerca,permessi,session, request);
  1036.                     }else{
  1037.                         listaS = apsCore.soggettiServizioList(superUser, ricerca,permessi,session, request);
  1038.                     }
  1039.                     AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  1040.                     apsHelper.prepareServiziList(ricerca, listaS);
  1041.                 }
  1042.                 else {
  1043.                     idLista = Liste.CONFIGURAZIONE_EROGAZIONE;
  1044.                     ricerca = saHelper.checkSearchParameters(idLista, ricerca);
  1045.                     int idServizio = Integer.parseInt(idAsps);
  1046.                     AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(saCore);
  1047.                     AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idServizio);
  1048.                     IDServizio idServizio2 = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  1049.                     Long idSoggetto = asps.getIdSoggetto() != null ? asps.getIdSoggetto() : -1L;
  1050.                     List<MappingErogazionePortaApplicativa> lista2 = apsCore.mappingServiziPorteAppList(idServizio2,asps.getId(),ricerca);
  1051.                     AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  1052.                     apsHelper.prepareServiziConfigurazioneList(lista2, idAsps, idSoggetto+"", ricerca);
  1053.                 }
  1054.                 break;
  1055.             case ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_SOGGETTO:
  1056.                 idLista = Liste.SERVIZI_APPLICATIVI_BY_SOGGETTO;
  1057.                 ricerca = saHelper.checkSearchParameters(idLista, ricerca);
  1058.                 lista = saCore.soggettiServizioApplicativoList(ricerca,soggLong);
  1059.                 saHelper.prepareServizioApplicativoList(ricerca, lista, useIdSogg);
  1060.                 break;
  1061.             case ServiziApplicativiCostanti.ATTRIBUTO_SERVIZI_APPLICATIVI_PARENT_NONE:
  1062.             default:
  1063.                 idLista = Liste.SERVIZIO_APPLICATIVO;
  1064.                 ricerca = saHelper.checkSearchParameters(idLista, ricerca);
  1065.                
  1066.                 if(saCore.isVisioneOggettiGlobale(superUser)){
  1067.                     lista = saCore.soggettiServizioApplicativoList(null, ricerca);
  1068.                 }else{
  1069.                     lista = saCore.soggettiServizioApplicativoList(superUser, ricerca);
  1070.                 }
  1071.                 saHelper.prepareServizioApplicativoList(ricerca, lista, useIdSogg);
  1072.                 break;
  1073.             }

  1074.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  1075.            
  1076.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,
  1077.                     ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_RISPOSTA_ASINCRONA);

  1078.         } catch (Exception e) {
  1079.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  1080.                     ServiziApplicativiCostanti.OBJECT_NAME_SERVIZI_APPLICATIVI,ServiziApplicativiCostanti.TIPO_OPERAZIONE_ENDPOINT_RISPOSTA_ASINCRONA);
  1081.         }

  1082.     }
  1083. }