Oracle Security Developer Tools Security Engine Java API Reference
10g (10.1.4.0.1)

B28175-01


oracle.security.crypto.cert
Class X500Name

java.lang.Object
  extended byoracle.security.crypto.cert.Entity
      extended byoracle.security.crypto.cert.X500Name

All Implemented Interfaces:
oracle.security.crypto.asn1.ASN1Object, java.io.Externalizable, java.io.Serializable, oracle.security.crypto.util.Streamable

public class X500Name
extends Entity
implements oracle.security.crypto.asn1.ASN1Object, java.io.Externalizable

This class represents distinguished names as used in the X.500 series of specifications, defined in X.520.

A X500Name is an Entity with support for some additional X.500 attributes. In addition to common name (which is the same as the entity name), the following attributes are supported using the old API methods: country, organization, organizational-unit, locality, state or province, and email. Using the new API methods, these as well as any other standard or custom attributes can be supported.

NB: It is an error to mix calls to methods used for definining attributes from both the old and new APIs.

This class implements hashCode and equals methods, and so may be used for keys in a hashtable.

Warning: The serialization capability of this class should only be used for short-term storage and RMI between applications running the same version of this product. It should not be relied on for long-term perisistence, as future versions of this class may use an incompatible serialization format. For now, applications requiring long-term persistence should use the ASN.1 encodings provided by the input(InputStream) and output(OutputStream) methods directly, instead of serialization.

See Also:
X509, X500RDN, Serialized Form

Constructor Summary
X500Name()
          Creates a new, empty X.500 name (one with no attributes).
X500Name(java.io.InputStream is)
           
X500Name(java.lang.String str)
          Parse an X.500 name from a string (e.g., one produced by toString).

 

Method Summary
 void addComponent(oracle.security.crypto.asn1.ASN1ObjectID type, oracle.security.crypto.asn1.ASN1String value)
          Add the specified type-and-value pair to this X500Name as a new component.
 void addComponent(oracle.security.crypto.asn1.ASN1ObjectID type, java.lang.String value)
          Add the specified type-and-value pair to this X500Name as a new component.
 void addComponent(java.lang.String name, java.lang.String value)
          Add the specified name-and-value pair to this X500Name as a new component; the name will be mapped to its registered OID.
 void addComponent(X500RDN rdn)
          Add the specified X500RDN to this X500Name as a new component.
 X500RDN componentAt(int i)
           
 java.util.Enumeration components()
           
 boolean equals(java.lang.Object o)
          Compares this X.500 name to the specified object.
 void forgetOriginalFormat()
          Deprecated. This method is no longer needed, as the X500Name class no longer remembers the original input string format, and calling it has no effect.
 X500RDN getAttribute(oracle.security.crypto.asn1.ASN1ObjectID type)
          Returns the first X500RDN with the given attribute type.
 X500RDN getAttribute(java.lang.String name)
          Returns the first X500RDN with the given attribute name.
 oracle.security.crypto.asn1.ASN1Object getAttributeValue(oracle.security.crypto.asn1.ASN1ObjectID type)
          Gets the value for the first X500RDN with the given attribute type.
 oracle.security.crypto.asn1.ASN1Object getAttributeValue(java.lang.String name)
          Gets the value for the first X500RDN with the given attribute name.
 java.lang.String getCommonName()
           
 java.util.Vector getComponents()
           
 java.lang.String getCountryName()
           
 java.lang.String getEmail()
           
 java.lang.String getLocalityName()
           
 java.lang.String getOrganizationName()
           
 java.lang.String getOrgUnitName()
           
 java.lang.String getStateName()
           
 int hashCode()
           
 void input(java.io.InputStream is)
          Initializes this X.500 name by reading its DER-encoding from the specified input stream.
 void input(java.lang.String s)
          Initializes this X.500 name by reading its description from the specified string.
 int length()
           
 void output(java.io.OutputStream os)
          Output to the specified output stream.
 void readExternal(java.io.ObjectInput is)
           
 void setAttr(java.lang.String name, java.lang.String value)
          Sets the attribute of this X.500 name indicated by the given string.
 void setCommonName(java.lang.String s)
           
 void setCountryName(java.lang.String s)
           
 void setEmail(java.lang.String s)
           
 void setLocalityName(java.lang.String s)
           
 void setOrganizationName(java.lang.String s)
           
 void setOrgUnitName(java.lang.String s)
           
 void setStateName(java.lang.String s)
           
 int size()
           
 java.lang.String toString()
          Returns a string representation of this X500Name.
 void writeExternal(java.io.ObjectOutput os)
           

 

Methods inherited from class oracle.security.crypto.cert.Entity
getName, initialize, save, setName

 

Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait

 

Constructor Detail

X500Name

public X500Name()
Creates a new, empty X.500 name (one with no attributes).

X500Name

public X500Name(java.lang.String str)
Parse an X.500 name from a string (e.g., one produced by toString). The following notation is used: attr=value, attr=value, ... There shall be no space around the equal sign or before the comma. A comma in the value may be escaped using a backslash. The attribute names are case-insensitive. The following attribute names are supported: C, ST, L, O, OU, CN, EMAIL.
See Also:
toString(), equals(java.lang.Object)

X500Name

public X500Name(java.io.InputStream is)
         throws java.io.IOException

Method Detail

addComponent

public void addComponent(X500RDN rdn)
Add the specified X500RDN to this X500Name as a new component.

addComponent

public void addComponent(oracle.security.crypto.asn1.ASN1ObjectID type,
                         oracle.security.crypto.asn1.ASN1String value)
Add the specified type-and-value pair to this X500Name as a new component.
See Also:
for defined OIDs from the id_at arc.

addComponent

public void addComponent(oracle.security.crypto.asn1.ASN1ObjectID type,
                         java.lang.String value)
Add the specified type-and-value pair to this X500Name as a new component.

The string value will be converted to an ASN1String of the appropriate type (IA5String, UTF8String, PrintableString) depending on the character composition of the value.

See Also:
for defined OIDs from the id_at arc., X500RDN.addAttribute(ASN1ObjectID type, String value)

addComponent

public void addComponent(java.lang.String name,
                         java.lang.String value)
Add the specified name-and-value pair to this X500Name as a new component; the name will be mapped to its registered OID.

The following names are recognized by default: C, ST, L, O, OU, CN, Email. Additional names may be mapped to OIDs at run-time using the OIDManager.setProperty(oracle.security.crypto.asn1.ASN1ObjectID, java.lang.String, java.lang.String) method with "attributeTypeName" as the key argument.


getAttributeValue

public oracle.security.crypto.asn1.ASN1Object getAttributeValue(java.lang.String name)
Gets the value for the first X500RDN with the given attribute name.
Parameters:
name - Code for which attribute to get (e.g. "C" for country name).
Returns:
The ASN1String value of the given attribute, or null if it has not been defined.

getAttributeValue

public oracle.security.crypto.asn1.ASN1Object getAttributeValue(oracle.security.crypto.asn1.ASN1ObjectID type)
Gets the value for the first X500RDN with the given attribute type.
Parameters:
type - OID for which attribute to get.
Returns:
The ASN1String value of the given attribute, or null if it has not been defined.

getAttribute

public X500RDN getAttribute(java.lang.String name)
Returns the first X500RDN with the given attribute name.
Parameters:
name - Code for which attribute to get (e.g. "C" for country name).
Returns:
The first X500RDN with the given attribute name, or null if it has not been defined.

getAttribute

public X500RDN getAttribute(oracle.security.crypto.asn1.ASN1ObjectID type)
Returns the first X500RDN with the given attribute type.
Parameters:
type - OID for which attribute to get.
Returns:
The first X500RDN with the given attribute type, or null if it has not been defined.

input

public void input(java.io.InputStream is)
           throws java.io.IOException
Initializes this X.500 name by reading its DER-encoding from the specified input stream.
Specified by:
input in interface oracle.security.crypto.util.Streamable
Throws:
java.io.IOException

input

public void input(java.lang.String s)
           throws oracle.security.crypto.util.InvalidFormatException
Initializes this X.500 name by reading its description from the specified string.
Throws:
oracle.security.crypto.util.InvalidFormatException - If the string is not the correct format

output

public void output(java.io.OutputStream os)
            throws java.io.IOException
Output to the specified output stream. The order of attributes is the same as the order in which they were defined (attributes with null values will be omitted).

Note: If the old API methods are used to define the attributes the the order of output is as follows: C, ST, L, O, OU, CN, EMAIL.

Specified by:
output in interface oracle.security.crypto.util.Streamable
Throws:
java.io.IOException

length

public int length()
Specified by:
length in interface oracle.security.crypto.util.Streamable

toString

public java.lang.String toString()
Returns a string representation of this X500Name. The output of this method is suitable for use in the constructor X500Name(String). The order of entries is the reverse of the order produced by the output method.
See Also:
X500Name(String), output(OutputStream)

getComponents

public java.util.Vector getComponents()

components

public java.util.Enumeration components()

size

public int size()

componentAt

public X500RDN componentAt(int i)

getCountryName

public java.lang.String getCountryName()

setCountryName

public void setCountryName(java.lang.String s)

getStateName

public java.lang.String getStateName()

setStateName

public void setStateName(java.lang.String s)

getLocalityName

public java.lang.String getLocalityName()

setLocalityName

public void setLocalityName(java.lang.String s)

getOrganizationName

public java.lang.String getOrganizationName()

setOrganizationName

public void setOrganizationName(java.lang.String s)

getOrgUnitName

public java.lang.String getOrgUnitName()

setOrgUnitName

public void setOrgUnitName(java.lang.String s)

getCommonName

public java.lang.String getCommonName()

setCommonName

public void setCommonName(java.lang.String s)

getEmail

public java.lang.String getEmail()

setEmail

public void setEmail(java.lang.String s)

setAttr

public void setAttr(java.lang.String name,
                    java.lang.String value)
Sets the attribute of this X.500 name indicated by the given string.

forgetOriginalFormat

public void forgetOriginalFormat()
Deprecated. This method is no longer needed, as the X500Name class no longer remembers the original input string format, and calling it has no effect.
Forgets the original string format used to input this X.500 name.

equals

public boolean equals(java.lang.Object o)

Compares this X.500 name to the specified object. Returns true if and only if the argument is not null, and represents the same X.500 name. For the purposes of this comparison operation, two X.500 names are considered the same if and only if all the attributes recognized by this implementation have the same value.

Overrides:
equals in class Entity

hashCode

public int hashCode()

writeExternal

public void writeExternal(java.io.ObjectOutput os)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput is)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

Oracle Security Developer Tools Security Engine Java API Reference
10g (10.1.4.0.1)

B28175-01


Copyright © 2005 ,2006 , Oracle. All rights reserved.