PorteApplicativeConnettoreDefault.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.pa;

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

  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.InvocazioneServizio;
  38. import org.openspcoop2.core.config.PortaApplicativa;
  39. import org.openspcoop2.core.config.PortaApplicativaServizioApplicativo;
  40. import org.openspcoop2.core.config.RispostaAsincrona;
  41. import org.openspcoop2.core.config.ServizioApplicativo;
  42. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  43. import org.openspcoop2.core.config.constants.InvocazioneServizioTipoAutenticazione;
  44. import org.openspcoop2.core.config.constants.TipologiaErogazione;
  45. import org.openspcoop2.core.config.constants.TipologiaFruizione;
  46. import org.openspcoop2.core.config.driver.db.IDServizioApplicativoDB;
  47. import org.openspcoop2.core.constants.CostantiConnettori;
  48. import org.openspcoop2.core.constants.TipiConnettore;
  49. import org.openspcoop2.core.controllo_traffico.ConfigurazioneGenerale;
  50. import org.openspcoop2.core.id.IDServizio;
  51. import org.openspcoop2.core.mapping.MappingErogazionePortaApplicativa;
  52. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  53. import org.openspcoop2.core.registry.Connettore;
  54. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  55. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  56. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  57. import org.openspcoop2.message.constants.ServiceBinding;
  58. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  59. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  60. import org.openspcoop2.web.ctrlstat.costanti.ConnettoreServletType;
  61. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  62. import org.openspcoop2.web.ctrlstat.plugins.ExtendedConnettore;
  63. import org.openspcoop2.web.ctrlstat.plugins.servlet.ServletExtendedConnettoreUtils;
  64. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  65. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  66. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  67. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCostanti;
  68. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaHelper;
  69. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  70. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoreStatusParams;
  71. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriCostanti;
  72. import org.openspcoop2.web.ctrlstat.servlet.connettori.ConnettoriHelper;
  73. import org.openspcoop2.web.ctrlstat.servlet.pd.PorteDelegateCostanti;
  74. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCore;
  75. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCostanti;
  76. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiHelper;
  77. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  78. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCostanti;
  79. import org.openspcoop2.web.lib.mvc.Costanti;
  80. import org.openspcoop2.web.lib.mvc.DataElement;
  81. import org.openspcoop2.web.lib.mvc.ForwardParams;
  82. import org.openspcoop2.web.lib.mvc.GeneralData;
  83. import org.openspcoop2.web.lib.mvc.PageData;
  84. import org.openspcoop2.web.lib.mvc.Parameter;
  85. import org.openspcoop2.web.lib.mvc.ServletUtils;
  86. import org.openspcoop2.web.lib.mvc.TipoOperazione;
  87. import org.openspcoop2.web.lib.users.dao.PermessiUtente;

  88. /**    
  89.  * PorteApplicativeConnettoreDefault
  90.  *
  91.  * @author Pintori Giuliano (pintori@link.it)
  92.  * @author $Author$
  93.  * @version $Rev$, $Date$
  94.  */
  95. public class PorteApplicativeConnettoreDefault extends Action {

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

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

  99.         // Inizializzo PageData
  100.         PageData pd = new PageData();

  101.         GeneralHelper generalHelper = new GeneralHelper(session);

  102.         // Inizializzo GeneralData
  103.         GeneralData gd = generalHelper.initGeneralData(request);

  104.         try {

  105.             PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(request, pd, session);
  106.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte applicative
  107.             Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, session, request);
  108.             if(parentPA == null) parentPA = PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE;
  109.            
  110.             // Preparo il menu
  111.             porteApplicativeHelper.makeMenu();

  112.             String id = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  113.             int idInt = Integer.parseInt(id);
  114.             String idsogg = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  115.             if(idsogg==null) {
  116.                 throw new CoreException("Param '"+PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO+"' is null");
  117.             }
  118.             int soggInt = Integer.parseInt(idsogg);
  119.             String idAsps = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  120.             if(idAsps == null)
  121.                 idAsps = "";

  122.             String idTab = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_ID_TAB);
  123.             if(!porteApplicativeHelper.isModalitaCompleta() && StringUtils.isNotEmpty(idTab)) {
  124.                 ServletUtils.setObjectIntoSession(request, session, idTab, CostantiControlStation.PARAMETRO_ID_TAB);
  125.             }

  126.             Properties parametersPOST = null;

  127.             String endpointtype = porteApplicativeHelper.readEndPointType();
  128.             String tipoconn = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TIPO_PERSONALIZZATO );
  129.             String autenticazioneHttp = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_HTTP);

  130.             String connettoreDebug = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_DEBUG);

  131.             // token policy
  132.             String autenticazioneTokenS = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY_STATO);
  133.             boolean autenticazioneToken = ServletUtils.isCheckBoxEnabled(autenticazioneTokenS);
  134.             String tokenPolicy = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TOKEN_POLICY);
  135.             boolean forcePDND = false;
  136.             boolean forceOAuth = false;

  137.             // proxy
  138.             String proxyEnabled = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_ENABLED);
  139.             String proxyHostname = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_HOSTNAME);
  140.             String proxyPort = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PORT);
  141.             String proxyUsername = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_USERNAME);
  142.             String proxyPassword = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_PROXY_PASSWORD);

  143.             // tempi risposta
  144.             String tempiRispostaEnabled = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_REDEFINE);
  145.             String tempiRispostaConnectionTimeout = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_CONNECTION_TIMEOUT);
  146.             String tempiRispostaReadTimeout = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_READ_TIMEOUT);
  147.             String tempiRispostaTempoMedioRisposta = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_TEMPI_RISPOSTA_TEMPO_MEDIO_RISPOSTA);

  148.             // opzioni avanzate
  149.             String transferMode = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_MODE);
  150.             String transferModeChunkSize = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_TRANSFER_CHUNK_SIZE);
  151.             String redirectMode = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MODE);
  152.             String redirectMaxHop = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_OPZIONI_AVANZATE_REDIRECT_MAX_HOP);
  153.             String opzioniAvanzate = ConnettoriHelper.getOpzioniAvanzate(porteApplicativeHelper, transferMode, redirectMode);

  154.             String user= null;
  155.             String password =null;

  156.             // http
  157.             String url = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_URL  );
  158.             if(TipiConnettore.HTTP.toString().equals(endpointtype)){
  159.                 user = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  160.                 password = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  161.             }
  162.            
  163.             // api key
  164.             String autenticazioneApiKey = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ENDPOINT_TYPE_ENABLE_API_KEY);
  165.             String apiKeyHeader = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_HEADER);
  166.             if(apiKeyHeader==null || StringUtils.isEmpty(apiKeyHeader)) {
  167.                 apiKeyHeader = CostantiConnettori.DEFAULT_HEADER_API_KEY;
  168.             }
  169.             String apiKeyValue = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_VALUE);
  170.             String appIdHeader = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_HEADER);
  171.             if(appIdHeader==null || StringUtils.isEmpty(appIdHeader)) {
  172.                 appIdHeader = CostantiConnettori.DEFAULT_HEADER_APP_ID;
  173.             }
  174.             String appIdValue = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_APP_ID_VALUE);
  175.             String useOAS3NamesTmp = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_NOMI_OAS);
  176.             boolean useOAS3Names=true;
  177.             if(useOAS3NamesTmp!=null && StringUtils.isNotEmpty(useOAS3NamesTmp)) {
  178.                 useOAS3Names = ServletUtils.isCheckBoxEnabled(useOAS3NamesTmp);
  179.             }
  180.             else {
  181.                 useOAS3Names = porteApplicativeHelper.isAutenticazioneApiKeyUseOAS3Names(apiKeyHeader, appIdHeader);
  182.             }
  183.             String useAppIdTmp = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_API_KEY_USE_APP_ID);
  184.             boolean useAppId=false;
  185.             if(useAppIdTmp!=null && StringUtils.isNotEmpty(useAppIdTmp)) {
  186.                 useAppId = ServletUtils.isCheckBoxEnabled(useAppIdTmp);
  187.             }
  188.             else {
  189.                 useAppId = porteApplicativeHelper.isAutenticazioneApiKeyUseAppId(appIdValue);
  190.             }

  191.             // jms
  192.             String nomeCodaJms = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_NOME_CODA);
  193.             String tipoJms = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_CODA);
  194.             String initcont = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_INIT_CTX);
  195.             String urlpgk = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_URL_PKG);
  196.             String provurl = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PROVIDER_URL);
  197.             String connfact = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_CONNECTION_FACTORY);
  198.             String tipoSendas = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_TIPO_OGGETTO_JMS);
  199.             if(TipiConnettore.JMS.toString().equals(endpointtype)){
  200.                 user = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_USERNAME);
  201.                 password = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_JMS_PASSWORD);
  202.             }

  203.             // https
  204.             String httpsurl = url;
  205.             String httpstipologia = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_SSL_TYPE );
  206.             String httpshostverifyS = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_HOST_VERIFY);
  207.             String httpsTrustVerifyCertS = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS );
  208.             boolean httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  209.             String httpspath = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_LOCATION );
  210.             String httpstipo = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_TYPE);
  211.             String httpspwd = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_PASSWORD);
  212.             String httpsalgoritmo = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_MANAGEMENT_ALGORITM);
  213.             String httpsstatoS = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_STATO);
  214.             String httpskeystore = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEYSTORE_CLIENT_AUTH_MODE);
  215.             String httpspwdprivatekeytrust = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_STORE);
  216.             String httpspathkey = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_LOCATION);
  217.             String httpstipokey = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_TYPE);
  218.             String httpspwdkey = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_PASSWORD);
  219.             String httpspwdprivatekey = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_PASSWORD_PRIVATE_KEY_KEYSTORE);
  220.             String httpsalgoritmokey = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_MANAGEMENT_ALGORITM);
  221.             String httpsKeyAlias = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_ALIAS_PRIVATE_KEY_KEYSTORE);
  222.             String httpsTrustStoreCRLs = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_CRL);
  223.             String httpsTrustStoreOCSPPolicy = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_TRUST_STORE_OCSP_POLICY);
  224.             String httpsKeyStoreBYOKPolicy = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_HTTPS_KEY_STORE_BYOK_POLICY);
  225.             if(TipiConnettore.HTTPS.toString().equals(endpointtype)){
  226.                 user = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_USERNAME);
  227.                 password = porteApplicativeHelper.getLockedParameter(ConnettoriCostanti.PARAMETRO_INVOCAZIONE_CREDENZIALI_AUTENTICAZIONE_PASSWORD);
  228.             }

  229.             // file
  230.             String requestOutputFileName = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME);
  231.             String requestOutputFileNamePermissions = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_PERMISSIONS);
  232.             String requestOutputFileNameHeaders = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS);
  233.             String requestOutputFileNameHeadersPermissions = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_FILE_NAME_HEADERS_PERMISSIONS);
  234.             String requestOutputParentDirCreateIfNotExists = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_AUTO_CREATE_DIR);
  235.             String requestOutputOverwriteIfExists = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_REQUEST_OUTPUT_OVERWRITE_FILE_NAME);
  236.             String responseInputMode = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_MODE);
  237.             String responseInputFileName = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME);
  238.             String responseInputFileNameHeaders = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_HEADERS);
  239.             String responseInputDeleteAfterRead = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_FILE_NAME_DELETE_AFTER_READ);
  240.             String responseInputWaitTime = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_FILE_RESPONSE_INPUT_WAIT_TIME);

  241.             // status
  242.             ConnettoreStatusParams connettoreStatusParams = ConnettoreStatusParams.fillFrom(porteApplicativeHelper);
  243.            
  244.             String erogazioneServizioApplicativoServerEnabledS = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ABILITA_USO_APPLICATIVO_SERVER);
  245.             boolean erogazioneServizioApplicativoServerEnabled = ServletUtils.isCheckBoxEnabled(erogazioneServizioApplicativoServerEnabledS);
  246.             String erogazioneServizioApplicativoServer = porteApplicativeHelper.getParameter(ConnettoriCostanti.PARAMETRO_CONNETTORE_ID_APPLICATIVO_SERVER);

  247.             boolean httpshostverify = false;
  248.             if (httpshostverifyS != null && httpshostverifyS.equals(Costanti.CHECK_BOX_ENABLED))
  249.                 httpshostverify = true;
  250.             boolean httpsstato = false;
  251.             if (httpsstatoS != null && httpsstatoS.equals(Costanti.CHECK_BOX_ENABLED))
  252.                 httpsstato = true;

  253.             Boolean isConnettoreCustomUltimaImmagineSalvata = null;

  254.             boolean forceEnableConnettore = false;
  255.             if( (!porteApplicativeHelper.isModalitaCompleta())) {
  256.                 forceEnableConnettore = true;
  257.             }

  258.             boolean postBackViaPost = true;
  259.            
  260.             Connettore conTmp = null;
  261.             List<ExtendedConnettore> listExtendedConnettore =
  262.                     ServletExtendedConnettoreUtils.getExtendedConnettore(conTmp, ConnettoreServletType.ACCORDO_SERVIZIO_PARTE_SPECIFICA_PORTA_APPLICATIVA_ADD, porteApplicativeHelper,
  263.                             parametersPOST, (endpointtype==null), endpointtype); // uso endpointtype per capire se è la prima volta che entro

  264.             // Prendo il nome della porta
  265.             PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore();
  266.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(porteApplicativeCore);
  267.             SoggettiCore soggettiCore = new SoggettiCore(porteApplicativeCore);
  268.             ServiziApplicativiCore saCore = new ServiziApplicativiCore(porteApplicativeCore);

  269.             boolean isApplicativiServerEnabled = apsCore.isApplicativiServerEnabled(porteApplicativeHelper);

  270.             // La lista degli SA viene filtrata per tipo se sono abilitati gli applicativiServer.
  271.             String tipoSA = (isApplicativiServerEnabled) ? ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER : null;

  272.             // Lista dei servizi applicativi per la creazione automatica
  273.             List<IDServizioApplicativoDB> listaIdSAServer = null;
  274.             if ((idsogg != null) && !idsogg.equals("")) {
  275.                 long idErogatore = Long.parseLong(idsogg);

  276.                 // I servizi applicativi da visualizzare sono quelli che hanno
  277.                 // -Integration Manager (getMessage abilitato)
  278.                 // -connettore != disabilitato
  279.                 listaIdSAServer = saCore.getIdServiziApplicativiWithIdErogatore(idErogatore, tipoSA, true, true);

  280.             }

  281.             PortaApplicativa portaApplicativa = porteApplicativeCore.getPortaApplicativa(idInt);
  282.             String idporta = portaApplicativa.getNome();

  283.             String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(portaApplicativa.getTipoSoggettoProprietario());

  284.             String modalita = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE);

  285.             String [] modalitaLabels = { PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_DEFAULT, PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_RIDEFINITO };
  286.             String [] modalitaValues = { PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_DEFAULT, PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_RIDEFINITO };

  287.             String postBackElementName = porteApplicativeHelper.getPostBackElementName();
  288.             boolean initConnettore = false;
  289.             // Controllo se ho modificato l'azione allora ricalcolo il nome
  290.             if(postBackElementName != null ){
  291.                 if(postBackElementName.equalsIgnoreCase(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE) &&
  292.                     // devo resettare il connettore
  293.                     modalita.equals(PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_RIDEFINITO)) {
  294.                     initConnettore = true;
  295.                 }

  296.                 if(postBackElementName.equalsIgnoreCase(ConnettoriCostanti.PARAMETRO_CONNETTORE_ABILITA_USO_APPLICATIVO_SERVER) &&
  297.                     // devo resettare il connettore se passo da SA Server a Default
  298.                     !erogazioneServizioApplicativoServerEnabled && modalita.equals(PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_RIDEFINITO)) {
  299.                     initConnettore = true;
  300.                 }
  301.             }

  302.             List<Parameter> lstParam = porteApplicativeHelper.getTitoloPA(parentPA, idsogg, idAsps);

  303.             String connettoreLabelDi = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DEFAULT_DI;
  304.             String connettoreLabel = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DEFAULT;
  305.             if(!porteApplicativeHelper.isModalitaCompleta()) {
  306.                 connettoreLabelDi = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE_DI;
  307.                 connettoreLabel = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONNETTORE;
  308.             }

  309.             String labelPerPorta = null;
  310.             if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  311.                 labelPerPorta = porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  312.                         connettoreLabelDi,
  313.                         connettoreLabel,
  314.                         portaApplicativa);
  315.             }
  316.             else {
  317.                 labelPerPorta = connettoreLabelDi+idporta;
  318.             }

  319.             lstParam.add(new Parameter(labelPerPorta,  null));

  320.             // setto la barra del titolo
  321.             ServletUtils.setPageDataTitle(pd, lstParam);
  322.            
  323.             // imposta menu' contestuale
  324.             porteApplicativeHelper.impostaComandiMenuContestualePA(idsogg, idAsps);

  325.             String servletConnettore = null;
  326.             Parameter[] parametriServletConnettore =null;

  327.             ServiceBinding serviceBinding = null;
  328.             if (!idAsps.equals("")) {
  329.                 long idAspsLong = Integer.parseInt(idAsps);
  330.                 AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(porteApplicativeCore);
  331.                 AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idAspsLong);
  332.                 AccordoServizioParteComuneSintetico aspc = apcCore.getAccordoServizioSintetico(IDAccordoFactory.getInstance().getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  333.                 serviceBinding = apcCore.toMessageServiceBinding(aspc.getServiceBinding());
  334.             }
  335.            
  336.             if( porteApplicativeHelper.isEditModeInProgress()){

  337.                 if(modalita == null) {
  338.                     modalita = PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_DEFAULT;
  339.                 }

  340.                 // solo in modalita' nuova
  341.                 if(initConnettore) {
  342.                     tipoconn = "";
  343.                     url = "";
  344.                     nomeCodaJms = "";
  345.                     user = "";
  346.                     password = "";
  347.                     initcont = "";
  348.                     urlpgk = "";
  349.                     provurl = "";
  350.                     connfact = "";
  351.                     httpsurl = "";
  352.                     httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE;
  353.                     httpshostverifyS = Costanti.CHECK_BOX_ENABLED_TRUE;
  354.                     httpshostverify = true;
  355.                     httpsTrustVerifyCert = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS;
  356.                     httpspath = "";
  357.                     httpstipo = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TIPOLOGIA_KEYSTORE_TYPE;
  358.                     httpspwd = "";
  359.                     httpsstato = false;
  360.                     httpskeystore = AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_DEFAULT;
  361.                     httpspwdprivatekeytrust = "";
  362.                     httpspathkey = "";
  363.                     httpstipokey =ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TIPOLOGIA_KEYSTORE_TYPE;
  364.                     httpspwdkey = "";
  365.                     httpspwdprivatekey = "";

  366.                     if(endpointtype==null) {
  367.                         if(!porteApplicativeHelper.isModalitaCompleta()) {
  368.                             endpointtype = TipiConnettore.HTTP.getNome();
  369.                         }
  370.                         else {
  371.                             endpointtype = AccordiServizioParteSpecificaCostanti.DEFAULT_VALUE_DISABILITATO;
  372.                         }
  373.                     }

  374.                     // default
  375.                     if(httpsalgoritmo==null || "".equals(httpsalgoritmo)){
  376.                         httpsalgoritmo = TrustManagerFactory.getDefaultAlgorithm();
  377.                     }
  378.                     if(httpsalgoritmokey==null || "".equals(httpsalgoritmokey)){
  379.                         httpsalgoritmokey = KeyManagerFactory.getDefaultAlgorithm();
  380.                     }
  381.                     if(httpstipologia==null || "".equals(httpstipologia)){
  382.                         httpstipologia = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TYPE;
  383.                     }
  384.                     if(httpshostverifyS==null || "".equals(httpshostverifyS)){
  385.                         httpshostverifyS = Costanti.CHECK_BOX_ENABLED_TRUE;
  386.                         httpshostverify = ServletUtils.isCheckBoxEnabled(httpshostverifyS);
  387.                     }
  388.                     if(httpsTrustVerifyCertS==null || "".equals(httpsTrustVerifyCertS)){
  389.                         httpsTrustVerifyCertS = ConnettoriCostanti.DEFAULT_CONNETTORE_HTTPS_TRUST_VERIFY_CERTS ? Costanti.CHECK_BOX_ENABLED_TRUE : Costanti.CHECK_BOX_DISABLED;
  390.                         httpsTrustVerifyCert = ServletUtils.isCheckBoxEnabled(httpsTrustVerifyCertS);
  391.                     }

  392.                     tipoSendas = ConnettoriCostanti.TIPO_SEND_AS[0];
  393.                     tipoJms = ConnettoriCostanti.TIPI_CODE_JMS[0];

  394.                     autenticazioneHttp = porteApplicativeHelper.getAutenticazioneHttp(autenticazioneHttp, endpointtype, user);

  395.                     tempiRispostaEnabled = null;
  396.                     ConfigurazioneCore configCore = new ConfigurazioneCore(porteApplicativeCore);
  397.                     ConfigurazioneGenerale configGenerale = configCore.getConfigurazioneControlloTraffico();
  398.                     tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaErogazione().getConnectionTimeout().intValue()+"";
  399.                     tempiRispostaReadTimeout = configGenerale.getTempiRispostaErogazione().getReadTimeout().intValue()+"";
  400.                     tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaErogazione().getTempoMedioRisposta().intValue()+"";

  401.                 }
  402.                 // Devo cmq rileggere i valori se non definiti
  403.                 if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout)
  404.                         ||
  405.                         tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout)
  406.                         ||
  407.                         tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ){
  408.                     ConfigurazioneCore configCore = new ConfigurazioneCore(porteApplicativeCore);
  409.                     ConfigurazioneGenerale configGenerale = configCore.getConfigurazioneControlloTraffico();
  410.                     if(tempiRispostaConnectionTimeout==null || "".equals(tempiRispostaConnectionTimeout) ) {
  411.                         tempiRispostaConnectionTimeout = configGenerale.getTempiRispostaErogazione().getConnectionTimeout().intValue()+"";
  412.                     }
  413.                     if(tempiRispostaReadTimeout==null || "".equals(tempiRispostaReadTimeout) ) {
  414.                         tempiRispostaReadTimeout = configGenerale.getTempiRispostaErogazione().getReadTimeout().intValue()+"";
  415.                     }
  416.                     if(tempiRispostaTempoMedioRisposta==null || "".equals(tempiRispostaTempoMedioRisposta) ) {
  417.                         tempiRispostaTempoMedioRisposta = configGenerale.getTempiRispostaErogazione().getTempoMedioRisposta().intValue()+"";
  418.                     }
  419.                 }
  420.                
  421.                 // preparo i campi
  422.                 List<DataElement> dati = new ArrayList<>();
  423.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  424.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER,id, idsogg, null,idAsps, dati);

  425.                 dati = porteApplicativeHelper.addConnettoreDefaultRidefinitoToDati(dati,TipoOperazione.OTHER, modalita, modalitaValues,modalitaLabels,false,servletConnettore,parametriServletConnettore);

  426.                 if(modalita.equals(PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_RIDEFINITO)) {
  427.                     dati = porteApplicativeHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp,
  428.                             null, //(porteApplicativeHelper.isModalitaCompleta() || !multitenant)?null:AccordiServizioParteSpecificaCostanti.LABEL_APS_APPLICATIVO_INTERNO_PREFIX ,
  429.                             url, nomeCodaJms,
  430.                             tipoJms, user,
  431.                             password, initcont, urlpgk,
  432.                             provurl, connfact, tipoSendas,
  433.                             AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,TipoOperazione.OTHER,
  434.                             httpsurl, httpstipologia, httpshostverify,
  435.                             httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  436.                             httpsalgoritmo, httpsstato, httpskeystore,
  437.                             httpspwdprivatekeytrust, httpspathkey,
  438.                             httpstipokey, httpspwdkey,
  439.                             httpspwdprivatekey, httpsalgoritmokey,
  440.                             httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  441.                             tipoconn, PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORE_DEFAULT, null, null,
  442.                             null, null, null, null, null, null, false,
  443.                             isConnettoreCustomUltimaImmagineSalvata,
  444.                             proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  445.                             tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  446.                             opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  447.                             requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  448.                             requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  449.                             responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  450.                             autenticazioneToken,tokenPolicy, forcePDND, forceOAuth,
  451.                             listExtendedConnettore, forceEnableConnettore,
  452.                             protocollo,false,false, isApplicativiServerEnabled, erogazioneServizioApplicativoServerEnabled,
  453.                             erogazioneServizioApplicativoServer, ServiziApplicativiHelper.toArray(listaIdSAServer),
  454.                             autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  455.                             connettoreStatusParams,
  456.                             postBackViaPost);
  457.                 }

  458.                 pd.setDati(dati);

  459.                 if(modalita.equals(PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_DEFAULT)) {
  460.                     pd.disableOnlyButton();
  461.                 }

  462.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  463.                 // Forward control to the specified success URI
  464.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONNETTORE_DEFAULT,
  465.                         ForwardParams.OTHER(""));
  466.             }

  467.             // Controlli sui campi immessi
  468.             boolean isOk = porteApplicativeHelper.connettoreDefaultRidefinitoCheckData(TipoOperazione.OTHER, modalita);

  469.             if(isOk && modalita.equals(PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_RIDEFINITO)) {
  470.                 isOk = porteApplicativeHelper.endPointCheckData(serviceBinding, protocollo, true,
  471.                         endpointtype, url, nomeCodaJms, tipoJms,
  472.                         user, password, initcont, urlpgk, provurl, connfact,
  473.                         tipoSendas, httpsurl, httpstipologia, httpshostverify,
  474.                         httpsTrustVerifyCert, httpspath, httpstipo, httpspwd, httpsalgoritmo, httpsstato,
  475.                         httpskeystore, httpspwdprivatekeytrust, httpspathkey,
  476.                         httpstipokey, httpspwdkey,
  477.                         httpspwdprivatekey, httpsalgoritmokey,
  478.                         httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  479.                         tipoconn,autenticazioneHttp,
  480.                         proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  481.                         tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  482.                         opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  483.                         requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  484.                         requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  485.                         responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  486.                         autenticazioneToken,tokenPolicy,
  487.                         autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  488.                         listExtendedConnettore,erogazioneServizioApplicativoServerEnabled,
  489.                         erogazioneServizioApplicativoServer);
  490.             }

  491.             if(!isOk) {
  492.                 // preparo i campi
  493.                 List<DataElement> dati = new ArrayList<>();

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

  495.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER,id, idsogg, null,idAsps, dati);

  496.                 dati = porteApplicativeHelper.addConnettoreDefaultRidefinitoToDati(dati,TipoOperazione.OTHER, modalita, modalitaValues,modalitaLabels,false,servletConnettore,parametriServletConnettore);

  497.                 if(modalita.equals(PorteApplicativeCostanti.VALUE_PARAMETRO_PORTE_APPLICATIVE_MODALITA_CONNETTORE_RIDEFINITO)) {
  498.                     dati = porteApplicativeHelper.addEndPointToDati(dati, serviceBinding, connettoreDebug, endpointtype, autenticazioneHttp,
  499.                             null, // (porteApplicativeHelper.isModalitaCompleta() || !multitenant)?null:AccordiServizioParteSpecificaCostanti.LABEL_APS_APPLICATIVO_INTERNO_PREFIX ,
  500.                             url, nomeCodaJms,
  501.                             tipoJms, user,
  502.                             password, initcont, urlpgk,
  503.                             provurl, connfact, tipoSendas,
  504.                             AccordiServizioParteSpecificaCostanti.OBJECT_NAME_APS_PORTE_APPLICATIVE,TipoOperazione.OTHER,
  505.                             httpsurl, httpstipologia, httpshostverify,
  506.                             httpsTrustVerifyCert, httpspath, httpstipo, httpspwd,
  507.                             httpsalgoritmo, httpsstato, httpskeystore,
  508.                             httpspwdprivatekeytrust, httpspathkey,
  509.                             httpstipokey, httpspwdkey,
  510.                             httpspwdprivatekey, httpsalgoritmokey,
  511.                             httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  512.                             tipoconn, PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONNETTORE_DEFAULT, null, null,
  513.                             null, null, null, null, null, null, false,
  514.                             isConnettoreCustomUltimaImmagineSalvata,
  515.                             proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  516.                             tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  517.                             opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  518.                             requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  519.                             requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  520.                             responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  521.                             autenticazioneToken,tokenPolicy, forcePDND, forceOAuth,
  522.                             listExtendedConnettore, forceEnableConnettore,
  523.                             protocollo,false,false, isApplicativiServerEnabled, erogazioneServizioApplicativoServerEnabled,
  524.                             erogazioneServizioApplicativoServer, ServiziApplicativiHelper.toArray(listaIdSAServer),
  525.                             autenticazioneApiKey, useOAS3Names, useAppId, apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  526.                             connettoreStatusParams,
  527.                             postBackViaPost);
  528.                 }

  529.                 pd.setDati(dati);

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

  531.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping,
  532.                         PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONNETTORE_DEFAULT,
  533.                         ForwardParams.OTHER(""));
  534.             }


  535.             // Connettore
  536.             Connettore connettore = new Connettore();
  537.             if (endpointtype.equals(ConnettoriCostanti.DEFAULT_CONNETTORE_TYPE_CUSTOM))
  538.                 connettore.setTipo(tipoconn);
  539.             else
  540.                 connettore.setTipo(endpointtype);

  541.             porteApplicativeHelper.fillConnettore(connettore, connettoreDebug, endpointtype, endpointtype, tipoconn, url,
  542.                     nomeCodaJms, tipoJms, user, password,
  543.                     initcont, urlpgk, url, connfact,
  544.                     tipoSendas, httpsurl, httpstipologia, httpshostverify,
  545.                     httpsTrustVerifyCert, httpspath, httpstipo,
  546.                     httpspwd, httpsalgoritmo, httpsstato,
  547.                     httpskeystore, httpspwdprivatekeytrust,
  548.                     httpspathkey, httpstipokey,
  549.                     httpspwdkey, httpspwdprivatekey,
  550.                     httpsalgoritmokey,
  551.                     httpsKeyAlias, httpsTrustStoreCRLs, httpsTrustStoreOCSPPolicy, httpsKeyStoreBYOKPolicy,
  552.                     proxyEnabled, proxyHostname, proxyPort, proxyUsername, proxyPassword,
  553.                     tempiRispostaEnabled, tempiRispostaConnectionTimeout, tempiRispostaReadTimeout, tempiRispostaTempoMedioRisposta,
  554.                     opzioniAvanzate, transferMode, transferModeChunkSize, redirectMode, redirectMaxHop,
  555.                     requestOutputFileName, requestOutputFileNamePermissions, requestOutputFileNameHeaders, requestOutputFileNameHeadersPermissions,
  556.                     requestOutputParentDirCreateIfNotExists,requestOutputOverwriteIfExists,
  557.                     responseInputMode, responseInputFileName, responseInputFileNameHeaders, responseInputDeleteAfterRead, responseInputWaitTime,
  558.                     tokenPolicy,
  559.                     apiKeyHeader, apiKeyValue, appIdHeader, appIdValue,
  560.                     connettoreStatusParams,
  561.                     listExtendedConnettore);

  562.             List<Object> listaOggettiDaCreare = new ArrayList<>();
  563.             List<Object> listaOggettiDaModificare = new ArrayList<>();

  564.             // creare un servizio applicativo
  565.             String nomeServizioApplicativoErogatore = portaApplicativa.getNome();

  566.             ServizioApplicativo sa = new ServizioApplicativo();
  567.             sa.setNome(nomeServizioApplicativoErogatore);
  568.             sa.setTipologiaFruizione(TipologiaFruizione.DISABILITATO.getValue());
  569.             sa.setTipologiaErogazione(TipologiaErogazione.TRASPARENTE.getValue());
  570.             sa.setIdSoggetto((long) soggInt);
  571.             sa.setTipoSoggettoProprietario(portaApplicativa.getTipoSoggettoProprietario());
  572.             sa.setNomeSoggettoProprietario(portaApplicativa.getNomeSoggettoProprietario());

  573.             RispostaAsincrona rispostaAsinc = new RispostaAsincrona();
  574.             rispostaAsinc.setAutenticazione(InvocazioneServizioTipoAutenticazione.NONE);
  575.             rispostaAsinc.setGetMessage(CostantiConfigurazione.DISABILITATO);
  576.             sa.setRispostaAsincrona(rispostaAsinc);

  577.             InvocazioneServizio invServizio = new InvocazioneServizio();
  578.             invServizio.setAutenticazione(InvocazioneServizioTipoAutenticazione.NONE);
  579.             invServizio.setGetMessage(CostantiConfigurazione.DISABILITATO);
  580.             invServizio.setConnettore(connettore.mappingIntoConnettoreConfigurazione());
  581.             sa.setInvocazioneServizio(invServizio);

  582.             listaOggettiDaCreare.add(sa);

  583.             portaApplicativa.getServizioApplicativoList().clear();

  584.             // Scelto un servizio applicativo server, creo il servizio di default e poi associo quello server
  585.             if(erogazioneServizioApplicativoServer != null && !"".equals(erogazioneServizioApplicativoServer)) {
  586.                 portaApplicativa.setServizioApplicativoDefault(nomeServizioApplicativoErogatore);
  587.                 nomeServizioApplicativoErogatore = erogazioneServizioApplicativoServer;
  588.             }
  589.            
  590.             PortaApplicativaServizioApplicativo paSA = new PortaApplicativaServizioApplicativo();
  591.             paSA.setNome(nomeServizioApplicativoErogatore);
  592.             portaApplicativa.getServizioApplicativoList().add(paSA);

  593.             listaOggettiDaModificare.add(portaApplicativa);

  594.             String userLogin = ServletUtils.getUserLoginFromSession(session);

  595.             porteApplicativeCore.performCreateOperation(userLogin, porteApplicativeHelper.smista(), listaOggettiDaCreare.toArray());
  596.             porteApplicativeCore.performUpdateOperation(userLogin, porteApplicativeHelper.smista(), listaOggettiDaModificare.toArray());

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


  599.             List<PortaApplicativa> lista = null;
  600.             int idLista = -1;


  601.             switch (parentPA) {
  602.             case PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE:

  603.                 boolean datiInvocazione = ServletUtils.isCheckBoxEnabled(porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_CONFIGURAZIONE_DATI_INVOCAZIONE));
  604.                 if(datiInvocazione) {
  605.                     idLista = Liste.SERVIZI;
  606.                     ricerca = porteApplicativeHelper.checkSearchParameters(idLista, ricerca);

  607.                     String tipologia = ServletUtils.getObjectFromSession(request, session, String.class, AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE);
  608.                     if(tipologia!=null &&
  609.                         AccordiServizioParteSpecificaCostanti.PARAMETRO_APS_TIPO_EROGAZIONE_VALUE_EROGAZIONE.equals(tipologia)) {
  610.                         ricerca.addFilter(idLista, Filtri.FILTRO_DOMINIO, SoggettiCostanti.SOGGETTO_DOMINIO_OPERATIVO_VALUE);
  611.                     }

  612.                     boolean [] permessi = new boolean[2];
  613.                     PermessiUtente pu = ServletUtils.getUserFromSession(request, session).getPermessi();
  614.                     permessi[0] = pu.isServizi();
  615.                     permessi[1] = pu.isAccordiCooperazione();
  616.                     List<AccordoServizioParteSpecifica> listaS = null;
  617.                     String superUser   = ServletUtils.getUserLoginFromSession(session);
  618.                     if(apsCore.isVisioneOggettiGlobale(superUser)){
  619.                         listaS = apsCore.soggettiServizioList(null, ricerca,permessi,session, request);
  620.                     }else{
  621.                         listaS = apsCore.soggettiServizioList(superUser, ricerca,permessi,session, request);
  622.                     }
  623.                     AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  624.                     apsHelper.prepareServiziList(ricerca, listaS);
  625.                 }
  626.                 else {          
  627.                     idLista = Liste.CONFIGURAZIONE_EROGAZIONE;
  628.                     ricerca = porteApplicativeHelper.checkSearchParameters(idLista, ricerca);
  629.                     int idServizio = Integer.parseInt(idAsps);
  630.                     AccordoServizioParteSpecifica asps = apsCore.getAccordoServizioParteSpecifica(idServizio);
  631.                     IDServizio idServizio2 = IDServizioFactory.getInstance().getIDServizioFromAccordo(asps);
  632.                     Long idSoggetto = asps.getIdSoggetto() != null ? asps.getIdSoggetto() : -1L;
  633.                     List<MappingErogazionePortaApplicativa> lista2 = apsCore.mappingServiziPorteAppList(idServizio2,asps.getId(),ricerca);
  634.                     AccordiServizioParteSpecificaHelper apsHelper = new AccordiServizioParteSpecificaHelper(request, pd, session);
  635.                     apsHelper.prepareServiziConfigurazioneList(lista2, idAsps, idSoggetto+"", ricerca);
  636.                 }
  637.                 break;
  638.             case PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_SOGGETTO:
  639.                 idLista = Liste.PORTE_APPLICATIVE_BY_SOGGETTO;
  640.                 ricerca = porteApplicativeHelper.checkSearchParameters(idLista, ricerca);
  641.                 lista = porteApplicativeCore.porteAppList(soggInt, ricerca);
  642.                 porteApplicativeHelper.preparePorteAppList(ricerca, lista,idLista);
  643.                 break;
  644.             case PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE:
  645.             default:
  646.                 idLista = Liste.PORTE_APPLICATIVE;
  647.                 ricerca = porteApplicativeHelper.checkSearchParameters(idLista, ricerca);
  648.                 lista = porteApplicativeCore.porteAppList(null, ricerca);
  649.                 porteApplicativeHelper.preparePorteAppList(ricerca, lista,idLista);
  650.                 break;
  651.             }


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

  653.             ForwardParams fwP = ForwardParams.OTHER("");
  654.             if(!porteApplicativeHelper.isModalitaCompleta()) {
  655.                 fwP = PorteDelegateCostanti.TIPO_OPERAZIONE_CONFIGURAZIONE;
  656.             }  

  657.             // Forward control to the specified success URI
  658.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONNETTORE_DEFAULT, fwP);

  659.         } catch (Exception e) {
  660.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  661.                     PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONNETTORE_DEFAULT ,
  662.                     ForwardParams.OTHER(""));
  663.         }
  664.     }

  665. }