use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method handleInitialize.
private boolean handleInitialize(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context, SequenceConfig sequenceConfig, AuthenticationGraph graph) throws FrameworkException {
AuthGraphNode startNode = graph.getStartNode();
if (startNode == null) {
throw new FrameworkException("Start node is not set for authentication graph:" + graph.getName());
}
context.setCurrentStep(0);
return handleNode(request, response, context, sequenceConfig, startNode);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph in project carbon-identity-framework by wso2.
the class JsGraphBuilderTest method testCreateDirectJavaInvalidStepId.
@Test
public void testCreateDirectJavaInvalidStepId() throws Exception {
ServiceProvider sp1 = getTestServiceProvider("js-sp-1.xml");
AuthenticationContext context = getAuthenticationContext(sp1);
Map<Integer, StepConfig> stepConfigMap = new HashMap<>();
stepConfigMap.put(1, new StepConfig());
JsGraphBuilder jsGraphBuilder = jsGraphBuilderFactory.createBuilder(context, stepConfigMap);
jsGraphBuilder.executeStep(2);
AuthenticationGraph graph = jsGraphBuilder.build();
assertNull(graph.getStartNode());
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph in project carbon-identity-framework by wso2.
the class JsAuthenticationContextTest method setupAuthContextWithStepData.
private void setupAuthContextWithStepData(AuthenticationContext context, AuthenticatedUser authenticatedUser) {
SequenceConfig sequenceConfig = new SequenceConfig();
Map<Integer, StepConfig> stepConfigMap = new HashMap<>();
StepConfig stepConfig = new StepConfig();
stepConfig.setOrder(1);
stepConfig.setAuthenticatedIdP(TEST_IDP);
stepConfigMap.put(1, stepConfig);
sequenceConfig.setStepMap(stepConfigMap);
AuthenticationGraph authenticationGraph = new AuthenticationGraph();
authenticationGraph.setStepMap(stepConfigMap);
sequenceConfig.setAuthenticationGraph(authenticationGraph);
context.setSequenceConfig(sequenceConfig);
Map<String, AuthenticatedIdPData> idPDataMap = new HashMap<>();
AuthenticatedIdPData idPData = new AuthenticatedIdPData();
idPData.setUser(authenticatedUser);
idPData.setIdpName(TEST_IDP);
idPDataMap.put(TEST_IDP, idPData);
context.setCurrentAuthenticatedIdPs(idPDataMap);
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph in project carbon-identity-framework by wso2.
the class AbstractApplicationAuthenticator method retryAuthenticationEnabled.
protected boolean retryAuthenticationEnabled(AuthenticationContext context) {
SequenceConfig sequenceConfig = context.getSequenceConfig();
AuthenticationGraph graph = sequenceConfig.getAuthenticationGraph();
boolean isRetryAuthenticatorEnabled = false;
Map<String, String> authParams = context.getAuthenticatorParams(context.getCurrentAuthenticator());
if (MapUtils.isNotEmpty(authParams)) {
isRetryAuthenticatorEnabled = Boolean.parseBoolean(authParams.get(ENABLE_RETRY_FROM_AUTHENTICATOR));
}
if (graph == null || !graph.isEnabled() || isRetryAuthenticatorEnabled) {
return retryAuthenticationEnabled();
}
return false;
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandler method handle.
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context) throws FrameworkException {
if (log.isDebugEnabled()) {
log.debug("Executing the Step Based Authentication...");
}
if (isBackToFirstStep(context)) {
modifyCurrentNodeAsFirstStep(context);
}
SequenceConfig sequenceConfig = context.getSequenceConfig();
String authenticationType = sequenceConfig.getApplicationConfig().getServiceProvider().getLocalAndOutBoundAuthenticationConfig().getAuthenticationType();
AuthenticationGraph graph = sequenceConfig.getAuthenticationGraph();
if (graph == null || !graph.isEnabled() || (!ApplicationConstants.AUTH_TYPE_FLOW.equals(authenticationType) && !ApplicationConstants.AUTH_TYPE_DEFAULT.equals(authenticationType))) {
// Handle pre-configured step array
if (log.isDebugEnabled()) {
log.debug("Authentication Graph not defined for the application. " + "Performing Step based authentication. Service Provider :" + sequenceConfig.getApplicationId());
}
DefaultStepBasedSequenceHandler.getInstance().handle(request, response, context);
return;
}
if (!graph.isBuildSuccessful()) {
throw new FrameworkException("Error while building graph from Javascript. Nested exception is: " + graph.getErrorReason());
}
boolean isInterrupted = false;
while (!isInterrupted && !context.getSequenceConfig().isCompleted()) {
AuthGraphNode currentNode = (AuthGraphNode) context.getProperty(FrameworkConstants.JSAttributes.PROP_CURRENT_NODE);
if (currentNode == null) {
isInterrupted = handleInitialize(request, response, context, sequenceConfig, graph);
} else {
isInterrupted = handleNode(request, response, context, sequenceConfig, currentNode);
}
}
}
Aggregations