public class X500Name extends Entity
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.
X509
,
X500RDN
,
Serialized FormConstructor and Description |
---|
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 ). |
Modifier and Type | Method and Description |
---|---|
void |
addComponent(ASN1ObjectID type,
ASN1String value)
Add the specified type-and-value pair to this
X500Name as
a new component. |
void |
addComponent(ASN1ObjectID type,
java.lang.String value)
Add the specified type-and-value pair to this
X500Name as
a new component. |
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(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. |
ASN1Object |
getAttributeValue(ASN1ObjectID type)
Gets the value for the first
X500RDN with the given
attribute type. |
ASN1Object |
getAttributeValue(java.lang.String name)
Gets the value for the first
X500RDN with the given
attribute name. |
java.lang.String |
getCommonName()
Deprecated.
Old API method - use #getAttributeValue instead.
|
java.util.Vector<X500RDN> |
getComponents()
Deprecated.
|
java.util.ArrayList<X500RDN> |
getComponentsAsList() |
java.lang.String |
getCountryName()
Deprecated.
Instead use
getAttributeValue(java.lang.String) instead. |
java.lang.String |
getEmail()
Deprecated.
Instead use
getAttributeValue(java.lang.String) instead. |
java.lang.String |
getLocalityName()
Deprecated.
Instead use
getAttributeValue(java.lang.String) instead. |
java.lang.String |
getOrganizationName()
Deprecated.
Instead use
getAttributeValue(java.lang.String) instead. |
java.lang.String |
getOrgUnitName()
Deprecated.
Instead use
getAttributeValue(java.lang.String) instead. |
java.lang.String |
getStateName()
Deprecated.
Instead use
getAttributeValue(java.lang.String) instead. |
int |
hashCode() |
void |
input(java.io.InputStream is)
Initializes this X.500 name by reading its DER-encoding from the
specified input stream.
|
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)
Deprecated.
Instead use
addComponent(oracle.security.crypto.cert.X500RDN) instead. |
void |
setCommonName(java.lang.String s)
Deprecated.
Instead use
addComponent(oracle.security.crypto.cert.X500RDN) at the appropriate location
in the DN, with the attribute type
PKIX.id_at_commonName . |
void |
setCountryName(java.lang.String s)
Deprecated.
Instead use
addComponent(oracle.security.crypto.cert.X500RDN) at the appropriate location
in the DN, with the attribute type
PKIX.id_at_countryName . |
void |
setEmail(java.lang.String s)
Deprecated.
To include a RFC-822 email address as part of the subject of a
X.509 certificate, use a
SubjectAltNameExtension .
If an email address must be included in a
X500Name , use addComponent(oracle.security.crypto.cert.X500RDN) at the
appropriate location in the DN, with the attribute type
PKIX.emailAddress . |
void |
setLocalityName(java.lang.String s)
Deprecated.
Instead use
addComponent(oracle.security.crypto.cert.X500RDN) at the appropriate location
in the DN, with the attribute type
PKIX.id_at_localityName . |
void |
setOrganizationName(java.lang.String s)
Deprecated.
Instead use
addComponent(oracle.security.crypto.cert.X500RDN) at the appropriate location
in the DN, with the attribute type
PKIX.id_at_organizationName . |
void |
setOrgUnitName(java.lang.String s)
Deprecated.
Instead use
addComponent(oracle.security.crypto.cert.X500RDN) at the appropriate location
in the DN, with the attribute type
PKIX.id_at_organizationalUnitName . |
void |
setStateName(java.lang.String s)
Deprecated.
Instead use
addComponent(oracle.security.crypto.cert.X500RDN) at the appropriate location
in the DN, with the attribute type
PKIX.id_at_stateOrProvinceName . |
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) |
public X500Name()
public X500Name(java.lang.String str)
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
, SERIALNUMBER
.toString()
,
equals(java.lang.Object)
public X500Name(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public static X500Name toX500Name(javax.security.auth.x500.X500Principal p)
public void addComponent(X500RDN rdn)
X500RDN
to this X500Name
as a new component.public void addComponent(ASN1ObjectID type, ASN1String value)
X500Name
as
a new component.for defined OIDs from the id_at
arc.
public void addComponent(ASN1ObjectID type, java.lang.String value)
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.
public ASN1Object getAttributeValue(java.lang.String name)
X500RDN
with the given
attribute name.name
- Code for which attribute to get (e.g. "C" for country name).ASN1String
value of the given attribute, or
null
if it has not been defined.public ASN1Object getAttributeValue(ASN1ObjectID type)
X500RDN
with the given
attribute type.type
- OID for which attribute to get.ASN1String
value of the given attribute, or
null
if it has not been defined.public X500RDN getAttribute(java.lang.String name)
X500RDN
with the given attribute name.name
- Code for which attribute to get (e.g. "C" for country name).X500RDN
with the given attribute name,
or null
if it has not been defined.public X500RDN getAttribute(ASN1ObjectID type)
X500RDN
with the given attribute type.type
- OID for which attribute to get.X500RDN
with the given attribute type,
or null
if it has not been defined.public void input(java.io.InputStream is) throws java.io.IOException
java.io.IOException
public void output(java.io.OutputStream os) throws java.io.IOException
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
.
java.io.IOException
public int length()
public java.lang.String toString()
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.toString
in class java.lang.Object
X500Name(String)
,
output(OutputStream)
public java.util.Vector<X500RDN> getComponents()
getComponentsAsList()
public java.util.ArrayList<X500RDN> getComponentsAsList()
public java.util.Enumeration<X500RDN> components()
getComponentsAsList()
and then get Iteratorpublic int size()
public X500RDN componentAt(int i)
public java.lang.String getCountryName()
getAttributeValue(java.lang.String)
instead.public void setCountryName(java.lang.String s)
addComponent(oracle.security.crypto.cert.X500RDN)
at the appropriate location
in the DN, with the attribute type
PKIX.id_at_countryName
.public java.lang.String getStateName()
getAttributeValue(java.lang.String)
instead.public void setStateName(java.lang.String s)
addComponent(oracle.security.crypto.cert.X500RDN)
at the appropriate location
in the DN, with the attribute type
PKIX.id_at_stateOrProvinceName
.public java.lang.String getLocalityName()
getAttributeValue(java.lang.String)
instead.public void setLocalityName(java.lang.String s)
addComponent(oracle.security.crypto.cert.X500RDN)
at the appropriate location
in the DN, with the attribute type
PKIX.id_at_localityName
.public java.lang.String getOrganizationName()
getAttributeValue(java.lang.String)
instead.public void setOrganizationName(java.lang.String s)
addComponent(oracle.security.crypto.cert.X500RDN)
at the appropriate location
in the DN, with the attribute type
PKIX.id_at_organizationName
.public java.lang.String getOrgUnitName()
getAttributeValue(java.lang.String)
instead.public void setOrgUnitName(java.lang.String s)
addComponent(oracle.security.crypto.cert.X500RDN)
at the appropriate location
in the DN, with the attribute type
PKIX.id_at_organizationalUnitName
.public java.lang.String getCommonName()
public void setCommonName(java.lang.String s)
addComponent(oracle.security.crypto.cert.X500RDN)
at the appropriate location
in the DN, with the attribute type
PKIX.id_at_commonName
.public java.lang.String getEmail()
getAttributeValue(java.lang.String)
instead.public void setEmail(java.lang.String s)
SubjectAltNameExtension
.
If an email address must be included in a
X500Name
, use addComponent(oracle.security.crypto.cert.X500RDN)
at the
appropriate location in the DN, with the attribute type
PKIX.emailAddress
.public void setAttr(java.lang.String name, java.lang.String value)
addComponent(oracle.security.crypto.cert.X500RDN)
instead.name
- Code for which attributes to set (e.g. "C" for country name).value
- Value to which the attribute will be set.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.
public int hashCode()
hashCode
in class java.lang.Object
public javax.security.auth.x500.X500Principal toX500Principal()
public void writeExternal(java.io.ObjectOutput os) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
writeExternal
in class Entity
java.io.IOException
public void readExternal(java.io.ObjectInput is) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
readExternal
in class Entity
java.io.IOException
java.lang.ClassNotFoundException