use of com.unboundid.ldap.sdk.Filter in project oxTrust by GluuFederation.
the class ScopeDescriptionService method findScopeDescriptions.
/**
* Search scope descriptions by pattern
*
* @param pattern Pattern
* @param sizeLimit Maximum count of results
* @return List of scope descriptions
*/
public List<ScopeDescription> findScopeDescriptions(String pattern, int sizeLimit) {
String[] targetArray = new String[] { pattern };
Filter oxIdFilter = Filter.createSubstringFilter("oxId", null, targetArray, null);
Filter displayNameFilter = Filter.createSubstringFilter(OxTrustConstants.displayName, null, targetArray, null);
Filter searchFilter = Filter.createORFilter(oxIdFilter, displayNameFilter);
List<ScopeDescription> result = ldapEntryManager.findEntries(getDnForScopeDescription(null), ScopeDescription.class, searchFilter, 0, sizeLimit);
return result;
}
use of com.unboundid.ldap.sdk.Filter in project oxTrust by GluuFederation.
the class CacheRefreshTimer method loadInumServerEntries.
private List<GluuInumMap> loadInumServerEntries(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection inumDbServerConnection) {
LdapEntryManager inumDbldapEntryManager = inumDbServerConnection.getLdapEntryManager();
String inumbaseDn = inumDbServerConnection.getBaseDns()[0];
Filter filterObjectClass = Filter.createEqualityFilter(OxTrustConstants.objectClass, OxTrustConstants.objectClassInumMap);
Filter filterStatus = Filter.createNOTFilter(Filter.createEqualityFilter(OxTrustConstants.gluuStatus, GluuStatus.INACTIVE.getValue()));
Filter filter = Filter.createANDFilter(filterObjectClass, filterStatus);
return inumDbldapEntryManager.findEntries(inumbaseDn, GluuInumMap.class, filter, null, cacheRefreshConfiguration.getLdapSearchSizeLimit());
}
use of com.unboundid.ldap.sdk.Filter in project oxTrust by GluuFederation.
the class CacheRefreshTimer method loadSourceServerEntries.
private List<GluuSimplePerson> loadSourceServerEntries(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[] twoLettersArray = createTwoLettersArray();
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();
for (String keyAttributeStart : twoLettersArray) {
Filter filter = cacheRefreshService.createFilter(keyAttributes, keyObjectClasses, keyAttributeStart, customFilter);
if (log.isDebugEnabled()) {
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 searchRequestorPools.
/**
* Search by pattern
*
* @param pattern Pattern
* @param sizeLimit Maximum count of results
* @return List of scopes
* @throws Exception
*/
public List<RequestorPoolEntry> searchRequestorPools(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
List<LDAPRequestorPoolEntry> entries = ldapEntryManager.findEntries(getDnForLDAPRequestorPoolEntry(null), LDAPRequestorPoolEntry.class, searchFilter, sizeLimit);
// convert result
List<RequestorPoolEntry> ret = new ArrayList<RequestorPoolEntry>();
for (LDAPRequestorPoolEntry entry : entries) {
ret.add(entry.getEntry());
}
return ret;
}
use of com.unboundid.ldap.sdk.Filter in project oxTrust by GluuFederation.
the class AttributeService method getAllActiveAtributesImpl.
/**
* @return
* @throws LDAPException
*/
private List<GluuAttribute> getAllActiveAtributesImpl(GluuUserRole gluuUserRole) {
Filter filter = Filter.createEqualityFilter("gluuStatus", "active");
List<GluuAttribute> attributeList = ldapEntryManager.findEntries(getDnForAttribute(null), GluuAttribute.class, filter);
String customOrigin = getCustomOrigin();
String[] objectClassTypes = appConfiguration.getPersonObjectClassTypes();
log.debug("objectClassTypes={}", Arrays.toString(objectClassTypes));
List<GluuAttribute> returnAttributeList = new ArrayList<GluuAttribute>();
for (GluuAttribute attribute : attributeList) {
if (StringHelper.equalsIgnoreCase(attribute.getOrigin(), appConfiguration.getPersonCustomObjectClass()) && (GluuUserRole.ADMIN == gluuUserRole)) {
attribute.setCustom(true);
returnAttributeList.add(attribute);
continue;
}
for (String objectClassType : objectClassTypes) {
if (attribute.getOrigin().equals(objectClassType) && ((attribute.allowViewBy(gluuUserRole) || attribute.allowEditBy(gluuUserRole)))) {
attribute.setCustom(customOrigin.equals(attribute.getOrigin()));
returnAttributeList.add(attribute);
break;
}
}
}
return returnAttributeList;
}
Aggregations