Search in sources :

Example 26 with Filter

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

the class UserService method getUsersByAttribute.

public List<User> getUsersByAttribute(String attributeName, Object attributeValue, Boolean multiValued, int limit) {
    log.debug("Getting user information from LDAP: attributeName = '{}', attributeValue = '{}'", attributeName, attributeValue);
    if (StringHelper.isEmpty(attributeName) || (attributeValue == null)) {
        return null;
    }
    Filter filter = Filter.createEqualityFilter(attributeName, attributeValue);
    if (multiValued != null) {
        filter.multiValued(multiValued);
    }
    List<User> entries = persistenceEntryManager.findEntries(getPeopleBaseDn(), User.class, filter, limit);
    log.debug("Found '{}' entries", entries.size());
    return entries;
}
Also used : User(org.gluu.oxauth.model.common.User) Filter(org.gluu.search.filter.Filter)

Example 27 with Filter

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

the class UserService method getUsersWithPersistentJwts.

// 
// // this method must be called only if app mode = MEMORY, in ldap case it's anyway persisted in ldap.
// public boolean saveLongLivedToken(String userId, PersistentJwt longLivedToken) {
// log.debug("Saving long-lived access token: userId = {}", userId);
// boolean succeed = false;
// 
// User user = getUser(userId);
// if (user != null) {
// int nTokens = 0;
// if (user.getOxAuthPersistentJwt() != null) {
// nTokens = user.getOxAuthPersistentJwt().length;
// }
// nTokens++;
// String[] persistentJwts = new String[nTokens];
// if (user.getOxAuthPersistentJwt() != null) {
// for (int i = 0; i < user.getOxAuthPersistentJwt().length; i++) {
// persistentJwts[i] = user.getOxAuthPersistentJwt()[i];
// }
// }
// persistentJwts[nTokens - 1] = longLivedToken.toString();
// 
// user.setOxAuthPersistentJwt(persistentJwts);
// ldapEntryManager.merge(user);
// succeed = true;
// }
// 
// return succeed;
// }
public List<User> getUsersWithPersistentJwts() {
    String baseDN = getPeopleBaseDn();
    Filter filter = Filter.createPresenceFilter("oxAuthPersistentJWT");
    return persistenceEntryManager.findEntries(baseDN, User.class, filter);
}
Also used : Filter(org.gluu.search.filter.Filter)

Example 28 with Filter

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

the class RegistrationService method getRegisterRequestMessageByRequestId.

public RegisterRequestMessageLdap getRegisterRequestMessageByRequestId(String requestId) {
    String baseDn = getDnForRegisterRequestMessage(null);
    Filter requestIdFilter = Filter.createEqualityFilter("oxRequestId", requestId);
    List<RegisterRequestMessageLdap> registerRequestMessagesLdap = ldapEntryManager.findEntries(baseDn, RegisterRequestMessageLdap.class, requestIdFilter);
    if ((registerRequestMessagesLdap == null) || registerRequestMessagesLdap.isEmpty()) {
        return null;
    }
    return registerRequestMessagesLdap.get(0);
}
Also used : Filter(org.gluu.search.filter.Filter)

Example 29 with Filter

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

the class UmaScopeService method createAnyFilterByIds.

private Filter createAnyFilterByIds(List<String> scopeIds) {
    if (scopeIds != null && !scopeIds.isEmpty()) {
        List<Filter> filters = new ArrayList<Filter>();
        for (String url : scopeIds) {
            Filter filter = Filter.createEqualityFilter("oxId", url);
            filters.add(filter);
        }
        Filter filter = Filter.createORFilter(filters.toArray(new Filter[0]));
        log.trace("Uma scope ids: " + scopeIds + ", ldapFilter: " + filter);
        return filter;
    }
    return null;
}
Also used : Filter(org.gluu.search.filter.Filter) ArrayList(java.util.ArrayList)

Example 30 with Filter

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

the class UmaPctService method getByCode.

public UmaPCT getByCode(String pctCode) {
    try {
        final Filter filter = Filter.createEqualityFilter("tknCde", pctCode);
        final List<UmaPCT> entries = ldapEntryManager.findEntries(branchBaseDn(), UmaPCT.class, filter);
        if (entries != null && !entries.isEmpty()) {
            return entries.get(0);
        } else {
            log.error("Failed to find PCT by code: " + pctCode);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return null;
}
Also used : UmaPCT(org.gluu.oxauth.uma.authorization.UmaPCT) Filter(org.gluu.search.filter.Filter)

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