IMessageSecurityReceiver.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;

  21. import java.security.PublicKey;
  22. import java.security.cert.X509Certificate;
  23. import java.util.List;
  24. import java.util.Map;

  25. import javax.xml.namespace.QName;

  26. import org.openspcoop2.message.OpenSPCoop2Message;
  27. import org.openspcoop2.message.OpenSPCoop2RestMessage;
  28. import org.openspcoop2.message.OpenSPCoop2SoapMessage;
  29. import org.openspcoop2.message.soap.reference.Reference;
  30. import org.openspcoop2.protocol.sdk.Busta;
  31. import org.openspcoop2.security.SecurityException;

  32. /**
  33.  * IMessageSecurityReceiver
  34.  *
  35.  * @author Andrea Poli (apoli@link.it)
  36.  * @author $Author$
  37.  * @version $Rev$, $Date$
  38.  */
  39. public interface IMessageSecurityReceiver {
  40.    
  41.     public default boolean checkExistsWSSecurityHeader() {
  42.         return true;
  43.     }
  44.    
  45.     /**
  46.      * Applica la sicurezza al messaggio
  47.      *
  48.      * @param messageSecurityContext MessageSecurityContext
  49.      * @param message Messaggio
  50.      * @param busta Busta
  51.      * @throws SecurityException
  52.      */
  53.     public void process(MessageSecurityContext messageSecurityContext,OpenSPCoop2Message message,Busta busta,org.openspcoop2.utils.Map<Object> ctx) throws SecurityException;
  54.    
  55.     /**
  56.      * Localizza gli elementi "toccati" dalla sicurezza
  57.      *
  58.      * @param messageSecurityContext MessageSecurityContext
  59.      * @param message Messaggio
  60.      * @return reference degli elementi
  61.      * @throws SecurityException
  62.      */
  63.     public List<Reference> getDirtyElements(MessageSecurityContext messageSecurityContext,OpenSPCoop2SoapMessage message) throws SecurityException;
  64.    
  65.     /**
  66.      * Verifica cifratura/firma elementi richiesti dalla configurazione, ritornando una lista di reference per gli elementi che dovrebbero risultare cifrati completamente (Encoding Element)
  67.      *
  68.      * @param messageSecurityContext MessageSecurityContext
  69.      * @param elementsToClean reference (localizzati con il metodo 'getDirtyElements')
  70.      * @param message Messaggio
  71.      * @param codiciErrore Lista di errori da valorizzare se durante il controllo si rileva una inconsistenza
  72.      * @return lista di reference per gli elementi che dovrebbero risultare cifrati completamente (Encoding Element)
  73.      * @throws SecurityException
  74.      */
  75.     public Map<QName, QName> checkEncryptSignatureParts(MessageSecurityContext messageSecurityContext,List<Reference> elementsToClean, OpenSPCoop2SoapMessage message,
  76.             List<SubErrorCodeSecurity> codiciErrore) throws SecurityException;
  77.        
  78.     /**
  79.      * Verifica che gli elementi cifrati come element (localizzati con il metodo 'checkEncryptSignatureParts'), siano presenti dopo la decifratura
  80.      *
  81.      * @param notResolved Reference non ancora risolte
  82.      * @param message Messaggio
  83.      * @param erroriRilevati Lista di errori da valorizzare se durante il controllo si rileva una inconsistenza
  84.      * @throws SecurityException
  85.      */
  86.     public void checkEncryptionPartElements(Map<QName, QName> notResolved, OpenSPCoop2SoapMessage message, List<SubErrorCodeSecurity> erroriRilevati) throws SecurityException;
  87.            
  88.    
  89.     public void cleanDirtyElements(MessageSecurityContext messageSecurityContext,OpenSPCoop2SoapMessage message, List<Reference> elementsToClean,
  90.             boolean detachHeaderWSSecurity, boolean removeAllIdRef) throws SecurityException;
  91.    
  92.     public void detachSecurity(MessageSecurityContext messageSecurityContext,OpenSPCoop2RestMessage<?> message) throws SecurityException;
  93.    
  94.     public String getCertificate() throws SecurityException;
  95.     public X509Certificate getX509Certificate() throws SecurityException;
  96.     public PublicKey getPublicKey() throws SecurityException;
  97.     public String getCertificateId() throws SecurityException;
  98.    
  99.    
  100. }