SignatureSenderProvider.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.  * SignatureSenderProvider
  31.  *
  32.  * @author Poli Andrea (poli@link.it)
  33.  * @author $Author$
  34.  * @version $Rev$, $Date$
  35.  */
  36. public class SignatureSenderProvider extends KeyStoreSecurityProvider {

  37.     public SignatureSenderProvider() {
  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, "Signature - KeyStore - File");
  54.             }
  55.         }
  56.        
  57.         String file = defaultP.getProperty("joseX509Url");
  58.         if(file!=null && StringUtils.isNotEmpty(file)) {
  59.             InputValidationUtils.validateTextAreaInput(file, "X.509 Certificate - URL");
  60.         }
  61.        
  62.         file = defaultP.getProperty("joseJWKSetUrl");
  63.         if(file!=null && StringUtils.isNotEmpty(file)) {
  64.             InputValidationUtils.validateTextAreaInput(file, "Public Key - URL");
  65.         }
  66.        
  67.         file = defaultP.getProperty("joseCriticalHeaders");
  68.         if(file!=null && StringUtils.isNotEmpty(file)) {
  69.             InputValidationUtils.validateTextAreaInput(file, "Content Type (cty) - Critical Headers (crit)");
  70.         }
  71.        
  72.        
  73.     }
  74.    
  75. }