Search in sources :

Example 6 with Filter

use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.

the class ScopeService method handleInternalScopes.

private List<String> handleInternalScopes(List<String> p_scopeUrls, List<String> result) {
    List<String> notProcessedScopeUrls = new ArrayList<String>(p_scopeUrls);
    try {
        final Filter filter = Filter.create(String.format("&(oxType=%s)", InternalExternal.INTERNAL.getValue()));
        final List<ScopeDescription> entries = ldapEntryManager.findEntries(baseDn(), ScopeDescription.class, filter);
        if (entries != null && !entries.isEmpty()) {
            for (String scopeUrl : p_scopeUrls) {
                for (ScopeDescription scopeDescription : entries) {
                    final String internalScopeUrl = getInternalScopeUrl(scopeDescription);
                    if (internalScopeUrl.equals(scopeUrl) && !result.contains(internalScopeUrl)) {
                        result.add(scopeDescription.getDn());
                        notProcessedScopeUrls.remove(scopeUrl);
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return notProcessedScopeUrls;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) WebApplicationException(javax.ws.rs.WebApplicationException) LDAPException(com.unboundid.ldap.sdk.LDAPException) ScopeDescription(org.xdi.oxauth.model.uma.persistence.ScopeDescription)

Example 7 with Filter

use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.

the class ScopeService method getScopesByUrls.

public List<ScopeDescription> getScopesByUrls(List<String> p_scopeUrls) {
    List<ScopeDescription> scopes = new ArrayList<ScopeDescription>();
    try {
        // external scopes
        Filter filter = createAnyFilterByUrls(p_scopeUrls);
        if (filter != null) {
            final List<ScopeDescription> entries = ldapEntryManager.findEntries(baseDn(), ScopeDescription.class, filter);
            if (entries != null) {
                scopes.addAll(entries);
            }
        }
        // internal scopes
        filter = Filter.create(String.format("&(oxType=%s)", InternalExternal.INTERNAL.getValue()));
        final List<ScopeDescription> entries = ldapEntryManager.findEntries(baseDn(), ScopeDescription.class, filter);
        if (entries != null && !entries.isEmpty()) {
            for (String scopeUrl : p_scopeUrls) {
                for (ScopeDescription scopeDescription : entries) {
                    final String internalScopeUrl = getInternalScopeUrl(scopeDescription);
                    if (internalScopeUrl.equals(scopeUrl) && !scopes.contains(internalScopeUrl)) {
                        scopes.add(scopeDescription);
                    }
                }
            }
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return scopes;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) WebApplicationException(javax.ws.rs.WebApplicationException) LDAPException(com.unboundid.ldap.sdk.LDAPException) ScopeDescription(org.xdi.oxauth.model.uma.persistence.ScopeDescription)

Example 8 with Filter

use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.

the class UserService method getUser.

public User getUser(String userId, String... returnAttributes) {
    log.debug("Getting user information from LDAP: userId = {}", userId);
    if (StringHelper.isEmpty(userId)) {
        return null;
    }
    Filter userUidFilter = Filter.createEqualityFilter("uid", userId);
    List<User> entries = ldapEntryManager.findEntries(staticConfiguration.getBaseDn().getPeople(), User.class, returnAttributes, userUidFilter);
    log.debug("Found {} entries for user id = {}", entries.size(), userId);
    if (entries.size() > 0) {
        return entries.get(0);
    } else {
        return null;
    }
}
Also used : User(org.xdi.oxauth.model.common.User) Filter(com.unboundid.ldap.sdk.Filter)

Example 9 with Filter

use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.

the class UserService method getUsersWithPersistentJwts.

public List<User> getUsersWithPersistentJwts() {
    String baseDN = staticConfiguration.getBaseDn().getPeople();
    Filter filter = Filter.createPresenceFilter("oxAuthPersistentJWT");
    return ldapEntryManager.findEntries(baseDN, User.class, filter);
}
Also used : Filter(com.unboundid.ldap.sdk.Filter)

Example 10 with Filter

use of com.unboundid.ldap.sdk.Filter in project oxAuth by GluuFederation.

the class ResourceSetPermissionManager method getResourceSetPermissionByTicket.

@Override
public ResourceSetPermission getResourceSetPermissionByTicket(String p_ticket) {
    try {
        final String baseDn = staticConfiguration.getBaseDn().getClients();
        final Filter filter = Filter.create(String.format("&(oxTicket=%s)", p_ticket));
        final List<ResourceSetPermission> entries = ldapEntryManager.findEntries(baseDn, ResourceSetPermission.class, filter);
        if (entries != null && !entries.isEmpty()) {
            return entries.get(0);
        }
    } catch (Exception e) {
        log.trace(e.getMessage(), e);
    }
    return null;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ResourceSetPermission(org.xdi.oxauth.model.uma.persistence.ResourceSetPermission) LDAPException(com.unboundid.ldap.sdk.LDAPException)

Aggregations

Filter (com.unboundid.ldap.sdk.Filter)61 ArrayList (java.util.ArrayList)21 LDAPException (com.unboundid.ldap.sdk.LDAPException)9 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)6 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)6 LinkedHashSet (java.util.LinkedHashSet)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 GluuGroup (org.gluu.oxtrust.model.GluuGroup)4 GluuAttribute (org.xdi.model.GluuAttribute)4 ScopeDescription (org.xdi.oxauth.model.uma.persistence.ScopeDescription)4 List (java.util.List)3 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)3 HashSet (java.util.HashSet)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2 GluuSimplePerson (org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson)2 GluuCustomFidoDevice (org.gluu.oxtrust.model.fido.GluuCustomFidoDevice)2 DEFAULT_COUNT (org.gluu.oxtrust.model.scim2.Constants.DEFAULT_COUNT)2 CustomAttribute (org.xdi.ldap.model.CustomAttribute)2 LdapDummyEntry (org.xdi.ldap.model.LdapDummyEntry)2 SortOrder (org.xdi.ldap.model.SortOrder)2