Search in sources :

Example 1 with LdapUriException

use of org.apache.directory.api.ldap.model.exception.LdapUriException in project directory-ldap-api by apache.

the class LdapUrl method parseDN.

/**
 * Parse a string and check that it complies with RFC 2253. Here, we will
 * just call the Dn parser to do the job.
 *
 * @param chars The char array to be checked
 * @param pos the starting position
 * @return -1 if the char array does not contains a Dn
 */
private int parseDN(char[] chars, int pos) {
    int end = pos;
    for (int i = pos; (i < chars.length) && (chars[i] != '?'); i++) {
        end++;
    }
    try {
        String dnStr = new String(chars, pos, end - pos);
        dn = new Dn(decode(dnStr));
    } catch (LdapUriException | LdapInvalidDnException e) {
        return -1;
    }
    return end;
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) LdapUriException(org.apache.directory.api.ldap.model.exception.LdapUriException) LdapInvalidDnException(org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)

Aggregations

LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)1 LdapUriException (org.apache.directory.api.ldap.model.exception.LdapUriException)1 Dn (org.apache.directory.api.ldap.model.name.Dn)1