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