org.glite.security.util
Class DNImpl

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

public class DNImpl
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.
 int count
          The number of fields in the DN.
 java.lang.String m_canonicalString
          The DN in canonical format.
 java.lang.String m_rfc2253String
          The DN in RFC2253 format.
 java.lang.String m_x500String
          The DN in X500 format.
 org.bouncycastle.asn1.DERObjectIdentifier[] oids
          The array of object identifiers.
 java.lang.String[] rdns
          The array of relative distiquished names.
static int RFC2253
          Marker for the RFC2253 format.
static int X500
          Marker for the X500 format.
 
Constructor Summary
DNImpl(org.bouncycastle.asn1.DERObjectIdentifier[] newOids, java.lang.String[] newRdns, int newCount)
          Creates a new instance of DN.
DNImpl(java.security.Principal principal)
          Creates a new DNImpl object.
DNImpl(java.lang.String name)
          Creates a new DNImpl object.
 
Method Summary
 java.lang.String constructRFC2253(boolean canon)
          Contructs the RFC2253 format string of the DN.
 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 getRFC2253()
          Generates a RFC2253 format string of the DN.
 java.lang.String getX500()
          Generates a X500 format string of the DN.
 int hashCode()
          Returns the hashcode of the instance.
 void parse(java.lang.String inputDN)
          Parses the RFC2253 format string and puts the fields into the internal structure.
 void parseX500(java.lang.String inputDN)
          Parses the X500 format string and puts the fields into the internal structure.
 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


rdns

public java.lang.String[] rdns
The array of relative distiquished names.


oids

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


count

public int count
The number of fields in the DN.

Constructor Detail

DNImpl

public DNImpl(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 distinquished names.
newCount - The number of fields in the DN (both oids and rdns have to have this number of items).

DNImpl

public DNImpl(java.lang.String name)
Creates a new DNImpl object.

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

DNImpl

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

Parameters:
principal - The Principal 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()
Generates a RFC2253 format string of the DN.

Specified by:
getRFC2253 in interface DN
Returns:
the RFC2253 format string of the DN.

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)
Contructs 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)
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)
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 checkin 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.