/******************************************************************************* *******************************************************************************/ package at.gv.egiz.eidas.specific.connector.config; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.gv.egiz.eaaf.core.api.data.EAAFConstants; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.exceptions.EAAFException; import at.gv.egiz.eaaf.core.impl.idp.conf.SPConfigurationImpl; import at.gv.egiz.eidas.specific.connector.MSeIDASNodeConstants; public class ServiceProviderConfiguration extends SPConfigurationImpl { private static final long serialVersionUID = 1L; private static final Logger log = LoggerFactory.getLogger(ServiceProviderConfiguration.class); private String minimumLoA = EAAFConstants.EIDAS_QAA_HIGH; private String bPKTargetIdentifier; public ServiceProviderConfiguration(Map spConfig, IConfiguration authConfig) { super(spConfig, authConfig); } @Override public boolean hasBaseIdInternalProcessingRestriction() { return false; } @Override public boolean hasBaseIdTransferRestriction() { return isConfigurationValue( MSeIDASNodeConstants.PROP_CONFIG_SP_POLICY_BASEIDTRANSFER_RESTRICTION, true); } @Override public String getMinimumLevelOfAssurence() { return minimumLoA; } @Override public String getAreaSpecificTargetIdentifier() { return bPKTargetIdentifier; } @Override public String getFriendlyName() { return getConfigurationValue( MSeIDASNodeConstants.PROP_CONFIG_SP_FRIENDLYNAME, "NO FRIENDLYNAME SET"); } /** * Set the minimum level of eIDAS authentication for this SP *
* Default: http://eidas.europa.eu/LoA/high or * * @param minimumLoA eIDAS LoA URI */ public void setMinimumLoA(String minimumLoA) { this.minimumLoA = minimumLoA; } /** * Set the bPK Target for this service provider * * @param bPKTargetIdentifier * @throws EAAFException If the bPKTargetIdentifier is NOT ALLOWED for this service provider */ public void setbPKTargetIdentifier(String bPKTargetIdentifier) throws EAAFException { String allowedTargetIdentifierRegExPattern = getConfigurationValue( MSeIDASNodeConstants.PROP_CONFIG_SP_POLICY_ALLOWED_TARGETS, MSeIDASNodeConstants.POLICY_DEFAULT_ALLOWED_TARGETS); log.trace("Use bPK-target regex pattern: " + allowedTargetIdentifierRegExPattern); Pattern p = Pattern.compile(allowedTargetIdentifierRegExPattern); Matcher m = p.matcher(bPKTargetIdentifier); if (m.matches()) { log.debug("Requested bPK-target: " + bPKTargetIdentifier + " matches regex pattern"); this.bPKTargetIdentifier = bPKTargetIdentifier; } else { log.warn("Requested bPK-target: " + bPKTargetIdentifier + " does NOT match regex pattern."); throw new EAAFException("TODO", new Object[] {bPKTargetIdentifier}, "Requested bPK-target: " + bPKTargetIdentifier + " does NOT match regex pattern."); } } }