org.glite.security.util
Class DNImplRFC2253

java.lang.Object
  extended by org.glite.security.util.DNImplRFC2253
All Implemented Interfaces:
DN
Direct Known Subclasses:
DNImpl

public class DNImplRFC2253
extends java.lang.Object
implements DN

DNImpl.java

Author:
Joni Hahkala Created on September 8, 2003, 7:21 PM

Field Summary
static int CANON
          Marker for the canonicalized format.
 java.lang.String m_canonicalString
          The DN in canonical format.
 int m_count
          The number of fields in the DN.
 org.bouncycastle.asn1.DERObjectIdentifier[] m_oids
          The array of object identifiers.
 java.lang.String[] m_rdns
          The array of relative distinguished names.
 java.lang.String m_rfc2253String
          The DN in RFC2253 format.
 java.lang.String m_x500String
          The DN in X500 format.
static int RFC2253
          Marker for the RFC2253 format.
static int X500
          Marker for the X500 format.
 
Constructor Summary
DNImplRFC2253(org.bouncycastle.asn1.DERObjectIdentifier[] newOids, java.lang.String[] newRdns, int newCount)
          Creates a new instance of DN.
DNImplRFC2253(java.security.Principal principal)
          Creates a new DNImpl object.
DNImplRFC2253(java.lang.String name)
          Creates a new DNImpl object.
DNImplRFC2253(java.lang.String name, boolean reversed)
          Creates a new DNImpl object.
DNImplRFC2253(org.bouncycastle.asn1.x509.X509Name x509Name)
          Creates a new DNImpl object.
 
Method Summary
 java.lang.String constructRFC2253(boolean canon)
          Deprecated. Use getXXX or internally use private construct method.
 java.lang.String constructX500()
          Contructs the X500 format string of the DN.
 boolean equals(java.lang.Object inputDN2)
          The equals comparison of the DN with another DN.
 java.lang.String getCanon()
          Generates a canonical format string of the DN.
 java.lang.String getLastCNValue()
          Returns the value of the last CN value in the DN.
 java.lang.String getRFC2253()
          Used to get the DN in RFC2253 format.
 java.lang.String getRFC2253v2()
          Used to get the DN in RFC2253 format.
 java.lang.String getRFCDN()
          Used to get the DN in RFC2253 format.
 java.lang.String getRFCDNv2()
          Used to get the DN in RFC2253 format.
 java.lang.String getX500()
          Generates a X500 format string of the DN.
 int hashCode()
          Returns the hashcode of the instance.
 boolean isEmpty()
          Method to check if the DN is empty.
 void parse(java.lang.String inputDN)
          Deprecated. internal method, replaced with parse(String inputDN, boolean reversed)
 void parseX500(java.lang.String inputDN)
          Deprecated. internal method, replaced with parseX500(String inputDN, boolean reversed)
 java.lang.String toString()
          Returns the RFC2253 format of the DN.
 DN withoutLastCN(boolean checkProxy)
          Returns the DN without the last CN.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RFC2253

public static final int RFC2253
Marker for the RFC2253 format.

See Also:
Constant Field Values

X500

public static final int X500
Marker for the X500 format.

See Also:
Constant Field Values

CANON

public static final int CANON
Marker for the canonicalized format.

See Also:
Constant Field Values

m_rfc2253String

public java.lang.String m_rfc2253String
The DN in RFC2253 format. A cache to avoid generating the string multiple times


m_x500String

public java.lang.String m_x500String
The DN in X500 format. A cache to avoid generating the string multiple times


m_canonicalString

public java.lang.String m_canonicalString
The DN in canonical format. A cache to avoid generating the string multiple times


m_rdns

public java.lang.String[] m_rdns
The array of relative distinguished names.


m_oids

public org.bouncycastle.asn1.DERObjectIdentifier[] m_oids
The array of object identifiers.


m_count

public int m_count
The number of fields in the DN.

Constructor Detail

DNImplRFC2253

public DNImplRFC2253(org.bouncycastle.asn1.DERObjectIdentifier[] newOids,
                     java.lang.String[] newRdns,
                     int newCount)
Creates a new instance of DN.

Parameters:
newOids - The array of object identifiers.
newRdns - The array or relative distinguished names.
newCount - The number of fields in the DN (both oids and rdns have to have this number of items).

DNImplRFC2253

public DNImplRFC2253(java.lang.String name)
Creates a new DNImpl object. Assumes the string represents either an old openssl x500 format DN in direct format or a proper reversed RFC2253 format DN.

Parameters:
name - Generates a new DNImpl class from the DN in the name.

DNImplRFC2253

public DNImplRFC2253(java.lang.String name,
                     boolean reversed)
Creates a new DNImpl object.

Parameters:
name - Generates a new DNImpl class from the DN in the name.
reversed - Whether the given DN is reversed or not for proper RFC 2254 DNs this should be true.

DNImplRFC2253

public DNImplRFC2253(java.security.Principal principal)
Creates a new DNImpl object.

Parameters:
principal - The Principal holding the information to generate the DN from.

DNImplRFC2253

public DNImplRFC2253(org.bouncycastle.asn1.x509.X509Name x509Name)
Creates a new DNImpl object.

Parameters:
x509Name - The X509Name instance holding the information to generate the DN from.
Method Detail

getX500

public java.lang.String getX500()
Generates a X500 format string of the DN.

Specified by:
getX500 in interface DN
Returns:
the X500 format string of the DN.

getRFC2253

public java.lang.String getRFC2253()
Description copied from interface: DN
Used to get the DN in RFC2253 format. E.g. "C=US,O=Nerd Heaven,CN=Nerd Nerdsten", emailaddress is showed as "Email"

Specified by:
getRFC2253 in interface DN
Returns:
String the DN in RFC2253 format

getRFC2253v2

public java.lang.String getRFC2253v2()
Description copied from interface: DN
Used to get the DN in RFC2253 format. E.g. "CN=Nerd Nerdsten,O=Nerd Heaven,C=US" (reverse=true) or "C=US,O=Nerd Heaven,CN=Nerd Nerdsten" (reverse=false), emailaddress is showed as "Email"

Specified by:
getRFC2253v2 in interface DN
Returns:
String the DN in RFC2253 format

getRFCDN

public java.lang.String getRFCDN()
Description copied from interface: DN
Used to get the DN in RFC2253 format. E.g. "CN=Nerd Nerdsten,O=Nerd Heaven,C=US", emailaddress is showed as "Email". Also serialnumber supported.

Specified by:
getRFCDN in interface DN
Returns:
String the DN in RFC2253 format

getRFCDNv2

public java.lang.String getRFCDNv2()
Description copied from interface: DN
Used to get the DN in RFC2253 format. E.g. "CN=Nerd Nerdsten,O=Nerd Heaven,C=US", emailaddress is showed as "emailAddress" and non supported RDN identifiers like serialnumber as an OID.

Specified by:
getRFCDNv2 in interface DN
Returns:
String the DN in RFC2253 format

getCanon

public java.lang.String getCanon()
Generates a canonical format string of the DN.

Specified by:
getCanon in interface DN
Returns:
the canonical format string of the DN.

constructX500

public java.lang.String constructX500()
Contructs the X500 format string of the DN.

Returns:
the X500 format string of the DN.

constructRFC2253

public java.lang.String constructRFC2253(boolean canon)
Deprecated. Use getXXX or internally use private construct method.

Constructs the RFC2253 format string of the DN.

Parameters:
canon - whether to construct canonical (lowercase) version of the string.
Returns:
the RFC2253 format string of the DN.

parse

public void parse(java.lang.String inputDN)
Deprecated. internal method, replaced with parse(String inputDN, boolean reversed)

Parses the RFC2253 format string and puts the fields into the internal structure.

Parameters:
inputDN - the string that contains the DN to parse.

parseX500

public void parseX500(java.lang.String inputDN)
Deprecated. internal method, replaced with parseX500(String inputDN, boolean reversed)

Parses the X500 format string and puts the fields into the internal structure.

Parameters:
inputDN - the string that contains the DN to parse.

equals

public boolean equals(java.lang.Object inputDN2)
The equals comparison of the DN with another DN. The comparison is done using oids and rdns.

Overrides:
equals in class java.lang.Object
Parameters:
inputDN2 - The DN to compare with.
Returns:
true if the DNs are equal (oids match, rdns match, count of fields match), false otherwise.

toString

public java.lang.String toString()
Returns the RFC2253 format of the DN.

Overrides:
toString in class java.lang.Object
Returns:
the RFC2253 format of the DN.

withoutLastCN

public DN withoutLastCN(boolean checkProxy)
Returns the DN without the last CN. Throws IllegalArgumentException in case the DN doesn't end with CN or in case the proxy checking is used and the DN does not end with the proxy CN.

Specified by:
withoutLastCN in interface DN
Parameters:
checkProxy - whether to check that the last CN is a proxy CN (matches "^((limited )*proxy|[0-9]*)$").
Returns:
The DN without the last CN.

hashCode

public int hashCode()
Returns the hashcode of the instance.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode.

getLastCNValue

public java.lang.String getLastCNValue()
Description copied from interface: DN
Returns the value of the last CN value in the DN. For example for the DN "C=CH, O=CERN, OU=Organic units, CN=John Doe, SN=1234" method would return "John Doe".

Specified by:
getLastCNValue in interface DN
Returns:
The value of the last CN.

isEmpty

public boolean isEmpty()
Description copied from interface: DN
Method to check if the DN is empty.

Specified by:
isEmpty in interface DN
Returns:
returns true if the DN fields are empty.