Search in sources :

Example 6 with JsFunctionRegistry

use of org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry in project identity-conditional-auth-functions by wso2-extensions.

the class UserStoreFunctionsServiceComponent method activate.

@Activate
protected void activate(ComponentContext ctxt) {
    try {
        UserStoreFunctions storeFunctions = new UserStoreFunctions();
        JsFunctionRegistry jsFunctionRegistry = UserStoreFunctionsServiceHolder.getInstance().getJsFunctionRegistry();
        jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getUniqueUserWithClaimValues", (GetUserWithClaimValues) storeFunctions::getUniqueUserWithClaimValues);
    } catch (Throwable e) {
        LOG.error("Error occurred during conditional authentication user functions bundle activation. ", e);
    }
}
Also used : JsFunctionRegistry(org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry) UserStoreFunctions(org.wso2.carbon.identity.conditional.auth.functions.user.store.UserStoreFunctions) Activate(org.osgi.service.component.annotations.Activate)

Example 7 with JsFunctionRegistry

use of org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry in project identity-conditional-auth-functions by wso2-extensions.

the class HTTPFunctionsServiceComponent method deactivate.

@Deactivate
protected void deactivate(ComponentContext ctxt) {
    JsFunctionRegistry jsFunctionRegistry = HTTPFunctionsServiceHolder.getInstance().getJsFunctionRegistry();
    if (jsFunctionRegistry != null) {
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, FUNC_SET_COOKIE);
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, FUNC_GET_COOKIE_VALUE);
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, FUNC_HTTP_POST);
    }
}
Also used : JsFunctionRegistry(org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry) Deactivate(org.osgi.service.component.annotations.Deactivate)

Example 8 with JsFunctionRegistry

use of org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry in project identity-conditional-auth-functions by wso2-extensions.

the class AnalyticsFunctionsServiceComponent method deactivate.

@Deactivate
protected void deactivate(ComponentContext ctxt) {
    JsFunctionRegistry jsFunctionRegistry = AnalyticsFunctionsServiceHolder.getInstance().getJsFunctionRegistry();
    if (jsFunctionRegistry != null) {
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, FUNC_CALL_SIDDHI);
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, FUNC_PUBLISH_SIDDHI);
    }
}
Also used : JsFunctionRegistry(org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry) Deactivate(org.osgi.service.component.annotations.Deactivate)

Example 9 with JsFunctionRegistry

use of org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry in project identity-conditional-auth-functions by wso2-extensions.

the class AnalyticsFunctionsServiceComponent method activate.

@Activate
protected void activate(ComponentContext context) {
    try {
        JsFunctionRegistry jsFunctionRegistry = AnalyticsFunctionsServiceHolder.getInstance().getJsFunctionRegistry();
        CallAnalyticsFunction callSiddhi = new CallAnalyticsFunctionImpl();
        jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, FUNC_CALL_SIDDHI, callSiddhi);
        PublishToAnalyticsFunction publishSiddhi = new PublishToAnalyticsFunctionImpl();
        jsFunctionRegistry.register(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, FUNC_PUBLISH_SIDDHI, publishSiddhi);
        BundleContext bundleContext = context.getBundleContext();
        AnalyticsEngineConfigImpl analyticsFunctionConfig = new AnalyticsEngineConfigImpl();
        bundleContext.registerService(IdentityConnectorConfig.class.getName(), analyticsFunctionConfig, null);
        AnalyticsAxis2ConfigurationContextObserver observer = new AnalyticsAxis2ConfigurationContextObserver();
        bundleContext.registerService(Axis2ConfigurationContextObserver.class.getName(), observer, null);
        ServerConfigurationService config = AnalyticsFunctionsServiceHolder.getInstance().getServerConfigurationService();
        String filePath = config.getFirstProperty("Security.TrustStore.Location");
        String keyStoreType = config.getFirstProperty("Security.TrustStore.Type");
        String password = config.getFirstProperty("Security.TrustStore.Password");
        try (InputStream keyStoreStream = new FileInputStream(filePath)) {
            // or "PKCS12"
            KeyStore keyStore = KeyStore.getInstance(keyStoreType);
            keyStore.load(keyStoreStream, password.toCharArray());
            AnalyticsFunctionsServiceHolder.getInstance().setTrustStore(keyStore);
        } catch (IOException | CertificateException | KeyStoreException | NoSuchAlgorithmException e) {
            LOG.error("Error while loading truststore.", e);
        }
    } catch (Throwable e) {
        LOG.error("Error while activating AnalyticsFunctionsServiceComponent");
    }
}
Also used : JsFunctionRegistry(org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry) PublishToAnalyticsFunctionImpl(org.wso2.carbon.identity.conditional.auth.functions.analytics.PublishToAnalyticsFunctionImpl) AnalyticsAxis2ConfigurationContextObserver(org.wso2.carbon.identity.conditional.auth.functions.analytics.listener.AnalyticsAxis2ConfigurationContextObserver) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) KeyStoreException(java.security.KeyStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStore(java.security.KeyStore) FileInputStream(java.io.FileInputStream) CallAnalyticsFunction(org.wso2.carbon.identity.conditional.auth.functions.analytics.CallAnalyticsFunction) PublishToAnalyticsFunction(org.wso2.carbon.identity.conditional.auth.functions.analytics.PublishToAnalyticsFunction) IdentityConnectorConfig(org.wso2.carbon.identity.governance.common.IdentityConnectorConfig) AnalyticsEngineConfigImpl(org.wso2.carbon.identity.conditional.auth.functions.analytics.AnalyticsEngineConfigImpl) ServerConfigurationService(org.wso2.carbon.base.api.ServerConfigurationService) Axis2ConfigurationContextObserver(org.wso2.carbon.utils.Axis2ConfigurationContextObserver) AnalyticsAxis2ConfigurationContextObserver(org.wso2.carbon.identity.conditional.auth.functions.analytics.listener.AnalyticsAxis2ConfigurationContextObserver) CallAnalyticsFunctionImpl(org.wso2.carbon.identity.conditional.auth.functions.analytics.CallAnalyticsFunctionImpl) BundleContext(org.osgi.framework.BundleContext) Activate(org.osgi.service.component.annotations.Activate)

Example 10 with JsFunctionRegistry

use of org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry in project identity-conditional-auth-functions by wso2-extensions.

the class UserFunctionsServiceComponent method deactivate.

@Deactivate
protected void deactivate(ComponentContext ctxt) {
    JsFunctionRegistry jsFunctionRegistry = UserFunctionsServiceHolder.getInstance().getJsFunctionRegistry();
    if (jsFunctionRegistry != null) {
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "hasRole");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "hasAnyOfTheRoles");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "isMemberOfAnyOfGroups");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "promptIdentifierForStep");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "checkSessionExistence");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "assignUserRoles");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "removeUserRoles");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getAssociatedLocalUser");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "getUserSessions");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "terminateUserSession");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "doAssociationWithLocalUser");
        jsFunctionRegistry.deRegister(JsFunctionRegistry.Subsystem.SEQUENCE_HANDLER, "isAnyOfTheRolesAssignedToUser");
    }
}
Also used : JsFunctionRegistry(org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry) Deactivate(org.osgi.service.component.annotations.Deactivate)

Aggregations

JsFunctionRegistry (org.wso2.carbon.identity.application.authentication.framework.JsFunctionRegistry)16 Activate (org.osgi.service.component.annotations.Activate)7 JsFunctionRegistryImpl (org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsFunctionRegistryImpl)5 Deactivate (org.osgi.service.component.annotations.Deactivate)4 JsAuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.config.model.graph.js.JsAuthenticationContext)3 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 KeyStore (java.security.KeyStore)2 KeyStoreException (java.security.KeyStoreException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 CertificateException (java.security.cert.CertificateException)2 BundleContext (org.osgi.framework.BundleContext)2 ServerConfigurationService (org.wso2.carbon.base.api.ServerConfigurationService)2 UIBasedConfigurationLoader (org.wso2.carbon.identity.application.authentication.framework.config.loader.UIBasedConfigurationLoader)2 JsGraphBuilderFactory (org.wso2.carbon.identity.application.authentication.framework.config.model.graph.JsGraphBuilderFactory)2 AuthHistory (org.wso2.carbon.identity.application.authentication.framework.context.AuthHistory)2 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)2 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)2 BiConsumer (java.util.function.BiConsumer)1