Class X500Principal
- java.lang.Object
-
- javax.security.auth.x500.X500Principal
-
- All Implemented Interfaces:
java.io.Serializable,Principal
public final class X500Principal extends java.lang.Object implements Principal, java.io.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
X500Principalcan be obtained by calling thegetNamemethods.Note that the
getSubjectX500PrincipalandgetIssuerX500Principalmethods ofX509Certificatereturn X500Principals representing the issuer and subject fields of the certificate.- Since:
- 1.4
- See Also:
X509Certificate, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description X500Principal(byte[] name)Creates anX500Principalfrom a distinguished name in ASN.1 DER encoded form.X500Principal(java.io.InputStream is)Creates anX500Principalfrom anInputStreamcontaining the distinguished name in ASN.1 DER encoded form.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)Compares the specifiedObjectwith thisX500Principalfor equality.java.lang.StringgetName()Returns a string representation of the X.500 distinguished name.inthashCode()Return a hash code for thisX500Principal.
-
-
-
Constructor Detail
-
X500Principal
public X500Principal(byte[] name)
Creates anX500Principalfrom a distinguished name in ASN.1 DER encoded form. The ASN.1 notation for this structure is as follows.Name ::= CHOICE { RDNSequence } RDNSequence ::= SEQUENCE OF RelativeDistinguishedName RelativeDistinguishedName ::= SET SIZE (1 .. MAX) OF AttributeTypeAndValue AttributeTypeAndValue ::= SEQUENCE { type AttributeType, value AttributeValue } AttributeType ::= OBJECT IDENTIFIER AttributeValue ::= ANY DEFINED BY AttributeType .... DirectoryString ::= CHOICE { teletexString TeletexString (SIZE (1..MAX)), printableString PrintableString (SIZE (1..MAX)), universalString UniversalString (SIZE (1..MAX)), utf8String UTF8String (SIZE (1.. MAX)), bmpString BMPString (SIZE (1..MAX)) }- Parameters:
name- a byte array containing the distinguished name in ASN.1 DER encoded form- Throws:
java.lang.IllegalArgumentException- if an encoding error occurs (incorrect form for DN)
-
X500Principal
public X500Principal(java.io.InputStream is)
Creates anX500Principalfrom anInputStreamcontaining the distinguished name in ASN.1 DER encoded form. The ASN.1 notation for this structure is supplied in the documentation forX500Principal(byte[] name).The read position of the input stream is positioned to the next available byte after the encoded distinguished name.
- Parameters:
is- anInputStreamcontaining the distinguished name in ASN.1 DER encoded form- Throws:
java.lang.NullPointerException- if theInputStreamisnulljava.lang.IllegalArgumentException- if an encoding error occurs (incorrect form for DN)
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns a string representation of the X.500 distinguished name.The chosen format is a '#' character followed by the hexadecimal encoding of de DER representation of the name. (No spaces between digits, letters in lower case).
- Returns:
- the distinguished name of this
X500Principal
-
equals
public boolean equals(@Nullable java.lang.Object o)Compares the specifiedObjectwith thisX500Principalfor equality.Specifically, this method returns
trueif theObjecto is anX500Principaland if the respective canonical string representations (obtained via thegetName(X500Principal.CANONICAL)method) of this object and o are equal.This implementation is compliant with the requirements of RFC 3280.
-
-