com.ibm.security12.sun.security.x509
Class X500Name

java.lang.Object
  |
  +--com.ibm.security12.sun.security.x509.X500Name

public class X500Name
extends Object
implements Principal, GeneralNameInterface

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.

Version:
1.38
Author:
David Brownell, Amit Kapoor, Hemma Prafullchandra
See Also:
GeneralName, GeneralNames, GeneralNameInterface

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 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 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 title_oid
          OID for the "T=" attribute, denoting a person's title.
 
Constructor Summary
X500Name(byte[] name)
          Constructs a name from an ASN.1 encoded byte array.
X500Name(DerInputStream in)
          Constructs a name from an ASN.1 encoded input stream.
X500Name(DerValue value)
          Constructs a name from an ASN.1 encoded value.
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 localityName, String stateName, String country)
          Constructs a name from fields common in Internet application environments.
 
Method Summary
 void emit(DerOutputStream out)
          Deprecated. Use encode() instead
 void encode(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.
 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.
 String getState()
          Returns a "State" name component.
 int getType()
          Return type of GeneralName.
 int hashCode()
          Calculates a hash code value for the object.
 String toString()
          Returns a string form of the X.500 distinguished name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

commonName_oid

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

countryName_oid

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

localityName_oid

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

orgName_oid

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

orgUnitName_oid

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

stateName_oid

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

streetAddress_oid

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

title_oid

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

ipAddress_oid

public static final ObjectIdentifier ipAddress_oid
OID for "IP=" IP address attributes, used with SKIP.
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 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(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(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.
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.
Overrides:
equals in class Object

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
Overrides:
hashCode in class Object

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.
Specified by:
getType in interface GeneralNameInterface

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.

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
Overrides:
toString in class Object

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(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(DerOutputStream out)
            throws IOException
Encodes the name in DER-encoded form.
Specified by:
encode in interface GeneralNameInterface
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.