Search in sources :

Example 26 with Filter

use of com.unboundid.ldap.sdk.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<ScopeDescription> 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<ScopeDescription> result = ldapEntryManager.findEntries(getDnForScopeDescription(null), ScopeDescription.class, searchFilter, 0, sizeLimit);
    return result;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ScopeDescription(org.xdi.oxauth.model.uma.persistence.ScopeDescription)

Example 27 with Filter

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

the class CacheRefreshTimer method loadInumServerEntries.

private List<GluuInumMap> loadInumServerEntries(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection inumDbServerConnection) {
    LdapEntryManager inumDbldapEntryManager = inumDbServerConnection.getLdapEntryManager();
    String inumbaseDn = inumDbServerConnection.getBaseDns()[0];
    Filter filterObjectClass = Filter.createEqualityFilter(OxTrustConstants.objectClass, OxTrustConstants.objectClassInumMap);
    Filter filterStatus = Filter.createNOTFilter(Filter.createEqualityFilter(OxTrustConstants.gluuStatus, GluuStatus.INACTIVE.getValue()));
    Filter filter = Filter.createANDFilter(filterObjectClass, filterStatus);
    return inumDbldapEntryManager.findEntries(inumbaseDn, GluuInumMap.class, filter, null, cacheRefreshConfiguration.getLdapSearchSizeLimit());
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) Filter(com.unboundid.ldap.sdk.Filter)

Example 28 with Filter

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

the class CacheRefreshTimer method loadSourceServerEntries.

private List<GluuSimplePerson> loadSourceServerEntries(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection[] sourceServerConnections) {
    Filter customFilter = cacheRefreshService.createFilter(cacheRefreshConfiguration.getCustomLdapFilter());
    String[] keyAttributes = getCompoundKeyAttributes(cacheRefreshConfiguration);
    String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
    String[] keyObjectClasses = getCompoundKeyObjectClasses(cacheRefreshConfiguration);
    String[] sourceAttributes = getSourceAttributes(cacheRefreshConfiguration);
    String[] twoLettersArray = createTwoLettersArray();
    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();
        LdapEntryManager sourceLdapEntryManager = sourceServerConnection.getLdapEntryManager();
        String[] baseDns = sourceServerConnection.getBaseDns();
        for (String keyAttributeStart : twoLettersArray) {
            Filter filter = cacheRefreshService.createFilter(keyAttributes, keyObjectClasses, keyAttributeStart, customFilter);
            if (log.isDebugEnabled()) {
                log.trace("Using next filter to load entris from source server: {}", filter);
            }
            for (String baseDn : baseDns) {
                List<GluuSimplePerson> currentSourcePersons = sourceLdapEntryManager.findEntries(baseDn, GluuSimplePerson.class, filter, returnAttributes, 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;
}
Also used : GluuSimplePerson(org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson) LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 29 with Filter

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

the class AsimbaService method searchRequestorPools.

/**
    * Search by pattern
    * 
    * @param pattern Pattern
    * @param sizeLimit Maximum count of results
    * @return List of scopes
    * @throws Exception
    */
public List<RequestorPoolEntry> searchRequestorPools(String pattern, int sizeLimit) throws Exception {
    // filter
    String[] targetArray = new String[] { pattern };
    Filter idFilter = Filter.createSubstringFilter(OxTrustConstants.uniqueIdentifier, null, targetArray, null);
    Filter friendlyNameFilter = Filter.createSubstringFilter(OxTrustConstants.friendlyName, null, targetArray, null);
    Filter descriptionFilter = Filter.createSubstringFilter(OxTrustConstants.description, null, targetArray, null);
    Filter inameFilter = Filter.createSubstringFilter(OxTrustConstants.iname, null, targetArray, null);
    Filter searchFilter = Filter.createORFilter(idFilter, friendlyNameFilter, descriptionFilter, inameFilter);
    // search
    List<LDAPRequestorPoolEntry> entries = ldapEntryManager.findEntries(getDnForLDAPRequestorPoolEntry(null), LDAPRequestorPoolEntry.class, searchFilter, sizeLimit);
    // convert result
    List<RequestorPoolEntry> ret = new ArrayList<RequestorPoolEntry>();
    for (LDAPRequestorPoolEntry entry : entries) {
        ret.add(entry.getEntry());
    }
    return ret;
}
Also used : LDAPRequestorPoolEntry(org.gluu.asimba.util.ldap.sp.LDAPRequestorPoolEntry) RequestorPoolEntry(org.gluu.asimba.util.ldap.sp.RequestorPoolEntry) Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) LDAPRequestorPoolEntry(org.gluu.asimba.util.ldap.sp.LDAPRequestorPoolEntry)

Example 30 with Filter

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

the class AttributeService method getAllActiveAtributesImpl.

/**
	 * @return
	 * @throws LDAPException
	 */
private List<GluuAttribute> getAllActiveAtributesImpl(GluuUserRole gluuUserRole) {
    Filter filter = Filter.createEqualityFilter("gluuStatus", "active");
    List<GluuAttribute> attributeList = ldapEntryManager.findEntries(getDnForAttribute(null), GluuAttribute.class, filter);
    String customOrigin = getCustomOrigin();
    String[] objectClassTypes = appConfiguration.getPersonObjectClassTypes();
    log.debug("objectClassTypes={}", Arrays.toString(objectClassTypes));
    List<GluuAttribute> returnAttributeList = new ArrayList<GluuAttribute>();
    for (GluuAttribute attribute : attributeList) {
        if (StringHelper.equalsIgnoreCase(attribute.getOrigin(), appConfiguration.getPersonCustomObjectClass()) && (GluuUserRole.ADMIN == gluuUserRole)) {
            attribute.setCustom(true);
            returnAttributeList.add(attribute);
            continue;
        }
        for (String objectClassType : objectClassTypes) {
            if (attribute.getOrigin().equals(objectClassType) && ((attribute.allowViewBy(gluuUserRole) || attribute.allowEditBy(gluuUserRole)))) {
                attribute.setCustom(customOrigin.equals(attribute.getOrigin()));
                returnAttributeList.add(attribute);
                break;
            }
        }
    }
    return returnAttributeList;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute)

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