Search in sources :

Example 96 with Filter

use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.

the class GroupService method searchGroups.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.gluu.oxtrust.ldap.service.IGroupService#searchGroups(java.lang.String,
	 * int)
	 */
@Override
public List<GluuGroup> searchGroups(String pattern, int sizeLimit) throws Exception {
    String[] targetArray = new String[] { pattern };
    Filter displayNameFilter = Filter.createSubstringFilter(OxTrustConstants.displayName, null, targetArray, null);
    Filter descriptionFilter = Filter.createSubstringFilter(OxTrustConstants.description, null, targetArray, null);
    Filter searchFilter = Filter.createORFilter(displayNameFilter, descriptionFilter);
    return persistenceEntryManager.findEntries(getDnForGroup(null), GluuGroup.class, searchFilter, sizeLimit);
}
Also used : Filter(org.gluu.search.filter.Filter)

Example 97 with Filter

use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.

the class Fido2DeviceService method getFido2DeviceById.

public GluuFido2Device getFido2DeviceById(String userId, String id) {
    GluuFido2Device f2d = null;
    try {
        String dn = getDnForFido2Device(id, userId);
        if (StringUtils.isNotEmpty(userId)) {
            f2d = ldapEntryManager.find(GluuFido2Device.class, dn);
        } else {
            Filter filter = Filter.createEqualityFilter("oxId", id);
            f2d = ldapEntryManager.findEntries(dn, GluuFido2Device.class, filter).get(0);
        }
    } catch (Exception e) {
        log.error("Failed to find Fido 2 device with id " + id, e);
    }
    return f2d;
}
Also used : Filter(org.gluu.search.filter.Filter) GluuFido2Device(org.gluu.oxtrust.model.GluuFido2Device) EntryPersistenceException(org.gluu.persist.exception.EntryPersistenceException)

Example 98 with Filter

use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.

the class PersonService method getPersonsByUid.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.gluu.oxtrust.ldap.service.IPersonService#getPersonsByUid(java.lang.
	 * String)
	 */
@Override
public List<GluuCustomPerson> getPersonsByUid(String uid, String... returnAttributes) {
    log.debug("Getting user information from DB: userId = {}", uid);
    if (StringHelper.isEmpty(uid)) {
        return null;
    }
    String personDn = getDnForPerson(null);
    Filter userUidFilter;
    if (dataSourceTypeService.isSpanner(personDn)) {
        userUidFilter = Filter.createEqualityFilter(OxConstants.UID, StringHelper.toLowerCase(uid));
    } else {
        userUidFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter(OxConstants.UID), StringHelper.toLowerCase(uid));
    }
    List<GluuCustomPerson> entries = persistenceEntryManager.findEntries(personDn, GluuCustomPerson.class, userUidFilter, returnAttributes);
    log.debug("Found {} entries for userId = {}", entries.size(), uid);
    return entries;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) Filter(org.gluu.search.filter.Filter)

Example 99 with Filter

use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.

the class PersonService method buildFilter.

private Filter buildFilter(String pattern) {
    String[] targetArray = new String[] { pattern };
    Filter uidFilter = Filter.createSubstringFilter(OxConstants.UID, null, targetArray, null);
    Filter mailFilter = Filter.createSubstringFilter(OxTrustConstants.mail, null, targetArray, null);
    Filter nameFilter = Filter.createSubstringFilter(OxTrustConstants.displayName, null, targetArray, null);
    Filter ppidFilter = Filter.createSubstringFilter(OxTrustConstants.ppid, null, targetArray, null);
    Filter inumFilter = Filter.createSubstringFilter(OxTrustConstants.inum, null, targetArray, null);
    Filter snFilter = Filter.createSubstringFilter(OxTrustConstants.sn, null, targetArray, null);
    Filter searchFilter = Filter.createORFilter(uidFilter, mailFilter, nameFilter, snFilter, inumFilter, ppidFilter);
    return searchFilter;
}
Also used : Filter(org.gluu.search.filter.Filter)

Example 100 with Filter

use of org.gluu.search.filter.Filter in project oxTrust by GluuFederation.

the class PersonService method getUserByUid.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.gluu.oxtrust.ldap.service.IPersonService#getUserByUid(java.lang.String)
	 */
@Override
public User getUserByUid(String uid) {
    String personDn = getDnForPerson(null);
    Filter userUidFilter;
    if (dataSourceTypeService.isSpanner(personDn)) {
        userUidFilter = Filter.createEqualityFilter(OxConstants.UID, StringHelper.toLowerCase(uid));
    } else {
        userUidFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter(OxConstants.UID), StringHelper.toLowerCase(uid));
    }
    List<SimplePerson> users = persistenceEntryManager.findEntries(personDn, SimplePerson.class, userUidFilter, 1);
    if ((users != null) && (users.size() > 0)) {
        return persistenceEntryManager.find(User.class, users.get(0).getDn());
    }
    return null;
}
Also used : Filter(org.gluu.search.filter.Filter) SimplePerson(org.gluu.oxtrust.model.SimplePerson)

Aggregations

Filter (org.gluu.search.filter.Filter)122 ArrayList (java.util.ArrayList)34 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)9 EntryPersistenceException (org.gluu.persist.exception.mapping.EntryPersistenceException)7 MappingException (org.gluu.persist.exception.mapping.MappingException)7 EntryPersistenceException (org.gluu.persist.exception.EntryPersistenceException)6 SearchException (org.gluu.persist.exception.operation.SearchException)6 List (java.util.List)5 GluuAttribute (org.gluu.model.GluuAttribute)5 PropertyAnnotation (org.gluu.persist.model.PropertyAnnotation)5 SearchResult (com.unboundid.ldap.sdk.SearchResult)4 ParseException (java.text.ParseException)4 GluuGroup (org.gluu.oxtrust.model.GluuGroup)4 PersistenceEntryManager (org.gluu.persist.PersistenceEntryManager)4 AuthenticationException (org.gluu.persist.exception.operation.AuthenticationException)4 ConnectionException (org.gluu.persist.exception.operation.ConnectionException)4 SearchScopeException (org.gluu.persist.exception.operation.SearchScopeException)4 GluuAttribute (org.xdi.model.GluuAttribute)4 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)3 Date (java.util.Date)3