use of org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig in project carbon-identity-framework by wso2.
the class FileBasedConfigurationBuilder method processSequenceElement.
/**
* Create SequenceDOs for each sequence entry
*
* @param sequenceElem
* @return
*/
private SequenceConfig processSequenceElement(OMElement sequenceElem) {
SequenceConfig sequenceConfig = new SequenceConfig();
String applicationId = "default";
OMAttribute appIdAttr = sequenceElem.getAttribute(new QName(FrameworkConstants.Config.ATTR_APPLICATION_ID));
if (appIdAttr != null) {
applicationId = appIdAttr.getAttributeValue();
}
sequenceConfig.setApplicationId(applicationId);
OMAttribute forceAuthnAttr = sequenceElem.getAttribute(new QName(FrameworkConstants.Config.ATTR_FORCE_AUTHENTICATE));
if (forceAuthnAttr != null) {
sequenceConfig.setForceAuthn(Boolean.valueOf(forceAuthnAttr.getAttributeValue()));
}
OMAttribute checkAuthnAttr = sequenceElem.getAttribute(new QName(FrameworkConstants.Config.ATTR_CHECK_AUTHENTICATE));
if (checkAuthnAttr != null) {
sequenceConfig.setCheckAuthn(Boolean.valueOf(checkAuthnAttr.getAttributeValue()));
}
// RequestPathAuthenticators
OMElement reqPathAuthenticatorsElem = sequenceElem.getFirstChildWithName(IdentityApplicationManagementUtil.getQNameWithIdentityApplicationNS(FrameworkConstants.Config.ELEM_REQ_PATH_AUTHENTICATOR));
if (reqPathAuthenticatorsElem != null) {
for (Iterator reqPathAuthenticatorElems = reqPathAuthenticatorsElem.getChildElements(); reqPathAuthenticatorElems.hasNext(); ) {
OMElement reqPathAuthenticatorElem = (OMElement) reqPathAuthenticatorElems.next();
String authenticatorName = reqPathAuthenticatorElem.getAttributeValue(IdentityApplicationManagementUtil.getQNameWithIdentityApplicationNS(FrameworkConstants.Config.ATTR_AUTHENTICATOR_NAME));
AuthenticatorConfig authenticatorConfig = authenticatorConfigMap.get(authenticatorName);
sequenceConfig.getReqPathAuthenticators().add(authenticatorConfig);
}
}
// for each step defined, create a StepDO instance
for (Iterator stepElements = sequenceElem.getChildrenWithLocalName(FrameworkConstants.Config.ELEM_STEP); stepElements.hasNext(); ) {
StepConfig stepConfig = processStepElement((OMElement) stepElements.next());
if (stepConfig != null) {
sequenceConfig.getStepMap().put(stepConfig.getOrder(), stepConfig);
}
}
return sequenceConfig;
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig in project carbon-identity-framework by wso2.
the class UIBasedConfigurationLoader method getSequenceConfig.
@Override
public SequenceConfig getSequenceConfig(AuthenticationContext context, Map<String, String[]> parameterMap, ServiceProvider serviceProvider) throws FrameworkException {
String tenantDomain = context.getTenantDomain();
AuthenticationStep[] authenticationSteps = null;
LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = serviceProvider.getLocalAndOutBoundAuthenticationConfig();
if (localAndOutboundAuthenticationConfig.getAuthenticationSteps() != null && localAndOutboundAuthenticationConfig.getAuthenticationSteps().length > 0) {
// Use the default steps when there are no chains configured.
authenticationSteps = localAndOutboundAuthenticationConfig.getAuthenticationSteps();
}
SequenceConfig sequenceConfig = getSequence(serviceProvider, tenantDomain, authenticationSteps);
// Use script based evaluation if script is present.
if (isAuthenticationScriptBasedSequence(localAndOutboundAuthenticationConfig)) {
// Clear the sequenceConfig step map, so that it will be re-populated by Dynamic execution
Map<Integer, StepConfig> originalStepConfigMap = new HashMap<>(sequenceConfig.getStepMap());
Map<Integer, StepConfig> stepConfigMapCopy = new HashMap<>();
originalStepConfigMap.forEach((k, v) -> stepConfigMapCopy.put(k, new StepConfig(v)));
sequenceConfig.getStepMap().clear();
JsGraphBuilderFactory jsGraphBuilderFactory = FrameworkServiceDataHolder.getInstance().getJsGraphBuilderFactory();
JsGraphBuilder jsGraphBuilder = jsGraphBuilderFactory.createBuilder(context, stepConfigMapCopy);
context.setServiceProviderName(serviceProvider.getApplicationName());
AuthenticationGraph graph = jsGraphBuilder.createWith(localAndOutboundAuthenticationConfig.getAuthenticationScriptConfig().getContent()).build();
graph.setEnabled(localAndOutboundAuthenticationConfig.getAuthenticationScriptConfig().isEnabled());
sequenceConfig.setAuthenticationGraph(graph);
graph.setStepMap(originalStepConfigMap);
}
return sequenceConfig;
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig in project carbon-identity-framework by wso2.
the class UIBasedConfigurationLoader method loadRequestPathAuthenticators.
protected void loadRequestPathAuthenticators(SequenceConfig sequenceConfig, ServiceProvider serviceProvider) {
if (serviceProvider.getRequestPathAuthenticatorConfigs() != null && serviceProvider.getRequestPathAuthenticatorConfigs().length > 0) {
List<AuthenticatorConfig> requestPathAuthenticators = new ArrayList<AuthenticatorConfig>();
RequestPathAuthenticatorConfig[] reqAuths = serviceProvider.getRequestPathAuthenticatorConfigs();
// for each request path authenticator
for (RequestPathAuthenticatorConfig reqAuth : reqAuths) {
AuthenticatorConfig authConfig = new AuthenticatorConfig();
String authenticatorName = reqAuth.getName();
authConfig.setName(authenticatorName);
authConfig.setEnabled(true);
// iterate through each system authentication config
for (ApplicationAuthenticator appAuthenticator : FrameworkServiceComponent.getAuthenticators()) {
if (authenticatorName.equalsIgnoreCase(appAuthenticator.getName())) {
authConfig.setApplicationAuthenticator(appAuthenticator);
break;
}
}
requestPathAuthenticators.add(authConfig);
}
sequenceConfig.setReqPathAuthenticators(requestPathAuthenticators);
}
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig in project carbon-identity-framework by wso2.
the class FrameworkUtils method isStepBasedSequenceHandlerExecuted.
/**
* @deprecated This method is a temporary solution and might get changed in the future.
* It is recommended not use this method.
*
* @param context AuthenticationContext.
* @return true if the handlers need to be executed, otherwise false.
*/
@Deprecated
public static boolean isStepBasedSequenceHandlerExecuted(AuthenticationContext context) {
boolean isNeeded = true;
SequenceConfig sequenceConfig = context.getSequenceConfig();
AuthenticatedUser authenticatedUser = sequenceConfig.getAuthenticatedUser();
Object isDefaultStepBasedSequenceHandlerTriggered = context.getProperty(FrameworkConstants.STEP_BASED_SEQUENCE_HANDLER_TRIGGERED);
// If authenticated user is null or if step based sequence handler is not trigged, exit the flow.
if (authenticatedUser == null || isDefaultStepBasedSequenceHandlerTriggered == null || !(boolean) isDefaultStepBasedSequenceHandlerTriggered) {
isNeeded = false;
}
return isNeeded;
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig in project carbon-identity-framework by wso2.
the class DefaultAuthenticationRequestHandlerTest method addSequence.
private void addSequence(AuthenticationContext context, boolean isCompleted) {
SequenceConfig sequenceConfig = new SequenceConfig();
sequenceConfig.setCompleted(isCompleted);
context.setSequenceConfig(sequenceConfig);
}
Aggregations