Search in sources :

Example 1 with JsFunctionRegistryImpl

use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.

the class FrameworkServiceComponent method activate.

@SuppressWarnings("unchecked")
@Activate
protected void activate(ComponentContext ctxt) {
    FrameworkServiceDataHolder dataHolder = FrameworkServiceDataHolder.getInstance();
    dataHolder.setJsFunctionRegistry(new JsFunctionRegistryImpl());
    BundleContext bundleContext = ctxt.getBundleContext();
    bundleContext.registerService(JsFunctionRegistry.class, dataHolder.getJsFunctionRegistry(), null);
    bundleContext.registerService(UserSessionManagementService.class.getName(), new UserSessionManagementServiceImpl(), null);
    bundleContext.registerService(HttpIdentityRequestFactory.class.getName(), new SessionExtenderRequestFactory(), null);
    bundleContext.registerService(HttpIdentityResponseFactory.class.getName(), new SessionExtenderResponseFactory(), null);
    bundleContext.registerService(IdentityProcessor.class.getName(), new SessionExtenderProcessor(), null);
    ServerSessionManagementService serverSessionManagementService = new ServerSessionManagementServiceImpl();
    bundleContext.registerService(ServerSessionManagementService.class.getName(), serverSessionManagementService, null);
    dataHolder.setServerSessionManagementService(serverSessionManagementService);
    setAdaptiveAuthExecutionSupervisor();
    boolean tenantDropdownEnabled = ConfigurationFacade.getInstance().getTenantDropdownEnabled();
    if (tenantDropdownEnabled) {
        // Register the tenant management listener for tracking changes to tenants
        bundleContext.registerService(TenantMgtListener.class.getName(), new AuthenticationEndpointTenantActivityListener(), null);
        if (log.isDebugEnabled()) {
            log.debug("AuthenticationEndpointTenantActivityListener is registered. Tenant Domains Dropdown is " + "enabled.");
        }
    }
    AuthenticationMethodNameTranslatorImpl authenticationMethodNameTranslator = new AuthenticationMethodNameTranslatorImpl();
    authenticationMethodNameTranslator.initializeConfigsWithServerConfig();
    bundleContext.registerService(AuthenticationMethodNameTranslator.class, authenticationMethodNameTranslator, null);
    dataHolder.setAuthenticationMethodNameTranslator(authenticationMethodNameTranslator);
    // Register Common servlet
    Servlet commonAuthServlet = new ContextPathServletAdaptor(new CommonAuthenticationServlet(), COMMON_SERVLET_URL);
    Servlet identityServlet = new ContextPathServletAdaptor(new IdentityServlet(), IDENTITY_SERVLET_URL);
    Servlet loginContextServlet = new ContextPathServletAdaptor(new LoginContextServlet(), LOGIN_CONTEXT_SERVLET_URL);
    try {
        httpService.registerServlet(COMMON_SERVLET_URL, commonAuthServlet, null, null);
        httpService.registerServlet(IDENTITY_SERVLET_URL, identityServlet, null, null);
        httpService.registerServlet(LOGIN_CONTEXT_SERVLET_URL, loginContextServlet, null, null);
    } catch (Exception e) {
        String errMsg = "Error when registering servlets via the HttpService.";
        log.error(errMsg, e);
        throw new RuntimeException(errMsg, e);
    }
    if (promptOnLongWait()) {
        Servlet longWaitStatusServlet = new ContextPathServletAdaptor(new LongWaitStatusServlet(), LONGWAITSTATUS_SERVLET_URL);
        try {
            httpService.registerServlet(LONGWAITSTATUS_SERVLET_URL, longWaitStatusServlet, null, null);
        } catch (Exception e) {
            String errMsg = "Error when registering longwaitstatus servlet via the HttpService.";
            log.error(errMsg, e);
            throw new RuntimeException(errMsg, e);
        }
    }
    dataHolder.setBundleContext(bundleContext);
    dataHolder.getHttpIdentityRequestFactories().add(new HttpIdentityRequestFactory());
    dataHolder.getHttpIdentityResponseFactories().add(new FrameworkLoginResponseFactory());
    dataHolder.getHttpIdentityResponseFactories().add(new FrameworkLogoutResponseFactory());
    JsGraphBuilderFactory jsGraphBuilderFactory = new JsGraphBuilderFactory();
    jsGraphBuilderFactory.init();
    UIBasedConfigurationLoader uiBasedConfigurationLoader = new UIBasedConfigurationLoader();
    dataHolder.setSequenceLoader(uiBasedConfigurationLoader);
    dataHolder.setJsGraphBuilderFactory(jsGraphBuilderFactory);
    PostAuthenticationMgtService postAuthenticationMgtService = new PostAuthenticationMgtService();
    bundleContext.registerService(PostAuthenticationMgtService.class.getName(), postAuthenticationMgtService, null);
    dataHolder.setPostAuthenticationMgtService(postAuthenticationMgtService);
    // Registering missing mandatory claim handler as a post authn handler
    PostAuthenticationHandler postAuthnMissingClaimHandler = new PostAuthnMissingClaimHandler();
    bundleContext.registerService(PostAuthenticationHandler.class.getName(), postAuthnMissingClaimHandler, null);
    SSOConsentService ssoConsentService = new SSOConsentServiceImpl();
    bundleContext.registerService(SSOConsentService.class.getName(), ssoConsentService, null);
    dataHolder.setSSOConsentService(ssoConsentService);
    bundleContext.registerService(PostAuthenticationHandler.class.getName(), consentMgtPostAuthnHandler, null);
    JITProvisioningIdentityProviderMgtListener jitProvisioningIDPMgtListener = new JITProvisioningIdentityProviderMgtListener();
    bundleContext.registerService(IdentityProviderMgtListener.class.getName(), jitProvisioningIDPMgtListener, null);
    bundleContext.registerService(ClaimFilter.class.getName(), new DefaultClaimFilter(), null);
    // this is done to load SessionDataStore class and start the cleanup tasks.
    SessionDataStore.getInstance();
    AsyncSequenceExecutor asyncSequenceExecutor = new AsyncSequenceExecutor();
    asyncSequenceExecutor.init();
    dataHolder.setAsyncSequenceExecutor(asyncSequenceExecutor);
    LongWaitStatusDAOImpl daoImpl = new LongWaitStatusDAOImpl();
    CacheBackedLongWaitStatusDAO cacheBackedDao = new CacheBackedLongWaitStatusDAO(daoImpl);
    String connectionTimeoutString = IdentityUtil.getProperty("AdaptiveAuth.HTTPConnectionTimeout");
    int connectionTimeout = 5000;
    if (connectionTimeoutString != null) {
        try {
            connectionTimeout = Integer.parseInt(connectionTimeoutString);
        } catch (NumberFormatException e) {
            log.error("Error while parsing connection timeout : " + connectionTimeoutString, e);
        }
    }
    LongWaitStatusStoreService longWaitStatusStoreService = new LongWaitStatusStoreService(cacheBackedDao, connectionTimeout);
    dataHolder.setLongWaitStatusStoreService(longWaitStatusStoreService);
    // Registering JIT, association and domain handler as post authentication handler
    PostAuthenticationHandler postJITProvisioningHandler = JITProvisioningPostAuthenticationHandler.getInstance();
    bundleContext.registerService(PostAuthenticationHandler.class.getName(), postJITProvisioningHandler, null);
    PostAuthenticationHandler postAuthAssociationHandler = PostAuthAssociationHandler.getInstance();
    bundleContext.registerService(PostAuthenticationHandler.class.getName(), postAuthAssociationHandler, null);
    PostAuthenticationHandler postAuthenticatedUserDomainHandler = PostAuthenticatedSubjectIdentifierHandler.getInstance();
    bundleContext.registerService(PostAuthenticationHandler.class.getName(), postAuthenticatedUserDomainHandler, null);
    if (log.isDebugEnabled()) {
        log.debug("Application Authentication Framework bundle is activated");
    }
    /**
     * Load and reade the require.js file in resources.
     */
    this.loadCodeForRequire();
    // Set user session mapping enabled.
    FrameworkServiceDataHolder.getInstance().setUserSessionMappingEnabled(FrameworkUtils.isUserSessionMappingEnabled());
    if (FrameworkServiceDataHolder.getInstance().getSessionSerializer() == null) {
        FrameworkServiceDataHolder.getInstance().setSessionSerializer(new JavaSessionSerializer());
    }
    bundleContext.registerService(ApplicationAuthenticationService.class.getName(), new ApplicationAuthenticationService(), null);
// Note : DO NOT add any activation related code below this point,
// to make sure the server doesn't start up if any activation failures
}
Also used : JsGraphBuilderFactory(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilderFactory) SessionExtenderProcessor(org.wso2.carbon.identity.application.authentication.framework.session.extender.processor.SessionExtenderProcessor) JsFunctionRegistryImpl(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl) CommonAuthenticationServlet(org.wso2.carbon.identity.application.authentication.framework.servlet.CommonAuthenticationServlet) AsyncSequenceExecutor(org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.AsyncSequenceExecutor) JavaSessionSerializer(org.wso2.carbon.identity.application.authentication.framework.store.JavaSessionSerializer) ServerSessionManagementServiceImpl(org.wso2.carbon.identity.application.authentication.framework.internal.impl.ServerSessionManagementServiceImpl) AuthenticationMethodNameTranslatorImpl(org.wso2.carbon.identity.application.authentication.framework.internal.impl.AuthenticationMethodNameTranslatorImpl) ApplicationAuthenticationService(org.wso2.carbon.identity.application.authentication.framework.ApplicationAuthenticationService) DefaultClaimFilter(org.wso2.carbon.identity.application.authentication.framework.handler.claims.impl.DefaultClaimFilter) LongWaitStatusServlet(org.wso2.carbon.identity.application.authentication.framework.servlet.LongWaitStatusServlet) TenantMgtListener(org.wso2.carbon.stratos.common.listeners.TenantMgtListener) LoginContextServlet(org.wso2.carbon.identity.application.authentication.framework.servlet.LoginContextServlet) UIBasedConfigurationLoader(org.wso2.carbon.identity.application.authentication.framework.config.loader.UIBasedConfigurationLoader) JITProvisioningIdentityProviderMgtListener(org.wso2.carbon.identity.application.authentication.framework.handler.provisioning.listener.JITProvisioningIdentityProviderMgtListener) CacheBackedLongWaitStatusDAO(org.wso2.carbon.identity.application.authentication.framework.dao.impl.CacheBackedLongWaitStatusDAO) LongWaitStatusStoreService(org.wso2.carbon.identity.application.authentication.framework.store.LongWaitStatusStoreService) IdentityProcessor(org.wso2.carbon.identity.application.authentication.framework.inbound.IdentityProcessor) Servlet(javax.servlet.Servlet) CommonAuthenticationServlet(org.wso2.carbon.identity.application.authentication.framework.servlet.CommonAuthenticationServlet) IdentityServlet(org.wso2.carbon.identity.application.authentication.framework.inbound.IdentityServlet) LoginContextServlet(org.wso2.carbon.identity.application.authentication.framework.servlet.LoginContextServlet) LongWaitStatusServlet(org.wso2.carbon.identity.application.authentication.framework.servlet.LongWaitStatusServlet) UserSessionManagementServiceImpl(org.wso2.carbon.identity.application.authentication.framework.internal.impl.UserSessionManagementServiceImpl) HttpIdentityRequestFactory(org.wso2.carbon.identity.application.authentication.framework.inbound.HttpIdentityRequestFactory) IdentityServlet(org.wso2.carbon.identity.application.authentication.framework.inbound.IdentityServlet) ClaimFilter(org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimFilter) DefaultClaimFilter(org.wso2.carbon.identity.application.authentication.framework.handler.claims.impl.DefaultClaimFilter) PostAuthenticationMgtService(org.wso2.carbon.identity.application.authentication.framework.services.PostAuthenticationMgtService) SessionExtenderRequestFactory(org.wso2.carbon.identity.application.authentication.framework.session.extender.request.SessionExtenderRequestFactory) FrameworkLogoutResponseFactory(org.wso2.carbon.identity.application.authentication.framework.inbound.FrameworkLogoutResponseFactory) UserSessionManagementService(org.wso2.carbon.identity.application.authentication.framework.UserSessionManagementService) FrameworkLoginResponseFactory(org.wso2.carbon.identity.application.authentication.framework.inbound.FrameworkLoginResponseFactory) SSOConsentService(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.SSOConsentService) IdentityProviderMgtListener(org.wso2.carbon.idp.mgt.listener.IdentityProviderMgtListener) JITProvisioningIdentityProviderMgtListener(org.wso2.carbon.identity.application.authentication.framework.handler.provisioning.listener.JITProvisioningIdentityProviderMgtListener) SessionExtenderResponseFactory(org.wso2.carbon.identity.application.authentication.framework.session.extender.response.SessionExtenderResponseFactory) PostAuthnMissingClaimHandler(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.PostAuthnMissingClaimHandler) IOException(java.io.IOException) FrameworkException(org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException) ContextPathServletAdaptor(org.eclipse.equinox.http.helper.ContextPathServletAdaptor) LongWaitStatusDAOImpl(org.wso2.carbon.identity.application.authentication.framework.dao.impl.LongWaitStatusDAOImpl) AuthenticationEndpointTenantActivityListener(org.wso2.carbon.identity.application.authentication.framework.listener.AuthenticationEndpointTenantActivityListener) HttpIdentityResponseFactory(org.wso2.carbon.identity.application.authentication.framework.inbound.HttpIdentityResponseFactory) ServerSessionManagementService(org.wso2.carbon.identity.application.authentication.framework.ServerSessionManagementService) SSOConsentServiceImpl(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.consent.SSOConsentServiceImpl) BundleContext(org.osgi.framework.BundleContext) JITProvisioningPostAuthenticationHandler(org.wso2.carbon.identity.application.authentication.framework.handler.request.impl.JITProvisioningPostAuthenticationHandler) PostAuthenticationHandler(org.wso2.carbon.identity.application.authentication.framework.handler.request.PostAuthenticationHandler) Activate(org.osgi.service.component.annotations.Activate)

Example 2 with JsFunctionRegistryImpl

use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.

the class GraphBasedSequenceHandlerAbstractTest method setupSuite.

@BeforeClass
protected void setupSuite() {
    configurationLoader = new UIBasedConfigurationLoader();
    graphBuilderFactory = new JsGraphBuilderFactory();
    JsFunctionRegistryImpl jsFunctionRegistry = new JsFunctionRegistryImpl();
    FrameworkServiceDataHolder.getInstance().setJsFunctionRegistry(jsFunctionRegistry);
    graphBuilderFactory.init();
    FrameworkServiceDataHolder.getInstance().setJsGraphBuilderFactory(graphBuilderFactory);
    AsyncSequenceExecutor asyncSequenceExecutor = new AsyncSequenceExecutor();
    asyncSequenceExecutor.init();
    FrameworkServiceDataHolder.getInstance().setAsyncSequenceExecutor(asyncSequenceExecutor);
}
Also used : UIBasedConfigurationLoader(org.wso2.carbon.identity.application.authentication.framework.config.loader.UIBasedConfigurationLoader) JsGraphBuilderFactory(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilderFactory) JsFunctionRegistryImpl(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with JsFunctionRegistryImpl

use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.

the class GraphBasedSequenceHandlerCustomFunctionsTest method testHandleDynamicBoolean.

public void testHandleDynamicBoolean() throws Exception {
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID);
    JsFunctionRegistry jsFunctionRegistrar = new JsFunctionRegistryImpl();
    FrameworkServiceDataHolder.getInstance().setJsFunctionRegistry(jsFunctionRegistrar);
    jsFunctionRegistrar.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "fn1", (Function<JsAuthenticationContext, String>) GraphBasedSequenceHandlerCustomFunctionsTest::customFunction1);
    jsFunctionRegistrar.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getTrueFunction", (Function<JsAuthenticationContext, Boolean>) GraphBasedSequenceHandlerCustomFunctionsTest::customBoolean);
    jsFunctionRegistrar.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getTrueFunction2", (BiFunction<JsAuthenticationContext, String, Boolean>) GraphBasedSequenceHandlerCustomFunctionsTest::customBoolean2);
    ServiceProvider sp1 = getTestServiceProvider("js-sp-dynamic-1.xml");
    String script = "var onLoginRequest = function(context) {\n" + "    var myBool = getTrueFunction2(context, 'a');\n" + "    Log.info(\"My Bool Value \"+myBool);\n" + "    if(myBool) {\n" + "        Log.info(\"My Bool Is Selected \"+myBool);\n" + "        executeStep(1, {\n" + "            onSuccess : function(context) {\n" + "                executeStep(3);\n" + "            }\n" + "        });\n" + "        executeStep(2);\n" + "    }  else {\n" + "        Log.info(\"My Bool Not Selected \"+myBool);\n" + "        executeStep(1);\n" + "        executeStep(3);\n" + "    }\n" + "};";
    sp1.getLocalAndOutBoundAuthenticationConfig().getAuthenticationScriptConfig().setContent(script);
    AuthenticationContext context = processAndGetAuthenticationContext(new String[0], sp1);
    List<AuthHistory> authHistories = context.getAuthenticationStepHistory();
    assertNotNull(authHistories);
    assertEquals(authHistories.size(), 3);
    assertEquals(authHistories.get(0).getAuthenticatorName(), "BasicMockAuthenticator");
    assertEquals(authHistories.get(1).getAuthenticatorName(), "FptMockAuthenticator");
    assertEquals(authHistories.get(2).getAuthenticatorName(), "HwkMockAuthenticator");
}
Also used : JsFunctionRegistry(org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry) JsAuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext) AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) JsAuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext) JsFunctionRegistryImpl(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) AuthHistory(org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory)

Example 4 with JsFunctionRegistryImpl

use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.

the class GraphBasedSequenceHandlerCustomFunctionsTest method testHandleDynamicJavascriptSerialization.

@Test
public void testHandleDynamicJavascriptSerialization() throws Exception {
    JsFunctionRegistry jsFunctionRegistrar = new JsFunctionRegistryImpl();
    FrameworkServiceDataHolder.getInstance().setJsFunctionRegistry(jsFunctionRegistrar);
    jsFunctionRegistrar.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "fn1", (Function<JsAuthenticationContext, String>) GraphBasedSequenceHandlerCustomFunctionsTest::customFunction1);
    ServiceProvider sp1 = getTestServiceProvider("js-sp-dynamic-1.xml");
    AuthenticationContext context = getAuthenticationContext(sp1);
    SequenceConfig sequenceConfig = configurationLoader.getSequenceConfig(context, Collections.<String, String[]>emptyMap(), sp1);
    context.setSequenceConfig(sequenceConfig);
    byte[] serialized = SerializationUtils.serialize(context);
    AuthenticationContext deseralizedContext = (AuthenticationContext) SerializationUtils.deserialize(serialized);
    assertNotNull(deseralizedContext);
    HttpServletRequest req = mock(HttpServletRequest.class);
    addMockAttributes(req);
    HttpServletResponse resp = mock(HttpServletResponse.class);
    UserCoreUtil.setDomainInThreadLocal("test_domain");
    graphBasedSequenceHandler.handle(req, resp, deseralizedContext);
    List<AuthHistory> authHistories = deseralizedContext.getAuthenticationStepHistory();
    assertNotNull(authHistories);
    assertEquals(3, authHistories.size());
    assertEquals(authHistories.get(0).getAuthenticatorName(), "BasicMockAuthenticator");
    assertEquals(authHistories.get(1).getAuthenticatorName(), "HwkMockAuthenticator");
    assertEquals(authHistories.get(2).getAuthenticatorName(), "FptMockAuthenticator");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) JsFunctionRegistry(org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry) JsAuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext) AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) JsAuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext) JsFunctionRegistryImpl(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) HttpServletResponse(javax.servlet.http.HttpServletResponse) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig) AuthHistory(org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory) Test(org.testng.annotations.Test)

Example 5 with JsFunctionRegistryImpl

use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.

the class GraphBasedSequenceHandlerExceptionRetryTest method testExceptionRetry.

public void testExceptionRetry() throws Exception {
    JsFunctionRegistryImpl jsFunctionRegistrar = new JsFunctionRegistryImpl();
    FrameworkServiceDataHolder.getInstance().setJsFunctionRegistry(jsFunctionRegistrar);
    LongWaitStatusDAOImpl daoImpl = new LongWaitStatusDAOImpl();
    CacheBackedLongWaitStatusDAO cacheBackedDao = new CacheBackedLongWaitStatusDAO(daoImpl);
    FrameworkServiceDataHolder.getInstance().getAuthenticators().add(new FailingMockAuthenticator("FailingMockAuthenticator"));
    FrameworkServiceDataHolder.getInstance().setLongWaitStatusStoreService(new LongWaitStatusStoreService(cacheBackedDao, 5000));
    jsFunctionRegistrar.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "hasAnyOfTheRoles", (BiFunction<JsAuthenticatedUser, List<String>, Boolean>) this::hasAnyOfTheRolesFunction);
    ServiceProvider sp1 = getTestServiceProvider("js-sp-exception-retry.xml");
    AuthenticationContext context = getAuthenticationContext(sp1);
    context.setSessionIdentifier("1234");
    SequenceConfig sequenceConfig = configurationLoader.getSequenceConfig(context, Collections.emptyMap(), sp1);
    context.setSequenceConfig(sequenceConfig);
    HttpServletRequest req = createMockHttpServletRequest();
    HttpServletResponse resp = mock(HttpServletResponse.class);
    UserCoreUtil.setDomainInThreadLocal("test_domain");
    graphBasedSequenceHandler.handle(req, resp, context);
    Integer currentAttempts = (Integer) context.getProperties().get(CONTEXT_ATTRIBUTE_NAME_CURRENT_FAIL_TRIES);
    Assert.assertNotNull(currentAttempts);
    Assert.assertEquals(currentAttempts.intValue(), 2);
}
Also used : AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) JsFunctionRegistryImpl(org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl) HttpServletResponse(javax.servlet.http.HttpServletResponse) LongWaitStatusDAOImpl(org.wso2.carbon.identity.application.authentication.framework.dao.impl.LongWaitStatusDAOImpl) HttpServletRequest(javax.servlet.http.HttpServletRequest) CacheBackedLongWaitStatusDAO(org.wso2.carbon.identity.application.authentication.framework.dao.impl.CacheBackedLongWaitStatusDAO) BiFunction(java.util.function.BiFunction) LongWaitStatusStoreService(org.wso2.carbon.identity.application.authentication.framework.store.LongWaitStatusStoreService) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)

Aggregations

JsFunctionRegistryImpl (org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl)11 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)7 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)6 Test (org.testng.annotations.Test)5 JsAuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext)5 AuthHistory (org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 JsFunctionRegistry (org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry)3 UIBasedConfigurationLoader (org.wso2.carbon.identity.application.authentication.framework.config.loader.UIBasedConfigurationLoader)3 SequenceConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)3 JsGraphBuilderFactory (org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilderFactory)3 CacheBackedLongWaitStatusDAO (org.wso2.carbon.identity.application.authentication.framework.dao.impl.CacheBackedLongWaitStatusDAO)3 LongWaitStatusDAOImpl (org.wso2.carbon.identity.application.authentication.framework.dao.impl.LongWaitStatusDAOImpl)3 LongWaitStatusStoreService (org.wso2.carbon.identity.application.authentication.framework.store.LongWaitStatusStoreService)3 AsyncSequenceExecutor (org.wso2.carbon.identity.application.authentication.framework.handler.sequence.impl.AsyncSequenceExecutor)2 IOException (java.io.IOException)1 BiFunction (java.util.function.BiFunction)1 Servlet (javax.servlet.Servlet)1 ContextPathServletAdaptor (org.eclipse.equinox.http.helper.ContextPathServletAdaptor)1