use of com.unboundid.ldap.sdk.Filter in project oxTrust by GluuFederation.
the class CacheRefreshTimer method updateTargetEntriesViaVDS.
private List<String> updateTargetEntriesViaVDS(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection targetServerConnection, Set<String> changedInums) {
List<String> result = new ArrayList<String>();
LdapEntryManager targetLdapEntryManager = targetServerConnection.getLdapEntryManager();
Filter filter = cacheRefreshService.createObjectClassPresenceFilter();
for (String changedInum : changedInums) {
String baseDn = "action=synchronizecache," + personService.getDnForPerson(changedInum);
try {
targetLdapEntryManager.findEntries(baseDn, GluuDummyEntry.class, filter, null, cacheRefreshConfiguration.getLdapSearchSizeLimit());
result.add(changedInum);
log.debug("Updated entry with inum {}", changedInum);
} catch (LdapMappingException ex) {
log.error("Failed to update entry with inum '{}' using baseDN {}", ex, changedInum, baseDn);
}
}
return result;
}
use of com.unboundid.ldap.sdk.Filter 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 com.unboundid.ldap.sdk.Filter in project oxTrust by GluuFederation.
the class AsimbaService method searchIDPs.
/**
* Search by pattern
*
* @param pattern Pattern
* @param sizeLimit Maximum count of results
* @return List of scopes
* @throws Exception
*/
public List<IDPEntry> searchIDPs(String pattern, int sizeLimit) throws Exception {
// filter
String[] targetArray = new String[] { pattern };
Filter idFilter = Filter.createSubstringFilter(OxTrustConstants.uniqueIdentifier, null, targetArray, null);
Filter friendlyNameFilter = Filter.createSubstringFilter(OxTrustConstants.friendlyName, null, targetArray, null);
Filter descriptionFilter = Filter.createSubstringFilter(OxTrustConstants.description, null, targetArray, null);
Filter inameFilter = Filter.createSubstringFilter(OxTrustConstants.iname, null, targetArray, null);
Filter searchFilter = Filter.createORFilter(idFilter, friendlyNameFilter, descriptionFilter, inameFilter);
// search
final List<LdapIDPEntry> entries = ldapEntryManager.findEntries(getDnForLdapIDPEntry(null), LdapIDPEntry.class, searchFilter, sizeLimit);
// convert result
List<IDPEntry> ret = new ArrayList<IDPEntry>();
for (LdapIDPEntry entry : entries) {
ret.add(entry.getEntry());
}
return ret;
}
use of com.unboundid.ldap.sdk.Filter in project oxTrust by GluuFederation.
the class AsimbaService method searchSelectors.
/**
* Search by pattern
*
* @param pattern Pattern
* @param sizeLimit Maximum count of results
* @return List of scopes
* @throws Exception
*/
public List<ApplicationSelectorEntry> searchSelectors(String pattern, int sizeLimit) throws Exception {
// filter
String[] targetArray = new String[] { pattern };
Filter idFilter = Filter.createSubstringFilter(OxTrustConstants.uniqueIdentifier, null, targetArray, null);
Filter friendlyNameFilter = Filter.createSubstringFilter(OxTrustConstants.friendlyName, null, targetArray, null);
Filter descriptionFilter = Filter.createSubstringFilter(OxTrustConstants.description, null, targetArray, null);
Filter inameFilter = Filter.createSubstringFilter(OxTrustConstants.iname, null, targetArray, null);
Filter organizationIdFilter = Filter.createSubstringFilter(OxTrustConstants.organizationId, null, targetArray, null);
Filter searchFilter = Filter.createORFilter(idFilter, friendlyNameFilter, descriptionFilter, inameFilter, organizationIdFilter);
// search
List<LDAPApplicationSelectorEntry> entries = ldapEntryManager.findEntries(getDnForLDAPApplicationSelectorEntry(null), LDAPApplicationSelectorEntry.class, searchFilter, sizeLimit);
// convert result
List<ApplicationSelectorEntry> ret = new ArrayList<ApplicationSelectorEntry>();
for (LDAPApplicationSelectorEntry entry : entries) {
ret.add(entry.getEntry());
}
return ret;
}
use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.
the class InumGenerator method contains.
public boolean contains(String inum, IdType type) {
final String baseDn = baseDn(type);
try {
final Filter filter = Filter.create(String.format("inum=%s", inum));
final List<LdapDummyEntry> entries = ldapEntryManager.findEntries(baseDn, LdapDummyEntry.class, filter);
return entries != null && !entries.isEmpty();
} catch (LDAPException e) {
log.error(e.getMessage(), e);
}
return false;
}
Aggregations