Search in sources :

Example 1 with LoginModuleFactory

use of org.apache.felix.jaas.LoginModuleFactory in project jackrabbit-oak by apache.

the class ExternalLoginModuleFactoryTest method setUpJaasFactoryWithInjection.

/**
     * Prepares the OSGi part with required services injected and configures
     * the factory in JAAS options which then delegates to ExternalLoginModuleFactory
     */
private void setUpJaasFactoryWithInjection() throws Exception {
    context.registerService(Repository.class, EasyMock.createMock(Repository.class));
    context.registerService(SyncManager.class, new SyncManagerImpl(whiteboard));
    context.registerService(ExternalIdentityProviderManager.class, new ExternalIDPManagerImpl(whiteboard));
    final LoginModuleFactory lmf = context.registerInjectActivateService(new ExternalLoginModuleFactory());
    options.put(ProxyLoginModule.PROP_LOGIN_MODULE_FACTORY, new ProxyLoginModule.BootLoginModuleFactory() {

        @Override
        public LoginModule createLoginModule() {
            return lmf.createLoginModule();
        }
    });
}
Also used : ProxyLoginModule(org.apache.felix.jaas.boot.ProxyLoginModule) Repository(javax.jcr.Repository) LoginModuleFactory(org.apache.felix.jaas.LoginModuleFactory) LoginModule(javax.security.auth.spi.LoginModule) ProxyLoginModule(org.apache.felix.jaas.boot.ProxyLoginModule)

Example 2 with LoginModuleFactory

use of org.apache.felix.jaas.LoginModuleFactory in project sling by apache.

the class JaasHelper method registerLoginModuleFactory.

private ServiceRegistration registerLoginModuleFactory(BundleContext ctx, Dictionary properties) {
    ServiceRegistration reg = null;
    try {
        java.util.Properties props = new java.util.Properties();
        final String desc = "LoginModule Support for FormAuthenticationHandler";
        props.put(Constants.SERVICE_DESCRIPTION, desc);
        props.put(Constants.SERVICE_VENDOR, ctx.getBundle().getHeaders().get(Constants.BUNDLE_VENDOR));
        props.put(LoginModuleFactory.JAAS_RANKING, properties.get(LoginModuleFactory.JAAS_RANKING));
        props.put(LoginModuleFactory.JAAS_CONTROL_FLAG, properties.get(LoginModuleFactory.JAAS_CONTROL_FLAG));
        props.put(LoginModuleFactory.JAAS_REALM_NAME, properties.get(LoginModuleFactory.JAAS_REALM_NAME));
        reg = ctx.registerService(LoginModuleFactory.class.getName(), new LoginModuleFactory() {

            public LoginModule createLoginModule() {
                return new FormLoginModule(authHandler);
            }

            @Override
            public String toString() {
                return desc + " (" + FormLoginModule.class.getName() + ")";
            }
        }, props);
        log.info("Registered FormLoginModuleFactory");
    } catch (Throwable e) {
        log.error("unable to create an register the SSO login module factory", e);
    }
    return reg;
}
Also used : LoginModuleFactory(org.apache.felix.jaas.LoginModuleFactory) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Aggregations

LoginModuleFactory (org.apache.felix.jaas.LoginModuleFactory)2 Repository (javax.jcr.Repository)1 LoginModule (javax.security.auth.spi.LoginModule)1 ProxyLoginModule (org.apache.felix.jaas.boot.ProxyLoginModule)1 ServiceRegistration (org.osgi.framework.ServiceRegistration)1