iaik.asn1.structures
Class RDN

java.lang.Object
  |
  +--iaik.asn1.structures.RDN
All Implemented Interfaces:
ASN1Type

public class RDN
extends Object
implements ASN1Type

This class implements the ASN.1 type RelativeDistinguishedName.

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.

Version:
File Revision 19
See Also:
Name, AVA

Field Summary
protected  Vector avas
          Repository for AttributeValueAssertion objects.
 
Constructor Summary
RDN()
          Creates an empty RelativeDistinguishedName.
RDN(ASN1Object obj)
          Creates a RelativeDistinguishedName from an ASN1Object.
RDN(ObjectID oid, Object value)
          Creates a new RelativeDistinguishedName for one AVA.
 
Method Summary
 void addAVA(AVA ava)
          Adds a AttributeValueAssertion to this RelativeDistinguishedName.
 void addAVA(ObjectID oid, 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.
 Enumeration elements()
          Returns an enumeration of the AVAs in this RDN.
 boolean equals(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.
 String getRFC2253String()
          Returns a string representation of this RDN according to RFC 2253.
 int hashCode()
          Returns the hashcode for this RDN.
 ASN1Object toASN1Object()
          Returns the RelativeDistinguishedName as an ASN1Object.
 String toString()
          Returns a string that represents the contents of this RDN.
 String toString(boolean detailed)
          Returns a string that represents the contents of this RDN.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

avas

protected Vector avas
Repository for AttributeValueAssertion objects.
Constructor Detail

RDN

public RDN()
Creates an empty RelativeDistinguishedName.

RDN

public RDN(ObjectID oid,
           Object value)
Creates a new RelativeDistinguishedName for one AVA. Further AttributeValueAssertion objects may be added by using a proper addAVA method.
Parameters:
oid - the type (object ID) of the AVA to be added
value - the value of the AVA to be added

RDN

public RDN(ASN1Object obj)
    throws CodingException
Creates a RelativeDistinguishedName from an ASN1Object.

The supplied ASN1Object represents an already existing RDN that may have been created by means of the toASN1Object method.

Parameters:
the - RelativeDistinguishedName as ASN1Object
Throws:
CodingException - if this ASN1Object could not be parsed
Method Detail

decode

public void decode(ASN1Object obj)
            throws CodingException
Decodes a RelativeDistinguishedName from the given ASN1Object.

The supplied ASN1Object represents an already existing RDN object that may have been created by means of the toASN1Object() method.

Specified by:
decode in interface ASN1Type
Parameters:
obj - the RDN as ASN1Object
Throws:
CodingException - if the ASN1Object has the wrong format

toASN1Object

public ASN1Object toASN1Object()
Returns the RelativeDistinguishedName as an ASN1Object.
Specified by:
toASN1Object in interface ASN1Type
Returns:
the RelativeDistinguishedName as ASN1Object

addAVA

public void addAVA(ObjectID oid,
                   Object value)
Creates a new AttributeValueAssertion with given type and value and adds it to this RelativeDistinguishedName. If an AVA of the given type already is included, it will be replaced by the new AVA.
Parameters:
oid - the attribute type of the AVA to be added, as object ID
value - the attribute value

addAVA

public void addAVA(AVA ava)
Adds a AttributeValueAssertion to this RelativeDistinguishedName. If an AVA of the same type already is included, it will be replaced by the new AVA.
Parameters:
ava - the AttributeValueAssertion to add

getAVA

public AVA getAVA(ObjectID oid)
Returns a AttributeValueAssertion of given type from this RelativeDistinguishedName.
Parameters:
oid - the type of the AVA to be searched for, as ObjectID
Returns:
the value of the desired attribute

getAVA

public AVA getAVA()
This method returns one AVA.
Returns:
the first AVA

elements

public Enumeration elements()
Returns an enumeration of the AVAs in this RDN.
Returns:
an enumeration of the AVAs in this RDN

hashCode

public int hashCode()
Returns the hashcode for this RDN.
Overrides:
hashCode in class Object
Returns:
a hashcode for this RDN

equals

public boolean equals(Object obj)
Compares two RelativeDistinguishedNames.
Overrides:
equals in class Object
Parameters:
obj - the other RelativeDistinguishedName
Returns:
true, if the two RelativeDistinguishedNames are equal, false otherwise

toString

public String toString()
Returns a string that represents the contents of this RDN.
Overrides:
toString in class Object
Returns:
the string representation

toString

public String toString(boolean detailed)
Returns a string that represents the contents of this RDN.
Returns:
the string representation

getRFC2253String

public String getRFC2253String()
                        throws RFC2253NameParserException
Returns a string representation of this RDN according to RFC 2253.

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:

Additionally this method escapes Any non printable ASCII (< 0x21 or > 0x7e) and any non-ASCII character by an hexadecimal representation of its UTF-8 encoding. The space character (0x21) only is escaped when appearing at the beginning or the end of the string.
Returns:
the string representation according to RFC 2253.
Throws:
RFC2253NameParserException - if the AVA cannot be represented according to the rules above

This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK