PorteApplicativeWS.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 javax.servlet.http.HttpServletRequest;
  24. import javax.servlet.http.HttpServletResponse;
  25. import javax.servlet.http.HttpSession;

  26. import org.apache.commons.lang.StringUtils;
  27. import org.apache.struts.action.Action;
  28. import org.apache.struts.action.ActionForm;
  29. import org.apache.struts.action.ActionForward;
  30. import org.apache.struts.action.ActionMapping;
  31. import org.openspcoop2.core.config.MessageSecurity;
  32. import org.openspcoop2.core.config.MessageSecurityFlow;
  33. import org.openspcoop2.core.config.PortaApplicativa;
  34. import org.openspcoop2.core.config.constants.MTOMProcessorType;
  35. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  36. import org.openspcoop2.core.mvc.properties.utils.ConfigManager;
  37. import org.openspcoop2.core.mvc.properties.utils.PropertiesSourceConfiguration;
  38. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  39. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  40. import org.openspcoop2.message.constants.ServiceBinding;
  41. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  42. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  43. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  44. import org.openspcoop2.web.ctrlstat.servlet.apc.AccordiServizioParteComuneCore;
  45. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  46. import org.openspcoop2.web.lib.mvc.Costanti;
  47. import org.openspcoop2.web.lib.mvc.DataElement;
  48. import org.openspcoop2.web.lib.mvc.ForwardParams;
  49. import org.openspcoop2.web.lib.mvc.GeneralData;
  50. import org.openspcoop2.web.lib.mvc.PageData;
  51. import org.openspcoop2.web.lib.mvc.Parameter;
  52. import org.openspcoop2.web.lib.mvc.ServletUtils;
  53. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  54. /**
  55.  * porteAppWS
  56.  *
  57.  * @author Andrea Poli (apoli@link.it)
  58.  * @author Stefano Corallo (corallo@link.it)
  59.  * @author Sandra Giangrandi (sandra@link.it)
  60.  * @author $Author$
  61.  * @version $Rev$, $Date$
  62.  *
  63.  */
  64. public final class PorteApplicativeWS extends Action {

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

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

  68.         // Inizializzo PageData
  69.         PageData pd = new PageData();

  70.         GeneralHelper generalHelper = new GeneralHelper(session);

  71.         // Inizializzo GeneralData
  72.         GeneralData gd = generalHelper.initGeneralData(request);

  73.         try {
  74.             Boolean contaListe = ServletUtils.getContaListeFromSession(session);

  75.             PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(request, pd, session);
  76.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte applicative
  77.             Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, session, request);
  78.             if(parentPA == null) parentPA = PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE;
  79.             String idPorta = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  80.             int idInt = Integer.parseInt(idPorta);
  81.             String idsogg = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  82.             String statoMessageSecurity = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY);
  83.             String applicaMTOMRichiesta = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_APPLICA_MTOM_RICHIESTA);
  84.             String applicaMTOMRisposta = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_APPLICA_MTOM_RISPOSTA);
  85.             String applicaModificaS = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_APPLICA_MODIFICA);
  86.             boolean applicaModifica = ServletUtils.isCheckBoxEnabled(applicaModificaS);
  87.             String idAsps = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  88.             if(idAsps == null)
  89.                 idAsps = "";
  90.            
  91.             String idPropertiesConfigReq = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME);
  92.             String idPropertiesConfigRes = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME);
  93.            
  94.             String idTab = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_ID_TAB);
  95.             if(!porteApplicativeHelper.isModalitaCompleta() && StringUtils.isNotEmpty(idTab)) {
  96.                 ServletUtils.setObjectIntoSession(request, session, idTab, CostantiControlStation.PARAMETRO_ID_TAB);
  97.             }
  98.            
  99.             // Preparo il menu
  100.             porteApplicativeHelper.makeMenu();

  101.             // modalitaInterfaccia
  102.             boolean isModalitaAvanzata = porteApplicativeHelper.isModalitaAvanzata();
  103.            
  104.             // Prendo il nome della porta
  105.             PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore();
  106.             AccordiServizioParteSpecificaCore aspsCore = new AccordiServizioParteSpecificaCore(porteApplicativeCore);
  107.             AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(aspsCore);

  108.             PortaApplicativa pa = porteApplicativeCore.getPortaApplicativa(idInt);
  109.             String idporta = pa.getNome();
  110.            
  111.             AccordoServizioParteSpecifica asps = aspsCore.getAccordoServizioParteSpecifica(Long.parseLong(idAsps));
  112.             AccordoServizioParteComuneSintetico as = apcCore.getAccordoServizioSintetico(asps.getIdAccordo());
  113.             ServiceBinding serviceBinding = apcCore.toMessageServiceBinding(as.getServiceBinding());

  114.             // Calcolo lo stato MTOM
  115.             boolean isMTOMAbilitatoReq = false;
  116.             boolean isMTOMAbilitatoRes= false;

  117.             MTOMProcessorType mtomReqTmp = null;
  118.             MTOMProcessorType mtomResTmp = null;

  119.             if(pa.getMtomProcessor()!= null){
  120.                 if(pa.getMtomProcessor().getRequestFlow() != null){
  121.                     mtomReqTmp = pa.getMtomProcessor().getRequestFlow().getMode();
  122.                 }

  123.                 if(pa.getMtomProcessor().getResponseFlow() != null){
  124.                     mtomResTmp = pa.getMtomProcessor().getResponseFlow().getMode();
  125.                 }
  126.             }

  127.             // calcolo lo stato di richiesta e risposta
  128.             if(isModalitaAvanzata && mtomReqTmp!= null && !mtomReqTmp.equals(MTOMProcessorType.DISABLE) && !mtomReqTmp.equals(MTOMProcessorType.VERIFY))
  129.                 isMTOMAbilitatoReq = true;

  130.             if(isModalitaAvanzata && mtomResTmp!= null && !mtomResTmp.equals(MTOMProcessorType.DISABLE ) && !mtomResTmp.equals(MTOMProcessorType.VERIFY))
  131.                 isMTOMAbilitatoRes = true;

  132.             // Conto i ws-request ed i ws-response
  133.             MessageSecurity paMessageSecurity = pa.getMessageSecurity();
  134.             int numMessageSecurityReq = 0;
  135.             int numMessageSecurityRes = 0;
  136.             String oldIdPropertiesConfigReq = null;
  137.             String oldIdPropertiesConfigRes = null;
  138.             if (paMessageSecurity != null) {
  139.                 if(paMessageSecurity.getRequestFlow()!=null){
  140.                     numMessageSecurityReq = paMessageSecurity.getRequestFlow().sizeParameterList();
  141.                     oldIdPropertiesConfigReq = paMessageSecurity.getRequestFlow().getMode();
  142.                 }
  143.                 if(paMessageSecurity.getResponseFlow()!=null){
  144.                     numMessageSecurityRes = paMessageSecurity.getResponseFlow().sizeParameterList();
  145.                     oldIdPropertiesConfigRes = paMessageSecurity.getResponseFlow().getMode();
  146.                 }
  147.             }

  148.             if(statoMessageSecurity == null)
  149.                 statoMessageSecurity = pa.getStatoMessageSecurity();
  150.            
  151.             // imposto lo stato iniziale del mode scelto
  152.             if(idPropertiesConfigReq == null)
  153.                 idPropertiesConfigReq = oldIdPropertiesConfigReq;
  154.            
  155.             if(idPropertiesConfigRes == null)
  156.                 idPropertiesConfigRes = oldIdPropertiesConfigRes;
  157.            
  158.             if(idPropertiesConfigReq == null)
  159.                 idPropertiesConfigReq = PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME_NESSUNO;
  160.            
  161.             if(idPropertiesConfigRes == null)
  162.                 idPropertiesConfigRes = PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME_NESSUNO;
  163.            
  164.             Parameter pId = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID   ,idPorta);
  165.             Parameter pIdSoggetto = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO  ,idsogg);
  166.             Parameter pIdAsps = new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps);
  167.             Parameter pIdPropertiesConfigReq= new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_PROPERTIES_CONFIG_NAME, idPropertiesConfigReq);
  168.             Parameter pIdPropertiesConfigRes= new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_PROPERTIES_CONFIG_NAME, idPropertiesConfigRes);

  169.             List<Parameter> lstParam = porteApplicativeHelper.getTitoloPA(parentPA, idsogg, idAsps);
  170.            
  171.             String labelPerPorta = null;
  172.             if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  173.                 labelPerPorta = porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  174.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_CONFIG_DI,
  175.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY,
  176.                         pa);
  177.             }
  178.             else {
  179.                 labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_CONFIG_DI+idporta;
  180.             }
  181.             lstParam.add(new Parameter(labelPerPorta,  null));
  182.            
  183.             Parameter[] urlReqParms = { pId,pIdSoggetto,pIdAsps,pIdPropertiesConfigReq };
  184.             Parameter[] urlResParms = { pId,pIdSoggetto,pIdAsps,pIdPropertiesConfigRes };
  185.            
  186.             String servletNameRequestList =  idPropertiesConfigReq.equals(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME)
  187.                     ? PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_LIST : PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_PROPERTIES_CONFIG;
  188.             String servletNameResponseList = idPropertiesConfigRes.equals(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME)
  189.                     ? PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_LIST  : PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_PROPERTIES_CONFIG;
  190.            
  191.             Parameter urlRequestList = new Parameter("", servletNameRequestList , urlReqParms);
  192.             Parameter urlResponseList = new Parameter("", servletNameResponseList , urlResParms);
  193.            
  194.             PropertiesSourceConfiguration propertiesSourceConfiguration = porteApplicativeCore.getMessageSecurityPropertiesSourceConfiguration();
  195.            
  196.             ConfigManager configManager = ConfigManager.getinstance(ControlStationCore.getLog());
  197.             configManager.leggiConfigurazioni(propertiesSourceConfiguration, true);
  198.            
  199.             List<String> nomiConfigurazioniReq = configManager.getNomiConfigurazioni(propertiesSourceConfiguration,serviceBinding.name(),PorteApplicativeCostanti.TAG_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST,PorteApplicativeCostanti.TAG_PORTE_APPLICATIVE_MESSAGE_SECURITY_PA);
  200.             List<String> labelConfigurazioniReq = configManager.convertToLabel(propertiesSourceConfiguration, nomiConfigurazioniReq);
  201.            
  202.             List<String> propConfigReqLabelListTmp = new ArrayList<>();
  203.             propConfigReqLabelListTmp.add(PorteApplicativeCostanti.LABEL_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME_NESSUNO);
  204.             propConfigReqLabelListTmp.addAll(labelConfigurazioniReq);
  205.             if(porteApplicativeHelper.isModalitaAvanzata())
  206.                 propConfigReqLabelListTmp.add(PorteApplicativeCostanti.LABEL_DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME);
  207.            
  208.            
  209.             List<String>  propConfigReqListTmp = new ArrayList<>();
  210.             propConfigReqListTmp.add(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME_NESSUNO);
  211.             propConfigReqListTmp.addAll(nomiConfigurazioniReq);
  212.             if(porteApplicativeHelper.isModalitaAvanzata())
  213.                 propConfigReqListTmp.add(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME);
  214.            
  215.             List<String> nomiConfigurazioniRes = configManager.getNomiConfigurazioni(propertiesSourceConfiguration,serviceBinding.name(),PorteApplicativeCostanti.TAG_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE,PorteApplicativeCostanti.TAG_PORTE_APPLICATIVE_MESSAGE_SECURITY_PA);
  216.             List<String> labelConfigurazioniRes = configManager.convertToLabel(propertiesSourceConfiguration, nomiConfigurazioniRes);
  217.            
  218.             List<String>  propConfigResLabelListTmp = new ArrayList<>();
  219.             propConfigResLabelListTmp.add(PorteApplicativeCostanti.LABEL_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME_NESSUNO);
  220.             propConfigResLabelListTmp.addAll(labelConfigurazioniRes);
  221.             if(porteApplicativeHelper.isModalitaAvanzata())
  222.                 propConfigResLabelListTmp.add(PorteApplicativeCostanti.LABEL_DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME);
  223.            
  224.            
  225.             List<String>  propConfigResListTmp = new ArrayList<>();
  226.             propConfigResListTmp.add(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME_NESSUNO);
  227.             propConfigResListTmp.addAll(nomiConfigurazioniRes);
  228.             if(porteApplicativeHelper.isModalitaAvanzata())
  229.                 propConfigResListTmp.add(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME);
  230.            
  231.             String[] propConfigReqLabelList = propConfigReqLabelListTmp.toArray(new String[propConfigReqLabelListTmp.size()]);
  232.             String[] propConfigReqList= propConfigReqListTmp.toArray(new String[propConfigReqListTmp.size()]);
  233.            
  234.             String[] propConfigResLabelList= propConfigResLabelListTmp.toArray(new String[propConfigResLabelListTmp.size()]);
  235.             String[] propConfigResList= propConfigResListTmp.toArray(new String[propConfigResListTmp.size()]);
  236.            
  237.             // controllo postback
  238.             String postBackElementName = porteApplicativeHelper.getPostBackElementName();
  239.             if(postBackElementName != null) {
  240.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME)) {
  241.                     applicaModifica = false;
  242.                 }
  243.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME)) {
  244.                     applicaModifica = false;
  245.                 }
  246.                 if(postBackElementName.equals(CostantiControlStation.PARAMETRO_MESSAGE_SECURITY)) {
  247.                     applicaModifica = false;
  248.                 }
  249.             }
  250.            
  251.             // setto la barra del titolo
  252.             ServletUtils.setPageDataTitle(pd, lstParam);
  253.            
  254.             // imposta menu' contestuale
  255.             porteApplicativeHelper.impostaComandiMenuContestualePA(idsogg, idAsps);

  256.             // Se idhid = null, devo visualizzare la pagina per la
  257.             // modifica dati
  258.             if (porteApplicativeHelper.isEditModeInProgress() && !applicaModifica) {


  259.                 // preparo i campi
  260.                 List<DataElement> dati = new ArrayList<>();
  261.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  262.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER, idPorta, idsogg, idPorta,  idAsps, dati);

  263.                 if (paMessageSecurity != null) {
  264.                     if(paMessageSecurity.getRequestFlow()!=null){
  265.                         StatoFunzionalita applyToMtomRich = paMessageSecurity.getRequestFlow().getApplyToMtom();
  266.                        
  267.                         if(applicaMTOMRichiesta == null) {
  268.                             if(applyToMtomRich != null && applyToMtomRich.equals(StatoFunzionalita.ABILITATO) && isMTOMAbilitatoReq)
  269.                                 applicaMTOMRichiesta = "yes";
  270.                             else
  271.                                 applicaMTOMRichiesta = "";
  272.                         }
  273.                     }
  274.                     if(paMessageSecurity.getResponseFlow()!=null){
  275.                         StatoFunzionalita applyToMtomRich = paMessageSecurity.getResponseFlow().getApplyToMtom();
  276.                        
  277.                         if(applicaMTOMRisposta == null) {
  278.                             if(applyToMtomRich != null && applyToMtomRich.equals(StatoFunzionalita.ABILITATO) && isMTOMAbilitatoRes)
  279.                                 applicaMTOMRisposta = "yes";
  280.                             else
  281.                                 applicaMTOMRisposta = "";
  282.                         }
  283.                     }
  284.                 }

  285.                 if(applicaMTOMRichiesta == null){
  286.                     applicaMTOMRichiesta = "";
  287.                 }

  288.                 if(applicaMTOMRisposta == null){
  289.                     applicaMTOMRisposta = "";
  290.                 }
  291.                
  292.                
  293.                 dati = porteApplicativeHelper.addMessageSecurityToDati(dati, false, idInt, statoMessageSecurity, urlRequestList.getValue(), urlResponseList.getValue(), contaListe, numMessageSecurityReq, numMessageSecurityRes,
  294.                         isMTOMAbilitatoReq, applicaMTOMRichiesta, isMTOMAbilitatoRes, applicaMTOMRisposta,idPropertiesConfigReq,idPropertiesConfigRes,propConfigReqLabelList, propConfigReqList,  propConfigResLabelList, propConfigResList,
  295.                         oldIdPropertiesConfigReq,oldIdPropertiesConfigRes);

  296.                 pd.setDati(dati);

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

  298.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY,
  299.                         ForwardParams.OTHER(""));
  300.             }

  301.             // Controlli sui campi immessi
  302.             boolean isOk = porteApplicativeHelper.WSCheckData(TipoOperazione.OTHER);
  303.             if (!isOk) {
  304.                 // preparo i campi
  305.                 List<DataElement> dati = new ArrayList<>();

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

  307.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER, idPorta, idsogg, null, idAsps, dati);

  308.                 dati = porteApplicativeHelper.addMessageSecurityToDati(dati,  false, idInt,  statoMessageSecurity, urlRequestList.getValue(), urlResponseList.getValue(), contaListe, numMessageSecurityReq, numMessageSecurityRes,
  309.                         isMTOMAbilitatoReq, applicaMTOMRichiesta, isMTOMAbilitatoRes, applicaMTOMRisposta,idPropertiesConfigReq,idPropertiesConfigRes,propConfigReqLabelList, propConfigReqList,  propConfigResLabelList, propConfigResList,
  310.                         oldIdPropertiesConfigReq,oldIdPropertiesConfigRes);

  311.                 pd.setDati(dati);

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

  313.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY,
  314.                         ForwardParams.OTHER(""));
  315.             }

  316.             // Modifico i dati della porta applicativa nel db
  317.             pa.setStatoMessageSecurity(statoMessageSecurity);

  318.             if (pa.getMessageSecurity() == null)
  319.                 pa.setMessageSecurity(new MessageSecurity());

  320.             if(pa.getMessageSecurity().getRequestFlow()==null){
  321.                 pa.getMessageSecurity().setRequestFlow(new MessageSecurityFlow());
  322.             }
  323.             if(pa.getMessageSecurity().getResponseFlow() ==null){
  324.                 pa.getMessageSecurity().setResponseFlow(new MessageSecurityFlow());
  325.             }
  326.            
  327.             String oldRequestMode = pa.getMessageSecurity().getRequestFlow().getMode();
  328.             String oldResponseMode = pa.getMessageSecurity().getResponseFlow().getMode();
  329.            
  330.             String newRequestMode = !idPropertiesConfigReq.equals(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST_FLOW_PROPERTIES_CONFIG_NAME_NESSUNO) ? idPropertiesConfigReq : null;
  331.             String newResponseMode = !idPropertiesConfigRes.equals(PorteApplicativeCostanti.DEFAULT_VALUE_PARAMETRO_PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE_FLOW_PROPERTIES_CONFIG_NAME_NESSUNO) ? idPropertiesConfigRes : null;
  332.            
  333.             // salvataggio della configurazione delle properties
  334.             pa.getMessageSecurity().getRequestFlow().setMode(newRequestMode);
  335.             pa.getMessageSecurity().getResponseFlow().setMode(newResponseMode);
  336.            
  337.             // se ho cambiato la modalita' di configurazione della sicurezza resetto la vecchia configurazione
  338.             if(oldRequestMode!= null && !oldRequestMode.equals(idPropertiesConfigReq)) {
  339.                 pa.getMessageSecurity().getRequestFlow().getParameterList().clear();
  340.             }
  341.             if(oldResponseMode!= null && !oldResponseMode.equals(idPropertiesConfigRes)) {
  342.                 pa.getMessageSecurity().getResponseFlow().getParameterList().clear();
  343.             }
  344.            

  345.             if(isMTOMAbilitatoReq){
  346.                 if(applicaMTOMRichiesta != null && (ServletUtils.isCheckBoxEnabled(applicaMTOMRichiesta))){
  347.                     pa.getMessageSecurity().getRequestFlow().setApplyToMtom(StatoFunzionalita.ABILITATO);
  348.                 }else {
  349.                     pa.getMessageSecurity().getRequestFlow().setApplyToMtom(StatoFunzionalita.DISABILITATO);
  350.                 }
  351.             }else
  352.                 pa.getMessageSecurity().getRequestFlow().setApplyToMtom(null);

  353.             if(isMTOMAbilitatoRes){
  354.                 if(applicaMTOMRisposta  != null && (ServletUtils.isCheckBoxEnabled(applicaMTOMRisposta))){
  355.                     pa.getMessageSecurity().getResponseFlow().setApplyToMtom(StatoFunzionalita.ABILITATO);
  356.                 }else {
  357.                     pa.getMessageSecurity().getResponseFlow().setApplyToMtom(StatoFunzionalita.DISABILITATO);
  358.                 }
  359.             }else
  360.                 pa.getMessageSecurity().getResponseFlow().setApplyToMtom(null);

  361.             if(!CostantiControlStation.DEFAULT_VALUE_PARAMETRO_MESSAGE_SECURITY_ABILITATO.equals(statoMessageSecurity)) {
  362.                 // Devo annullare altrimenti si possono creare inconsistenze tra link accesso alla configurazione della sicurezza e non salvataggio reale dello stato generale (se si abilita la sicurezza e precedentemente esisteva giĆ  una config per la request o response)
  363.                 pa.getMessageSecurity().setRequestFlow(null);
  364.                 pa.getMessageSecurity().setResponseFlow(null);
  365.             }
  366.            
  367.             String userLogin = ServletUtils.getUserLoginFromSession(session);

  368.             porteApplicativeCore.performUpdateOperation(userLogin, porteApplicativeHelper.smista(), pa);

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

  371.             dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER, idPorta, idsogg, null, dati);

  372.             // Aggiorno valori MessageSecurity request e response
  373.             pa = porteApplicativeCore.getPortaApplicativa(idInt);
  374.            
  375.             paMessageSecurity = pa.getMessageSecurity();

  376.             applicaMTOMRichiesta = null;
  377.             applicaMTOMRisposta = null;

  378.             if (paMessageSecurity != null) {
  379.                 if(paMessageSecurity.getRequestFlow()!=null){
  380.                     numMessageSecurityReq = paMessageSecurity.getRequestFlow().sizeParameterList();
  381.                     oldIdPropertiesConfigReq = paMessageSecurity.getRequestFlow().getMode();
  382.                     StatoFunzionalita applyToMtomRich = paMessageSecurity.getRequestFlow().getApplyToMtom();

  383.                     if(applicaMTOMRichiesta == null) {
  384.                         if(applyToMtomRich != null && applyToMtomRich.equals(StatoFunzionalita.ABILITATO) && isMTOMAbilitatoReq)
  385.                             applicaMTOMRichiesta = "yes";
  386.                         else
  387.                             applicaMTOMRichiesta = "";
  388.                     }
  389.                 }
  390.                 if(paMessageSecurity.getResponseFlow()!=null){
  391.                     numMessageSecurityRes = paMessageSecurity.getResponseFlow().sizeParameterList();
  392.                     oldIdPropertiesConfigRes = paMessageSecurity.getResponseFlow().getMode();
  393.                     StatoFunzionalita applyToMtomRich = paMessageSecurity.getResponseFlow().getApplyToMtom();

  394.                     if(applicaMTOMRisposta ==null) {
  395.                         if(applyToMtomRich != null && applyToMtomRich.equals(StatoFunzionalita.ABILITATO) && isMTOMAbilitatoRes)
  396.                             applicaMTOMRisposta = "yes";
  397.                         else
  398.                             applicaMTOMRisposta = "";
  399.                     }
  400.                 }
  401.             }
  402.            
  403.             if(applicaMTOMRichiesta == null){
  404.                 applicaMTOMRichiesta = "";
  405.             }

  406.             if(applicaMTOMRisposta == null){
  407.                 applicaMTOMRisposta = "";
  408.             }
  409.          
  410.             dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER, idPorta, idsogg, null, idAsps, dati);
  411.            
  412.             dati = porteApplicativeHelper.addMessageSecurityToDati(dati, false, idInt,   statoMessageSecurity, urlRequestList.getValue(), urlResponseList.getValue(),
  413.                     contaListe, numMessageSecurityReq, numMessageSecurityRes,isMTOMAbilitatoReq, applicaMTOMRichiesta, isMTOMAbilitatoRes, applicaMTOMRisposta,
  414.                     idPropertiesConfigReq,idPropertiesConfigRes,propConfigReqLabelList, propConfigReqList,  propConfigResLabelList, propConfigResList,
  415.                     oldIdPropertiesConfigReq,oldIdPropertiesConfigRes);

  416.             pd.setDati(dati);

  417.             pd.setMessage(CostantiControlStation.LABEL_AGGIORNAMENTO_EFFETTUATO_CON_SUCCESSO, Costanti.MESSAGE_TYPE_INFO);
  418.             dati.add(ServletUtils.getDataElementForEditModeFinished());
  419.            
  420.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  421.             // Forward control to the specified success URI
  422.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY,
  423.                     ForwardParams.OTHER(""));
  424.         } catch (Exception e) {
  425.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  426.                     PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_MESSAGE_SECURITY,
  427.                     ForwardParams.OTHER(""));
  428.         }  
  429.     }
  430. }