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);
}
}
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;
}
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);
}
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;
}
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();
}
Aggregations