Search in sources :

Example 51 with Filter

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

the class CacheRefreshTimer method updateTargetEntriesViaVDS.

private List<String> updateTargetEntriesViaVDS(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection targetServerConnection, Set<String> changedInums) {
    List<String> result = new ArrayList<String>();
    LdapEntryManager targetLdapEntryManager = targetServerConnection.getLdapEntryManager();
    Filter filter = cacheRefreshService.createObjectClassPresenceFilter();
    for (String changedInum : changedInums) {
        String baseDn = "action=synchronizecache," + personService.getDnForPerson(changedInum);
        try {
            targetLdapEntryManager.findEntries(baseDn, GluuDummyEntry.class, filter, null, cacheRefreshConfiguration.getLdapSearchSizeLimit());
            result.add(changedInum);
            log.debug("Updated entry with inum {}", changedInum);
        } catch (LdapMappingException ex) {
            log.error("Failed to update entry with inum '{}' using baseDN {}", ex, changedInum, baseDn);
        }
    }
    return result;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) Filter(com.unboundid.ldap.sdk.Filter) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException) ArrayList(java.util.ArrayList)

Example 52 with Filter

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

the class CacheRefreshTimer method loadSourceServerEntriesWithoutLimits.

private List<GluuSimplePerson> loadSourceServerEntriesWithoutLimits(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[] 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();
        Filter filter = cacheRefreshService.createFilter(keyAttributes, keyObjectClasses, "", customFilter);
        if (log.isTraceEnabled()) {
            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 53 with Filter

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

the class AsimbaService method searchIDPs.

/**
    * Search by pattern
    * 
    * @param pattern Pattern
    * @param sizeLimit Maximum count of results
    * @return List of scopes
    * @throws Exception
    */
public List<IDPEntry> searchIDPs(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
    final List<LdapIDPEntry> entries = ldapEntryManager.findEntries(getDnForLdapIDPEntry(null), LdapIDPEntry.class, searchFilter, sizeLimit);
    // convert result
    List<IDPEntry> ret = new ArrayList<IDPEntry>();
    for (LdapIDPEntry entry : entries) {
        ret.add(entry.getEntry());
    }
    return ret;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) LdapIDPEntry(org.gluu.asimba.util.ldap.idp.LdapIDPEntry) LdapIDPEntry(org.gluu.asimba.util.ldap.idp.LdapIDPEntry) IDPEntry(org.gluu.asimba.util.ldap.idp.IDPEntry)

Example 54 with Filter

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

the class AsimbaService method searchSelectors.

/**
    * Search by pattern
    * 
    * @param pattern Pattern
    * @param sizeLimit Maximum count of results
    * @return List of scopes
    * @throws Exception
    */
public List<ApplicationSelectorEntry> searchSelectors(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 organizationIdFilter = Filter.createSubstringFilter(OxTrustConstants.organizationId, null, targetArray, null);
    Filter searchFilter = Filter.createORFilter(idFilter, friendlyNameFilter, descriptionFilter, inameFilter, organizationIdFilter);
    // search
    List<LDAPApplicationSelectorEntry> entries = ldapEntryManager.findEntries(getDnForLDAPApplicationSelectorEntry(null), LDAPApplicationSelectorEntry.class, searchFilter, sizeLimit);
    // convert result
    List<ApplicationSelectorEntry> ret = new ArrayList<ApplicationSelectorEntry>();
    for (LDAPApplicationSelectorEntry entry : entries) {
        ret.add(entry.getEntry());
    }
    return ret;
}
Also used : Filter(com.unboundid.ldap.sdk.Filter) ArrayList(java.util.ArrayList) LDAPApplicationSelectorEntry(org.gluu.asimba.util.ldap.selector.LDAPApplicationSelectorEntry) ApplicationSelectorEntry(org.gluu.asimba.util.ldap.selector.ApplicationSelectorEntry) LDAPApplicationSelectorEntry(org.gluu.asimba.util.ldap.selector.LDAPApplicationSelectorEntry)

Example 55 with Filter

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

the class InumGenerator method contains.

public boolean contains(String inum, IdType type) {
    final String baseDn = baseDn(type);
    try {
        final Filter filter = Filter.create(String.format("inum=%s", inum));
        final List<LdapDummyEntry> entries = ldapEntryManager.findEntries(baseDn, LdapDummyEntry.class, filter);
        return entries != null && !entries.isEmpty();
    } catch (LDAPException e) {
        log.error(e.getMessage(), e);
    }
    return false;
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) Filter(com.unboundid.ldap.sdk.Filter) LdapDummyEntry(org.xdi.ldap.model.LdapDummyEntry)

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