X500Principal

public final class X500Principal extends Object
implements Principal Serializable

This class represents an X.500 Principal. X500Principals 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 3280: 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.

See Also

Constant Summary

String CANONICAL Canonical String format of Distinguished Names.
String RFC1779 RFC 1779 String format of Distinguished Names.
String RFC2253 RFC 2253 String format of Distinguished Names.

Public Constructor Summary

X500Principal(String name)
Creates an X500Principal from a string representation of an X.500 distinguished name (ex: "CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US").
X500Principal(String name, Map<StringString> keywordMap)
Creates an X500Principal from a string representation of an X.500 distinguished name (ex: "CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US").
X500Principal(byte[] name)
Creates an X500Principal from a distinguished name in ASN.1 DER encoded form.
X500Principal(InputStream is)
Creates an X500Principal from an InputStream containing the distinguished name in ASN.1 DER encoded form.

Public Method Summary

boolean
equals(Object o)
Compares the specified Object with this X500Principal for equality.
byte[]
getEncoded()
Returns the distinguished name in ASN.1 DER encoded form.
String
getName(String format)
Returns a string representation of the X.500 distinguished name using the specified format.
String
getName()
Returns a string representation of the X.500 distinguished name using the format defined in RFC 2253.
String
getName(String format, Map<StringString> oidMap)
Returns a string representation of the X.500 distinguished name using the specified format.
int
hashCode()
Return a hash code for this X500Principal.
String
toString()
Return a user-friendly string representation of this X500Principal.

Inherited Method Summary

Constants

public static final String CANONICAL

Canonical String format of Distinguished Names.

Constant Value: "CANONICAL"

public static final String RFC1779

RFC 1779 String format of Distinguished Names.

Constant Value: "RFC1779"

public static final String RFC2253

RFC 2253 String format of Distinguished Names.

Constant Value: "RFC2253"

Public Constructors

public X500Principal (String name)

Creates an X500Principal from a string representation of an X.500 distinguished name (ex: "CN=Duke, OU=JavaSoft, O=Sun Microsystems, C=US"). The distinguished name must be specified using the grammar defined in RFC 1779 or RFC 2253 (either format is acceptable).

This constructor recognizes the attribute type keywords defined in RFC 1779 and RFC 2253 (and listed in getName(String format)), as well as the T, DNQ or DNQUALIFIER, SURNAME, GIVENNAME, INITIALS, GENERATION, EMAILADDRESS, and SERIALNUMBER keywords whose OIDs are defined in RFC 3280 and its successor. Any other attribute type must be specified as an OID.

Parameters
name an X.500 distinguished name in RFC 1779 or RFC 2253 format