use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.
the class CacheRefreshTimer method loadSourceServerEntriesWithoutLimits.
private List<GluuSimplePerson> loadSourceServerEntriesWithoutLimits(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection[] sourceServerConnections) throws SearchException {
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();
PersistenceEntryManager sourcePersistenceEntryManager = sourceServerConnection.getPersistenceEntryManager();
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 = sourcePersistenceEntryManager.findEntries(baseDn, GluuSimplePerson.class, filter, SearchScope.SUB, returnAttributes, null, 0, 0, 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.search.filter.Filter in project oxTrust by GluuFederation.
the class PasswordResetService method getExpiredPasswordResetRequests.
public List<PasswordResetRequest> getExpiredPasswordResetRequests(BatchOperation<PasswordResetRequest> batchOperation, Date expirationDate, String[] returnAttributes, int sizeLimit, int chunkSize) {
final String baseDn = getDnForPasswordResetRequest(null);
Filter expirationFilter = Filter.createLessOrEqualFilter("creationDate", ldapEntryManager.encodeTime(baseDn, expirationDate));
List<PasswordResetRequest> passwordResetRequests = ldapEntryManager.findEntries(baseDn, PasswordResetRequest.class, expirationFilter, SearchScope.SUB, returnAttributes, batchOperation, 0, sizeLimit, chunkSize);
return passwordResetRequests;
}
use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.
the class PushDeviceService method findPushDevices.
/**
* Search oxPush devices by pattern
*
* @param pattern Pattern
* @param sizeLimit Maximum count of results
* @return List of oxPush devices
*/
public List<PushDevice> findPushDevices(String pattern, int sizeLimit) {
String[] targetArray = new String[] { pattern };
Filter oxIdFilter = Filter.createSubstringFilter("oxId", null, targetArray, null);
Filter oxTypeFilter = Filter.createSubstringFilter("oxType", null, targetArray, null);
Filter oxAuthUserIdFilter = Filter.createSubstringFilter("oxAuthUserId", null, targetArray, null);
Filter searchFilter = Filter.createORFilter(oxIdFilter, oxTypeFilter, oxAuthUserIdFilter);
List<PushDevice> result = ldapEntryManager.findEntries(getDnForPushDevice(null), PushDevice.class, searchFilter, sizeLimit);
return result;
}
use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.
the class FidoDeviceService method getGluuCustomFidoDeviceById.
@Override
public GluuCustomFidoDevice getGluuCustomFidoDeviceById(String userId, String id) {
GluuCustomFidoDevice gluuCustomFidoDevice = null;
try {
String dn = getDnForFidoDevice(userId, id);
if (StringUtils.isNotEmpty(userId))
gluuCustomFidoDevice = ldapEntryManager.find(GluuCustomFidoDevice.class, dn);
else {
Filter filter = Filter.createEqualityFilter("oxId", id);
gluuCustomFidoDevice = ldapEntryManager.findEntries(dn, GluuCustomFidoDevice.class, filter).get(0);
}
} catch (Exception e) {
log.error("Failed to find device by id " + id, e);
}
return gluuCustomFidoDevice;
}
use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.
the class GroupService method isMemberOrOwner.
/*
* (non-Javadoc)
*
* @see
* org.gluu.oxtrust.ldap.service.IGroupService#isMemberOrOwner(java.lang.String,
* java.lang.String)
*/
@Override
public boolean isMemberOrOwner(String groupDN, String personDN) {
Filter ownerFilter = Filter.createEqualityFilter(OxTrustConstants.owner, personDN);
Filter memberFilter = Filter.createEqualityFilter(OxTrustConstants.member, personDN);
Filter searchFilter = Filter.createORFilter(ownerFilter, memberFilter);
boolean isMemberOrOwner = false;
try {
isMemberOrOwner = persistenceEntryManager.findEntries(groupDN, GluuGroup.class, searchFilter, 1).size() > 0;
} catch (EntryPersistenceException ex) {
log.error("Failed to determine if person '{}' memeber or owner of group '{}'", personDN, groupDN, ex);
}
return isMemberOrOwner;
}
Aggregations