ModIValidazioneSemanticaProfiloSicurezza.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.protocol.utils;

  21. import org.openspcoop2.core.constants.CostantiDB;
  22. import org.openspcoop2.protocol.sdk.Busta;
  23. import org.openspcoop2.protocol.sdk.ProtocolException;

  24. /**
  25.  * ModIValidazioneSemanticaProfiloSicurezza
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author Lorenzo Nardi (nardi@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. public class ModIValidazioneSemanticaProfiloSicurezza {

  33.     private Busta busta;
  34.    
  35.     private String securityMessageProfileNonFiltratoPDND;
  36.    
  37.     private boolean sicurezzaTokenOauth;
  38.     private String securityMessageProfileSorgenteTokenIdAuth;
  39.    
  40.     private boolean sicurezzaMessaggio;
  41.     private boolean sicurezzaMessaggioIDAR04 = false;
  42.     private String securityMessageProfile;
  43.    
  44.     private boolean sicurezzaAudit;
  45.     private String securityAuditPattern;
  46.    
  47.     public ModIValidazioneSemanticaProfiloSicurezza(Busta bustaParam, boolean isRichiesta) throws ProtocolException {
  48.        
  49.         this.busta = bustaParam;
  50.        
  51.         this.securityMessageProfileNonFiltratoPDND = this.busta.getProperty(CostantiDB.MODIPA_BUSTA_EXT_PROFILO_SICUREZZA_MESSAGGIO);
  52.         if(this.securityMessageProfileNonFiltratoPDND!=null) {
  53.             this.securityMessageProfileNonFiltratoPDND = ModIUtils.convertProfiloSicurezzaToConfigurationValue(this.securityMessageProfileNonFiltratoPDND);
  54.         }
  55.        
  56.         this.securityMessageProfileSorgenteTokenIdAuth = this.busta.getProperty(CostantiDB.MODIPA_BUSTA_EXT_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN);
  57.         if(this.securityMessageProfileSorgenteTokenIdAuth!=null) {
  58.             this.securityMessageProfileSorgenteTokenIdAuth = ModIUtils.convertProfiloSicurezzaSorgenteTokenToConfigurationValue(this.securityMessageProfileSorgenteTokenIdAuth);
  59.         }
  60.        
  61.         this.securityMessageProfile = this.securityMessageProfileNonFiltratoPDND;
  62.         if(this.securityMessageProfileSorgenteTokenIdAuth!=null &&
  63.             (  
  64.                 CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM01.equals(this.securityMessageProfileNonFiltratoPDND)
  65.                     ||
  66.                 CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM02.equals(this.securityMessageProfileNonFiltratoPDND)
  67.             )
  68.             &&
  69.             (  
  70.                 CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_PDND.equals(this.securityMessageProfileSorgenteTokenIdAuth)
  71.                     ||
  72.                 CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_OAUTH.equals(this.securityMessageProfileSorgenteTokenIdAuth)
  73.             )
  74.         ){
  75.             this.securityMessageProfile = null;
  76.         }
  77.                    
  78.         this.sicurezzaTokenOauth = CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_PDND.equals(this.securityMessageProfileSorgenteTokenIdAuth)
  79.                 ||
  80.             CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_SORGENTE_TOKEN_IDAUTH_VALUE_OAUTH.equals(this.securityMessageProfileSorgenteTokenIdAuth);
  81.        
  82.         this.sicurezzaMessaggio = this.securityMessageProfile!=null && !CostantiDB.MODIPA_VALUE_UNDEFINED.equals(this.securityMessageProfile);
  83.         this.sicurezzaMessaggioIDAR04 = false;
  84.         if(this.sicurezzaMessaggio) {
  85.             this.sicurezzaMessaggioIDAR04 = CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM0401.equals(this.securityMessageProfile)
  86.                                             ||
  87.                                         CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_VALUE_IDAM0402.equals(this.securityMessageProfile);
  88.         }
  89.        
  90.         this.securityAuditPattern = this.busta.getProperty(CostantiDB.MODIPA_BUSTA_EXT_PROFILO_SICUREZZA_MESSAGGIO_CORNICE_SICUREZZA_AUDIT_PATTERN);
  91.        
  92.         if(this.securityAuditPattern!=null) {
  93.             this.securityAuditPattern = ModIUtils.convertProfiloAuditToConfigurationValue(this.securityAuditPattern);
  94.         }
  95.        
  96.         this.sicurezzaAudit = isRichiesta &&
  97.                 this.securityAuditPattern!=null && !CostantiDB.MODIPA_PROFILO_SICUREZZA_MESSAGGIO_CORNICE_SICUREZZA_PATTERN_OLD.equals(this.securityAuditPattern);
  98.        
  99.     }

  100.     public Busta getBusta() {
  101.         return this.busta;
  102.     }
  103.    
  104.     public String getSecurityMessageProfileNonFiltratoPDND() {
  105.         return this.securityMessageProfileNonFiltratoPDND;
  106.     }
  107.    
  108.     public boolean isSicurezzaTokenOauth() {
  109.         return this.sicurezzaTokenOauth;
  110.     }
  111.     public String getSecurityMessageProfileSorgenteTokenIdAuth() {
  112.         return this.securityMessageProfileSorgenteTokenIdAuth;
  113.     }

  114.     public boolean isSicurezzaMessaggio() {
  115.         return this.sicurezzaMessaggio;
  116.     }
  117.     public boolean isSicurezzaMessaggioIDAR04() {
  118.         return this.sicurezzaMessaggioIDAR04;
  119.     }
  120.     public String getSecurityMessageProfile() {
  121.         return this.securityMessageProfile;
  122.     }

  123.     public boolean isSicurezzaAudit() {
  124.         return this.sicurezzaAudit;
  125.     }
  126.     public String getSecurityAuditPattern() {
  127.         return this.securityAuditPattern;
  128.     }
  129. }