public class RDN extends java.lang.Object implements ASN1Type
A Distinguished Name is used to specify a path within a X.500 directory information tree. A distinguished name is defined as a sequence of relative distinguished names, where a relative distinguished name is defined as follows:
RelativeDistinguishedName ::= SET OF AttributeValueAssertion
AttributeValueAssertion ::= SEQUENCE {
AttributeType OBJECT IDENTIFIER,
AttributeValue ANY
}
You may directly supply a AttributeValueAssertion (AVA) when creating a
RelativeDistinguishedName object, or (and) you may use the addAVA
method for later adding some AVA, e.g.:
RDN rel_dis_name = new RDN(ObjectID.country, "AT"); rel_dis_name.addAVA(ObjectID.locality, "Graz");
When specifying issuer or subject within a X.509 certificate by a distinguished name composed of relative distinguished names, it is recommended that each set of AttributeValueAssertions constituting a RelativeDistinguishedName only should contain one element. This class only allows one AVA of a specific type to be added to a RDN object.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Vector<AVA> |
avas
Repository for AttributeValueAssertion objects.
|
| Constructor and Description |
|---|
RDN()
Creates an empty RelativeDistinguishedName.
|
RDN(ASN1Object obj)
Creates a RelativeDistinguishedName from an ASN1Object.
|
RDN(ObjectID oid,
java.lang.Object value)
Creates a new RelativeDistinguishedName for one AVA.
|
RDN(java.lang.String rdn)
Creates a RelativeDistinguishedName from a String.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAVA(AVA ava)
Adds a AttributeValueAssertion to this RelativeDistinguishedName.
|
void |
addAVA(ObjectID oid,
java.lang.Object value)
Creates a new AttributeValueAssertion with given type and value
and adds it to this RelativeDistinguishedName.
|
void |
decode(ASN1Object obj)
Decodes a RelativeDistinguishedName from the given ASN1Object.
|
java.util.Enumeration<AVA> |
elements()
Returns an enumeration of the AVAs in this RDN.
|
boolean |
equals(java.lang.Object obj)
Compares two RelativeDistinguishedNames.
|
AVA |
getAVA()
This method returns one AVA.
|
AVA |
getAVA(ObjectID oid)
Returns a AttributeValueAssertion of given type
from this RelativeDistinguishedName.
|
java.lang.String |
getComparableString()
Returns a string that represents the contents of this RDN, according
to the name comparison rules in RFC 2459/3280.
|
java.lang.String |
getRFC2253String()
Returns a string representation of this RDN according to RFC 2253.
|
java.lang.String |
getRFC2253String(boolean escapeNonPrintableAscii)
Returns a RFC 2253 representation of the RDN.
|
int |
hashCode()
Returns the hashcode for this RDN.
|
ASN1Object |
toASN1Object()
Returns the RelativeDistinguishedName as an ASN1Object.
|
java.lang.String |
toString()
Returns a string that represents the contents of this RDN.
|
java.lang.String |
toString(boolean detailed)
Returns a string that represents the contents of this RDN.
|
protected java.util.Vector<AVA> avas
public RDN()
public RDN(ObjectID oid, java.lang.Object value)
AttributeValueAssertion objects
may be added by using a proper addAVA method.oid - the type (object ID) of the AVA to be addedvalue - the value of the AVA to be addedpublic RDN(ASN1Object obj) throws CodingException
The supplied ASN1Object represents an already existing RDN
that may have been created by means of the toASN1Object method.
the - RelativeDistinguishedName as ASN1ObjectCodingException - if this ASN1Object could not be parsedpublic RDN(java.lang.String rdn)
The supplied String represents an encoded RDN that may
have been created by means of the toString method.
the - RelativeDistinguishedName as Stringpublic void decode(ASN1Object obj) throws CodingException
The supplied ASN1Object represents an already existing RDN object that
may have been created by means of the toASN1Object()
method.
decode in interface ASN1Typeobj - the RDN as ASN1ObjectCodingException - if the ASN1Object has the wrong formatpublic ASN1Object toASN1Object()
toASN1Object in interface ASN1Typepublic void addAVA(ObjectID oid, java.lang.Object value)
oid - the attribute type of the AVA to be added, as object IDvalue - the attribute valuepublic void addAVA(AVA ava)
ava - the AttributeValueAssertion to addpublic AVA getAVA(ObjectID oid)
oid - the type of the AVA to be searched for, as ObjectIDpublic AVA getAVA()
public java.util.Enumeration<AVA> elements()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the other RelativeDistinguishedNametrue, if the two RelativeDistinguishedNames are equal, false otherwisepublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(boolean detailed)
public java.lang.String getRFC2253String()
throws RFC2253NameParserException
RFC 2253 specifies a string representation of Distinguished Names as used for LDAP lookups.
Each included AttributeTypeAndValue is represented as specified in
sections 2.3, 2.4 of RFC 2253 (adjoining AttributeTypeAndValues
(or AVAs) are separated by a plus ("+")
character):
The attribute type is represented as described in section 2.3 of RFC 2253. If there is no known name string for the attribute type a dotted-decimal encoding of the attribute type´s identifier.
The string representation of the attribute value is either a hexadecimal represenation of its BER encoding (introduced by a "#" character) or based on the algorithm given in section 2.4 of RFC 2253 applying the following escaping mechanisms:
RFC2253NameParserException - if the AVA cannot be represented
according to the rules abovepublic java.lang.String getRFC2253String(boolean escapeNonPrintableAscii)
escapeNonPrintableAndNonAscii - indicates whether or not every non-printable character and
non-ASCII character should be represented in escaped formatpublic java.lang.String getComparableString()
According to the name comparison rules in RFC 2459/3280, the names differ only by whitespace and capitalization should be considered the same name (e.g., " Marianne Swanson" is the same as "MARIANNE SWANSON "). This method converts all characters to upper case, removes leading and trailing whitespace, and converts internal substrings of one or more consecutive white space characters to a single space. The string output is compatible to RFC 1779/2253 except for escaping.