Search in sources :

Example 6 with AuthenticationGraph

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);
}
Also used : FrameworkException(org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException) AuthGraphNode(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthGraphNode)

Example 7 with AuthenticationGraph

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());
}
Also used : AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) HashMap(java.util.HashMap) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) StepConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.StepConfig) Test(org.testng.annotations.Test) AbstractFrameworkTest(org.wso2.carbon.identity.application.authentication.framework.AbstractFrameworkTest) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 8 with AuthenticationGraph

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);
}
Also used : HashMap(java.util.HashMap) StepConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.StepConfig) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig) AuthenticationGraph(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph) AuthenticatedIdPData(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedIdPData)

Example 9 with AuthenticationGraph

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;
}
Also used : SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig) AuthenticationGraph(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph)

Example 10 with AuthenticationGraph

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);
        }
    }
}
Also used : FrameworkException(org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig) AuthenticationGraph(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph) AuthGraphNode(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthGraphNode)

Aggregations

HashMap (java.util.HashMap)7 StepConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.StepConfig)6 AuthenticationGraph (org.wso2.carbon.identity.application.authentication.framework.config.model.graph.AuthenticationGraph)5 BeforeTest (org.testng.annotations.BeforeTest)4 Test (org.testng.annotations.Test)4 SequenceConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)4 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)4 AfterTest (org.testng.annotations.AfterTest)3 AbstractFrameworkTest (org.wso2.carbon.identity.application.authentication.framework.AbstractFrameworkTest)3 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)3 Serializable (java.io.Serializable)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 UUID (java.util.UUID)1 BiConsumer (java.util.function.BiConsumer)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1