use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.
the class FidoDeviceWebService method searchDevices.
private ListViewResponse<BaseScimResource> searchDevices(String userId, String filter, String sortBy, SortOrder sortOrder, int startIndex, int count, String url) throws Exception {
Filter ldapFilter = scimFilterParserService.createLdapFilter(filter, "oxId=*", FidoDeviceResource.class);
log.info("Executing search for fido devices using: ldapfilter '{}', sortBy '{}', sortOrder '{}', startIndex '{}', count '{}'", ldapFilter.toString(), sortBy, sortOrder.getValue(), startIndex, count);
ListViewResponse<GluuCustomFidoDevice> list = ldapEntryManager.findListViewResponse(fidoDeviceService.getDnForFidoDevice(userId, null), GluuCustomFidoDevice.class, ldapFilter, startIndex, count, getMaxCount(), sortBy, sortOrder, null);
List<BaseScimResource> resources = new ArrayList<BaseScimResource>();
for (GluuCustomFidoDevice device : list.getResult()) {
FidoDeviceResource scimDev = new FidoDeviceResource();
transferAttributesToFidoResource(device, scimDev, url, getUserInumFromDN(device.getDn()));
resources.add(scimDev);
}
log.info("Found {} matching entries - returning {}", list.getTotalResults(), list.getResult().size());
ListViewResponse<BaseScimResource> result = new ListViewResponse<BaseScimResource>();
result.setResult(resources);
result.setTotalResults(list.getTotalResults());
return result;
}
use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.
the class TrustService method searchSAMLTrustRelationships.
public List<GluuSAMLTrustRelationship> searchSAMLTrustRelationships(String pattern, int sizeLimit) {
String[] targetArray = new String[] { pattern };
Filter displayNameFilter = Filter.createSubstringFilter(OxTrustConstants.displayName, null, targetArray, null);
Filter descriptionFilter = Filter.createSubstringFilter(OxTrustConstants.description, null, targetArray, null);
Filter inameFilter = Filter.createSubstringFilter(OxTrustConstants.iname, null, targetArray, null);
Filter inumFilter = Filter.createSubstringFilter(OxTrustConstants.inum, null, targetArray, null);
Filter searchFilter = Filter.createORFilter(displayNameFilter, descriptionFilter, inameFilter, inumFilter);
List<GluuSAMLTrustRelationship> result = ldapEntryManager.findEntries(getDnForTrustRelationShip(null), GluuSAMLTrustRelationship.class, searchFilter, sizeLimit);
return result;
}
use of org.gluu.search.filter.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<UmaScopeDescription> 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<UmaScopeDescription> result = ldapEntryManager.findEntries(getDnForScopeDescription(null), UmaScopeDescription.class, searchFilter, sizeLimit);
return result;
}
use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.
the class Scim2GroupService method searchGroups.
public ListViewResponse<BaseScimResource> searchGroups(String filter, String sortBy, SortOrder sortOrder, int startIndex, int count, String groupsUrl, String usersUrl, int maxCount) throws Exception {
Filter ldapFilter = scimFilterParserService.createLdapFilter(filter, "inum=*", GroupResource.class);
log.info("Executing search for groups using: ldapfilter '{}', sortBy '{}', sortOrder '{}', startIndex '{}', count '{}'", ldapFilter.toString(), sortBy, sortOrder.getValue(), startIndex, count);
ListViewResponse<GluuGroup> list = ldapEntryManager.findListViewResponse(groupService.getDnForGroup(null), GluuGroup.class, ldapFilter, startIndex, count, maxCount, sortBy, sortOrder, null);
List<BaseScimResource> resources = new ArrayList<BaseScimResource>();
for (GluuGroup group : list.getResult()) {
GroupResource scimGroup = new GroupResource();
transferAttributesToGroupResource(group, scimGroup, groupsUrl, usersUrl);
// TODO: Delete this IF in the future - added for backwards compatibility with SCIM-Client <= 3.1.2.
if (scimGroup.getMembers() == null)
scimGroup.setMembers(new HashSet<Member>());
resources.add(scimGroup);
}
log.info("Found {} matching entries - returning {}", list.getTotalResults(), list.getResult().size());
ListViewResponse<BaseScimResource> result = new ListViewResponse<BaseScimResource>();
result.setResult(resources);
result.setTotalResults(list.getTotalResults());
return result;
}
use of org.gluu.search.filter.Filter in project oxCore by GluuFederation.
the class LdapEntryManager method findEntries.
@Override
public <T> List<T> findEntries(String baseDN, Class<T> entryClass, Filter filter, SearchScope scope, String[] ldapReturnAttributes, BatchOperation<T> batchOperation, int startIndex, int sizeLimit, int chunkSize) {
if (StringHelper.isEmptyString(baseDN)) {
throw new MappingException("Base DN to find entries is null");
}
// Check entry class
checkEntryClass(entryClass, false);
String[] objectClasses = getTypeObjectClasses(entryClass);
List<PropertyAnnotation> propertiesAnnotations = getEntryPropertyAnnotations(entryClass);
String[] currentLdapReturnAttributes = ldapReturnAttributes;
if (ArrayHelper.isEmpty(currentLdapReturnAttributes)) {
currentLdapReturnAttributes = getLdapAttributes(null, propertiesAnnotations, false);
}
// Find entries
Filter searchFilter;
if (objectClasses.length > 0) {
searchFilter = addObjectClassFilter(filter, objectClasses);
} else {
searchFilter = filter;
}
SearchResult searchResult = null;
try {
LdapBatchOperationWraper<T> batchOperationWraper = new LdapBatchOperationWraper<T>(batchOperation, this, entryClass, propertiesAnnotations);
searchResult = this.ldapOperationService.search(baseDN, toLdapFilter(searchFilter), toLdapSearchScope(scope), batchOperationWraper, startIndex, chunkSize, sizeLimit, null, currentLdapReturnAttributes);
if (!ResultCode.SUCCESS.equals(searchResult.getResultCode())) {
throw new EntryPersistenceException(String.format("Failed to find entries with baseDN: %s, filter: %s", baseDN, searchFilter));
}
} catch (Exception ex) {
throw new EntryPersistenceException(String.format("Failed to find entries with baseDN: %s, filter: %s", baseDN, searchFilter), ex);
}
if (searchResult.getEntryCount() == 0) {
return new ArrayList<T>(0);
}
List<T> entries = createEntities(entryClass, propertiesAnnotations, searchResult.getSearchEntries().toArray(new SearchResultEntry[searchResult.getSearchEntries().size()]));
// Default sort if needed
sortEntriesIfNeeded(entryClass, entries);
return entries;
}
Aggregations