This class represents an X.500 Principal
.
X500Principal
s are represented by distinguished names such as
"CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US".
This class can be instantiated by using a string representation of the distinguished name, or by using the ASN.1 DER encoded byte representation of the distinguished name. The current specification for the string representation of a distinguished name is defined in RFC 2253: Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names. This class, however, accepts string formats from both RFC 2253 and RFC 1779: A String Representation of Distinguished Names, and also recognizes attribute type keywords whose OIDs (Object Identifiers) are defined in RFC 5280: Internet X.509 Public Key Infrastructure Certificate and CRL Profile.
The string representation for this X500Principal
can be obtained by calling the getName
methods.
Note that the getSubjectX500Principal
and
getIssuerX500Principal
methods of
X509Certificate
return X500Principals representing the
issuer and subject fields of the certificate.
java.security.cert.X509Certificate
Modifier and Type | Field and Description |
---|---|
public static final String | CANONICAL
Canonical String format of Distinguished Names. |
public static final String | RFC1779
RFC 1779 String format of Distinguished Names. |
public static final String | RFC2253
RFC 2253 String format of Distinguished Names. |
private static final long | |
private transient X500Name | thisX500Name
The X500Name representing this principal. |
Access | Constructor and Description |
---|---|
pack-priv | |
public | X500Principal(String
an X.500 distinguished name in RFC 1779 or RFC 2253 format name)Creates an |
public | X500Principal(String
an X.500 distinguished name in RFC 1779 or RFC 2253 format name, Map<String, String> an attribute type keyword map, where each key is a
keyword String that maps to a corresponding object identifier in String
form (a sequence of nonnegative integers separated by periods). The map
may be empty but never keywordMap)null .Creates an |
public | X500Principal(byte[]
a byte array containing the distinguished name in ASN.1
DER encoded form name)Creates an |
public | X500Principal(InputStream
an is)InputStream containing the distinguished
name in ASN.1 DER encoded formCreates an |
Modifier and Type | Method and Description |
---|---|
public boolean | Returns: true if the specified Object is equal
to this X500Principal , false otherwiseObject to be compared for equality with this
o)X500Principal Overrides java. Implements java. Compares the specified |
public byte[] | Returns: a byte array containing the distinguished name in ASN.1 DER encoded formReturns the distinguished name in ASN.1 DER encoded form. |
public String | Returns: the distinguished name of thisX500Principal Implements java. Returns a string representation of the X.500 distinguished name using the format defined in RFC 2253. |
public String | |
public String | Returns: a string representation of thisX500Principal
using the specified formatthe format to use format, Map<String, String> an OID map, where each key is an object identifier in
String form (a sequence of nonnegative integers separated by periods)
that maps to a corresponding attribute type keyword String.
The map may be empty but never oidMap)null .Returns a string representation of the X.500 distinguished name using the specified format. |
public int | Returns: a hash code for thisX500Principal Overrides java. Implements java. Returns a hash code for this |
private void | readObject(ObjectInputStream
the s)ObjectInputStream from which data is readReads this object from a stream (i.e., deserializes it). |
public String | Returns: a string representation of thisX500Principal Overrides java. Implements java. Return a user-friendly string representation of this
|
private void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to which data is writtenSave the X500Principal object to a stream. |
CANONICAL | back to summary |
---|---|
public static final String CANONICAL Canonical String format of Distinguished Names. |
RFC1779 | back to summary |
---|---|
public static final String RFC1779 RFC 1779 String format of Distinguished Names. |
RFC2253 | back to summary |
---|---|
public static final String RFC2253 RFC 2253 String format of Distinguished Names. |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID
|
thisX500Name | back to summary |
---|---|
private transient X500Name thisX500Name The X500Name representing this principal. Note this field is accessed using shared secrets from within X500Name. |
X500Principal | back to summary |
---|---|
pack-priv X500Principal(X500Name x500Name) Creates an X500Principal by wrapping an X500Name. Note The constructor is package private. It is intended to be accessed using shared secrets from classes in sun.security.*. Currently, it is referenced from sun.security.x509.X500Name.asX500Principal(). |
X500Principal | back to summary |
---|---|
public X500Principal(String name) Creates an This constructor recognizes the attribute type keywords
defined in RFC 1779 and RFC 2253
(and listed in This implementation enforces a more restrictive OID syntax than defined in RFC 1779 and 2253. It uses the more correct syntax defined in RFC 4512, which specifies that OIDs contain at least 2 digits:
|
X500Principal | back to summary |
---|---|
public X500Principal(String name, Map<String, String> keywordMap) Creates an This constructor recognizes the attribute type keywords specified
in This implementation enforces a more restrictive OID syntax than defined in RFC 1779 and 2253. It uses the more correct syntax defined in RFC 4512, which specifies that OIDs contain at least 2 digits:
|
X500Principal | back to summary |
---|---|
public X500Principal(byte[] name) Creates an
|
X500Principal | back to summary |
---|---|
public X500Principal(InputStream is) Creates an The read position of the input stream is positioned to the next available byte after the encoded distinguished name.
|
equals | back to summary |
---|---|
public boolean equals(Object o) Overrides java. Implements java. Compares the specified Specifically, this method returns This implementation is compliant with the requirements of RFC 5280. |
getEncoded | back to summary |
---|---|
public byte[] getEncoded() Returns the distinguished name in ASN.1 DER encoded form. The ASN.1
notation for this structure is supplied in the documentation for
Note that the byte array returned is cloned to protect against subsequent modifications.
|
getName | back to summary |
---|---|
public String getName() Implements java. Returns a string representation of the X.500 distinguished name using the format defined in RFC 2253. This method is equivalent to calling
|
getName | back to summary |
---|---|
public String getName(String format) Returns a string representation of the X.500 distinguished name using the specified format. Valid values for the format are "RFC1779", "RFC2253", and "CANONICAL" (case-insensitive). If "RFC1779" is specified as the format, this method emits the attribute type keywords defined in RFC 1779 (CN, L, ST, O, OU, C, STREET). Any other attribute type is emitted as an OID. If "RFC2253" is specified as the format, this method emits the attribute type keywords defined in RFC 2253 (CN, L, ST, O, OU, C, STREET, DC, UID). Any other attribute type is emitted as an OID. Under a strict reading, RFC 2253 only specifies a UTF-8 string representation. The String returned by this method is the Unicode string achieved by decoding this UTF-8 representation. If "CANONICAL" is specified as the format, this method returns an RFC 2253 conformant string representation with the following additional canonicalizations:
Additional standard formats may be introduced in the future.
|
getName | back to summary |
---|---|
public String getName(String format, Map<String, String> oidMap) Returns a string representation of the X.500 distinguished name
using the specified format. Valid values for the format are
"RFC1779" and "RFC2253" (case-insensitive). "CANONICAL" is not
permitted and an This method returns Strings in the format as specified in
Additional standard formats may be introduced in the future. Warning additional attribute type keywords may not be recognized by other implementations; therefore do not use this method if you are unsure if these keywords will be recognized by other implementations.
|
hashCode | back to summary |
---|---|
public int hashCode() Overrides java. Implements java. Returns a hash code for this The hash code is calculated via:
|
readObject | back to summary |
---|---|
private void readObject(ObjectInputStream s) throws IOException, NotActiveException, ClassNotFoundException Reads this object from a stream (i.e., deserializes it).
|
toString | back to summary |
---|---|
public String toString() Overrides java. Implements java. Return a user-friendly string representation of this
|
writeObject | back to summary |
---|---|
private void writeObject(ObjectOutputStream s) throws IOException Save the X500Principal object to a stream.
|