Search in sources :

Example 1 with GluuLdapConfiguration

use of org.xdi.model.ldap.GluuLdapConfiguration 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 2 with GluuLdapConfiguration

use of org.xdi.model.ldap.GluuLdapConfiguration 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)

Example 3 with GluuLdapConfiguration

use of org.xdi.model.ldap.GluuLdapConfiguration in project oxAuth by GluuFederation.

the class AuthenticationService method externalAuthenticate.

private boolean externalAuthenticate(String keyValue, String password) {
    for (int i = 0; i < this.ldapAuthConfigs.size(); i++) {
        GluuLdapConfiguration ldapAuthConfig = this.ldapAuthConfigs.get(i);
        LdapEntryManager ldapAuthEntryManager = this.ldapAuthEntryManagers.get(i);
        String primaryKey = "uid";
        if (StringHelper.isNotEmpty(ldapAuthConfig.getPrimaryKey())) {
            primaryKey = ldapAuthConfig.getPrimaryKey();
        }
        String localPrimaryKey = "uid";
        if (StringHelper.isNotEmpty(ldapAuthConfig.getLocalPrimaryKey())) {
            localPrimaryKey = ldapAuthConfig.getLocalPrimaryKey();
        }
        boolean authenticated = authenticate(ldapAuthConfig, ldapAuthEntryManager, keyValue, password, primaryKey, localPrimaryKey);
        if (authenticated) {
            return authenticated;
        }
    }
    return false;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration)

Example 4 with GluuLdapConfiguration

use of org.xdi.model.ldap.GluuLdapConfiguration in project oxTrust by GluuFederation.

the class ConfigureCacheRefreshAction method getOxTrustCacheRefreshConfig.

private CacheRefreshConfiguration getOxTrustCacheRefreshConfig() {
    CacheRefreshConfiguration cacheRefreshConfiguration = jsonConfigurationService.getOxTrustCacheRefreshConfiguration();
    if (cacheRefreshConfiguration == null) {
        cacheRefreshConfiguration = new CacheRefreshConfiguration();
        cacheRefreshConfiguration.setUpdateMethod(CacheRefreshUpdateMethod.COPY.getValue());
        cacheRefreshConfiguration.setSourceConfigs(new ArrayList<GluuLdapConfiguration>());
        cacheRefreshConfiguration.setInumConfig(new GluuLdapConfiguration());
        cacheRefreshConfiguration.setTargetConfig(new GluuLdapConfiguration());
        cacheRefreshConfiguration.setKeyAttributes(new ArrayList<String>(0));
        cacheRefreshConfiguration.setKeyObjectClasses(new ArrayList<String>());
        cacheRefreshConfiguration.setSourceAttributes(new ArrayList<String>());
        cacheRefreshConfiguration.setAttributeMapping(new ArrayList<CacheRefreshAttributeMapping>());
        cacheRefreshConfiguration.setDefaultInumServer(true);
    }
    this.updateMethod = CacheRefreshUpdateMethod.getByValue(cacheRefreshConfiguration.getUpdateMethod());
    this.keyAttributes = toSimpleProperties(cacheRefreshConfiguration.getKeyAttributes());
    this.keyObjectClasses = toSimpleProperties(cacheRefreshConfiguration.getKeyObjectClasses());
    this.sourceAttributes = toSimpleProperties(cacheRefreshConfiguration.getSourceAttributes());
    this.attributeMapping = toSimpleCustomProperties(cacheRefreshConfiguration.getAttributeMapping());
    return cacheRefreshConfiguration;
}
Also used : CacheRefreshConfiguration(org.xdi.config.oxtrust.CacheRefreshConfiguration) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration) CacheRefreshAttributeMapping(org.xdi.config.oxtrust.CacheRefreshAttributeMapping)

Example 5 with GluuLdapConfiguration

use of org.xdi.model.ldap.GluuLdapConfiguration in project oxTrust by GluuFederation.

the class ConfigureCacheRefreshAction method addLdapConfig.

@Override
public void addLdapConfig(List<GluuLdapConfiguration> ldapConfigList) {
    GluuLdapConfiguration ldapConfiguration = new GluuLdapConfiguration();
    ldapConfiguration.setBindPassword("");
    ldapConfigList.add(ldapConfiguration);
}
Also used : GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration)

Aggregations

GluuLdapConfiguration (org.xdi.model.ldap.GluuLdapConfiguration)15 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)3 JsonParseException (org.codehaus.jackson.JsonParseException)3 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)3 OxIDPAuthConf (org.gluu.oxtrust.model.OxIDPAuthConf)3 BaseMappingException (org.gluu.persist.exception.mapping.BaseMappingException)3 EncryptionException (org.xdi.util.security.StringEncrypter.EncryptionException)3 GluuAppliance (org.gluu.oxtrust.model.GluuAppliance)2 LdapOxPassportConfiguration (org.xdi.config.oxtrust.LdapOxPassportConfiguration)2 SocketException (java.net.SocketException)1 EntryPersistenceException (org.gluu.persist.exception.mapping.EntryPersistenceException)1 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)1 CacheRefreshAttributeMapping (org.xdi.config.oxtrust.CacheRefreshAttributeMapping)1 CacheRefreshConfiguration (org.xdi.config.oxtrust.CacheRefreshConfiguration)1 CustomScriptType (org.xdi.model.custom.script.CustomScriptType)1 CustomScript (org.xdi.model.custom.script.model.CustomScript)1 MetricType (org.xdi.model.metric.MetricType)1