LDAP Classes
Implements Java LDAP

com.novell.ldap
Class LDAPDN

java.lang.Object
  extended bycom.novell.ldap.LDAPDN

public class LDAPDN
extends java.lang.Object

A utility class to facilitate composition and deomposition of distinguished names (DNs).

Specifies methods for manipulating a distinguished name (DN) and a relative distinguished name (RDN).


Constructor Summary
LDAPDN()
           
 
Method Summary
static boolean equals(java.lang.String dn1, java.lang.String dn2)
          Compares the two strings per the distinguishedNameMatch equality matching (using case-ignore matching).
static java.lang.String escapeRDN(java.lang.String rdn)
          Returns the RDN after escaping the characters requiring escaping.
static java.lang.String[] explodeDN(java.lang.String dn, boolean noTypes)
          Returns the individual components of a distinguished name (DN).
static java.lang.String[] explodeRDN(java.lang.String rdn, boolean noTypes)
          Returns the individual components of a relative distinguished name (RDN), normalized.
static boolean isValid(java.lang.String dn)
          Returns true if the string conforms to distinguished name syntax.
static java.lang.String normalize(java.lang.String dn)
          Returns the DN normalized by removal of non-significant space characters as per RFC 2253, section4.
static java.lang.String unescapeRDN(java.lang.String rdn)
          Returns the RDN after unescaping the characters requiring escaping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDAPDN

public LDAPDN()
Method Detail

equals

public static boolean equals(java.lang.String dn1,
                             java.lang.String dn2)
Compares the two strings per the distinguishedNameMatch equality matching (using case-ignore matching). IllegalArgumentException is thrown if one or both DNs are invalid. UnsupportedOpersationException is thrown if the API implementation is not able to detemine if the DNs match or not.

Parameters:
dn1 - String form of the first DN to compare.

dn2 - String form of the second DN to compare.
Returns:
Returns true if the two strings correspond to the same DN; false if the DNs are different.

escapeRDN

public static java.lang.String escapeRDN(java.lang.String rdn)
Returns the RDN after escaping the characters requiring escaping.

For example, for the rdn "cn=Acme, Inc", the escapeRDN method returns "cn=Acme\, Inc".

escapeRDN escapes the AttributeValue by inserting '\' before the following chars: * ',' '+' '"' '\' '<' '>' ';'
'#' if it comes at the beginning of the string, and
' ' (space) if it comes at the beginning or the end of a string. Note that single-valued attributes can be used because of ambiguity. See RFC 2253

Parameters:
rdn - The RDN to escape.
Returns:
The RDN with escaping characters.

explodeDN

public static java.lang.String[] explodeDN(java.lang.String dn,
                                           boolean noTypes)
Returns the individual components of a distinguished name (DN).

Parameters:
dn - The distinguished name, for example, "cn=Babs Jensen,ou=Accounting,o=Acme,c=US"

noTypes - If true, returns only the values of the components and not the names. For example, "Babs Jensen", "Accounting", "Acme", "US" instead of "cn=Babs Jensen", "ou=Accounting", "o=Acme", and "c=US".
Returns:
An array of strings representing the individual components of a DN, or null if the DN is not valid.

explodeRDN

public static java.lang.String[] explodeRDN(java.lang.String rdn,
                                            boolean noTypes)
Returns the individual components of a relative distinguished name (RDN), normalized.

Parameters:
rdn - The relative distinguished name, or in other words, the left-most component of a distinguished name.

noTypes - If true, returns only the values of the components, and not the names of the component, for example "Babs Jensen" instead of "cn=Babs Jensen".
Returns:
An array of strings representing the individual components of an RDN, or null if the RDN is not a valid RDN.

isValid

public static boolean isValid(java.lang.String dn)
Returns true if the string conforms to distinguished name syntax.

Parameters:
dn - String to evaluate fo distinguished name syntax.
Returns:
true if the dn is valid.

normalize

public static java.lang.String normalize(java.lang.String dn)
Returns the DN normalized by removal of non-significant space characters as per RFC 2253, section4.

Returns:
a normalized string

unescapeRDN

public static java.lang.String unescapeRDN(java.lang.String rdn)
Returns the RDN after unescaping the characters requiring escaping.

For example, for the rdn "cn=Acme\, Inc", the unescapeRDN method returns "cn=Acme, Inc".

Note:This function doesn't check for the validity of the RDN string use isValid(String) function to check the validity. The results is undefined for invalid RDN's.

unescapeRDN unescapes the AttributeValue by removing the '\' when the next character fits the following:
',' '+' '"' '\' '<' '>' ';'
'#' if it comes at the beginning of the Attribute Name (without the '\').
' ' (space) if it comes at the beginning or the end of the Attribute Name

Parameters:
rdn - The RDN to unescape.
Returns:
The RDN with the escaping characters removed.
See Also:
isValid(String)

LDAP Classes
Implements Java LDAP

Copyright © 2002 Novell, Inc. All Rights Reserved.
Novell, Inc.
1800 South Novell Place
Provo, Ut 84606
Phone: (801) 861-5000