package at.gv.egiz.eaaf.modules.auth.sl20; import java.util.Arrays; import java.util.List; import javax.annotation.PostConstruct; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import at.gv.egiz.eaaf.core.api.data.EAAFConstants; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.api.idp.ISPConfiguration; import at.gv.egiz.eaaf.core.api.idp.auth.modules.AuthModule; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.impl.idp.auth.AbstractAuthenticationManager; import at.gv.egiz.eaaf.modules.auth.sl20.utils.SL20Constants; /** * @author tlenz * */ public abstract class AbstractSL20AuthenticationModulImpl implements AuthModule { private static final Logger log = LoggerFactory.getLogger(AbstractSL20AuthenticationModulImpl.class); private int priority = 3; public static final List VDA_TYPE_IDS = Arrays.asList("1", "2", "3", "4"); @Autowired(required=true) protected IConfiguration authConfig; @Autowired(required=true) private AbstractAuthenticationManager authManager; @Override public int getPriority() { return priority; } /** * Sets the priority of this module. Default value is {@code 0}. * @param priority The priority. */ public void setPriority(int priority) { this.priority = priority; } @PostConstruct protected void initalSL20Authentication() { //parameter to whiteList authManager.addHeaderNameToWhiteList(SL20Constants.HTTP_HEADER_SL20_CLIENT_TYPE); authManager.addHeaderNameToWhiteList(SL20Constants.HTTP_HEADER_SL20_VDA_TYPE); } /* (non-Javadoc) * @see at.gv.egovernment.moa.id.auth.modules.AuthModule#selectProcess(at.gv.egovernment.moa.id.process.api.ExecutionContext) */ @Override public String selectProcess(ExecutionContext context) { final ISPConfiguration spConfig = (ISPConfiguration) context.get(EAAFConstants.PROCESSCONTEXT_SP_CONFIG); final String sl20ClientTypeHeader = (String) context.get(SL20Constants.HTTP_HEADER_SL20_CLIENT_TYPE.toLowerCase()); final String sl20VDATypeHeader = (String) context.get(SL20Constants.HTTP_HEADER_SL20_VDA_TYPE.toLowerCase()); if (spConfig != null && StringUtils.isNotEmpty(spConfig.getConfigurationValue(getConfigPropertyNameEnableModule())) && Boolean.valueOf(spConfig.getConfigurationValue(getConfigPropertyNameEnableModule()))) { log.debug("SL2.0 is enabled for " + spConfig.getUniqueIdentifier()); log.trace(SL20Constants.HTTP_HEADER_SL20_CLIENT_TYPE + ": " + sl20ClientTypeHeader); log.trace(SL20Constants.HTTP_HEADER_SL20_VDA_TYPE + ": " + sl20VDATypeHeader); return getProcessName(); } else { log.trace("SL2.0 is NOT enabled for " + spConfig.getUniqueIdentifier()); return null; } } /** * Get the SP specific configuration-key that holds the enabled key for this authentication module * * @return configuration key for SP configuration */ public abstract String getConfigPropertyNameEnableModule(); /** * Get the name of this specific SL2.0 process * * @return */ public abstract String getProcessName(); /* (non-Javadoc) * @see at.gv.egovernment.moa.id.auth.modules.AuthModule#getProcessDefinitions() */ @Override public abstract String[] getProcessDefinitions(); }