Skip navigation links

Oracle Fusion Middleware Security Engine Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10674-04


oracle.security.crypto.cert
Class X500Name

java.lang.Object
  extended by oracle.security.crypto.cert.Entity
      extended by oracle.security.crypto.cert.X500Name

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

public class X500Name
extends Entity
implements oracle.security.crypto.asn1.ASN1Object

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<X500RDN> components()
          Deprecated. Use getComponentsAsList() and then get Iterator
 boolean equals(java.lang.Object o)
           Compares this X.500 name to the specified object, which must be of type X500Name or X500Principal.
 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<X500RDN> getComponents()
          Deprecated. Use getComponentsAsList()
 java.util.ArrayList<X500RDN> getComponentsAsList()
           
 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.
static X500Name toX500Name(javax.security.auth.x500.X500Principal p)
           
 javax.security.auth.x500.X500Principal toX500Principal()
           
 void writeExternal(java.io.ObjectOutput os)
           

 

Methods inherited from class oracle.security.crypto.cert.Entity
getName, 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
Throws:
java.io.IOException

Method Detail

toX500Name

public static X500Name toX500Name(javax.security.auth.x500.X500Principal p)

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 (or EmailAddress) Additional names may be mapped to OIDs at run-time using the oracle.security.crypto.util.OIDManager.setAttributeTypeName method.


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.
Overrides:
toString in class java.lang.Object
See Also:
X500Name(String), output(OutputStream)

getComponents

public java.util.Vector<X500RDN> getComponents()
Deprecated. Use getComponentsAsList()

getComponentsAsList

public java.util.ArrayList<X500RDN> getComponentsAsList()

components

public java.util.Enumeration<X500RDN> components()
Deprecated. Use getComponentsAsList() and then get Iterator
Returns:

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.
Parameters:
attr - Code for which attributes to set (e.g. "C" for country name).
val - Value to which the attribute will be set.

equals

public boolean equals(java.lang.Object o)

Compares this X.500 name to the specified object, which must be of type X500Name or X500Principal. 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()
Overrides:
hashCode in class java.lang.Object

toX500Principal

public javax.security.auth.x500.X500Principal toX500Principal()

writeExternal

public void writeExternal(java.io.ObjectOutput os)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Overrides:
writeExternal in class Entity
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
Overrides:
readExternal in class Entity
Throws:
java.io.IOException
java.lang.ClassNotFoundException

Skip navigation links

Oracle Fusion Middleware Security Engine Java API Reference for Oracle Security Developer Tools
11g Release 1 (11.1.1)

E10674-04


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