Search in sources :

Example 1 with RDN

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

the class InumGenerator method baseDn.

public String baseDn(IdType p_type) {
    final BaseDnConfiguration baseDn = staticConfiguration.getBaseDn();
    switch(p_type) {
        case CLIENTS:
            return baseDn.getClients();
        case APPLIANCE:
            return baseDn.getAppliance();
        case ATTRIBUTE:
            return baseDn.getAttributes();
        case PEOPLE:
            return baseDn.getPeople();
    }
    // if not able to identify baseDn by type then return organization baseDn, e.g. o=gluu
    try {
        // baseDn.getClients(), e.g. ou=clients,o=@!1111,o=gluu
        final DN dnObj = new DN(baseDn.getClients());
        final RDN[] rdns = dnObj.getRDNs();
        final RDN rdn = rdns[rdns.length - 1];
        return rdn.toNormalizedString();
    } catch (LDAPException e) {
        log.error(e.getMessage(), e);
    }
    log.error("Use fallback DN: o=gluu, for ID generator, please check oxAuth configuration, clientDn must be valid DN");
    return "o=gluu";
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) BaseDnConfiguration(org.xdi.oxauth.model.config.BaseDnConfiguration) RDN(com.unboundid.ldap.sdk.RDN)

Example 2 with RDN

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

the class LdapUtils method createAnyFilterFromDnList.

/**
     * Creates any filter to load all objects represented by this dn list.
     *
     * @param p_filterAttributeName filter attribute name
     * @param p_dnList              dn list
     * @return filter
     */
public static Filter createAnyFilterFromDnList(String p_filterAttributeName, List<String> p_dnList) {
    try {
        if (p_dnList != null && !p_dnList.isEmpty()) {
            final StringBuilder sb = new StringBuilder("(|");
            for (String dn : p_dnList) {
                final DN dnObj = new DN(dn);
                final RDN rdn = dnObj.getRDN();
                if (rdn.getAttributeNames()[0].equals(p_filterAttributeName)) {
                    final String[] values = rdn.getAttributeValues();
                    if (values != null && values.length == 1) {
                        sb.append("(");
                        sb.append(p_filterAttributeName).append("=");
                        sb.append(values[0]);
                        sb.append(")");
                    }
                }
            }
            sb.append(")");
            final String filterAsString = sb.toString();
            log.trace("dnList: " + p_dnList + ", ldapFilter: " + filterAsString);
            return Filter.create(filterAsString);
        }
    } catch (LDAPException e) {
        log.trace(e.getMessage(), e);
    }
    return null;
}
Also used : LDAPException(com.unboundid.ldap.sdk.LDAPException) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) RDN(com.unboundid.ldap.sdk.RDN)

Aggregations

DN (com.unboundid.ldap.sdk.DN)2 LDAPException (com.unboundid.ldap.sdk.LDAPException)2 RDN (com.unboundid.ldap.sdk.RDN)2 BaseDnConfiguration (org.xdi.oxauth.model.config.BaseDnConfiguration)1