com.ibm.security.x509
Class X500Name

com.ibm.security.x509.X500Name

public final class X500Name
implements Principal

X.500 names are used to identify entities, such as those which are identified by X.509 certificates. They are world-wide, hierarchical, and descriptive. Entities can be identified by attributes, and in some systems can be searched for according to those attributes.

X500Name objects are immutable; they cannot be changed once created.


Field Summary
static ObjectIdentifier commonName_oid
          OID for the "CN=" attribute, denoting a person's common name.
static ObjectIdentifier countryName_oid
          OID for the "C=" attribute, denoting a country.
static ObjectIdentifier dnQualifier_oid
          OID for the "=" attribute, denoting a person's initials.
static ObjectIdentifier domainComponent_oid
          OID for the "DC=" attribute, denoting an entry's domain component.
static ObjectIdentifier emailAddress_oid
          OID for the "EMAIL=" attribute, denoting a person's email address.
static ObjectIdentifier generationQualifier_oid
          OID for the "GENERATION=" attribute.
static ObjectIdentifier givenName_oid
          OID for the "=" attribute, denoting a person's given name.
static ObjectIdentifier initials_oid
          OID for the "=" attribute, denoting a person's initials.
static ObjectIdentifier ipAddress_oid
          OID for "IP=" IP address attributes, used with SKIP.
static ObjectIdentifier localityName_oid
          OID for the "L=" attribute, denoting a locality (such as a city)
static ObjectIdentifier orgName_oid
          OID for the "O=" attribute, denoting an organization name
static ObjectIdentifier orgUnitName_oid
          OID for the "OU=" attribute, denoting an organizational unit name
static ObjectIdentifier postalCode_oid
          OID for the "POSTALCODE=" attribute, denoting a postal code.
static ObjectIdentifier serialNumber_oid
          OID for the "serialNumber=" attribute, denoting a person's serial number.
static ObjectIdentifier stateName_oid
          OID for the "S=" attribute, denoting a state (such as Delaware)
static ObjectIdentifier streetAddress_oid
          OID for the "STREET=" attribute, denoting a street address.
static ObjectIdentifier surName_oid
          OID for the "=" attribute, denoting a person's surname.
static ObjectIdentifier title_oid
          OID for the "T=" attribute, denoting a person's title.
static ObjectIdentifier userid_oid
          OID for the "UID=" attribute, denoting an entry's user ID.
 
Constructor Summary
X500Name(byte[] name)
          Constructs a name from an ASN.1 encoded byte array.
X500Name(com.ibm.security.util.DerInputStream in)
          Constructs a name from an ASN.1 encoded input stream.
X500Name(com.ibm.security.util.DerValue value)
          Constructs a name from an ASN.1 encoded value.
X500Name(com.ibm.security.x509.RDN[] rdns)
           
X500Name(String dname)
          Constructs a name from a conventionally formatted string, such as "CN=Dave, OU=JavaSoft, O=Sun Microsystems, C=US".
X500Name(String commonName, String organizationUnit, String organizationName, String country)
          Constructs a name from fields common in enterprise application environments.
X500Name(String commonName, String organizationUnit, String organizationName, String country, String emailAddress)
          Constructs a name from fields common in enterprise application environments.
X500Name(String commonName, String organizationUnit, String organizationName, String localityName, String stateName, String country)
          Constructs a name from fields common in Internet application environments.
X500Name(String commonName, String organizationUnit, String organizationName, String localityName, String stateName, String postalCode, String country)
          Constructs a name from fields common in Internet application environments.
 
Method Summary
 void emit(com.ibm.security.util.DerOutputStream out)
          Deprecated. Use encode() instead
 void encode(com.ibm.security.util.DerOutputStream out)
          Encodes the name in DER-encoded form.
 boolean equals(Object other)
          Compares this name with another, for equality.
 boolean equals(X500Name other)
          Compares this name with another, for equality.
 String getCommonName()
          Returns a "Common Name" component.
 String getCountry()
          Returns a "Country" name component.
 String getEmail()
          Returns a "Email" component.
 byte[] getEncoded()
          Gets the name in DER-encoded form.
 String getLocality()
          Returns a "Locality" name component.
 String getName()
          Returns the value of toString().
 String getOrganization()
          Returns an "Organization" name component.
 String getOrganizationalUnit()
          Returns an "Organizational Unit" name component.
 X500Name getParentDn()
           
 String getPostalCode()
          Returns a "postalCode" component.
 com.ibm.security.x509.RDN getRDN(int index)
           
 String getRFC1779Name()
          Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 1779.
 String getRFC2253CanonicalName()
           
 String getRFC2253Name()
          Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 2253.
 String getState()
          Returns a "State" name component.
 int getType()
          Return type of GeneralName.
 int hashCode()
          Calculates a hash code value for the object.
 boolean isAbove(X500Name other)
           
 int size()
           
 String toString()
          Returns a string form of the X.500 distinguished name.
 

Field Detail

emailAddress_oid

public static ObjectIdentifier emailAddress_oid
OID for the "EMAIL=" attribute, denoting a person's email address.

postalCode_oid

public static ObjectIdentifier postalCode_oid
OID for the "POSTALCODE=" attribute, denoting a postal code.

serialNumber_oid

public static ObjectIdentifier serialNumber_oid
OID for the "serialNumber=" attribute, denoting a person's serial number.

commonName_oid

public static ObjectIdentifier commonName_oid
OID for the "CN=" attribute, denoting a person's common name.

countryName_oid

public static ObjectIdentifier countryName_oid
OID for the "C=" attribute, denoting a country.

localityName_oid

public static ObjectIdentifier localityName_oid
OID for the "L=" attribute, denoting a locality (such as a city)

orgName_oid

public static ObjectIdentifier orgName_oid
OID for the "O=" attribute, denoting an organization name

orgUnitName_oid

public static ObjectIdentifier orgUnitName_oid
OID for the "OU=" attribute, denoting an organizational unit name

stateName_oid

public static ObjectIdentifier stateName_oid
OID for the "S=" attribute, denoting a state (such as Delaware)

streetAddress_oid

public static ObjectIdentifier streetAddress_oid
OID for the "STREET=" attribute, denoting a street address.

title_oid

public static ObjectIdentifier title_oid
OID for the "T=" attribute, denoting a person's title.

surName_oid

public static ObjectIdentifier surName_oid
OID for the "=" attribute, denoting a person's surname.

givenName_oid

public static ObjectIdentifier givenName_oid
OID for the "=" attribute, denoting a person's given name.

initials_oid

public static ObjectIdentifier initials_oid
OID for the "=" attribute, denoting a person's initials.

ipAddress_oid

public static ObjectIdentifier ipAddress_oid
OID for "IP=" IP address attributes, used with SKIP.

dnQualifier_oid

public static ObjectIdentifier dnQualifier_oid
OID for the "=" attribute, denoting a person's initials.

domainComponent_oid

public static ObjectIdentifier domainComponent_oid
OID for the "DC=" attribute, denoting an entry's domain component.

generationQualifier_oid

public static ObjectIdentifier generationQualifier_oid
OID for the "GENERATION=" attribute.

userid_oid

public static ObjectIdentifier userid_oid
OID for the "UID=" attribute, denoting an entry's user ID.
Constructor Detail

X500Name

public X500Name(String dname)
         throws IOException
Constructs a name from a conventionally formatted string, such as "CN=Dave, OU=JavaSoft, O=Sun Microsystems, C=US". (RFC 1779 style).
Parameters:
DN - X.500 Distinguished Name

X500Name

public X500Name(String commonName,
                String organizationUnit,
                String organizationName,
                String country)
         throws IOException
Constructs a name from fields common in enterprise application environments.

NOTE: The behaviour when any of these strings contain characters outside the ASCII range is unspecified in currently relevant standards.

Parameters:
commonName - common name of a person, e.g. "Vivette Davis"
organizationUnit - small organization name, e.g. "Purchasing"
organizationName - large organization name, e.g. "Onizuka, Inc."
country - two letter country code, e.g. "CH"

X500Name

public X500Name(String commonName,
                String organizationUnit,
                String organizationName,
                String country,
                String emailAddress)
         throws IOException
Constructs a name from fields common in enterprise application environments.

NOTE: The behaviour when any of these strings contain characters outside the ASCII range is unspecified in currently relevant standards.

Parameters:
commonName - common name of a person, e.g. "Vivette Davis"
organizationUnit - small organization name, e.g. "Purchasing"
organizationName - large organization name, e.g. "Onizuka, Inc."
country - two letter country code, e.g. "CH"
emailAddress - email address string, e.g. "javauser@us.ibm.com"

X500Name

public X500Name(String commonName,
                String organizationUnit,
                String organizationName,
                String localityName,
                String stateName,
                String country)
         throws IOException
Constructs a name from fields common in Internet application environments.

NOTE: The behaviour when any of these strings contain characters outside the ASCII range is unspecified in currently relevant standards.

Parameters:
commonName - common name of a person, e.g. "Vivette Davis"
organizationUnit - small organization name, e.g. "Purchasing"
organizationName - large organization name, e.g. "Onizuka, Inc."
localityName - locality (city) name, e.g. "Palo Alto"
stateName - state name, e.g. "California"
country - two letter country code, e.g. "CH"

X500Name

public X500Name(String commonName,
                String organizationUnit,
                String organizationName,
                String localityName,
                String stateName,
                String postalCode,
                String country)
         throws IOException
Constructs a name from fields common in Internet application environments.

NOTE: The behaviour when any of these strings contain characters outside the ASCII range is unspecified in currently relevant standards.

Parameters:
commonName - common name of a person, e.g. "Vivette Davis"
organizationUnit - small organization name, e.g. "Purchasing"
organizationName - large organization name, e.g. "Onizuka, Inc."
localityName - locality (city) name, e.g. "Palo Alto"
stateName - state name, e.g. "California"
postalCode - the zip code in the United States.
country - two letter country code, e.g. "CH"

X500Name

public X500Name(com.ibm.security.util.DerValue value)
         throws IOException
Constructs a name from an ASN.1 encoded value. The encoding of the name in the stream uses DER (a BER/1 subset).
Parameters:
value - a DER-encoded value holding an X.500 name.

X500Name

public X500Name(com.ibm.security.util.DerInputStream in)
         throws IOException
Constructs a name from an ASN.1 encoded input stream. The encoding of the name in the stream uses DER (a BER/1 subset).
Parameters:
in - DER-encoded data holding an X.500 name.

X500Name

public X500Name(byte[] name)
         throws IOException
Constructs a name from an ASN.1 encoded byte array.
Parameters:
name - DER-encoded byte array holding an X.500 name.

X500Name

public X500Name(com.ibm.security.x509.RDN[] rdns)
Method Detail

equals

public boolean equals(Object other)
Compares this name with another, for equality.
Specified by:
equals in interface Principal
Returns:
true iff the names are identical.

hashCode

public int hashCode()
Calculates a hash code value for the object. Objects which are equal will also have the same hashcode.
Specified by:
hashCode in interface Principal

equals

public boolean equals(X500Name other)
Compares this name with another, for equality.
Returns:
true iff the names are identical.

getType

public int getType()
Return type of GeneralName.

getCountry

public String getCountry()
                  throws IOException
Returns a "Country" name component. If more than one such attribute exists, the topmost one is returned.
Returns:
"C=" component of the name, if any.

getOrganization

public String getOrganization()
                       throws IOException
Returns an "Organization" name component. If more than one such attribute exists, the topmost one is returned.
Returns:
"O=" component of the name, if any.

getOrganizationalUnit

public String getOrganizationalUnit()
                             throws IOException
Returns an "Organizational Unit" name component. If more than one such attribute exists, the topmost one is returned.
Returns:
"OU=" component of the name, if any.

getCommonName

public String getCommonName()
                     throws IOException
Returns a "Common Name" component. If more than one such attribute exists, the topmost one is returned.
Returns:
"CN=" component of the name, if any.

getLocality

public String getLocality()
                   throws IOException
Returns a "Locality" name component. If more than one such component exists, the topmost one is returned.
Returns:
"L=" component of the name, if any.

getState

public String getState()
                throws IOException
Returns a "State" name component. If more than one such component exists, the topmost one is returned.
Returns:
"S=" component of the name, if any.

getEmail

public String getEmail()
                throws IOException
Returns a "Email" component. If more than one such attribute exists, the topmost one is returned.
Returns:
"EMAIL=" component of the name, if any.

getPostalCode

public String getPostalCode()
                     throws IOException
Returns a "postalCode" component. If more than one such attribute exists, the topmost one is returned.
Returns:
"POSTALCODE=" component of the name, if any.

toString

public String toString()
Returns a string form of the X.500 distinguished name. The format of the string is from RFC 1779.
Specified by:
toString in interface Principal

getName

public String getName()
Returns the value of toString(). This call is needed to implement the java.security.Principal interface.
Specified by:
getName in interface Principal

emit

public void emit(com.ibm.security.util.DerOutputStream out)
          throws IOException
Deprecated. Use encode() instead

Encodes the name in DER-encoded form.
Parameters:
out - where to put the DER-encoded X.500 name

encode

public void encode(com.ibm.security.util.DerOutputStream out)
            throws IOException
Encodes the name in DER-encoded form.
Parameters:
out - where to put the DER-encoded X.500 name

getEncoded

public byte[] getEncoded()
                  throws IOException
Gets the name in DER-encoded form.
Returns:
the DER encoded byte array of this name.

size

public int size()

getRDN

public com.ibm.security.x509.RDN getRDN(int index)

getParentDn

public X500Name getParentDn()

getRFC1779Name

public String getRFC1779Name()
Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 1779. Only standard attribute type keywords defined in RFC 1779 are emitted.

getRFC2253Name

public String getRFC2253Name()
Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 2253. Only standard attribute type keywords defined in RFC 2253 are emitted.

getRFC2253CanonicalName

public String getRFC2253CanonicalName()

isAbove

public boolean isAbove(X500Name other)