iaik.asn1.structures
Class RDN

java.lang.Object
  |
  +--iaik.asn1.structures.RDN

public class RDN
extends java.lang.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.

See Also:
Name, AVA

Field Summary
protected  java.util.Hashtable avas
          Repository for AttributeValueAssertion objects.
 
Constructor Summary
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.
 
Method Summary
 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 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.
 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.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

avas

protected java.util.Hashtable avas
Repository for AttributeValueAssertion objects.
Constructor Detail

RDN

public RDN()
Creates an empty RelativeDistinguishedName.

RDN

public RDN(ObjectID oid,
           java.lang.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

RDN

public RDN(java.lang.String rdn)
Creates a RelativeDistinguishedName from a String.

The supplied String represents an encoded RDN that may have been created by means of the toString method.

Parameters:
the - RelativeDistinguishedName as String
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,
                   java.lang.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 java.util.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 java.lang.Object
Returns:
a hashcode for this RDN

equals

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

toString

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

toString

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