PorteApplicativeControlloAccessi.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.Arrays;
  23. import java.util.List;

  24. import javax.servlet.http.HttpServletRequest;
  25. import javax.servlet.http.HttpServletResponse;
  26. import javax.servlet.http.HttpSession;

  27. import org.apache.commons.lang.StringUtils;
  28. import org.apache.struts.action.Action;
  29. import org.apache.struts.action.ActionForm;
  30. import org.apache.struts.action.ActionForward;
  31. import org.apache.struts.action.ActionMapping;
  32. import org.openspcoop2.core.commons.CoreException;
  33. import org.openspcoop2.core.commons.Liste;
  34. import org.openspcoop2.core.config.AutorizzazioneRuoli;
  35. import org.openspcoop2.core.config.AutorizzazioneScope;
  36. import org.openspcoop2.core.config.GenericProperties;
  37. import org.openspcoop2.core.config.GestioneToken;
  38. import org.openspcoop2.core.config.GestioneTokenAutenticazione;
  39. import org.openspcoop2.core.config.PortaApplicativa;
  40. import org.openspcoop2.core.config.PortaApplicativaAutorizzazioneToken;
  41. import org.openspcoop2.core.config.Proprieta;
  42. import org.openspcoop2.core.config.constants.RuoloTipoMatch;
  43. import org.openspcoop2.core.config.constants.ScopeTipoMatch;
  44. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  45. import org.openspcoop2.core.config.constants.StatoFunzionalitaConWarning;
  46. import org.openspcoop2.core.config.constants.TipoAutenticazione;
  47. import org.openspcoop2.core.config.constants.TipoAutenticazionePrincipal;
  48. import org.openspcoop2.core.config.constants.TipoAutorizzazione;
  49. import org.openspcoop2.core.id.IDServizio;
  50. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  51. import org.openspcoop2.core.registry.beans.AccordoServizioParteComuneSintetico;
  52. import org.openspcoop2.core.registry.constants.RuoloTipologia;
  53. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  54. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  55. import org.openspcoop2.message.constants.ServiceBinding;
  56. import org.openspcoop2.pdd.core.autorizzazione.CostantiAutorizzazione;
  57. import org.openspcoop2.utils.BooleanNullable;
  58. import org.openspcoop2.utils.SortedMap;
  59. import org.openspcoop2.utils.properties.PropertiesUtilities;
  60. import org.openspcoop2.web.ctrlstat.core.AutorizzazioneUtilities;
  61. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  62. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  63. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  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.config.ConfigurazioneCore;
  68. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCostanti;
  69. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  70. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  71. import org.openspcoop2.web.lib.mvc.Costanti;
  72. import org.openspcoop2.web.lib.mvc.DataElement;
  73. import org.openspcoop2.web.lib.mvc.ForwardParams;
  74. import org.openspcoop2.web.lib.mvc.GeneralData;
  75. import org.openspcoop2.web.lib.mvc.PageData;
  76. import org.openspcoop2.web.lib.mvc.Parameter;
  77. import org.openspcoop2.web.lib.mvc.ServletUtils;
  78. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  79. /***
  80.  *
  81.  * PorteApplicativeControlloAccessi
  82.  *
  83.  * @author Giuliano Pintori (pintori@link.it)
  84.  * @author $Author$
  85.  * @version $Rev$, $Date$
  86.  */
  87. public class PorteApplicativeControlloAccessi extends Action {

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

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

  91.         // Inizializzo PageData
  92.         PageData pd = new PageData();

  93.         GeneralHelper generalHelper = new GeneralHelper(session);

  94.         // Inizializzo GeneralData
  95.         GeneralData gd = generalHelper.initGeneralData(request);

  96.         boolean isPortaDelegata = false;

  97.         try {
  98.             Boolean contaListe = ServletUtils.getContaListeFromSession(session);
  99.             Boolean confPers = ServletUtils.getObjectFromSession(request, session, Boolean.class, CostantiControlStation.SESSION_PARAMETRO_GESTIONE_CONFIGURAZIONI_PERSONALIZZATE);

  100.             PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(request, pd, session);
  101.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte applicative
  102.             Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, session, request);
  103.             if(parentPA == null) parentPA = PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE;
  104.            
  105.             String id = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  106.             int idInt = Integer.parseInt(id);
  107.             String idsogg = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  108.             int soggInt = Integer.parseInt(idsogg);
  109.             String idAsps = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  110.             if(idAsps == null)
  111.                 idAsps = "";

  112.             String autenticazione = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE );
  113.             String autenticazioneOpzionale = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_OPZIONALE );
  114.             String autenticazionePrincipalTipo = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_PRINCIPAL_TIPO);
  115.             TipoAutenticazionePrincipal autenticazionePrincipal = TipoAutenticazionePrincipal.toEnumConstant(autenticazionePrincipalTipo, false);
  116.             List<String> autenticazioneParametroList = porteApplicativeHelper.convertFromDataElementValue_parametroAutenticazioneList(autenticazione, autenticazionePrincipal);
  117.             String autenticazioneCustom = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM );
  118.             String autorizzazione = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE);
  119.             String autorizzazioneCustom = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM);

  120.             String autorizzazioneAutenticati = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE);
  121.             String autorizzazioneRuoli = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI);
  122.             String autorizzazioneRuoliTipologia = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA);
  123.             String ruoloMatch = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_RUOLO_MATCH);

  124.             String autorizzazioneAutenticatiToken = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_AUTENTICAZIONE_TOKEN);
  125.             String autorizzazioneRuoliToken = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_RUOLI_TOKEN);
  126.             String autorizzazioneRuoliTipologiaToken = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_RUOLO_TIPOLOGIA_TOKEN);
  127.             String autorizzazioneRuoliMatchToken = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_RUOLO_MATCH_TOKEN);
  128.            
  129.             String autorizzazioneContenuti = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI);
  130.             String autorizzazioneContenutiStato = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI_STATO);
  131.             String autorizzazioneContenutiProperties = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI_PROPERTIES);

  132.             String applicaModificaS = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_APPLICA_MODIFICA);
  133.             boolean applicaModifica = ServletUtils.isCheckBoxEnabled(applicaModificaS);

  134.             String gestioneToken = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN);
  135.             String gestioneTokenPolicy = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_POLICY);
  136.             String gestioneTokenOpzionale = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_OPZIONALE);
  137.             String gestioneTokenValidazioneInput = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_VALIDAZIONE_INPUT);
  138.             String gestioneTokenIntrospection = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_INTROSPECTION);
  139.             String gestioneTokenUserInfo = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_USERINFO);
  140.             String gestioneTokenTokenForward = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_GESTIONE_TOKEN_TOKEN_FORWARD);

  141.             String autenticazioneTokenIssuer = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_ISSUER);
  142.             String autenticazioneTokenClientId = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_CLIENT_ID);
  143.             String autenticazioneTokenSubject = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_SUBJECT);
  144.             String autenticazioneTokenUsername = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_USERNAME);
  145.             String autenticazioneTokenEMail = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE_TOKEN_MAIL);

  146.             String autorizzazioneToken = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN);
  147.             String autorizzazioneTokenOptions = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_TOKEN_OPTIONS);
  148.             String autorizzazioneScope = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_AUTORIZZAZIONE_SCOPE);
  149.             String autorizzazioneScopeMatch = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_SCOPE_MATCH);

  150.             BinaryParameter allegatoXacmlPolicy = porteApplicativeHelper.getBinaryParameter(CostantiControlStation.PARAMETRO_DOCUMENTO_SICUREZZA_XACML_POLICY);

  151.             String identificazioneAttributiStato = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_STATO);
  152.             String [] attributeAuthoritySelezionate = porteApplicativeHelper.getParameterValues(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY);
  153.             String attributeAuthorityAttributi = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_PORTE_ATTRIBUTI_AUTHORITY_ATTRIBUTI);
  154.            
  155.             String idTab = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_ID_TAB);
  156.             if(!porteApplicativeHelper.isModalitaCompleta() && StringUtils.isNotEmpty(idTab)) {
  157.                 ServletUtils.setObjectIntoSession(request, session, idTab, CostantiControlStation.PARAMETRO_ID_TAB);
  158.             }
  159.             // Preparo il menu
  160.             porteApplicativeHelper.makeMenu();

  161.             // Prendo il nome della porta
  162.             PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore();
  163.             AccordiServizioParteSpecificaCore apsCore = new AccordiServizioParteSpecificaCore(porteApplicativeCore);
  164.             SoggettiCore soggettiCore = new SoggettiCore(porteApplicativeCore);
  165.             ConfigurazioneCore confCore = new ConfigurazioneCore(porteApplicativeCore);
  166.             AccordiServizioParteComuneCore apcCore = new AccordiServizioParteComuneCore(porteApplicativeCore);
  167.            
  168.             PortaApplicativa pa = porteApplicativeCore.getPortaApplicativa(idInt);
  169.             if(pa==null) {
  170.                 throw new CoreException("PortaApplicativa con id '"+idInt+"' non trovata");
  171.             }
  172.             String idporta = pa.getNome();

  173.             List<String> ruoli = new ArrayList<>();
  174.             if(pa!=null && pa.getRuoli()!=null && pa.getRuoli().sizeRuoloList()>0){
  175.                 for (int i = 0; i < pa.getRuoli().sizeRuoloList(); i++) {
  176.                     ruoli.add(pa.getRuoli().getRuolo(i).getNome());
  177.                 }
  178.             }

  179.             int numRuoli = 0;
  180.             if(pa.getRuoli()!=null){
  181.                 numRuoli = pa.getRuoli().sizeRuoloList();
  182.             }
  183.             int numScope = 0;
  184.             if(pa.getScope()!=null){
  185.                 numScope = pa.getScope().sizeScopeList();
  186.             }

  187.             int numAutenticatiToken = 0;
  188.             if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getServiziApplicativi()!=null){
  189.                 numAutenticatiToken = pa.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList();
  190.             }
  191.            
  192.             int numRuoliToken = 0;
  193.             if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getRuoli()!=null){
  194.                 numRuoliToken = pa.getAutorizzazioneToken().getRuoli().sizeRuoloList();
  195.             }
  196.            
  197.             int numAutenticazioneCustomPropertiesList = pa.sizeProprietaAutenticazioneList();
  198.             int numAutorizzazioneCustomPropertiesList = pa.sizeProprietaAutorizzazioneList();
  199.             int numAutorizzazioneContenutiCustomPropertiesList = pa.sizeProprietaAutorizzazioneContenutoList();
  200.             String oldAutorizzazioneContenuto = pa.getAutorizzazioneContenuto() ;
  201.             String oldAutorizzazioneContenutoStato = StatoFunzionalita.DISABILITATO.getValue();
  202.            
  203.             boolean oldAutenticazioneCustom = pa.getAutenticazione() != null && !TipoAutenticazione.getValues().contains(pa.getAutenticazione());
  204.             boolean oldAutorizzazioneContenutiCustom = false;
  205.             if(oldAutorizzazioneContenuto != null) {
  206.                 if(oldAutorizzazioneContenuto.equals(CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN)) {
  207.                     oldAutorizzazioneContenutoStato = StatoFunzionalita.ABILITATO.getValue();
  208.                 } else { // custom
  209.                     oldAutorizzazioneContenutiCustom = true;
  210.                     oldAutorizzazioneContenutoStato = CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM;
  211.                 }
  212.             }
  213.            
  214.             IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(pa.getServizio().getTipo(), pa.getServizio().getNome(),
  215.                     pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario(),
  216.                     pa.getServizio().getVersione());
  217.             AccordoServizioParteSpecifica asps = apsCore.getServizio(idServizio,false);
  218.             AccordoServizioParteComuneSintetico aspc = apcCore.getAccordoServizioSintetico(porteApplicativeHelper.getIDAccordoFromUri(asps.getAccordoServizioParteComune()));
  219.             ServiceBinding serviceBinding = porteApplicativeCore.toMessageServiceBinding(aspc.getServiceBinding());
  220.            
  221.             ConsoleSearch searchForCount = new ConsoleSearch(true,1);
  222.             porteApplicativeCore.porteAppSoggettoList(idInt, searchForCount);
  223.             int sizeSoggettiPA = searchForCount.getNumEntries(Liste.PORTE_APPLICATIVE_SOGGETTO);

  224.             ConsoleSearch searchForCountSAAutorizzati = new ConsoleSearch(true,1);
  225.             porteApplicativeCore.porteAppServiziApplicativiAutorizzatiList(idInt, searchForCountSAAutorizzati);
  226.             int numErogazioneApplicativiAutenticati = searchForCountSAAutorizzati.getNumEntries(Liste.PORTE_APPLICATIVE_SERVIZIO_APPLICATIVO_AUTORIZZATO);
  227.            
  228.             // Prendo nome, tipo e pdd del soggetto
  229.             String tipoSoggettoProprietario = null;
  230.             if(porteApplicativeCore.isRegistroServiziLocale()){
  231.                 org.openspcoop2.core.registry.Soggetto soggetto = soggettiCore.getSoggettoRegistro(soggInt);
  232.                 tipoSoggettoProprietario = soggetto.getTipo();
  233.             }
  234.             else{
  235.                 org.openspcoop2.core.config.Soggetto soggetto = soggettiCore.getSoggetto(soggInt);
  236.                 tipoSoggettoProprietario = soggetto.getTipo();
  237.             }

  238.             String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(tipoSoggettoProprietario);
  239.             boolean isSupportatoAutenticazione = soggettiCore.isSupportatoAutenticazioneSoggetti(protocollo);
  240.                        
  241.             boolean forceAutenticato = false;
  242.             boolean forceHttps = false;
  243.             boolean forceDisableOptional = false;
  244.             boolean forcePDND = false;
  245.             boolean forceOAuth = false;
  246.             boolean forceGestioneToken = false;
  247.             if(porteApplicativeHelper.isProfiloModIPA(protocollo)) {
  248.                 forceAutenticato = true; // in modI ci vuole sempre autenticazione https sull'erogazione (cambia l'opzionalita' o meno)
  249.                 forceHttps = forceAutenticato;
  250.                
  251.                 BooleanNullable forceHttpsClientWrapper = BooleanNullable.NULL();
  252.                 BooleanNullable forcePDNDWrapper = BooleanNullable.NULL();
  253.                 BooleanNullable forceOAuthWrapper = BooleanNullable.NULL();
  254.                
  255.                 porteApplicativeHelper.readModIConfiguration(forceHttpsClientWrapper, forcePDNDWrapper, forceOAuthWrapper,
  256.                         IDAccordoFactory.getInstance().getIDAccordoFromUri(asps.getAccordoServizioParteComune()), asps.getPortType(),
  257.                         pa.getAzione()!=null && pa.getAzione().getAzioneDelegataList()!=null && !pa.getAzione().getAzioneDelegataList().isEmpty() ? pa.getAzione().getAzioneDelegataList() : null);
  258.                
  259.                 if(forceHttpsClientWrapper.getValue()!=null) {
  260.                     forceDisableOptional = forceHttpsClientWrapper.getValue().booleanValue();
  261.                 }
  262.                 if(forcePDNDWrapper.getValue()!=null) {
  263.                     forcePDND = forcePDNDWrapper.getValue().booleanValue();
  264.                 }
  265.                 if(forceOAuthWrapper.getValue()!=null) {
  266.                     forceOAuth = forceOAuthWrapper.getValue().booleanValue();
  267.                 }

  268.                 if(forcePDND || forceOAuth) {
  269.                     forceGestioneToken = true;
  270.                 }
  271.             }
  272.            
  273.             List<Parameter> lstParam = porteApplicativeHelper.getTitoloPA(parentPA, idsogg, idAsps);

  274.             String labelPerPorta = null;
  275.             if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  276.                 labelPerPorta = porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  277.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONTROLLO_ACCESSI_CONFIG_DI,
  278.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONTROLLO_ACCESSI,
  279.                         pa);
  280.             }
  281.             else {
  282.                 labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_CONTROLLO_ACCESSI_CONFIG_DI+idporta;
  283.             }

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

  285.             // setto la barra del titolo
  286.             ServletUtils.setPageDataTitle(pd, lstParam);

  287.             // imposta menu' contestuale
  288.             porteApplicativeHelper.impostaComandiMenuContestualePA(idsogg, idAsps);

  289.             Parameter[] urlParmsAutorizzazioneAutenticati = {
  290.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  291.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  292.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps) };
  293.             Parameter urlAutorizzazioneAutenticatiParam= new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_SOGGETTO_LIST, urlParmsAutorizzazioneAutenticati);
  294.             String urlAutorizzazioneAutenticati = urlAutorizzazioneAutenticatiParam.getValue();

  295.             Parameter[] urlParmsAutorizzazioneErogazioneApplicativiAutenticati = {
  296.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  297.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  298.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps) };
  299.             Parameter urlAutorizzazioneErogazioneApplicativiAutenticatiParam= new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_SERVIZIO_APPLICATIVO_AUTORIZZATO_LIST, urlParmsAutorizzazioneErogazioneApplicativiAutenticati);
  300.             String urlAutorizzazioneErogazioneApplicativiAutenticati = urlAutorizzazioneErogazioneApplicativiAutenticatiParam.getValue();

  301.             Parameter[] urlParmsAutorizzazioneRuoli = {
  302.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  303.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  304.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps) };
  305.             Parameter urlAutorizzazioneRuoliParam = new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_RUOLI_LIST , urlParmsAutorizzazioneRuoli);
  306.             String urlAutorizzazioneRuoli = urlAutorizzazioneRuoliParam.getValue();
  307.            
  308.             Parameter[] urlParmsAutorizzazioneAutenticatiToken = {
  309.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  310.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  311.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps),
  312.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TOKEN_AUTHORIZATION, true+"")};
  313.             Parameter urlAutorizzazioneAutenticatiParamToken= new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_SERVIZIO_APPLICATIVO_AUTORIZZATO_LIST, urlParmsAutorizzazioneAutenticatiToken);
  314.             String urlAutorizzazioneAutenticatiToken = urlAutorizzazioneAutenticatiParamToken.getValue();

  315.             Parameter[] urlParmsAutorizzazioneRuoliToken = {
  316.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  317.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  318.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps),
  319.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_TOKEN_AUTHORIZATION, true+"") };
  320.             Parameter urlAutorizzazioneRuoliParamToken = new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_RUOLI_LIST , urlParmsAutorizzazioneRuoliToken);
  321.             String urlAutorizzazioneRuoliToken = urlAutorizzazioneRuoliParamToken.getValue();

  322.             Parameter[] urlParmsAutorizzazioneScope = {
  323.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  324.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  325.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps) };
  326.             Parameter urlAutorizzazioneScopeParam = new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_SCOPE_LIST , urlParmsAutorizzazioneScope);
  327.             String urlAutorizzazioneScope = urlAutorizzazioneScopeParam.getValue();
  328.            
  329.             Parameter[] urlParmsAutenticazioneCustomProperties = {
  330.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  331.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  332.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps) };
  333.             Parameter urlAutenticazioneCustomPropertiesParam = new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_AUTENTICAZIONE_CUSTOM_PROPERTIES_LIST , urlParmsAutenticazioneCustomProperties);
  334.             String urlAutenticazioneCustomProperties = urlAutenticazioneCustomPropertiesParam.getValue();

  335.             Parameter[] urlParmsAutorizzazioneCustomProperties = {
  336.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  337.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  338.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps) };
  339.             Parameter urlAutorizzazioneCustomPropertiesParam = new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_AUTORIZZAZIONE_CUSTOM_PROPERTIES_LIST , urlParmsAutorizzazioneCustomProperties);
  340.             String urlAutorizzazioneCustomProperties = urlAutorizzazioneCustomPropertiesParam.getValue();
  341.            
  342.             Parameter[] urlParmsAutorizzazioneContenutiCustomProperties = {
  343.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID,id)   ,
  344.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO,idsogg),
  345.                     new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS,idAsps) };
  346.             Parameter urlAutorizzazioneContenutiCustomPropertiesParam = new Parameter("", PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI_CUSTOM_PROPERTIES_LIST , urlParmsAutorizzazioneContenutiCustomProperties);
  347.             String urlAutorizzazioneContenutiCustomPropertiesList = urlAutorizzazioneContenutiCustomPropertiesParam.getValue();

  348.             String servletChiamante = PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI;

  349.             // Token Policy
  350.             String [] policyLabels = null;
  351.             String [] policyValues = null;
  352.             if(forcePDND || forceOAuth) {
  353.                
  354.                 String policyConfigurata = null;
  355.                 if(gestioneTokenPolicy==null && porteApplicativeHelper.isEditModeInProgress() && !applicaModifica && gestioneToken == null) {
  356.                     if(pa.getGestioneToken() != null) {
  357.                         policyConfigurata = pa.getGestioneToken().getPolicy();
  358.                     }
  359.                 }
  360.                 else {
  361.                     policyConfigurata = gestioneTokenPolicy;
  362.                 }
  363.                
  364.                 if(forcePDND) {
  365.                     List<String> tokenPolicies = porteApplicativeHelper.getTokenPolicyGestione(true, false,
  366.                             true,
  367.                             policyConfigurata, TipoOperazione.CHANGE);
  368.                     if(tokenPolicies!=null && !tokenPolicies.isEmpty()) {
  369.                         policyLabels = tokenPolicies.toArray(new String[1]);
  370.                         policyValues = tokenPolicies.toArray(new String[1]);
  371.                     }
  372.                 }
  373.                 else {
  374.                     List<String> tokenPolicies = porteApplicativeHelper.getTokenPolicyGestione(false, true,
  375.                             true,
  376.                             policyConfigurata, TipoOperazione.CHANGE);
  377.                     if(tokenPolicies!=null && !tokenPolicies.isEmpty()) {
  378.                         policyLabels = tokenPolicies.toArray(new String[1]);
  379.                         policyValues = tokenPolicies.toArray(new String[1]);
  380.                     }
  381.                 }
  382.             }
  383.             else {
  384.                 List<GenericProperties> gestorePolicyTokenList = confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_GESTIONE_POLICY_TOKEN, null);
  385.                 policyLabels = new String[gestorePolicyTokenList.size() + 1];
  386.                 policyValues = new String[gestorePolicyTokenList.size() + 1];
  387.    
  388.                 policyLabels[0] = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  389.                 policyValues[0] = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  390.    
  391.                 for (int i = 0; i < gestorePolicyTokenList.size(); i++) {
  392.                     GenericProperties genericProperties = gestorePolicyTokenList.get(i);
  393.                     policyLabels[(i+1)] = genericProperties.getNome();
  394.                     policyValues[(i+1)] = genericProperties.getNome();
  395.                 }
  396.             }


  397.             // La XACML Policy, se definita nella porta delegata può solo essere cambiata, non annullata.
  398.             if(allegatoXacmlPolicy!=null && allegatoXacmlPolicy.getValue()==null &&
  399.                 pa.getXacmlPolicy()!=null && !"".equals(pa.getXacmlPolicy())) {
  400.                 allegatoXacmlPolicy.setValue(pa.getXacmlPolicy().getBytes());
  401.             }
  402.            
  403.             // AttributeAuthority
  404.             List<GenericProperties> attributeAuthorityList = confCore.gestorePolicyTokenList(null, ConfigurazioneCostanti.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TIPOLOGIA_ATTRIBUTE_AUTHORITY, null);
  405.             String [] attributeAuthorityLabels = new String[attributeAuthorityList.size()];
  406.             String [] attributeAuthorityValues = new String[attributeAuthorityList.size()];
  407.             for (int i = 0; i < attributeAuthorityList.size(); i++) {
  408.                 GenericProperties genericProperties = attributeAuthorityList.get(i);
  409.                 attributeAuthorityLabels[i] = genericProperties.getNome();
  410.                 attributeAuthorityValues[i] = genericProperties.getNome();
  411.             }
  412.            
  413.             // postback
  414.             String postBackElementName = porteApplicativeHelper.getPostBackElementName();
  415.             if(postBackElementName != null) {
  416.                 if(postBackElementName.equals(CostantiControlStation.PARAMETRO_PORTE_AUTENTICAZIONE) &&
  417.                     autenticazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM)) {
  418.                     autenticazioneCustom = "";
  419.                 }
  420.                
  421.                 if(postBackElementName.equals(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI_STATO)) {
  422.                     if(autorizzazioneContenutiStato.equals(StatoFunzionalita.DISABILITATO.getValue()) || autorizzazioneContenutiStato.equals(CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM)) {
  423.                         autorizzazioneContenuti = "";
  424.                     }
  425.                     if(autorizzazioneContenutiStato.equals(StatoFunzionalita.ABILITATO.getValue())) {
  426.                         autorizzazioneContenuti = CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN;
  427.                     }
  428.                 }
  429.             }

  430.             if( porteApplicativeHelper.isEditModeInProgress() && !applicaModifica){

  431.                 if (autenticazione == null) {
  432.                     autenticazione = pa.getAutenticazione();
  433.                     if (autenticazione != null &&
  434.                             !TipoAutenticazione.getValues().contains(autenticazione)) {
  435.                         autenticazioneCustom = autenticazione;
  436.                         autenticazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  437.                     }

  438.                     autenticazionePrincipal = porteApplicativeCore.getTipoAutenticazionePrincipal(pa.getProprietaAutenticazioneList());
  439.                     autenticazioneParametroList = porteApplicativeCore.getParametroAutenticazione(autenticazione, pa.getProprietaAutenticazioneList());
  440.                 }
  441.                 if(autenticazioneOpzionale==null){
  442.                     autenticazioneOpzionale = "";
  443.                     if(pa.getAutenticazioneOpzionale()!=null &&
  444.                         pa.getAutenticazioneOpzionale().equals(StatoFunzionalita.ABILITATO)) {
  445.                         autenticazioneOpzionale = Costanti.CHECK_BOX_ENABLED;
  446.                     }
  447.                 }
  448.                 if (autorizzazione == null) {
  449.                     if (pa.getAutorizzazione() != null &&
  450.                             !TipoAutorizzazione.getAllValues().contains(pa.getAutorizzazione())) {
  451.                         autorizzazioneCustom = pa.getAutorizzazione();
  452.                         autorizzazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM;
  453.                     }
  454.                     else{
  455.                         autorizzazione = AutorizzazioneUtilities.convertToStato(pa.getAutorizzazione());
  456.                         if(TipoAutorizzazione.isAuthenticationRequired(pa.getAutorizzazione()))
  457.                             autorizzazioneAutenticati = Costanti.CHECK_BOX_ENABLED;
  458.                         if(TipoAutorizzazione.isRolesRequired(pa.getAutorizzazione()))
  459.                             autorizzazioneRuoli = Costanti.CHECK_BOX_ENABLED;
  460.                         autorizzazioneRuoliTipologia = AutorizzazioneUtilities.convertToRuoloTipologia(pa.getAutorizzazione()).getValue();
  461.                     }
  462.                 }
  463.                
  464.                 if (ruoloMatch == null &&
  465.                     pa.getRuoli()!=null && pa.getRuoli().getMatch()!=null){
  466.                     ruoloMatch = pa.getRuoli().getMatch().getValue();
  467.                 }

  468.                 if(autorizzazioneAutenticatiToken==null &&
  469.                     pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getAutorizzazioneApplicativi()!=null) {
  470.                     autorizzazioneAutenticatiToken = StatoFunzionalita.ABILITATO.equals(pa.getAutorizzazioneToken().getAutorizzazioneApplicativi()) ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED;
  471.                 }
  472.                
  473.                 if(autorizzazioneRuoliToken==null &&
  474.                     pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getAutorizzazioneRuoli()!=null) {
  475.                     autorizzazioneRuoliToken = StatoFunzionalita.ABILITATO.equals(pa.getAutorizzazioneToken().getAutorizzazioneRuoli()) ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED;
  476.                 }
  477.                 if(autorizzazioneRuoliTipologiaToken==null &&
  478.                     pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getTipologiaRuoli()!=null) {
  479.                     autorizzazioneRuoliTipologiaToken = pa.getAutorizzazioneToken().getTipologiaRuoli().getValue();
  480.                 }
  481.                 if (autorizzazioneRuoliMatchToken == null &&
  482.                     pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getRuoli()!=null && pa.getAutorizzazioneToken().getRuoli().getMatch()!=null){
  483.                     autorizzazioneRuoliMatchToken = pa.getAutorizzazioneToken().getRuoli().getMatch().getValue();
  484.                 }
  485.                
  486.                 if(autorizzazioneContenutiStato==null){
  487.                     autorizzazioneContenuti = pa.getAutorizzazioneContenuto();
  488.                    
  489.                     if(autorizzazioneContenuti == null || "".equals(autorizzazioneContenuti)) {
  490.                         autorizzazioneContenutiStato = StatoFunzionalita.DISABILITATO.getValue();
  491.                     } else if(autorizzazioneContenuti.equals(CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN)) {
  492.                         autorizzazioneContenutiStato = StatoFunzionalita.ABILITATO.getValue();
  493.                         List<Proprieta> proprietaAutorizzazioneContenutoList = pa.getProprietaAutorizzazioneContenutoList();
  494.                         SortedMap<List<String>> map = porteApplicativeCore.toSortedListMap(proprietaAutorizzazioneContenutoList);
  495.                         autorizzazioneContenutiProperties = PropertiesUtilities.convertSortedListMapToText(map, true);
  496.                     } else { // custom
  497.                         autorizzazioneContenutiStato = CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM;
  498.                     }
  499.                 }

  500.                 if(gestioneToken == null) {
  501.                     if(pa.getGestioneToken() != null) {
  502.                         gestioneTokenPolicy = pa.getGestioneToken().getPolicy();
  503.                         if(gestioneTokenPolicy == null) {
  504.                             gestioneToken = StatoFunzionalita.DISABILITATO.getValue();
  505.                             gestioneTokenPolicy = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  506.                         } else {
  507.                             gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  508.                         }

  509.                         StatoFunzionalita tokenOpzionale = pa.getGestioneToken().getTokenOpzionale();
  510.                         if(tokenOpzionale == null) {
  511.                             gestioneTokenOpzionale = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_OPZIONALE;
  512.                         }else {
  513.                             gestioneTokenOpzionale = tokenOpzionale.getValue();
  514.                         }

  515.                         StatoFunzionalitaConWarning validazione = pa.getGestioneToken().getValidazione();
  516.                         if(validazione == null) {
  517.                             gestioneTokenValidazioneInput = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_VALIDAZIONE_INPUT;
  518.                         }else {
  519.                             gestioneTokenValidazioneInput = validazione.getValue();
  520.                         }

  521.                         StatoFunzionalitaConWarning introspection = pa.getGestioneToken().getIntrospection();
  522.                         if(introspection == null) {
  523.                             gestioneTokenIntrospection = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_INTROSPECTION;
  524.                         }else {
  525.                             gestioneTokenIntrospection = introspection.getValue();
  526.                         }

  527.                         StatoFunzionalitaConWarning userinfo = pa.getGestioneToken().getUserInfo();
  528.                         if(userinfo == null) {
  529.                             gestioneTokenUserInfo = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_USER_INFO;
  530.                         }else {
  531.                             gestioneTokenUserInfo = userinfo.getValue();
  532.                         }

  533.                         StatoFunzionalita tokenForward = pa.getGestioneToken().getForward();
  534.                         if(tokenForward == null) {
  535.                             gestioneTokenTokenForward = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TOKEN_FORWARD;
  536.                         }else {
  537.                             gestioneTokenTokenForward = tokenForward.getValue();
  538.                         }

  539.                         autorizzazioneTokenOptions = pa.getGestioneToken().getOptions();
  540.                         if((autorizzazioneTokenOptions!=null && !"".equals(autorizzazioneTokenOptions))) {
  541.                             autorizzazioneToken = Costanti.CHECK_BOX_ENABLED;
  542.                         }
  543.                         else {
  544.                             autorizzazioneToken = Costanti.CHECK_BOX_DISABLED;
  545.                         }

  546.                         if(pa.getGestioneToken().getAutenticazione() != null) {

  547.                             StatoFunzionalita issuer = pa.getGestioneToken().getAutenticazione().getIssuer();
  548.                             if(issuer == null) {
  549.                                 autenticazioneTokenIssuer = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_ISSUER;
  550.                             }else {
  551.                                 autenticazioneTokenIssuer = issuer.getValue();
  552.                             }

  553.                             StatoFunzionalita clientId = pa.getGestioneToken().getAutenticazione().getClientId();
  554.                             if(clientId == null) {
  555.                                 autenticazioneTokenClientId = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_CLIENT_ID;
  556.                             }else {
  557.                                 autenticazioneTokenClientId = clientId.getValue();
  558.                             }

  559.                             StatoFunzionalita subject = pa.getGestioneToken().getAutenticazione().getSubject();
  560.                             if(subject == null) {
  561.                                 autenticazioneTokenSubject = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_SUBJECT;
  562.                             }else {
  563.                                 autenticazioneTokenSubject = subject.getValue();
  564.                             }

  565.                             StatoFunzionalita username = pa.getGestioneToken().getAutenticazione().getUsername();
  566.                             if(username == null) {
  567.                                 autenticazioneTokenUsername = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_USERNAME;
  568.                             }else {
  569.                                 autenticazioneTokenUsername = username.getValue();
  570.                             }

  571.                             StatoFunzionalita mailTmp = pa.getGestioneToken().getAutenticazione().getEmail();
  572.                             if(mailTmp == null) {
  573.                                 autenticazioneTokenEMail = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_EMAIL;
  574.                             }else {
  575.                                 autenticazioneTokenEMail = mailTmp.getValue();
  576.                             }

  577.                         }
  578.                         else {
  579.                             autenticazioneTokenIssuer = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_ISSUER;
  580.                             autenticazioneTokenClientId = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_CLIENT_ID;
  581.                             autenticazioneTokenSubject = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_SUBJECT;
  582.                             autenticazioneTokenUsername = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_USERNAME;
  583.                             autenticazioneTokenEMail = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_EMAIL;
  584.                         }
  585.                     }
  586.                     else {
  587.                         gestioneToken = StatoFunzionalita.DISABILITATO.getValue();
  588.                         gestioneTokenPolicy = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  589.                         gestioneTokenOpzionale = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_OPZIONALE;

  590.                         gestioneTokenValidazioneInput = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_VALIDAZIONE_INPUT;
  591.                         gestioneTokenIntrospection = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_INTROSPECTION;
  592.                         gestioneTokenUserInfo = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_USER_INFO;
  593.                         gestioneTokenTokenForward = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TOKEN_FORWARD;

  594.                         autenticazioneTokenIssuer = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_ISSUER;
  595.                         autenticazioneTokenClientId = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_CLIENT_ID;
  596.                         autenticazioneTokenSubject = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_SUBJECT;
  597.                         autenticazioneTokenUsername = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_USERNAME;
  598.                         autenticazioneTokenEMail = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_EMAIL;
  599.                     }
  600.                 }

  601.                 if( forceGestioneToken && (gestioneTokenPolicy == null || gestioneTokenPolicy.equals(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO))) {
  602.                     // Si arriva in una configurazione in cui l'API è stata modificata successivamente
  603.                     forceGestioneToken = false;
  604.                    
  605.                     if(policyLabels!=null && policyLabels.length>0 && policyValues!=null && policyValues.length>0) {
  606.                    
  607.                         List<String> newPolicyLabels = new ArrayList<>();
  608.                         List<String> newPolicyValues = new ArrayList<>();
  609.                        
  610.                         if(!CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO.equals(policyValues[0])){
  611.                             newPolicyLabels.add(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO);
  612.                             newPolicyValues.add(CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO);
  613.                         }
  614.                         newPolicyLabels.addAll(Arrays.asList(policyLabels));
  615.                         newPolicyValues.addAll(Arrays.asList(policyValues));
  616.                        
  617.                         policyLabels = newPolicyLabels.toArray(new String[1]);
  618.                         policyValues = newPolicyValues.toArray(new String[1]);
  619.                        
  620.                     }
  621.                    
  622.                 }
  623.                
  624.                 if(autorizzazioneScope == null) {
  625.                     if(pa.getScope() != null) {
  626.                         autorizzazioneScope =  pa.getScope().getStato().equals(StatoFunzionalita.ABILITATO) ? Costanti.CHECK_BOX_ENABLED : "";
  627.                     } else {
  628.                         autorizzazioneScope = "";
  629.                     }
  630.                 }

  631.                 if(autorizzazioneScopeMatch == null &&
  632.                     pa.getScope()!=null && pa.getScope().getMatch()!=null){
  633.                     autorizzazioneScopeMatch = pa.getScope().getMatch().getValue();
  634.                 }
  635.                
  636.                 if(identificazioneAttributiStato==null) {
  637.                     identificazioneAttributiStato = pa.sizeAttributeAuthorityList()>0 ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue();
  638.                     if(pa.sizeAttributeAuthorityList()>0) {
  639.                         attributeAuthoritySelezionate = porteApplicativeCore.buildAuthorityArrayString(pa.getAttributeAuthorityList());
  640.                         attributeAuthorityAttributi = porteApplicativeCore.buildAttributesStringFromAuthority(pa.getAttributeAuthorityList());
  641.                     }
  642.                 }

  643.                 // preparo i campi
  644.                 List<DataElement> dati = new ArrayList<>();
  645.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  646.                 porteApplicativeHelper.controlloAccessiGestioneToken(dati, TipoOperazione.OTHER, gestioneToken, policyLabels, policyValues,
  647.                         gestioneTokenPolicy, gestioneTokenOpzionale,
  648.                         gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward, pa,protocollo,false,
  649.                         forceGestioneToken);

  650.                 porteApplicativeHelper.controlloAccessiAutenticazione(dati, TipoOperazione.OTHER, servletChiamante,pa,protocollo,
  651.                         autenticazione, autenticazioneCustom, autenticazioneOpzionale, autenticazionePrincipal, autenticazioneParametroList, confPers, isSupportatoAutenticazione,false,
  652.                         gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  653.                         oldAutenticazioneCustom, urlAutenticazioneCustomProperties, numAutenticazioneCustomPropertiesList,
  654.                         forceHttps, forceDisableOptional);

  655.                 // Tipo operazione = CHANGE per evitare di aggiungere if, questa e' a tutti gli effetti una servlet di CHANGE
  656.                 porteApplicativeHelper.controlloAccessiAutorizzazione(dati, TipoOperazione.CHANGE, servletChiamante,pa,protocollo,
  657.                         autenticazione, autenticazioneCustom,
  658.                         autorizzazione, autorizzazioneCustom,
  659.                         autorizzazioneAutenticati, urlAutorizzazioneAutenticati, sizeSoggettiPA, null, null,
  660.                         autorizzazioneRuoli,  urlAutorizzazioneRuoli, numRuoli, null,
  661.                         autorizzazioneRuoliTipologia, ruoloMatch,
  662.                         confPers, isSupportatoAutenticazione, contaListe, false, false,autorizzazioneScope,urlAutorizzazioneScope,numScope,null,autorizzazioneScopeMatch,
  663.                         gestioneToken, gestioneTokenPolicy, autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  664.                         urlAutorizzazioneErogazioneApplicativiAutenticati, numErogazioneApplicativiAutenticati,
  665.                         urlAutorizzazioneCustomProperties, numAutorizzazioneCustomPropertiesList,
  666.                         identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  667.                         autorizzazioneAutenticatiToken, urlAutorizzazioneAutenticatiToken, numAutenticatiToken,
  668.                         autorizzazioneRuoliToken,  urlAutorizzazioneRuoliToken, numRuoliToken, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);

  669.                 porteApplicativeHelper.controlloAccessiAutorizzazioneContenuti(dati, TipoOperazione.OTHER, false, pa,protocollo,
  670.                         autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties, serviceBinding,
  671.                         oldAutorizzazioneContenutiCustom, urlAutorizzazioneContenutiCustomPropertiesList, numAutorizzazioneContenutiCustomPropertiesList,
  672.                         confPers);

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

  674.                 pd.setDati(dati);

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

  676.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping,
  677.                         PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI, ForwardParams.OTHER(""));
  678.             }

  679.             // Controlli sui campi immessi
  680.             boolean isOk = porteApplicativeHelper.controlloAccessiCheck(TipoOperazione.OTHER, autenticazione, autenticazioneOpzionale, autenticazionePrincipal, autenticazioneParametroList,
  681.                     autorizzazione, autorizzazioneAutenticati, autorizzazioneRuoli,
  682.                     autorizzazioneRuoliTipologia, ruoloMatch,
  683.                     isSupportatoAutenticazione, isPortaDelegata, pa, ruoli,gestioneToken, gestioneTokenPolicy,
  684.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward,
  685.                     autorizzazioneAutenticatiToken, autorizzazioneRuoliToken,
  686.                     autorizzazioneToken,autorizzazioneTokenOptions,
  687.                     autorizzazioneScope,autorizzazioneScopeMatch,allegatoXacmlPolicy,
  688.                     autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties,
  689.                     protocollo,
  690.                     identificazioneAttributiStato, attributeAuthoritySelezionate, attributeAuthorityAttributi);
  691.            
  692.             if (!isOk) {
  693.                 // preparo i campi
  694.                 List<DataElement> dati = new ArrayList<>();

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

  696.                 porteApplicativeHelper.controlloAccessiGestioneToken(dati, TipoOperazione.OTHER, gestioneToken, policyLabels, policyValues,
  697.                         gestioneTokenPolicy, gestioneTokenOpzionale, gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward, pa,protocollo,false,
  698.                         forceGestioneToken);

  699.                 porteApplicativeHelper.controlloAccessiAutenticazione(dati, TipoOperazione.OTHER, servletChiamante,pa,protocollo,
  700.                         autenticazione, autenticazioneCustom, autenticazioneOpzionale, autenticazionePrincipal, autenticazioneParametroList, confPers, isSupportatoAutenticazione,false,
  701.                         gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  702.                         oldAutenticazioneCustom, urlAutenticazioneCustomProperties, numAutenticazioneCustomPropertiesList,
  703.                         forceHttps, forceDisableOptional);
  704.                
  705.                 // Tipo operazione = CHANGE per evitare di aggiungere if, questa e' a tutti gli effetti una servlet di CHANGE
  706.                 porteApplicativeHelper.controlloAccessiAutorizzazione(dati, TipoOperazione.CHANGE, servletChiamante,pa,protocollo,
  707.                         autenticazione, autenticazioneCustom,
  708.                         autorizzazione, autorizzazioneCustom,
  709.                         autorizzazioneAutenticati, urlAutorizzazioneAutenticati, sizeSoggettiPA, null, null,
  710.                         autorizzazioneRuoli,  urlAutorizzazioneRuoli, numRuoli, null,
  711.                         autorizzazioneRuoliTipologia, ruoloMatch,
  712.                         confPers, isSupportatoAutenticazione, contaListe, false, false,
  713.                         autorizzazioneScope,urlAutorizzazioneScope,numScope,null,autorizzazioneScopeMatch,
  714.                         gestioneToken, gestioneTokenPolicy, autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  715.                         urlAutorizzazioneErogazioneApplicativiAutenticati, numErogazioneApplicativiAutenticati,
  716.                         urlAutorizzazioneCustomProperties, numAutorizzazioneCustomPropertiesList,
  717.                         identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  718.                         autorizzazioneAutenticatiToken, urlAutorizzazioneAutenticatiToken, numAutenticatiToken,
  719.                         autorizzazioneRuoliToken,  urlAutorizzazioneRuoliToken, numRuoliToken, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);

  720.                 porteApplicativeHelper.controlloAccessiAutorizzazioneContenuti(dati, TipoOperazione.OTHER, false, pa,protocollo,
  721.                         autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties, serviceBinding,
  722.                         oldAutorizzazioneContenutiCustom, urlAutorizzazioneContenutiCustomPropertiesList, numAutorizzazioneContenutiCustomPropertiesList,
  723.                         confPers);

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

  725.                 pd.setDati(dati);

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

  727.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping,
  728.                         PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI,
  729.                         ForwardParams.OTHER(""));
  730.             }


  731.             if (autenticazione == null || !autenticazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM))
  732.                 pa.setAutenticazione(autenticazione);
  733.             else {
  734.                 pa.setAutenticazione(autenticazioneCustom);
  735.                
  736.                 if(!oldAutenticazioneCustom)
  737.                     pa.getProprietaAutenticazioneList().clear();
  738.             }
  739.             if(autenticazioneOpzionale != null){
  740.                 if(ServletUtils.isCheckBoxEnabled(autenticazioneOpzionale))
  741.                     pa.setAutenticazioneOpzionale(StatoFunzionalita.ABILITATO);
  742.                 else
  743.                     pa.setAutenticazioneOpzionale(StatoFunzionalita.DISABILITATO);
  744.             } else
  745.                 pa.setAutenticazioneOpzionale(null);
  746.            
  747.             if (autenticazione == null || !autenticazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM)) {
  748.                 pa.getProprietaAutenticazioneList().clear();
  749.                 List<Proprieta> proprietaAutenticazione = porteApplicativeCore.convertToAutenticazioneProprieta(autenticazione, autenticazionePrincipal, autenticazioneParametroList);
  750.                 if(proprietaAutenticazione!=null && !proprietaAutenticazione.isEmpty()) {
  751.                     pa.getProprietaAutenticazioneList().addAll(proprietaAutenticazione);
  752.                 }
  753.             }

  754.             if (autorizzazione == null || !autorizzazione.equals(CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM)) {
  755.                 pa.setAutorizzazione(AutorizzazioneUtilities.convertToTipoAutorizzazioneAsString(autorizzazione,
  756.                         ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticati),
  757.                         ServletUtils.isCheckBoxEnabled(autorizzazioneRuoli),
  758.                         ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticatiToken),
  759.                         ServletUtils.isCheckBoxEnabled(autorizzazioneRuoliToken),
  760.                         ServletUtils.isCheckBoxEnabled(autorizzazioneScope),
  761.                         autorizzazioneTokenOptions,
  762.                         RuoloTipologia.toEnumConstant(autorizzazioneRuoliTipologia)));
  763.                 pa.getProprietaAutorizzazioneList().clear();
  764.             }else {
  765.                 pa.setAutorizzazione(autorizzazioneCustom);
  766.             }

  767.             if(autorizzazione != null && autorizzazione.equals(AutorizzazioneUtilities.STATO_XACML_POLICY) && allegatoXacmlPolicy.getValue() != null) {
  768.                 pa.setXacmlPolicy(new String(allegatoXacmlPolicy.getValue()));
  769.             } else {
  770.                 pa.setXacmlPolicy(null);
  771.             }

  772.             if(ruoloMatch!=null && !"".equals(ruoloMatch)){
  773.                 RuoloTipoMatch tipoRuoloMatch = RuoloTipoMatch.toEnumConstant(ruoloMatch);
  774.                 if(tipoRuoloMatch!=null){
  775.                     if(pa.getRuoli()==null){
  776.                         pa.setRuoli(new AutorizzazioneRuoli());
  777.                     }
  778.                     pa.getRuoli().setMatch(tipoRuoloMatch);
  779.                 }
  780.             }

  781.             if(ServletUtils.isCheckBoxEnabled(autorizzazioneAutenticatiToken ) ) {
  782.                 if(pa.getAutorizzazioneToken()==null) {
  783.                     pa.setAutorizzazioneToken(new PortaApplicativaAutorizzazioneToken());
  784.                 }
  785.                 pa.getAutorizzazioneToken().setAutorizzazioneApplicativi(StatoFunzionalita.ABILITATO);
  786.             }
  787.             else {
  788.                 if(pa.getAutorizzazioneToken()!=null) {
  789.                     pa.getAutorizzazioneToken().setAutorizzazioneApplicativi(StatoFunzionalita.DISABILITATO);
  790.                     pa.getAutorizzazioneToken().setServiziApplicativi(null);
  791.                 }
  792.             }
  793.            
  794.             if(ServletUtils.isCheckBoxEnabled(autorizzazioneRuoliToken ) ) {
  795.                 if(pa.getAutorizzazioneToken()==null) {
  796.                     pa.setAutorizzazioneToken(new PortaApplicativaAutorizzazioneToken());
  797.                 }
  798.                 pa.getAutorizzazioneToken().setAutorizzazioneRuoli(StatoFunzionalita.ABILITATO);
  799.                
  800.                 if(autorizzazioneRuoliMatchToken!=null && !"".equals(autorizzazioneRuoliMatchToken)){
  801.                     RuoloTipoMatch ruoloTipoMatch = RuoloTipoMatch.toEnumConstant(autorizzazioneRuoliMatchToken);
  802.                     if(ruoloTipoMatch!=null){
  803.                         if(pa.getAutorizzazioneToken().getRuoli()==null){
  804.                             pa.getAutorizzazioneToken().setRuoli(new AutorizzazioneRuoli());
  805.                         }
  806.                         pa.getAutorizzazioneToken().getRuoli().setMatch(ruoloTipoMatch);
  807.                     }
  808.                     else {
  809.                         if(pa.getAutorizzazioneToken().getRuoli()!=null){
  810.                             pa.getAutorizzazioneToken().getRuoli().setMatch(null);
  811.                         }
  812.                     }
  813.                 }
  814.                 else {
  815.                     if(pa.getAutorizzazioneToken().getRuoli()!=null){
  816.                         pa.getAutorizzazioneToken().getRuoli().setMatch(null);
  817.                     }
  818.                 }
  819.                
  820.                 if(autorizzazioneRuoliTipologiaToken!=null && !"".equals(autorizzazioneRuoliTipologiaToken)){
  821.                     org.openspcoop2.core.config.constants.RuoloTipologia ruoloTipologia = org.openspcoop2.core.config.constants.RuoloTipologia.toEnumConstant(autorizzazioneRuoliTipologiaToken);
  822.                     if(ruoloTipologia!=null){
  823.                         pa.getAutorizzazioneToken().setTipologiaRuoli(ruoloTipologia);
  824.                     }
  825.                     else {
  826.                         pa.getAutorizzazioneToken().setTipologiaRuoli(null);
  827.                     }
  828.                 }
  829.                 else {
  830.                     pa.getAutorizzazioneToken().setTipologiaRuoli(null);
  831.                 }
  832.             }
  833.             else {
  834.                 if(pa.getAutorizzazioneToken()!=null) {
  835.                     pa.getAutorizzazioneToken().setAutorizzazioneRuoli(StatoFunzionalita.DISABILITATO);
  836.                     pa.getAutorizzazioneToken().setRuoli(null);
  837.                 }
  838.             }
  839.            
  840.             if(ServletUtils.isCheckBoxEnabled(autorizzazioneScope )) {
  841.                 if(pa.getScope() == null)
  842.                     pa.setScope(new AutorizzazioneScope());

  843.                 pa.getScope().setStato(StatoFunzionalita.ABILITATO);
  844.             }
  845.             else {
  846.                 pa.setScope(null);
  847.             }
  848.             if(autorizzazioneScopeMatch!=null && !"".equals(autorizzazioneScopeMatch)){
  849.                 ScopeTipoMatch scopeTipoMatch = ScopeTipoMatch.toEnumConstant(autorizzazioneScopeMatch);
  850.                 if(scopeTipoMatch!=null){
  851.                     if(pa.getScope()==null){
  852.                         pa.setScope(new AutorizzazioneScope());
  853.                     }
  854.                     pa.getScope().setMatch(scopeTipoMatch);
  855.                 }
  856.             }

  857.             if(autorizzazioneContenutiStato.equals(StatoFunzionalita.DISABILITATO.getValue())) {
  858.                 pa.setAutorizzazioneContenuto(null);
  859.                 pa.getProprietaAutorizzazioneContenutoList().clear();
  860.             } else if(autorizzazioneContenutiStato.equals(StatoFunzionalita.ABILITATO.getValue())) {
  861.                 pa.setAutorizzazioneContenuto(CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN);
  862.                 pa.getProprietaAutorizzazioneContenutoList().clear();
  863.                 // Fix: non rispettava l'ordine
  864.                 SortedMap<List<String>> convertTextToProperties = PropertiesUtilities.convertTextToSortedListMap(autorizzazioneContenutiProperties, true);
  865.                 porteApplicativeCore.addFromSortedListMap(pa.getProprietaAutorizzazioneContenutoList(), convertTextToProperties);
  866.             } else {
  867.                 pa.setAutorizzazioneContenuto(autorizzazioneContenuti);
  868.                 if(!autorizzazioneContenutiStato.equals(oldAutorizzazioneContenutoStato))
  869.                     pa.getProprietaAutorizzazioneContenutoList().clear();
  870.             }

  871.             if(pa.getGestioneToken() == null)
  872.                 pa.setGestioneToken(new GestioneToken());

  873.             if(gestioneToken.equals(StatoFunzionalita.ABILITATO.getValue())) {
  874.                 pa.getGestioneToken().setPolicy(gestioneTokenPolicy);
  875.                 if(ServletUtils.isCheckBoxEnabled(gestioneTokenOpzionale)) {
  876.                     pa.getGestioneToken().setTokenOpzionale(StatoFunzionalita.ABILITATO);
  877.                 }
  878.                 else {
  879.                     pa.getGestioneToken().setTokenOpzionale(StatoFunzionalita.DISABILITATO);
  880.                 }
  881.                 pa.getGestioneToken().setValidazione(StatoFunzionalitaConWarning.toEnumConstant(gestioneTokenValidazioneInput));
  882.                 pa.getGestioneToken().setIntrospection(StatoFunzionalitaConWarning.toEnumConstant(gestioneTokenIntrospection));
  883.                 pa.getGestioneToken().setUserInfo(StatoFunzionalitaConWarning.toEnumConstant(gestioneTokenUserInfo));
  884.                 pa.getGestioneToken().setForward(StatoFunzionalita.toEnumConstant(gestioneTokenTokenForward));
  885.                 pa.getGestioneToken().setOptions(autorizzazioneTokenOptions);
  886.                 if(pa.getGestioneToken().getAutenticazione()==null) {
  887.                     pa.getGestioneToken().setAutenticazione(new GestioneTokenAutenticazione());
  888.                 }
  889.                 pa.getGestioneToken().getAutenticazione().setIssuer(ServletUtils.isCheckBoxEnabled(autenticazioneTokenIssuer) ? StatoFunzionalita.ABILITATO : StatoFunzionalita.toEnumConstant(autenticazioneTokenIssuer));
  890.                 pa.getGestioneToken().getAutenticazione().setClientId(ServletUtils.isCheckBoxEnabled(autenticazioneTokenClientId) ? StatoFunzionalita.ABILITATO : StatoFunzionalita.toEnumConstant(autenticazioneTokenClientId));
  891.                 pa.getGestioneToken().getAutenticazione().setSubject(ServletUtils.isCheckBoxEnabled(autenticazioneTokenSubject) ? StatoFunzionalita.ABILITATO : StatoFunzionalita.toEnumConstant(autenticazioneTokenSubject));
  892.                 pa.getGestioneToken().getAutenticazione().setUsername(ServletUtils.isCheckBoxEnabled(autenticazioneTokenUsername) ? StatoFunzionalita.ABILITATO : StatoFunzionalita.toEnumConstant(autenticazioneTokenUsername));
  893.                 pa.getGestioneToken().getAutenticazione().setEmail(ServletUtils.isCheckBoxEnabled(autenticazioneTokenEMail) ? StatoFunzionalita.ABILITATO : StatoFunzionalita.toEnumConstant(autenticazioneTokenEMail));
  894.             } else {
  895.                 pa.getGestioneToken().setPolicy(null);
  896.                 pa.getGestioneToken().setTokenOpzionale(StatoFunzionalita.DISABILITATO);
  897.                 pa.getGestioneToken().setValidazione(StatoFunzionalitaConWarning.DISABILITATO);
  898.                 pa.getGestioneToken().setIntrospection(StatoFunzionalitaConWarning.DISABILITATO);
  899.                 pa.getGestioneToken().setUserInfo(StatoFunzionalitaConWarning.DISABILITATO);
  900.                 pa.getGestioneToken().setForward(StatoFunzionalita.DISABILITATO);
  901.                 pa.getGestioneToken().setOptions(null);
  902.                 if(pa.getGestioneToken().getAutenticazione()!=null) {
  903.                     pa.getGestioneToken().setAutenticazione(null);
  904.                 }
  905.             }
  906.            
  907.             while (pa.sizeAttributeAuthorityList()>0) {
  908.                 pa.removeAttributeAuthority(0);
  909.             }
  910.             if(StatoFunzionalita.ABILITATO.getValue().equals(identificazioneAttributiStato) && attributeAuthoritySelezionate!=null && attributeAuthoritySelezionate.length>0) {
  911.                 for (String aaName : attributeAuthoritySelezionate) {
  912.                     pa.addAttributeAuthority(porteApplicativeCore.buildAttributeAuthority(attributeAuthoritySelezionate.length, aaName, attributeAuthorityAttributi));
  913.                 }
  914.             }
  915.                        
  916.             String userLogin = ServletUtils.getUserLoginFromSession(session);

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

  918.             // cancello i file temporanei
  919.             porteApplicativeHelper.deleteBinaryParameters(allegatoXacmlPolicy);

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

  922.             pa = porteApplicativeCore.getPortaApplicativa(idInt);
  923.             if(pa==null) {
  924.                 throw new CoreException("PortaApplicativa con id '"+idInt+"' non trovata");
  925.             }

  926.             ruoli = new ArrayList<>();
  927.             if(pa!=null && pa.getRuoli()!=null && pa.getRuoli().sizeRuoloList()>0){
  928.                 for (int i = 0; i < pa.getRuoli().sizeRuoloList(); i++) {
  929.                     ruoli.add(pa.getRuoli().getRuolo(i).getNome());
  930.                 }
  931.             }

  932.             numRuoli = 0;
  933.             if(pa.getRuoli()!=null){
  934.                 numRuoli = pa.getRuoli().sizeRuoloList();
  935.             }
  936.            
  937.             numAutenticatiToken = 0;
  938.             if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getServiziApplicativi()!=null){
  939.                 numAutenticatiToken = pa.getAutorizzazioneToken().getServiziApplicativi().sizeServizioApplicativoList();
  940.             }
  941.            
  942.             numRuoliToken = 0;
  943.             if(pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getRuoli()!=null){
  944.                 numRuoliToken = pa.getAutorizzazioneToken().getRuoli().sizeRuoloList();
  945.             }

  946.             numAutenticazioneCustomPropertiesList = pa.sizeProprietaAutenticazioneList();
  947.             numAutorizzazioneCustomPropertiesList = pa.sizeProprietaAutorizzazioneList();
  948.             numAutorizzazioneContenutiCustomPropertiesList = pa.sizeProprietaAutorizzazioneContenutoList();
  949.             oldAutorizzazioneContenutiCustom = pa.getAutorizzazioneContenuto() != null && !pa.getAutorizzazioneContenuto().equals(CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN);
  950.             oldAutenticazioneCustom = pa.getAutenticazione() != null && !TipoAutenticazione.getValues().contains(pa.getAutenticazione());
  951.            
  952.             if (autenticazione == null) {
  953.                 autenticazione = pa.getAutenticazione();
  954.                 if (autenticazione != null &&
  955.                         !TipoAutenticazione.getValues().contains(autenticazione)) {
  956.                     autenticazioneCustom = autenticazione;
  957.                     autenticazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTENTICAZIONE_CUSTOM;
  958.                 }

  959.                 autenticazionePrincipal = porteApplicativeCore.getTipoAutenticazionePrincipal(pa.getProprietaAutenticazioneList());
  960.                 autenticazioneParametroList = porteApplicativeCore.getParametroAutenticazione(autenticazione, pa.getProprietaAutenticazioneList());
  961.             }
  962.             if(autenticazioneOpzionale==null){
  963.                 autenticazioneOpzionale = "";
  964.                 if(pa.getAutenticazioneOpzionale()!=null &&
  965.                     pa.getAutenticazioneOpzionale().equals(StatoFunzionalita.ABILITATO)) {
  966.                     autenticazioneOpzionale = Costanti.CHECK_BOX_ENABLED;
  967.                 }
  968.             }
  969.             if (autorizzazione == null) {
  970.                 if (pa.getAutorizzazione() != null &&
  971.                         !TipoAutorizzazione.getAllValues().contains(pa.getAutorizzazione())) {
  972.                     autorizzazioneCustom = pa.getAutorizzazione();
  973.                     autorizzazione = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_PORTE_AUTORIZZAZIONE_CUSTOM;
  974.                 }
  975.                 else{
  976.                     autorizzazione = AutorizzazioneUtilities.convertToStato(pa.getAutorizzazione());
  977.                     if(TipoAutorizzazione.isAuthenticationRequired(pa.getAutorizzazione()))
  978.                         autorizzazioneAutenticati = Costanti.CHECK_BOX_ENABLED;
  979.                     if(TipoAutorizzazione.isRolesRequired(pa.getAutorizzazione()))
  980.                         autorizzazioneRuoli = Costanti.CHECK_BOX_ENABLED;
  981.                     autorizzazioneRuoliTipologia = AutorizzazioneUtilities.convertToRuoloTipologia(pa.getAutorizzazione()).getValue();
  982.                 }
  983.             }

  984.             if (ruoloMatch == null &&
  985.                 pa.getRuoli()!=null && pa.getRuoli().getMatch()!=null){
  986.                 ruoloMatch = pa.getRuoli().getMatch().getValue();
  987.             }

  988.             if(autorizzazioneAutenticatiToken==null &&
  989.                 pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getAutorizzazioneApplicativi()!=null) {
  990.                 autorizzazioneAutenticatiToken = StatoFunzionalita.ABILITATO.equals(pa.getAutorizzazioneToken().getAutorizzazioneApplicativi()) ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED;
  991.             }
  992.            
  993.             if(autorizzazioneRuoliToken==null &&
  994.                 pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getAutorizzazioneRuoli()!=null) {
  995.                 autorizzazioneRuoliToken = StatoFunzionalita.ABILITATO.equals(pa.getAutorizzazioneToken().getAutorizzazioneRuoli()) ? Costanti.CHECK_BOX_ENABLED : Costanti.CHECK_BOX_DISABLED;
  996.             }
  997.             if(autorizzazioneRuoliTipologiaToken==null &&
  998.                 pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getTipologiaRuoli()!=null) {
  999.                 autorizzazioneRuoliTipologiaToken = pa.getAutorizzazioneToken().getTipologiaRuoli().getValue();
  1000.             }
  1001.             if (autorizzazioneRuoliMatchToken == null &&
  1002.                 pa.getAutorizzazioneToken()!=null && pa.getAutorizzazioneToken().getRuoli()!=null && pa.getAutorizzazioneToken().getRuoli().getMatch()!=null){
  1003.                 autorizzazioneRuoliMatchToken = pa.getAutorizzazioneToken().getRuoli().getMatch().getValue();
  1004.             }
  1005.            
  1006.             autorizzazioneContenuti = pa.getAutorizzazioneContenuto();
  1007.            
  1008.             if(autorizzazioneContenuti == null) {
  1009.                 autorizzazioneContenutiStato = StatoFunzionalita.DISABILITATO.getValue();
  1010.             } else if(autorizzazioneContenuti.equals(CostantiAutorizzazione.AUTORIZZAZIONE_CONTENUTO_BUILT_IN)) {
  1011.                 autorizzazioneContenutiStato = StatoFunzionalita.ABILITATO.getValue();
  1012.                 List<Proprieta> proprietaAutorizzazioneContenutoList = pa.getProprietaAutorizzazioneContenutoList();
  1013.                 SortedMap<List<String>> map = porteApplicativeCore.toSortedListMap(proprietaAutorizzazioneContenutoList);
  1014.                 autorizzazioneContenutiProperties = PropertiesUtilities.convertSortedListMapToText(map, true);
  1015.             } else { // custom
  1016.                 autorizzazioneContenutiStato = CostantiControlStation.VALUE_PARAMETRO_PORTE_CONTROLLO_ACCESSI_AUTORIZZAZIONE_CONTENUTI_STATO_CUSTOM;
  1017.             }

  1018.             if(pa.getGestioneToken() != null) {
  1019.                 gestioneTokenPolicy = pa.getGestioneToken().getPolicy();
  1020.                 if(gestioneTokenPolicy == null) {
  1021.                     gestioneToken = StatoFunzionalita.DISABILITATO.getValue();
  1022.                     gestioneTokenPolicy = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  1023.                 } else {
  1024.                     gestioneToken = StatoFunzionalita.ABILITATO.getValue();
  1025.                 }

  1026.                 StatoFunzionalita tokenOpzionale = pa.getGestioneToken().getTokenOpzionale();
  1027.                 if(tokenOpzionale == null) {
  1028.                     gestioneTokenOpzionale = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_OPZIONALE;
  1029.                 }else {
  1030.                     gestioneTokenOpzionale = tokenOpzionale.getValue();
  1031.                 }

  1032.                 StatoFunzionalitaConWarning validazione = pa.getGestioneToken().getValidazione();
  1033.                 if(validazione == null) {
  1034.                     gestioneTokenValidazioneInput = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_VALIDAZIONE_INPUT;
  1035.                 }else {
  1036.                     gestioneTokenValidazioneInput = validazione.getValue();
  1037.                 }

  1038.                 StatoFunzionalitaConWarning introspection = pa.getGestioneToken().getIntrospection();
  1039.                 if(introspection == null) {
  1040.                     gestioneTokenIntrospection = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_INTROSPECTION;
  1041.                 }else {
  1042.                     gestioneTokenIntrospection = introspection.getValue();
  1043.                 }

  1044.                 StatoFunzionalitaConWarning userinfo = pa.getGestioneToken().getUserInfo();
  1045.                 if(userinfo == null) {
  1046.                     gestioneTokenUserInfo = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_USER_INFO;
  1047.                 }else {
  1048.                     gestioneTokenUserInfo = userinfo.getValue();
  1049.                 }

  1050.                 StatoFunzionalita tokenForward = pa.getGestioneToken().getForward();
  1051.                 if(tokenForward == null) {
  1052.                     gestioneTokenTokenForward = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TOKEN_FORWARD;
  1053.                 }else {
  1054.                     gestioneTokenTokenForward = tokenForward.getValue();
  1055.                 }

  1056.                 autorizzazioneTokenOptions = pa.getGestioneToken().getOptions();

  1057.                 if(pa.getGestioneToken().getAutenticazione() != null) {

  1058.                     StatoFunzionalita issuer = pa.getGestioneToken().getAutenticazione().getIssuer();
  1059.                     if(issuer == null) {
  1060.                         autenticazioneTokenIssuer = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_ISSUER;
  1061.                     }else {
  1062.                         autenticazioneTokenIssuer = issuer.getValue();
  1063.                     }

  1064.                     StatoFunzionalita clientId = pa.getGestioneToken().getAutenticazione().getClientId();
  1065.                     if(clientId == null) {
  1066.                         autenticazioneTokenClientId = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_CLIENT_ID;
  1067.                     }else {
  1068.                         autenticazioneTokenClientId = clientId.getValue();
  1069.                     }

  1070.                     StatoFunzionalita subject = pa.getGestioneToken().getAutenticazione().getSubject();
  1071.                     if(subject == null) {
  1072.                         autenticazioneTokenSubject = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_SUBJECT;
  1073.                     }else {
  1074.                         autenticazioneTokenSubject = subject.getValue();
  1075.                     }

  1076.                     StatoFunzionalita username = pa.getGestioneToken().getAutenticazione().getUsername();
  1077.                     if(username == null) {
  1078.                         autenticazioneTokenUsername = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_USERNAME;
  1079.                     }else {
  1080.                         autenticazioneTokenUsername = username.getValue();
  1081.                     }

  1082.                     StatoFunzionalita mailTmp = pa.getGestioneToken().getAutenticazione().getEmail();
  1083.                     if(mailTmp == null) {
  1084.                         autenticazioneTokenEMail = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_EMAIL;
  1085.                     }else {
  1086.                         autenticazioneTokenEMail = mailTmp.getValue();
  1087.                     }

  1088.                 }
  1089.                 else {
  1090.                     autenticazioneTokenIssuer = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_ISSUER;
  1091.                     autenticazioneTokenClientId = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_CLIENT_ID;
  1092.                     autenticazioneTokenSubject = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_SUBJECT;
  1093.                     autenticazioneTokenUsername = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_USERNAME;
  1094.                     autenticazioneTokenEMail = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_EMAIL;
  1095.                 }
  1096.             }
  1097.             else {
  1098.                 gestioneToken = StatoFunzionalita.DISABILITATO.getValue();
  1099.                 gestioneTokenPolicy = CostantiControlStation.DEFAULT_VALUE_NON_SELEZIONATO;
  1100.                 gestioneTokenOpzionale = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_OPZIONALE;

  1101.                 gestioneTokenValidazioneInput = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_VALIDAZIONE_INPUT;
  1102.                 gestioneTokenIntrospection = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_INTROSPECTION;
  1103.                 gestioneTokenUserInfo = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_USER_INFO;
  1104.                 gestioneTokenTokenForward = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_TOKEN_FORWARD;

  1105.                 autenticazioneTokenIssuer = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_ISSUER;
  1106.                 autenticazioneTokenClientId = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_CLIENT_ID;
  1107.                 autenticazioneTokenSubject = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_SUBJECT;
  1108.                 autenticazioneTokenUsername = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_USERNAME;
  1109.                 autenticazioneTokenEMail = CostantiControlStation.DEFAULT_VALUE_PARAMETRO_CONFIGURAZIONE_GESTORE_POLICY_TOKEN_AUTENTICAZIONE_EMAIL;
  1110.             }

  1111.             if(autorizzazioneScope == null) {
  1112.                 if(pa.getScope() != null) {
  1113.                     autorizzazioneScope =  pa.getScope().getStato().equals(StatoFunzionalita.ABILITATO) ? Costanti.CHECK_BOX_ENABLED : "";
  1114.                 } else {
  1115.                     autorizzazioneScope = "";
  1116.                 }
  1117.             }

  1118.             if(autorizzazioneScopeMatch == null &&
  1119.                 pa.getScope()!=null && pa.getScope().getMatch()!=null){
  1120.                 autorizzazioneScopeMatch = pa.getScope().getMatch().getValue();
  1121.             }

  1122.             if(identificazioneAttributiStato==null) {
  1123.                 identificazioneAttributiStato = pa.sizeAttributeAuthorityList()>0 ? StatoFunzionalita.ABILITATO.getValue() : StatoFunzionalita.DISABILITATO.getValue();
  1124.                 if(pa.sizeAttributeAuthorityList()>0) {
  1125.                     attributeAuthoritySelezionate = porteApplicativeCore.buildAuthorityArrayString(pa.getAttributeAuthorityList());
  1126.                     attributeAuthorityAttributi = porteApplicativeCore.buildAttributesStringFromAuthority(pa.getAttributeAuthorityList());
  1127.                 }
  1128.             }
  1129.            
  1130.             porteApplicativeHelper.controlloAccessiGestioneToken(dati, TipoOperazione.OTHER, gestioneToken, policyLabels, policyValues,
  1131.                     gestioneTokenPolicy, gestioneTokenOpzionale,
  1132.                     gestioneTokenValidazioneInput, gestioneTokenIntrospection, gestioneTokenUserInfo, gestioneTokenTokenForward, pa,protocollo,false,
  1133.                     forceGestioneToken);

  1134.             porteApplicativeHelper.controlloAccessiAutenticazione(dati, TipoOperazione.OTHER, servletChiamante,pa,protocollo,
  1135.                     autenticazione, autenticazioneCustom, autenticazioneOpzionale, autenticazionePrincipal, autenticazioneParametroList,confPers, isSupportatoAutenticazione,false,
  1136.                     gestioneToken, gestioneTokenPolicy, autenticazioneTokenIssuer, autenticazioneTokenClientId, autenticazioneTokenSubject, autenticazioneTokenUsername, autenticazioneTokenEMail,
  1137.                     oldAutenticazioneCustom, urlAutenticazioneCustomProperties, numAutenticazioneCustomPropertiesList,
  1138.                     forceHttps, forceDisableOptional);
  1139.            
  1140.             // Tipo operazione = CHANGE per evitare di aggiungere if, questa e' a tutti gli effetti una servlet di CHANGE
  1141.             porteApplicativeHelper.controlloAccessiAutorizzazione(dati, TipoOperazione.CHANGE, servletChiamante,pa,protocollo,
  1142.                     autenticazione, autenticazioneCustom,
  1143.                     autorizzazione, autorizzazioneCustom,
  1144.                     autorizzazioneAutenticati, urlAutorizzazioneAutenticati, sizeSoggettiPA, null, null,
  1145.                     autorizzazioneRuoli,  urlAutorizzazioneRuoli, numRuoli, null,
  1146.                     autorizzazioneRuoliTipologia, ruoloMatch,
  1147.                     confPers, isSupportatoAutenticazione, contaListe, false, false
  1148.                     ,autorizzazioneScope,urlAutorizzazioneScope,numScope,null,autorizzazioneScopeMatch,
  1149.                     gestioneToken, gestioneTokenPolicy, autorizzazioneToken, autorizzazioneTokenOptions,allegatoXacmlPolicy,
  1150.                     urlAutorizzazioneErogazioneApplicativiAutenticati, numErogazioneApplicativiAutenticati,
  1151.                     urlAutorizzazioneCustomProperties, numAutorizzazioneCustomPropertiesList,
  1152.                     identificazioneAttributiStato, attributeAuthorityLabels, attributeAuthorityValues, attributeAuthoritySelezionate, attributeAuthorityAttributi,
  1153.                     autorizzazioneAutenticatiToken, urlAutorizzazioneAutenticatiToken, numAutenticatiToken,
  1154.                     autorizzazioneRuoliToken,  urlAutorizzazioneRuoliToken, numRuoliToken, autorizzazioneRuoliTipologiaToken, autorizzazioneRuoliMatchToken);

  1155.             porteApplicativeHelper.controlloAccessiAutorizzazioneContenuti(dati, TipoOperazione.OTHER, false, pa,protocollo,
  1156.                     autorizzazioneContenutiStato, autorizzazioneContenuti, autorizzazioneContenutiProperties, serviceBinding,
  1157.                     oldAutorizzazioneContenutiCustom, urlAutorizzazioneContenutiCustomPropertiesList, numAutorizzazioneContenutiCustomPropertiesList,
  1158.                     confPers);

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

  1160.             pd.setDati(dati);

  1161.             pd.setMessage(CostantiControlStation.LABEL_AGGIORNAMENTO_EFFETTUATO_CON_SUCCESSO, Costanti.MESSAGE_TYPE_INFO);

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

  1163.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  1164.             // Forward control to the specified success URI
  1165.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI,
  1166.                     ForwardParams.OTHER(""));

  1167.         } catch (Exception e) {
  1168.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  1169.                     PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_CONTROLLO_ACCESSI ,
  1170.                     ForwardParams.OTHER(""));
  1171.         }
  1172.     }

  1173. }