org.ldaptive
Class DnParser

java.lang.Object
  extended by org.ldaptive.DnParser

public final class DnParser
extends Object

Parses DNs following the rules in RFC 4514. Attempts to be as generous as possible in the format of allowed DNs.

Version:
$Revision: 3120 $ $Date: 2015-10-01 11:50:02 -0400 (Thu, 01 Oct 2015) $
Author:
Middleware Services

Method Summary
static List<LdapAttribute> convertDnToAttributes(String dn)
          Parses the supplied DN and converts each RDN into a LdapAttribute.
protected static byte[] decodeHexValue(char[] value)
          Decodes the supplied hexadecimal value.
protected static String decodeStringValue(String value)
          Decodes the supplied string attribute value.
static String getValue(String dn, String name)
          Returns the RDN value for the attribute type with the supplied name.
static Collection<String> getValues(String dn, String name)
          Returns the RDN values for the attribute type with the supplied name.
static String substring(String dn, int beginIndex)
          Returns a string representation of the supplied DN beginning at the supplied index.
static String substring(String dn, int beginIndex, int endIndex)
          Returns a string representation of the supplied DN beginning at beginIndex (inclusive) and ending at endIndex (exclusive).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getValues

public static Collection<String> getValues(String dn,
                                           String name)
Returns the RDN values for the attribute type with the supplied name.

Parameters:
dn - to parse
name - of the attribute type to return values for
Returns:
DN attribute values

getValue

public static String getValue(String dn,
                              String name)
Returns the RDN value for the attribute type with the supplied name. If the component has multiple values, the first one is returned.

Parameters:
dn - to parse
name - of the attribute to return value for
Returns:
DN attribute value

substring

public static String substring(String dn,
                               int beginIndex)
Returns a string representation of the supplied DN beginning at the supplied index. The leftmost RDN component begins at index 0.

Parameters:
dn - to parse
beginIndex - index of first RDN to include in the result in the range [0, N-1] where N is the number of elements in the DN
Returns:
DN from the supplied index
Throws:
IndexOutOfBoundsException - if beginIndex is less than 0 or greater than the number of RDNs

substring

public static String substring(String dn,
                               int beginIndex,
                               int endIndex)
Returns a string representation of the supplied DN beginning at beginIndex (inclusive) and ending at endIndex (exclusive). The leftmost RDN component begins at index 0. Where n is the number of RDNs, both beginIndex and endIndex are on the range [0, N-1].

Parameters:
dn - to parse
beginIndex - index of first RDN to include in the result in the range [0, N-2] where N is the number of elements in the DN
endIndex - index of last RDN to include in the result in the range [1, N-1] where N is the number of elements in the RDN
Returns:
DN from beginIndex (inclusive) to endIndex (exclusive)
Throws:
IndexOutOfBoundsException - if beginIndex is less than 0, if beginIndex is greater than endIndex, or endIndex is greater than the number of RDNs

convertDnToAttributes

public static List<LdapAttribute> convertDnToAttributes(String dn)
Parses the supplied DN and converts each RDN into a LdapAttribute.

Parameters:
dn - to parse
Returns:
list of ldap attributes for each RDN

decodeHexValue

protected static byte[] decodeHexValue(char[] value)
Decodes the supplied hexadecimal value.

Parameters:
value - hex to decode
Returns:
decoded bytes

decodeStringValue

protected static String decodeStringValue(String value)
Decodes the supplied string attribute value. Unescapes escaped characters. If escaped character is a hex value, it is decoded.

Parameters:
value - to decode
Returns:
decoded string


Copyright © 2003-2015 Virginia Tech. All Rights Reserved.