Search in sources :

Example 1 with GluuLdapConfiguration

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

the class AppInitializer method reloadConfiguration.

private void reloadConfiguration() {
    PersistenceEntryManager localPersistenceEntryManager = persistenceEntryManagerInstance.get();
    log.trace("Attempting to use {}: {}", ApplicationFactory.PERSISTENCE_ENTRY_MANAGER_NAME, localPersistenceEntryManager.getOperationService());
    GluuConfiguration newConfiguration = loadConfiguration(localPersistenceEntryManager, "oxIDPAuthentication", "oxAuthenticationMode");
    List<GluuLdapConfiguration> newPersistenceAuthConfigs = loadPersistenceAuthConfigs(newConfiguration);
    if (!this.persistenceAuthConfigs.equals(newPersistenceAuthConfigs)) {
        recreatePersistenceAuthEntryManagers(newPersistenceAuthConfigs);
        this.persistenceAuthConfigs = newPersistenceAuthConfigs;
        event.select(ReloadAuthScript.Literal.INSTANCE).fire(ExternalAuthenticationService.MODIFIED_INTERNAL_TYPES_EVENT_TYPE);
    }
    setDefaultAuthenticationMethod(newConfiguration);
}
Also used : PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) GluuConfiguration(org.oxauth.persistence.model.configuration.GluuConfiguration) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 2 with GluuLdapConfiguration

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

the class AppInitializer method recreatePersistenceAuthEntryManagers.

public void recreatePersistenceAuthEntryManagers(List<GluuLdapConfiguration> newPersistenceAuthConfigs) {
    // Get existing application scoped instance
    List<PersistenceEntryManager> oldPersistenceAuthEntryManagers = CdiUtil.getContextBean(beanManager, new ParameterizedTypeImpl(List.class, PersistenceEntryManager.class), ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME);
    // Recreate components
    this.persistenceAuthConfigs = newPersistenceAuthConfigs;
    // Close existing connections
    closePersistenceEntryManagers(oldPersistenceAuthEntryManagers);
    // Destroy old Ldap auth entry managers
    for (PersistenceEntryManager oldPersistenceAuthEntryManager : oldPersistenceAuthEntryManagers) {
        log.debug("Attempting to destroy {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, oldPersistenceAuthEntryManager);
        oldPersistenceAuthEntryManager.destroy();
        log.debug("Destroyed {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, oldPersistenceAuthEntryManager);
        externalPersistenceExtensionService.executePersistenceExtensionAfterDestroy(oldPersistenceAuthEntryManager);
    }
    // Force to create new Ldap auth entry managers bean
    List<PersistenceEntryManager> persistenceAuthEntryManagers = persistenceAuthEntryManagerInstance.get();
    persistenceAuthEntryManagerInstance.destroy(persistenceAuthEntryManagers);
    log.info("Recreated instance {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, persistenceAuthEntryManagers);
    // Force to create new auth configuration bean
    List<GluuLdapConfiguration> oldPersistenceAuthConfigs = persistenceAuthConfigInstance.get();
    persistenceAuthConfigInstance.destroy(oldPersistenceAuthConfigs);
}
Also used : PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) List(java.util.List) ArrayList(java.util.ArrayList) ParameterizedTypeImpl(org.jboss.weld.util.reflection.ParameterizedTypeImpl) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 3 with GluuLdapConfiguration

use of org.gluu.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);
        PersistenceEntryManager 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, false);
        if (authenticated) {
            return authenticated;
        }
    }
    return false;
}
Also used : PersistenceEntryManager(org.gluu.persist.PersistenceEntryManager) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration)

Example 4 with GluuLdapConfiguration

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

Example 5 with GluuLdapConfiguration

use of org.gluu.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.gluu.config.oxtrust.CacheRefreshConfiguration) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration) CacheRefreshAttributeMapping(org.gluu.config.oxtrust.CacheRefreshAttributeMapping)

Aggregations

GluuLdapConfiguration (org.gluu.model.ldap.GluuLdapConfiguration)23 ArrayList (java.util.ArrayList)6 Operation (io.swagger.v3.oas.annotations.Operation)3 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)3 LdapConfigurationDuplicatedException (org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException)3 OxIDPAuthConf (org.gluu.oxtrust.model.OxIDPAuthConf)3 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)3 PersistenceEntryManager (org.gluu.persist.PersistenceEntryManager)3 BasePersistenceException (org.gluu.persist.exception.BasePersistenceException)3 IOException (java.io.IOException)2 EncryptionException (org.gluu.util.security.StringEncrypter.EncryptionException)2 SocketException (java.net.SocketException)1 List (java.util.List)1 Properties (java.util.Properties)1 CacheRefreshAttributeMapping (org.gluu.config.oxtrust.CacheRefreshAttributeMapping)1 CacheRefreshConfiguration (org.gluu.config.oxtrust.CacheRefreshConfiguration)1 CustomScript (org.gluu.model.custom.script.model.CustomScript)1 ConnectionStatusDTO (org.gluu.oxtrust.api.server.model.ConnectionStatusDTO)1 GluuConfiguration (org.gluu.oxtrust.model.GluuConfiguration)1 LdapConfigurationLookup (org.gluu.oxtrust.util.LdapConfigurationLookup)1