Search in sources :

Example 26 with LdapEntryManager

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

the class AppInitializer method createCentralLdapEntryManager.

@Produces
@ApplicationScoped
@Named(LDAP_CENTRAL_ENTRY_MANAGER_NAME)
@CentralLdap
public LdapEntryManager createCentralLdapEntryManager() {
    if (this.centralConnectionProvider == null) {
        return null;
    }
    LdapEntryManager centralLdapEntryManager = new LdapEntryManager(new OperationsFacade(this.centralConnectionProvider));
    log.info("Created {}: {}", new Object[] { LDAP_CENTRAL_ENTRY_MANAGER_NAME, centralLdapEntryManager.getLdapOperationService() });
    return centralLdapEntryManager;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) OperationsFacade(org.gluu.site.ldap.OperationsFacade) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) CentralLdap(org.gluu.oxtrust.service.cdi.event.CentralLdap) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 27 with LdapEntryManager

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

the class CacheRefreshTimer method loadSourceServerEntriesWithoutLimits.

private List<GluuSimplePerson> loadSourceServerEntriesWithoutLimits(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection[] sourceServerConnections) {
    Filter customFilter = cacheRefreshService.createFilter(cacheRefreshConfiguration.getCustomLdapFilter());
    String[] keyAttributes = getCompoundKeyAttributes(cacheRefreshConfiguration);
    String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
    String[] keyObjectClasses = getCompoundKeyObjectClasses(cacheRefreshConfiguration);
    String[] sourceAttributes = getSourceAttributes(cacheRefreshConfiguration);
    String[] returnAttributes = ArrayHelper.arrayMerge(keyAttributesWithoutValues, sourceAttributes);
    Set<String> addedDns = new HashSet<String>();
    List<GluuSimplePerson> sourcePersons = new ArrayList<GluuSimplePerson>();
    for (LdapServerConnection sourceServerConnection : sourceServerConnections) {
        String sourceServerName = sourceServerConnection.getSourceServerName();
        LdapEntryManager sourceLdapEntryManager = sourceServerConnection.getLdapEntryManager();
        String[] baseDns = sourceServerConnection.getBaseDns();
        Filter filter = cacheRefreshService.createFilter(keyAttributes, keyObjectClasses, "", customFilter);
        if (log.isTraceEnabled()) {
            log.trace("Using next filter to load entris from source server: {}", filter);
        }
        for (String baseDn : baseDns) {
            List<GluuSimplePerson> currentSourcePersons = sourceLdapEntryManager.findEntries(baseDn, GluuSimplePerson.class, filter, returnAttributes, cacheRefreshConfiguration.getLdapSearchSizeLimit());
            // Add to result and ignore root entry if needed
            for (GluuSimplePerson currentSourcePerson : currentSourcePersons) {
                currentSourcePerson.setSourceServerName(sourceServerName);
                // if (!StringHelper.equalsIgnoreCase(baseDn,
                // currentSourcePerson.getDn())) {
                String currentSourcePersonDn = currentSourcePerson.getDn().toLowerCase();
                if (!addedDns.contains(currentSourcePersonDn)) {
                    sourcePersons.add(currentSourcePerson);
                    addedDns.add(currentSourcePersonDn);
                }
            // }
            }
        }
    }
    return sourcePersons;
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 28 with LdapEntryManager

use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxTrust 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);
    LdapEntryManager ldapCentralEntryManager = ldapCentralEntryManagerInstance.get();
    if (ldapCentralEntryManager != null) {
        closeLdapEntryManager(ldapCentralEntryManager);
    }
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager)

Example 29 with LdapEntryManager

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

the class ConfigurationFactory method loadConfigurationFromLdap.

private Conf loadConfigurationFromLdap(String... returnAttributes) {
    final LdapEntryManager ldapManager = ldapEntryManagerInstance.get();
    final String dn = getLdapConfiguration().getString("oxauth_ConfigurationEntryDN");
    try {
        final Conf conf = ldapManager.find(Conf.class, dn, returnAttributes);
        return conf;
    } catch (LdapMappingException ex) {
        log.error(ex.getMessage());
    }
    return null;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException)

Example 30 with LdapEntryManager

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

the class AppInitializer method getLdapEntryManager.

@Produces
@ApplicationScoped
@Named(LDAP_ENTRY_MANAGER_NAME)
public LdapEntryManager getLdapEntryManager() {
    LdapEntryManager ldapEntryManager = new LdapEntryManager(new OperationsFacade(this.connectionProvider, this.bindConnectionProvider));
    log.info("Created {}: {}", new Object[] { LDAP_ENTRY_MANAGER_NAME, ldapEntryManager.getLdapOperationService() });
    return ldapEntryManager;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) OperationsFacade(org.gluu.site.ldap.OperationsFacade) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

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