SignatureReceiverProvider.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.jose;

  21. import java.util.Map;
  22. import java.util.Properties;

  23. import org.apache.commons.lang.StringUtils;
  24. import org.openspcoop2.core.mvc.properties.provider.InputValidationUtils;
  25. import org.openspcoop2.core.mvc.properties.provider.ProviderException;
  26. import org.openspcoop2.core.mvc.properties.provider.ProviderValidationException;
  27. import org.openspcoop2.core.mvc.properties.utils.MultiPropertiesUtilities;
  28. import org.openspcoop2.security.message.constants.SecurityConstants;

  29. /**    
  30.  * SignatureReceiverProvider
  31.  *
  32.  * @author Poli Andrea (poli@link.it)
  33.  * @author $Author$
  34.  * @version $Rev$, $Date$
  35.  */
  36. public class SignatureReceiverProvider extends TrustStoreSecurityProvider {

  37.     public SignatureReceiverProvider() {
  38.         super();
  39.     }

  40.    
  41.     @Override
  42.     public void validate(Map<String, Properties> mapProperties) throws ProviderException, ProviderValidationException {
  43.         super.validate(mapProperties);
  44.        
  45.         Properties defaultP = MultiPropertiesUtilities.getDefaultProperties(mapProperties);
  46.        
  47.         Properties p = mapProperties.get("signaturePropRefId");
  48.         if(p!=null && p.size()>0 &&
  49.             !p.containsKey(SecurityConstants.JOSE_KEYSTORE) && !p.containsKey(SecurityConstants.JOSE_KEYSTORE_JWKSET)) {
  50.             // altrimenti รจ stato fatto inject del keystore
  51.             String file = p.getProperty(SecurityConstants.JOSE_KEYSTORE_FILE);
  52.             if(file!=null && StringUtils.isNotEmpty(file)) {
  53.                 InputValidationUtils.validateTextAreaInput(file, "Verifier Signature - TrustStore - File");
  54.             }
  55.         }
  56.        
  57.         String file = defaultP.getProperty(SecurityConstants.JOSE_TRUSTSTORE_SSL_FILE);
  58.         if(file!=null && StringUtils.isNotEmpty(file)) {
  59.             InputValidationUtils.validateTextAreaInput(file, "Configurazione HTTPS (jku/x5u) - TrustStore - File");
  60.         }
  61.        
  62.         file = defaultP.getProperty(SecurityConstants.JOSE_TRUSTSTORE_SSL_CRL);
  63.         if(file!=null && StringUtils.isNotEmpty(file)) {
  64.             InputValidationUtils.validateTextAreaInput(file, "Configurazione HTTPS (jku/x5u) - TrustStore - CRL File(s)");
  65.         }
  66.        
  67.         file = defaultP.getProperty("joseUseHeaders.truststore.file");
  68.         if(file!=null && StringUtils.isNotEmpty(file)) {
  69.             InputValidationUtils.validateTextAreaInput(file, "Validazione Certificati X.509 (x5c/x5u) - TrustStore - File");
  70.         }
  71.        
  72.         file = defaultP.getProperty("signatureCRL");
  73.         if(file!=null && StringUtils.isNotEmpty(file)) {
  74.             InputValidationUtils.validateTextAreaInput(file, "Validazione Certificati X.509 (x5c/x5u) - TrustStore - CRL File(s)");
  75.         }
  76.        
  77.        
  78.     }
  79.    
  80. }