Search in sources :

Example 1 with LdapEntryManager

use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxAuth by GluuFederation.

the class AppInitializer method closeLdapAuthEntryManagers.

private void closeLdapAuthEntryManagers(List<LdapEntryManager> oldLdapAuthEntryManagers) {
    // Close existing connections
    for (LdapEntryManager oldLdapAuthEntryManager : oldLdapAuthEntryManagers) {
        log.debug("Attempting to destroy {}: {}", LDAP_AUTH_ENTRY_MANAGER_NAME, oldLdapAuthEntryManager);
        oldLdapAuthEntryManager.destroy();
        log.debug("Destroyed {}: {}", LDAP_AUTH_ENTRY_MANAGER_NAME, oldLdapAuthEntryManager);
    }
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager)

Example 2 with LdapEntryManager

use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxAuth by GluuFederation.

the class AppInitializer method createLdapAuthEntryManager.

/*
	 * Utility method which can be used in custom scripts
	 */
public LdapEntryManager createLdapAuthEntryManager(GluuLdapConfiguration ldapAuthConfig) {
    LdapConnectionProviders ldapConnectionProviders = createAuthConnectionProviders(ldapAuthConfig);
    LdapEntryManager ldapAuthEntryManager = new LdapEntryManager(new OperationsFacade(ldapConnectionProviders.getConnectionProvider(), ldapConnectionProviders.getConnectionBindProvider()));
    log.debug("Created custom authentication LdapEntryManager: {}", ldapAuthEntryManager);
    return ldapAuthEntryManager;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) OperationsFacade(org.gluu.site.ldap.OperationsFacade)

Example 3 with LdapEntryManager

use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxAuth by GluuFederation.

the class AppInitializer method destroy.

public void destroy(@Observes @BeforeDestroyed(ApplicationScoped.class) ServletContext init) {
    log.info("Closing LDAP connection at server shutdown...");
    LdapEntryManager ldapEntryManager = ldapEntryManagerInstance.get();
    closeLdapEntryManager(ldapEntryManager);
    List<LdapEntryManager> ldapAuthEntryManagers = ldapAuthEntryManagerInstance.get();
    closeLdapAuthEntryManagers(ldapAuthEntryManagers);
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager)

Example 4 with LdapEntryManager

use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxAuth by GluuFederation.

the class AuthenticationService method authenticate.

public boolean authenticate(String keyValue, String password, String primaryKey, String localPrimaryKey) {
    if (this.ldapAuthConfigs == null) {
        return authenticate(null, ldapEntryManager, keyValue, password, primaryKey, localPrimaryKey);
    }
    boolean authenticated = false;
    com.codahale.metrics.Timer.Context timerContext = metricService.getTimer(MetricType.OXAUTH_USER_AUTHENTICATION_RATE).time();
    try {
        for (int i = 0; i < this.ldapAuthConfigs.size(); i++) {
            GluuLdapConfiguration ldapAuthConfig = this.ldapAuthConfigs.get(i);
            LdapEntryManager ldapAuthEntryManager = this.ldapAuthEntryManagers.get(i);
            authenticated = authenticate(ldapAuthConfig, ldapAuthEntryManager, keyValue, password, primaryKey, localPrimaryKey);
            if (authenticated) {
                break;
            }
        }
    } finally {
        timerContext.stop();
    }
    MetricType metricType;
    if (authenticated) {
        metricType = MetricType.OXAUTH_USER_AUTHENTICATION_SUCCESS;
    } else {
        metricType = MetricType.OXAUTH_USER_AUTHENTICATION_FAILURES;
    }
    metricService.incCounter(metricType);
    return authenticated;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) MetricType(org.xdi.model.metric.MetricType) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration)

Example 5 with LdapEntryManager

use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxAuth by GluuFederation.

the class AppInitializer method applicationInitialized.

public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) {
    createConnectionProvider();
    configurationFactory.create();
    LdapEntryManager localLdapEntryManager = ldapEntryManagerInstance.get();
    List<GluuLdapConfiguration> ldapAuthConfigs = loadLdapAuthConfigs(localLdapEntryManager);
    createAuthConnectionProviders(ldapAuthConfigs);
    setDefaultAuthenticationMethod(localLdapEntryManager);
    // Initialize python interpreter
    pythonService.initPythonInterpreter(configurationFactory.getLdapConfiguration().getString("pythonModulesDir", null));
    // Initialize script manager
    List<CustomScriptType> supportedCustomScriptTypes = Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION, CustomScriptType.CLIENT_REGISTRATION, CustomScriptType.ID_GENERATOR, CustomScriptType.UMA_AUTHORIZATION_POLICY, CustomScriptType.APPLICATION_SESSION, CustomScriptType.DYNAMIC_SCOPE);
    // Start timer
    quartzSchedulerManager.start();
    // Schedule timer tasks
    metricService.initTimer();
    configurationFactory.initTimer();
    ldapStatusTimer.initTimer();
    cleanerTimer.initTimer();
    customScriptManager.initTimer(supportedCustomScriptTypes);
    keyGeneratorTimer.initTimer();
    initTimer();
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) CustomScriptType(org.xdi.model.custom.script.CustomScriptType) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration)

Aggregations

LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)33 OperationsFacade (org.gluu.site.ldap.OperationsFacade)8 Filter (com.unboundid.ldap.sdk.Filter)6 ArrayList (java.util.ArrayList)6 GluuSimplePerson (org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson)5 ApplicationScoped (javax.enterprise.context.ApplicationScoped)4 Produces (javax.enterprise.inject.Produces)4 Named (javax.inject.Named)4 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)4 GluuLdapConfiguration (org.xdi.model.ldap.GluuLdapConfiguration)4 Properties (java.util.Properties)3 GluuInumMap (org.gluu.oxtrust.ldap.cache.model.GluuInumMap)3 LDAPConnectionProvider (org.gluu.site.ldap.LDAPConnectionProvider)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 CacheCompoundKey (org.gluu.oxtrust.ldap.cache.model.CacheCompoundKey)2 CustomAttribute (org.xdi.ldap.model.CustomAttribute)2