MessageSecurityReceiver.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.security.message.engine;

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

  23. import org.openspcoop2.message.OpenSPCoop2Message;
  24. import org.openspcoop2.protocol.sdk.Busta;
  25. import org.openspcoop2.protocol.sdk.constants.CodiceErroreCooperazione;
  26. import org.openspcoop2.security.message.MessageSecurityContext;
  27. import org.openspcoop2.security.message.SubErrorCodeSecurity;


  28. /**
  29.  * Classe per la gestione della Sicurezza (role:Receiver)
  30.  *
  31.  * @author Spadafora Marcello (Ma.Spadafora@finsiel.it)
  32.  * @author Montebove Luciano (L.Montebove@finsiel.it)
  33.  * @author $Author$
  34.  * @version $Rev$, $Date$
  35.  *
  36.  */
  37. public abstract class MessageSecurityReceiver{

  38.     /** Eventuale messaggio di errore avvenuto durante il processo di validazione */
  39.     protected String msgErrore;
  40.     /** Eventuale codice di errore avvenuto durante il processo di validazione  */
  41.     protected CodiceErroreCooperazione codiceErrore;
  42.     /** Eventuale subCodici di errore */
  43.     protected List<SubErrorCodeSecurity> listaSubCodiceErrore = new ArrayList<SubErrorCodeSecurity>();
  44.     /** Contiene il message Context */
  45.     protected MessageSecurityContext messageSecurityContext;
  46.     /** Certificato del client */
  47.     protected String subject;

  48.     protected MessageSecurityReceiver(MessageSecurityContext messageSecurityContext) {
  49.         this.messageSecurityContext = messageSecurityContext;
  50.     }

  51.     protected abstract boolean process(OpenSPCoop2Message message,Busta busta,org.openspcoop2.utils.Map<Object> ctx);
  52.        
  53.    
  54.     /**
  55.      * In caso di avvenuto errore durante il processo di validazione,
  56.      * questo metodo ritorna il motivo dell'errore.
  57.      *
  58.      * @return motivo dell'errore (se avvenuto).
  59.      *
  60.      */
  61.     protected String getMsgErrore(){
  62.         return this.msgErrore;
  63.     }
  64.    
  65.     public List<SubErrorCodeSecurity> getListaSubCodiceErrore() {
  66.         return this.listaSubCodiceErrore;
  67.     }

  68.     /**
  69.      * In caso di avvenuto errore, questo metodo ritorna il codice dell'errore.
  70.      *
  71.      * @return codice dell'errore (se avvenuto).
  72.      *
  73.      */
  74.     protected CodiceErroreCooperazione getCodiceErrore(){
  75.         return this.codiceErrore;
  76.     }
  77.    
  78.     protected String getActor() {
  79.         return this.messageSecurityContext.getActor();
  80.     }
  81.    
  82.     protected String getSubject() {
  83.         return this.subject;
  84.     }

  85.     public MessageSecurityContext getMessageSecurityContext() {
  86.         return this.messageSecurityContext;
  87.     }

  88. }