Note
As of 1.4, the public class, javax.security.auth.x500.X500Principal, should be used when parsing, generating, and comparing X.500 DNs. This class contains other useful methods for checking name constraints and retrieving DNs by keyword.
X.500 names are used to identify entities, such as those which are identified by X.509 certificates. They are world-wide, hierarchical, and descriptive. Entities can be identified by attributes, and in some systems can be searched for according to those attributes.
The ASN.1 for this is:
GeneralName ::= CHOICE { .... directoryName [4] Name, .... Name ::= CHOICE { RDNSequence } RDNSequence ::= SEQUENCE OF RelativeDistinguishedName RelativeDistinguishedName ::= SET 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)) }
This specification requires only a subset of the name comparison functionality specified in the X.500 series of specifications. The requirements for conforming implementations are as follows:
These name comparison rules permit a certificate user to validate certificates issued using languages or encodings unfamiliar to the certificate user.
In addition, implementations of this specification MAY use these comparison rules to process unfamiliar attribute types for name chaining. This allows implementations to process certificates with unfamiliar attributes in the issuer name.
Note that the comparison rules defined in the X.500 series of specifications indicate that the character sets used to encode data in distinguished names are irrelevant. The characters themselves are compared without regard to encoding. Implementations of the profile are permitted to use the comparison algorithm defined in the X.500 series. Such an implementation will recognize a superset of name matches recognized by the algorithm specified above.
Note that instances of this class are immutable.
GeneralName
, GeneralNames
, GeneralNameInterface
Modifier and Type | Field and Description |
---|---|
private volatile List | |
private String | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
private String | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
private byte[] | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
private RDN[] | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
private volatile List | |
private String | |
private String | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
public static final ObjectIdentifier | |
private X500Principal |
Access | Constructor and Description |
---|---|
public | |
public | |
public | |
public | X500Name(String
common name of a person, e.g. "Vivette Davis" commonName, String small organization name, e.g. "Purchasing" organizationUnit, String large organization name, e.g. "Onizuka, Inc." organizationName, String two-letter country code, e.g. "CH" country)Constructs a name from fields common in enterprise application environments. |
public | X500Name(String
common name of a person, e.g. "Vivette Davis" commonName, String small organization name, e.g. "Purchasing" organizationUnit, String large organization name, e.g. "Onizuka, Inc." organizationName, String locality (city) name, e.g. "Palo Alto" localityName, String state name, e.g. "California" stateName, String two-letter country code, e.g. "CH" country)Constructs a name from fields common in Internet application environments. |
public | |
public | |
public | X500Name(DerInputStream
DER-encoded data holding an X.500 name. in)Constructs a name from an ASN.1 encoded input stream. |
public | X500Name(byte[]
DER-encoded byte array holding an X.500 name. name)Constructs a name from an ASN.1 encoded byte array. |
Modifier and Type | Method and Description |
---|---|
public List | |
public static X500Name | |
public X500Principal | |
public int | |
public int | Returns: constraint type aboveto be checked for being constrained inputName)Implements sun. Return constraint type:
|
pack-priv static int | |
public void | emit(DerOutputStream
where to put the DER-encoded X.500 name out)
Deprecated
Use encode() instead
Encodes the name in DER-encoded form. |
public void | encode(DerOutputStream
where to put the DER-encoded X.500 name out)Implements sun. Encodes the name in DER-encoded form. |
public boolean | Returns: true iff the names are identical.Principal to compare with.Overrides java. Implements java. Compares this name with another, for equality. |
private static boolean | |
private DerValue | findAttribute(ObjectIdentifier attribute)
Find the first instance of this attribute in a "top down" search of all the attributes in the name. |
public DerValue | findMostSpecificAttribute(ObjectIdentifier attribute)
Find the most specific ("last") attribute of the given type. |
private void | |
private String | |
private String | |
public String | |
public String | |
public String | Returns: "DNQ=" component of the name, if any.Returns a "DN Qualifier" name component. |
public String | |
public byte[] | |
public byte[] | |
public String | Returns: "GENERATION=" component of the name, if any.Returns a "Generation Qualifier" name component. |
public String | Returns: "GIVENNAME=" component of the name, if any.Returns a "Given Name" name component. |
public String | Returns: "INITIALS=" component of the name, if any.Returns an "Initials" name component. |
public String | |
public String | |
public String | |
public String | Returns: "O=" component of the name, if any.Returns an "Organization" name component. |
public String | Returns: "OU=" component of the name, if any.Returns an "Organizational Unit" name component. |
public String | getRFC1779Name()
Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 1779. |
public String | getRFC1779Name(Map<String, String> oidMap)
Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 1779. |
public String | |
public String | getRFC2253Name()
Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 2253. |
public String | getRFC2253Name(Map<String, String> oidMap)
Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 2253. |
public String | |
private String | |
public String | |
public int | |
public int | hashCode()
Overrides java. Implements java. Calculates a hash code value for the object. |
public boolean | |
private boolean | Returns: true iff this name is within the subtree of other.Compares this name with another and determines if it is within the subtree of the other. |
private void | |
private void | |
private void | |
public List | |
public int | |
public int | Returns: distance of name from rootImplements sun. Return subtree depth of this name for purposes of determining NameConstraints minimum and maximum bounds and for calculating path lengths in name subtrees. |
public String | toString()
Overrides java. Implements java. Returns a string form of the X.500 distinguished name. |
allAvaList | back to summary |
---|---|
private volatile List<AVA> allAvaList |
canonicalDn | back to summary |
---|---|
private String canonicalDn |
commonName_oid | back to summary |
---|---|
public static final ObjectIdentifier commonName_oid |
countryName_oid | back to summary |
---|---|
public static final ObjectIdentifier countryName_oid |
dn | back to summary |
---|---|
private String dn |
DNQUALIFIER_OID | back to summary |
---|---|
public static final ObjectIdentifier DNQUALIFIER_OID |
DOMAIN_COMPONENT_OID | back to summary |
---|---|
public static final ObjectIdentifier DOMAIN_COMPONENT_OID |
encoded | back to summary |
---|---|
private byte[] encoded |
GENERATIONQUALIFIER_OID | back to summary |
---|---|
public static final ObjectIdentifier GENERATIONQUALIFIER_OID |
GIVENNAME_OID | back to summary |
---|---|
public static final ObjectIdentifier GIVENNAME_OID |
INITIALS_OID | back to summary |
---|---|
public static final ObjectIdentifier INITIALS_OID |
ipAddress_oid | back to summary |
---|---|
public static final ObjectIdentifier ipAddress_oid |
localityName_oid | back to summary |
---|---|
public static final ObjectIdentifier localityName_oid |
names | back to summary |
---|---|
private RDN[] names |
orgName_oid | back to summary |
---|---|
public static final ObjectIdentifier orgName_oid |
orgUnitName_oid | back to summary |
---|---|
public static final ObjectIdentifier orgUnitName_oid |
rdnList | back to summary |
---|---|
private volatile List<RDN> rdnList |
rfc1779Dn | back to summary |
---|---|
private String rfc1779Dn |
rfc2253Dn | back to summary |
---|---|
private String rfc2253Dn |
SERIALNUMBER_OID | back to summary |
---|---|
public static final ObjectIdentifier SERIALNUMBER_OID |
stateName_oid | back to summary |
---|---|
public static final ObjectIdentifier stateName_oid |
streetAddress_oid | back to summary |
---|---|
public static final ObjectIdentifier streetAddress_oid |
SURNAME_OID | back to summary |
---|---|
public static final ObjectIdentifier SURNAME_OID |
title_oid | back to summary |
---|---|
public static final ObjectIdentifier title_oid |
userid_oid | back to summary |
---|---|
public static final ObjectIdentifier userid_oid |
x500Principal | back to summary |
---|---|
private X500Principal x500Principal |
X500Name | back to summary |
---|---|
public X500Name(String dname) throws IOException Constructs a name from a conventionally formatted string, such as "CN=Dave, OU=JavaSoft, O=Sun Microsystems, C=US". (RFC 1779, 2253, or 4514 style).
|
X500Name | back to summary |
---|---|
public X500Name(String dname, Map<String, String> keywordMap) throws IOException Constructs a name from a conventionally formatted string, such as "CN=Dave, OU=JavaSoft, O=Sun Microsystems, C=US". (RFC 1779, 2253, or 4514 style). |
X500Name | back to summary |
---|---|
public X500Name(String dname, String format) throws IOException Constructs a name from a string formatted according to format. Currently, the formats DEFAULT and RFC2253 are supported. DEFAULT is the default format used by the X500Name(String) constructor. RFC2253 is the format strictly according to RFC2253 without extensions. |
X500Name | back to summary |
---|---|
public X500Name(String commonName, String organizationUnit, String organizationName, String country) throws IOException Constructs a name from fields common in enterprise application environments. Note The behaviour when any of these strings contain characters outside the ASCII range is unspecified in currently relevant standards. |
X500Name | back to summary |
---|---|
public X500Name(String commonName, String organizationUnit, String organizationName, String localityName, String stateName, String country) throws IOException Constructs a name from fields common in Internet application environments. Note The behaviour when any of these strings contain characters outside the ASCII range is unspecified in currently relevant standards.
|
X500Name | back to summary |
---|---|
public X500Name(RDN[] rdnArray) throws IOException Constructs a name from an array of relative distinguished names
|
X500Name | back to summary |
---|---|
public X500Name(DerValue value) throws IOException Constructs a name from an ASN.1 encoded value. The encoding of the name in the stream uses DER (a BER/1 subset).
|
X500Name | back to summary |
---|---|
public X500Name(DerInputStream in) throws IOException Constructs a name from an ASN.1 encoded input stream. The encoding of the name in the stream uses DER (a BER/1 subset).
|
X500Name | back to summary |
---|---|
public X500Name(byte[] name) throws IOException Constructs a name from an ASN.1 encoded byte array.
|
allAvas | back to summary |
---|---|
public List Return an immutable List of the AVAs contained in all the RDNs of this X500Name. |
asX500Name | back to summary |
---|---|
public static X500Name asX500Name(X500Principal p) Get the X500Name contained in the given X500Principal. |
asX500Principal | back to summary |
---|---|
public X500Principal asX500Principal() Get an X500Principal backed by this X500Name. |
avaSize | back to summary |
---|---|
public int avaSize() Return the total number of AVAs contained in all the RDNs of this X500Name. |
constrains | back to summary |
---|---|
public int constrains(GeneralNameInterface inputName) throws UnsupportedOperationException Implements sun. Return constraint type:
|
countQuotes | back to summary |
---|---|
pack-priv static int countQuotes(String string, int from, int to) |
emit | back to summary |
---|---|
public void emit(DerOutputStream out) throws IOException
Deprecated Use encode() instead Encodes the name in DER-encoded form.
|
encode | back to summary |
---|---|
public void encode(DerOutputStream out) Implements sun. Encodes the name in DER-encoded form.
|
equals | back to summary |
---|---|
public boolean equals(Object obj) Overrides java. Implements java. Compares this name with another, for equality.
|
escaped | back to summary |
---|---|
private static boolean escaped(int rdnEnd, int searchOffset, String dnString) |
findAttribute | back to summary |
---|---|
private DerValue findAttribute(ObjectIdentifier attribute) Find the first instance of this attribute in a "top down" search of all the attributes in the name. |
findMostSpecificAttribute | back to summary |
---|---|
public DerValue findMostSpecificAttribute(ObjectIdentifier attribute) Find the most specific ("last") attribute of the given type. |
generateDN | back to summary |
---|---|
private void generateDN() |
generateRFC1779DN | back to summary |
---|---|
private String generateRFC1779DN(Map<String, String> oidMap) |
generateRFC2253DN | back to summary |
---|---|
private String generateRFC2253DN(Map<String, String> oidMap) |
getCommonName | back to summary |
---|---|
public String getCommonName() throws IOException Returns a "Common Name" component. If more than one such attribute exists, the topmost one is returned.
|
getCountry | back to summary |
---|---|
public String getCountry() throws IOException Returns a "Country" name component. If more than one such attribute exists, the topmost one is returned.
|
getDNQualifier | back to summary |
---|---|
public String getDNQualifier() throws IOException Returns a "DN Qualifier" name component. If more than one such component exists, the topmost one is returned.
|
getDomain | back to summary |
---|---|
public String getDomain() throws IOException Returns a "Domain" name component. If more than one such component exists, the topmost one is returned.
|
getEncoded | back to summary |
---|---|
public byte[] getEncoded() throws IOException Gets the name in DER-encoded form.
|
getEncodedInternal | back to summary |
---|---|
public byte[] getEncodedInternal() throws IOException Returned the encoding as an uncloned byte array. Callers must guarantee that they neither modify it not expose it to untrusted code. |
getGeneration | back to summary |
---|---|
public String getGeneration() throws IOException Returns a "Generation Qualifier" name component. If more than one such component exists, the topmost one is returned.
|
getGivenName | back to summary |
---|---|
public String getGivenName() throws IOException Returns a "Given Name" name component. If more than one such component exists, the topmost one is returned.
|
getInitials | back to summary |
---|---|
public String getInitials() throws IOException Returns an "Initials" name component. If more than one such component exists, the topmost one is returned.
|
getIP | back to summary |
---|---|
public String getIP() throws IOException Returns an "IP address" name component. If more than one such component exists, the topmost one is returned.
|
getLocality | back to summary |
---|---|
public String getLocality() throws IOException Returns a "Locality" name component. If more than one such component exists, the topmost one is returned.
|
getName | back to summary |
---|---|
public String getName() Implements java. Returns the value of toString(). This call is needed to implement the java.security.Principal interface.
|
getOrganization | back to summary |
---|---|
public String getOrganization() throws IOException Returns an "Organization" name component. If more than one such attribute exists, the topmost one is returned.
|
getOrganizationalUnit | back to summary |
---|---|
public String getOrganizationalUnit() throws IOException Returns an "Organizational Unit" name component. If more than one such attribute exists, the topmost one is returned.
|
getRFC1779Name | back to summary |
---|---|
public String getRFC1779Name() Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 1779. Only standard attribute type keywords defined in RFC 1779 are emitted. |
getRFC1779Name | back to summary |
---|---|
public String getRFC1779Name(Map<String, String> oidMap) throws IllegalArgumentException Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 1779. Attribute type keywords defined in RFC 1779 are emitted, as well as additional keywords contained in the OID/keyword map. |
getRFC2253CanonicalName | back to summary |
---|---|
public String getRFC2253CanonicalName() |
getRFC2253Name | back to summary |
---|---|
public String getRFC2253Name() Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 2253. Only standard attribute type keywords defined in RFC 2253 are emitted. |
getRFC2253Name | back to summary |
---|---|
public String getRFC2253Name(Map<String, String> oidMap) Returns a string form of the X.500 distinguished name using the algorithm defined in RFC 2253. Attribute type keywords defined in RFC 2253 are emitted, as well as additional keywords contained in the OID/keyword map. |
getState | back to summary |
---|---|
public String getState() throws IOException Returns a "State" name component. If more than one such component exists, the topmost one is returned.
|
getString | back to summary |
---|---|
private String getString(DerValue attribute) throws IOException |
getSurname | back to summary |
---|---|
public String getSurname() throws IOException Returns a "Surname" name component. If more than one such component exists, the topmost one is returned.
|
getType | back to summary |
---|---|
public int getType() Implements sun. Return type of GeneralName. |
hashCode | back to summary |
---|---|
public int hashCode() Overrides java. Implements java. Calculates a hash code value for the object. Objects which are equal will also have the same hashcode.
|
isEmpty | back to summary |
---|---|
public boolean isEmpty() Return whether this X500Name is empty. An X500Name is not empty if it has at least one RDN containing at least one AVA. |
isWithinSubtree | back to summary |
---|---|
private boolean isWithinSubtree(X500Name other) Compares this name with another and determines if it is within the subtree of the other. Useful for checking against the name constraints extension.
|
parseDER | back to summary |
---|---|
private void parseDER(DerInputStream in) throws IOException |
parseDN | back to summary |
---|---|
private void parseDN(String input, Map<String, String> keywordMap) throws IOException |
parseRFC2253DN | back to summary |
---|---|
private void parseRFC2253DN(String dnString) throws IOException |
rdns | back to summary |
---|---|
public List Return an immutable List of all RDNs in this X500Name. |
size | back to summary |
---|---|
public int size() Return the number of RDNs in this X500Name. |
subtreeDepth | back to summary |
---|---|
public int subtreeDepth() throws UnsupportedOperationException Implements sun. Return subtree depth of this name for purposes of determining NameConstraints minimum and maximum bounds and for calculating path lengths in name subtrees.
|
toString | back to summary |
---|---|
public String toString() Overrides java. Implements java. Returns a string form of the X.500 distinguished name. The format of the string is from RFC 1779. The returned string may contain non-standardised keywords for more readability (keywords from RFCs 1779, 2253, and 5280).
|