Class DistinguishedName
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Object>
,Name
Name
corresponding to an LDAP path. A Distinguished
Name manipulation implementation is included in JDK1.5 (LdapName), but not in prior
releases.
A DistinguishedName
is particularly useful when building or modifying an
LDAP path dynamically, as escaping will be taken care of.
A path is split into several names. The Name
interface specifies that the most
significant part be in position 0.
Example:
- The path
- uid=adam.skogman, ou=People, ou=EU
- Name[0]
- ou=EU
- Name[1]
- ou=People
- Name[2]
- uid=adam.skogman
Name
instances, and consequently DistinguishedName
instances
are naturally mutable, which is useful when constructing DistinguishedNames. Example:
DistinguishedName path = new DistinguishedName("dc=jayway,dc=se"); path.add("ou", "People"); path.add("uid", "adam.skogman"); String dn = path.toString();will render
uid=adam.skogman,ou=People,dc=jayway,dc=se
.
NOTE: The fact that DistinguishedName instances are mutable needs to be taken
into careful account, as this means that they may be modified involuntarily. This means
that whenever a DistinguishedName
instance is kept for reference (e.g. for
identification of a domain entry) or as a constant, you should consider getting an
immutable copy of the instance using immutableDistinguishedName()
or
immutableDistinguishedName(String)
.
NB:As of version 1.3 the default toString representation of DistinguishedName
now defaults to a compact one, without spaces between the respective RDNs. For backward
compatibility, set the SPACED_DN_FORMAT_PROPERTY
("org.springframework.ldap.core.spacedDnFormat") to true
.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final DistinguishedName
Deprecated.An empty, unmodifiable DistinguishedName.static final String
Deprecated.static final String
Deprecated.static final String
Deprecated.System property that will be inspected to determine whether creating a DistinguishedName will convert the keys to lowercase, convert the keys to uppercase, or leave the keys as they were in the original String, ie none.static final String
Deprecated.static final String
Deprecated.System property that will be inspected to determine whethertoString()
will format the DN with spaces after each comma or use a more compact representation, i.e.:uid=adam.skogman, ou=People, dc=jayway, dc=se
rather thanuid=adam.skogman,ou=People,dc=jayway,dc=se
. -
Constructor Summary
ConstructorDescriptionDeprecated.Construct a new DistinguishedName with no components.DistinguishedName
(String path) Deprecated.Construct a newDistinguishedName
from a String.DistinguishedName
(List list) Deprecated.DistinguishedName
(Name name) Deprecated.Construct a newDistinguishedName
from the suppliedName
. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.void
Deprecated.Add the suppliedLdapRdn
att the specified index.Deprecated.void
Deprecated.Add a newLdapRdn
using the supplied key and value.void
Deprecated.Add the suppliedLdapRdn
last in the list of Rdns.Deprecated.Deprecated.Deprecated.Append a newLdapRdn
using the supplied key and value.append
(DistinguishedName path) Deprecated.Add an LDAP path last in this DistinguishedName.clone()
Deprecated.int
Deprecated.Compare this instance to another object.boolean
contains
(DistinguishedName path) Deprecated.Determines if thisDistinguishedName
path contains another path.encode()
Deprecated.Builds a complete LDAP path, ldap encoded, useful as a DN.boolean
Deprecated.Determines if thisDistinguishedName
ends with a certian path.boolean
Deprecated.get
(int index) Deprecated.getAll()
Deprecated.getLdapRdn
(int index) Deprecated.Get theLdapRdn
at a specified position.getLdapRdn
(String key) Deprecated.Get theLdapRdn
with the specified key.getNames()
Deprecated.Get the nameList
.getPrefix
(int index) Deprecated.getSuffix
(int index) Deprecated.Deprecated.Get the value of theLdapRdnComponent
with the specified key (Attribute value).int
hashCode()
Deprecated.Deprecated.Return an immutable copy of this instance.static final DistinguishedName
immutableDistinguishedName
(String dnString) Deprecated.Create an immutable DistinguishedName instance, suitable as a constant.boolean
isEmpty()
Deprecated.protected final void
Deprecated.Parse the supplied String and make this instance represent the corresponding distinguished name.void
prepend
(DistinguishedName path) Deprecated.Add an LDAP path first in this DistinguishedName.remove
(int arg0) Deprecated.Deprecated.Remove the first part of thisDistinguishedName
.void
removeFirst
(Name path) Deprecated.Remove the supplied path from the beginning of thisDistinguishedName
if this instance starts withpath
.Deprecated.Remove the last part of thisDistinguishedName
.int
size()
Deprecated.boolean
startsWith
(Name name) Deprecated.Deprecated.Get the compact String representation of thisDistinguishedName
.toString()
Deprecated.Get the String representation of thisDistinguishedName
.toUrl()
Deprecated.Builds a complete LDAP path, ldap and url encoded.
-
Field Details
-
SPACED_DN_FORMAT_PROPERTY
Deprecated.System property that will be inspected to determine whethertoString()
will format the DN with spaces after each comma or use a more compact representation, i.e.:uid=adam.skogman, ou=People, dc=jayway, dc=se
rather thanuid=adam.skogman,ou=People,dc=jayway,dc=se
. A value other than null or blank will trigger the spaced format. Default is the compact representation.Valid values are:
- blank or null (property not set)
- any non-blank value
- Since:
- 1.3
- See Also:
-
KEY_CASE_FOLD_PROPERTY
Deprecated.System property that will be inspected to determine whether creating a DistinguishedName will convert the keys to lowercase, convert the keys to uppercase, or leave the keys as they were in the original String, ie none. Default is to convert the keys to lowercase.Valid values are:
- "lower" or blank or null (property not set)
- "upper"
- "none"
- Since:
- 1.3.1
- See Also:
-
KEY_CASE_FOLD_LOWER
Deprecated.- See Also:
-
KEY_CASE_FOLD_UPPER
Deprecated.- See Also:
-
KEY_CASE_FOLD_NONE
Deprecated.- See Also:
-
EMPTY_PATH
Deprecated.An empty, unmodifiable DistinguishedName.
-
-
Constructor Details
-
DistinguishedName
public DistinguishedName()Deprecated.Construct a new DistinguishedName with no components. -
DistinguishedName
Deprecated.Construct a newDistinguishedName
from a String.- Parameters:
path
- a String corresponding to a (syntactically) valid LDAP path.
-
DistinguishedName
Deprecated.- Parameters:
list
- the components that this instance will consist of.
-
DistinguishedName
Deprecated.Construct a newDistinguishedName
from the suppliedName
. The parts of the suppliedName
must be syntactically correctLdapRdn
s.- Parameters:
name
- theName
to construct a newDistinguishedName
from.
-
-
Method Details
-
parse
Deprecated.Parse the supplied String and make this instance represent the corresponding distinguished name.- Parameters:
path
- the LDAP path to parse.
-
getLdapRdn
Deprecated.Get theLdapRdn
at a specified position. -
getLdapRdn
Deprecated.Get theLdapRdn
with the specified key. If there are severalRdn
s with the same key, the first one found (in order of significance) will be returned.- Parameters:
key
- Attribute name of theLdapRdn
to retrieve.- Returns:
- the
LdapRdn
with the requested key. - Throws:
IllegalArgumentException
- if no Rdn matches the given key.
-
getValue
Deprecated.Get the value of theLdapRdnComponent
with the specified key (Attribute value). If there are several Rdns with the same key, the value of the first one found (in order of significance) will be returned.- Parameters:
key
- Attribute name of theLdapRdn
to retrieve.- Returns:
- the value.
- Throws:
IllegalArgumentException
- if no Rdn matches the given key.
-
getNames
Deprecated.Get the nameList
.- Returns:
- the list of
LdapRdn
s that thisDistinguishedName
consists of.
-
toCompactString
Deprecated.Get the compact String representation of thisDistinguishedName
. Add no space after each comma, to make it compact.- Returns:
- a syntactically correct, properly escaped String representation of the
DistinguishedName
.
-
encode
Deprecated.Builds a complete LDAP path, ldap encoded, useful as a DN. Always uses lowercase, always separates with ", " i.e. comma and a space.- Returns:
- the LDAP path.
-
toUrl
Deprecated.Builds a complete LDAP path, ldap and url encoded. Separates only with ",".- Returns:
- the LDAP path, for use in an url.
-
contains
Deprecated.Determines if thisDistinguishedName
path contains another path.- Parameters:
path
- the path to check.- Returns:
true
if the supplied path is conained in this instance,false
otherwise.
-
append
Deprecated.Add an LDAP path last in this DistinguishedName. E.g.:DistinguishedName name1 = new DistinguishedName("c=SE, dc=jayway, dc=se"); DistinguishedName name2 = new DistinguishedName("ou=people"); name1.append(name2);
will result inou=people, c=SE, dc=jayway, dc=se
- Parameters:
path
- the path to append.- Returns:
- this instance.
-
append
Deprecated.Append a newLdapRdn
using the supplied key and value. -
prepend
Deprecated.Add an LDAP path first in this DistinguishedName. E.g.:DistinguishedName name1 = new DistinguishedName("ou=people"); DistinguishedName name2 = new DistinguishedName("c=SE, dc=jayway, dc=se"); name1.prepend(name2);
will result inou=people, c=SE, dc=jayway, dc=se
- Parameters:
path
- the path to prepend.
-
removeFirst
Deprecated.Remove the first part of thisDistinguishedName
.- Returns:
- the removed entry.
-
removeFirst
Deprecated.Remove the supplied path from the beginning of thisDistinguishedName
if this instance starts withpath
. Useful for stripping base path suffix from aDistinguishedName
.- Parameters:
path
- the path to remove from the beginning of this instance.
-
clone
Deprecated. -
equals
Deprecated. -
hashCode
public int hashCode()Deprecated. -
toString
Deprecated.Get the String representation of thisDistinguishedName
. Depending on the setting of propertyorg.springframework.ldap.core.spacedDnFormat
a space will be added after each comma, to make the result more readable. Default is compact representation, i.e. without any spaces. -
compareTo
Deprecated.Compare this instance to another object. Note that the comparison is done in order of significance, so the most significant Rdn is compared first, then the second and so on.- Specified by:
compareTo
in interfaceComparable<Object>
- Specified by:
compareTo
in interfaceName
- See Also:
-
size
public int size()Deprecated. -
isEmpty
public boolean isEmpty()Deprecated. -
getAll
Deprecated. -
get
Deprecated. -
getPrefix
Deprecated. -
getSuffix
Deprecated. -
startsWith
Deprecated.- Specified by:
startsWith
in interfaceName
-
endsWith
Deprecated.Determines if thisDistinguishedName
ends with a certian path. If the argument path is empty (no names in path) this method will returnfalse
. -
addAll
Deprecated.- Specified by:
addAll
in interfaceName
- Throws:
InvalidNameException
-
addAll
Deprecated.- Specified by:
addAll
in interfaceName
- Throws:
InvalidNameException
-
add
Deprecated.- Specified by:
add
in interfaceName
- Throws:
InvalidNameException
-
add
Deprecated.- Specified by:
add
in interfaceName
- Throws:
InvalidNameException
-
remove
Deprecated.- Specified by:
remove
in interfaceName
- Throws:
InvalidNameException
-
removeLast
Deprecated.Remove the last part of thisDistinguishedName
.- Returns:
- the removed
LdapRdn
.
-
add
Deprecated.Add a newLdapRdn
using the supplied key and value. -
add
Deprecated.Add the suppliedLdapRdn
last in the list of Rdns.- Parameters:
rdn
- theLdapRdn
to add.
-
add
Deprecated.Add the suppliedLdapRdn
att the specified index.- Parameters:
idx
- the index at which to add the LdapRdn.rdn
- the LdapRdn to add.
-
immutableDistinguishedName
Deprecated.Return an immutable copy of this instance. It will not be possible to add or remove any Rdns to or from the returned instance, and the respective Rdns will also be immutable in turn.- Returns:
- a copy of this instance backed by an immutable list.
- Since:
- 1.2
-
immutableDistinguishedName
Deprecated.Create an immutable DistinguishedName instance, suitable as a constant.- Parameters:
dnString
- the DN string to parse.- Returns:
- an immutable DistinguishedName corresponding to the supplied DN string.
- Since:
- 1.3
-
LdapName
along with utility methods inLdapUtils
instead.