use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project identity-conditional-auth-functions by wso2-extensions.
the class JsSequenceHandlerRunner method init.
public void init(URL applicationAuthenticatorConfigFileLocation) throws InvocationTargetException {
this.applicationAuthenticatorConfigFileLocation = applicationAuthenticatorConfigFileLocation;
configurationLoader = new UIBasedConfigurationLoader();
graphBuilderFactory = new JsGraphBuilderFactory();
jsFunctionRegistry = new JsFunctionRegistryImpl();
FrameworkServiceDataHolder.getInstance().setJsFunctionRegistry(jsFunctionRegistry);
jsExecutionSupervisor = new JSExecutionSupervisor(THREAD_COUNT, SUPERVISOR_TIMEOUT);
FrameworkServiceDataHolder.getInstance().setJsExecutionSupervisor(jsExecutionSupervisor);
graphBuilderFactory.init();
FrameworkServiceDataHolder.getInstance().setJsGraphBuilderFactory(graphBuilderFactory);
AsyncSequenceExecutor asyncSequenceExecutor = new AsyncSequenceExecutor();
asyncSequenceExecutor.init();
FrameworkServiceDataHolder.getInstance().setAsyncSequenceExecutor(asyncSequenceExecutor);
if (applicationAuthenticatorConfigFileLocation == null) {
this.applicationAuthenticatorConfigFileLocation = this.getClass().getClassLoader().getResource(DEFAULT_APPLICATION_AUTHENTICATION_XML_FILE_NAME);
}
reset();
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandlerCustomFunctionsTest method testHandleDynamicOnFallback.
@Test
public void testHandleDynamicOnFallback() throws Exception {
FrameworkServiceDataHolder.getInstance().getAuthenticators().add(new MockFallbackAuthenticator("MockFallbackAuthenticator"));
JsFunctionRegistryImpl 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-on-fallback.xml");
AuthenticationContext context = processAndGetAuthenticationContext(new String[0], sp1);
List<AuthHistory> authHistories = context.getAuthenticationStepHistory();
assertNotNull(authHistories);
assertEquals(authHistories.size(), 4);
assertEquals(authHistories.get(0).getAuthenticatorName(), "MockFallbackAuthenticator");
assertEquals(authHistories.get(1).getAuthenticatorName(), "BasicMockAuthenticator");
assertEquals(authHistories.get(2).getAuthenticatorName(), "HwkMockAuthenticator");
assertEquals(authHistories.get(3).getAuthenticatorName(), "FptMockAuthenticator");
assertTrue(context.isRequestAuthenticated());
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandlerCustomFunctionsTest method testHandleDynamicOnFail.
@Test
public void testHandleDynamicOnFail() throws Exception {
FrameworkServiceDataHolder.getInstance().getAuthenticators().add(new MockFailingAuthenticator("BasicFailingMockAuthenticator"));
JsFunctionRegistryImpl 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-on-fail.xml");
AuthenticationContext context = processAndGetAuthenticationContext(new String[0], sp1);
List<AuthHistory> authHistories = context.getAuthenticationStepHistory();
assertNotNull(authHistories);
assertEquals(authHistories.size(), 3);
assertEquals(authHistories.get(0).getAuthenticatorName(), "BasicFailingMockAuthenticator");
assertEquals(authHistories.get(1).getAuthenticatorName(), "BasicMockAuthenticator");
assertEquals(authHistories.get(2).getAuthenticatorName(), "FptMockAuthenticator");
assertTrue(context.isRequestAuthenticated());
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandlerCustomFunctionsTest method testHandleDynamicJavascript1.
@Test
public void testHandleDynamicJavascript1() throws Exception {
JsFunctionRegistryImpl 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, "fn2", new CustomFunctionImpl2());
AuthenticationContext context = processSequenceWithAcr(new String[] { "acr1" });
List<AuthHistory> authHistories = context.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");
}
use of org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl in project carbon-identity-framework by wso2.
the class GraphBasedSequenceHandlerLongWaitTest method testHandleLongWait.
@Test
public void testHandleLongWait() throws Exception {
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID);
JsFunctionRegistryImpl jsFunctionRegistrar = new JsFunctionRegistryImpl();
FrameworkServiceDataHolder.getInstance().setJsFunctionRegistry(jsFunctionRegistrar);
LongWaitStatusDAOImpl daoImpl = new LongWaitStatusDAOImpl();
CacheBackedLongWaitStatusDAO cacheBackedDao = new CacheBackedLongWaitStatusDAO(daoImpl);
FrameworkServiceDataHolder.getInstance().setLongWaitStatusStoreService(new LongWaitStatusStoreService(cacheBackedDao, 5000));
jsFunctionRegistrar.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "testLongWaitCall", new AsyncAnalyticsCbFunctionImpl());
ServiceProvider sp1 = getTestServiceProvider("js-sp-longwait-1.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);
}
Aggregations