Search in sources :

Example 1 with LdapDummyEntry

use of org.xdi.ldap.model.LdapDummyEntry in project oxAuth by GluuFederation.

the class BaseAuthFilterService method loadEntryDN.

public String loadEntryDN(LdapEntryManager p_manager, AuthenticationFilterWithParameters authenticationFilterWithParameters, Map<String, String> normalizedAttributeValues) {
    final String filter = buildFilter(authenticationFilterWithParameters, normalizedAttributeValues);
    Filter ldapFilter;
    try {
        ldapFilter = Filter.create(filter);
    } catch (LDAPException ex) {
        log.error("Failed to create Ldap filter: '{}'", ex, filter);
        return null;
    }
    List<LdapDummyEntry> foundEntries = p_manager.findEntries(authenticationFilterWithParameters.getAuthenticationFilter().getBaseDn(), LdapDummyEntry.class, new String[0], ldapFilter);
    if (foundEntries.size() > 1) {
        log.error("Found more than one entry by filter: '{}'. Entries:\n", ldapFilter, foundEntries);
        return null;
    }
    if (!(foundEntries.size() == 1)) {
        return null;
    }
    return foundEntries.get(0).getDn();
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) Filter(com.unboundid.ldap.sdk.Filter) BaseFilter(org.xdi.oxauth.model.configuration.BaseFilter) LdapDummyEntry(org.xdi.ldap.model.LdapDummyEntry)

Example 2 with LdapDummyEntry

use of org.xdi.ldap.model.LdapDummyEntry 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)2 LDAPException (com.unboundid.ldap.sdk.LDAPException)2 LdapDummyEntry (org.xdi.ldap.model.LdapDummyEntry)2 BaseFilter (org.xdi.oxauth.model.configuration.BaseFilter)1