anon.crypto
Class X509DistinguishedName

java.lang.Object
  extended by anon.crypto.X509DistinguishedName

public final class X509DistinguishedName
extends java.lang.Object

Objects of this class represent an X509 distinguished name. The name consists of attributes, that are pairs of identifiers and values. Each attribute may have exactly one value. For each identifier, there also exists a string representation.

Author:
Rolf Wendolsky

Nested Class Summary
 class X509DistinguishedName.IllegalCharacterException
          Represents an error that is thrown when an illegal character is used in a distinguished name attribute.
 
Field Summary
static java.lang.String IDENTIFIER_C
          Country code : X509 identifier for the string "C"
static java.lang.String IDENTIFIER_CN
          Common name : X509 identifier for the string "CN"
static java.lang.String IDENTIFIER_E
          E-Mail : X509 identifier for the string "E"
static java.lang.String IDENTIFIER_EmailAddress
          E-Mail 2: X509 identifier for the string "EmailAddress"
static java.lang.String IDENTIFIER_GIVENNAME
          Given name : Identifier for the string "GIVENNAME"
static java.lang.String IDENTIFIER_L
          locality name : X509 identifier for the string "L"
static java.lang.String IDENTIFIER_O
          Organisation : X509 identifier for the string "O"
static java.lang.String IDENTIFIER_OU
          Organisational Unit : X509 identifier for the string "OU"
static java.lang.String IDENTIFIER_ST
          State or province : X509 identifier for the string "CN"
static java.lang.String IDENTIFIER_SURNAME
          Surname : Identifier for the string "SURNAME"
static java.lang.String LABEL_COMMON_NAME
           
static java.lang.String LABEL_COUNTRY
           
static java.lang.String LABEL_EMAIL
           
static java.lang.String LABEL_EMAIL_ADDRESS
           
static java.lang.String LABEL_GIVENNAME
           
static java.lang.String LABEL_LOCALITY
           
static java.lang.String LABEL_ORGANISATION
           
static java.lang.String LABEL_ORGANISATIONAL_UNIT
           
static java.lang.String LABEL_STATE_OR_PROVINCE
           
static java.lang.String LABEL_SURNAME
           
private  org.bouncycastle.asn1.x509.X509Name m_bcX509Name
           
private static java.util.Vector m_sortedIdentifiers
           
 
Constructor Summary
X509DistinguishedName(java.util.Hashtable a_attributes)
          Constructs a distinguished name from a Hashtable of attributes.
X509DistinguishedName(java.lang.String a_x509distinguishedName)
          Constructs a distinguished name from a String of the form "C=DE, ST=Bavaria, ..."
X509DistinguishedName(org.bouncycastle.asn1.x509.X509Name a_bcX509Name)
          Constructs a distinguished name from a BouncyCastle X509Name object.
 
Method Summary
 boolean equals(java.lang.Object a_object)
           
 java.util.Vector getAttributeIdentifiers()
          Returns the identifiers of attributes in this X509 name.
static java.lang.String getAttributeNameFromAttributeIdentifier(java.lang.String a_identifier)
          Returns the X509 attribute label corresponding to a given attribute identifier.
 java.lang.String getAttributeValue(java.lang.String a_identifier)
          Returns the attribute value corresponding to a given identifier.
 java.util.Vector getAttributeValues()
          Returns the values of attributes in this X509 name.
 java.lang.String getCommonName()
          Returns the common name.
 java.lang.String getCountryCode()
          Returns the country code;
 java.util.Hashtable getDistinguishedName()
          Returns the distinguished name as Hashtable (identifier-attribute).
 java.lang.String getE_EmailAddress()
          Returns the email address specified by the identifier "E".
 java.lang.String getEmailAddress()
          Returns the email address specified by the identifier "EmailAddress".
 java.lang.String getGivenName()
          Returns the given name.
 java.lang.String getLocalityName()
          Returns the locality name.
 java.lang.String getOrganisation()
          Returns the organisation.
 java.lang.String getOrganisationalUnit()
          Returns the organisational unit.
private static java.util.Enumeration getSortedIdentifiers()
          Returns the most important BC object identifiers sorted in a reasonable way.
 java.lang.String getStateOrProvince()
          Returns the state or province.
 java.lang.String getSurname()
          Returns the surname.
(package private)  org.bouncycastle.asn1.x509.X509Name getX509Name()
          Returns the BouncyCastle X509Name representation of this object.
 int hashCode()
           
 java.lang.String toString()
          Writes the distinguished name as a single String.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IDENTIFIER_CN

public static final java.lang.String IDENTIFIER_CN
Common name : X509 identifier for the string "CN"


IDENTIFIER_C

public static final java.lang.String IDENTIFIER_C
Country code : X509 identifier for the string "C"


IDENTIFIER_ST

public static final java.lang.String IDENTIFIER_ST
State or province : X509 identifier for the string "CN"


IDENTIFIER_L

public static final java.lang.String IDENTIFIER_L
locality name : X509 identifier for the string "L"


IDENTIFIER_O

public static final java.lang.String IDENTIFIER_O
Organisation : X509 identifier for the string "O"


IDENTIFIER_OU

public static final java.lang.String IDENTIFIER_OU
Organisational Unit : X509 identifier for the string "OU"


IDENTIFIER_E

public static final java.lang.String IDENTIFIER_E
E-Mail : X509 identifier for the string "E"


IDENTIFIER_EmailAddress

public static final java.lang.String IDENTIFIER_EmailAddress
E-Mail 2: X509 identifier for the string "EmailAddress"


IDENTIFIER_SURNAME

public static final java.lang.String IDENTIFIER_SURNAME
Surname : Identifier for the string "SURNAME"


IDENTIFIER_GIVENNAME

public static final java.lang.String IDENTIFIER_GIVENNAME
Given name : Identifier for the string "GIVENNAME"


LABEL_COMMON_NAME

public static final java.lang.String LABEL_COMMON_NAME
See Also:
Constant Field Values

LABEL_COUNTRY

public static final java.lang.String LABEL_COUNTRY
See Also:
Constant Field Values

LABEL_STATE_OR_PROVINCE

public static final java.lang.String LABEL_STATE_OR_PROVINCE
See Also:
Constant Field Values

LABEL_LOCALITY

public static final java.lang.String LABEL_LOCALITY
See Also:
Constant Field Values

LABEL_ORGANISATION

public static final java.lang.String LABEL_ORGANISATION
See Also:
Constant Field Values

LABEL_ORGANISATIONAL_UNIT

public static final java.lang.String LABEL_ORGANISATIONAL_UNIT
See Also:
Constant Field Values

LABEL_EMAIL

public static final java.lang.String LABEL_EMAIL
See Also:
Constant Field Values

LABEL_EMAIL_ADDRESS

public static final java.lang.String LABEL_EMAIL_ADDRESS
See Also:
Constant Field Values

LABEL_SURNAME

public static final java.lang.String LABEL_SURNAME
See Also:
Constant Field Values

LABEL_GIVENNAME

public static final java.lang.String LABEL_GIVENNAME
See Also:
Constant Field Values

m_sortedIdentifiers

private static java.util.Vector m_sortedIdentifiers

m_bcX509Name

private org.bouncycastle.asn1.x509.X509Name m_bcX509Name
Constructor Detail

X509DistinguishedName

public X509DistinguishedName(java.lang.String a_x509distinguishedName)
Constructs a distinguished name from a String of the form "C=DE, ST=Bavaria, ..."

Parameters:
a_x509distinguishedName - String

X509DistinguishedName

public X509DistinguishedName(java.util.Hashtable a_attributes)
                      throws X509DistinguishedName.IllegalCharacterException
Constructs a distinguished name from a Hashtable of attributes. The Hashtable contains the attribute identifiers as keys and the attributes as values. Do not use the string representation of the identifiers! Commas (,) are interpreted as multiple attributes for the same identifier.

Parameters:
a_attributes - a Hashtable of attributes
Throws:
X509DistinguishedName.IllegalCharacterException - if an illegal character is contained in the DN

X509DistinguishedName

public X509DistinguishedName(org.bouncycastle.asn1.x509.X509Name a_bcX509Name)
Constructs a distinguished name from a BouncyCastle X509Name object. For internal use only.

Parameters:
a_bcX509Name - a BouncyCastle X509Name object.
Method Detail

getAttributeNameFromAttributeIdentifier

public static java.lang.String getAttributeNameFromAttributeIdentifier(java.lang.String a_identifier)
Returns the X509 attribute label corresponding to a given attribute identifier.

Parameters:
a_identifier - an X509 attribute identifier
Returns:
the X509 attribute label corresponding to a given attribute identifier

getCommonName

public java.lang.String getCommonName()
Returns the common name.

Returns:
the common name or null if not set

getSurname

public java.lang.String getSurname()
Returns the surname.

Returns:
the surname or null if not set

getGivenName

public java.lang.String getGivenName()
Returns the given name.

Returns:
the given name or null if not set

getCountryCode

public java.lang.String getCountryCode()
Returns the country code;

Returns:
the country code or null if not set

getStateOrProvince

public java.lang.String getStateOrProvince()
Returns the state or province.

Returns:
the state or province or null if not set

getLocalityName

public java.lang.String getLocalityName()
Returns the locality name.

Returns:
the locality name or null if not set

getOrganisation

public java.lang.String getOrganisation()
Returns the organisation.

Returns:
the organisation or null if not set

getOrganisationalUnit

public java.lang.String getOrganisationalUnit()
Returns the organisational unit.

Returns:
the organisational unit

getE_EmailAddress

public java.lang.String getE_EmailAddress()
Returns the email address specified by the identifier "E".

Returns:
the email address or null if not set

getEmailAddress

public java.lang.String getEmailAddress()
Returns the email address specified by the identifier "EmailAddress".

Returns:
the email address or null if not set

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String a_identifier)
Returns the attribute value corresponding to a given identifier. If there is more than one attribute for this identifier, the attributes are comma-separated.

Parameters:
a_identifier - an attribute identifier
Returns:
String the attribute value corresponding to a given identifier or null if the attribute is not set in this X509 name

getAttributeIdentifiers

public java.util.Vector getAttributeIdentifiers()
Returns the identifiers of attributes in this X509 name.

Returns:
the identifiers of attributes in this X509 name

getAttributeValues

public java.util.Vector getAttributeValues()
Returns the values of attributes in this X509 name.

Returns:
the values of attributes in this X509 name

getDistinguishedName

public java.util.Hashtable getDistinguishedName()
Returns the distinguished name as Hashtable (identifier-attribute).

Returns:
the distinguished name as Hashtable (identifier-attribute)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object a_object)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Writes the distinguished name as a single String. Identifiers and values are separated by "=", the whole attributes are comma-separated.

Overrides:
toString in class java.lang.Object
Returns:
String

getX509Name

org.bouncycastle.asn1.x509.X509Name getX509Name()
Returns the BouncyCastle X509Name representation of this object. For internal use only.

Returns:
the BouncyCastle X509Name representation of this object

getSortedIdentifiers

private static java.util.Enumeration getSortedIdentifiers()
Returns the most important BC object identifiers sorted in a reasonable way.

Returns:
an Enumeration of the the most important BC object identifiers sorted in a reasonable way