public class X500Name extends java.lang.Object implements GeneralNameInterface, java.security.Principal
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 |
|---|---|
static com.tencent.kona.sun.security.util.ObjectIdentifier |
commonName_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
countryName_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
DNQUALIFIER_OID |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
DOMAIN_COMPONENT_OID |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
GENERATIONQUALIFIER_OID |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
GIVENNAME_OID |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
INITIALS_OID |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
ipAddress_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
localityName_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
orgName_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
orgUnitName_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
SERIALNUMBER_OID |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
stateName_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
streetAddress_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
SURNAME_OID |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
title_oid |
static com.tencent.kona.sun.security.util.ObjectIdentifier |
userid_oid |
NAME_ANY, NAME_DIFF_TYPE, NAME_DIRECTORY, NAME_DNS, NAME_EDI, NAME_IP, NAME_MATCH, NAME_NARROWS, NAME_OID, NAME_RFC822, NAME_SAME_TYPE, NAME_URI, NAME_WIDENS, NAME_X400| Constructor and Description |
|---|
X500Name(byte[] name)
Constructs a name from an ASN.1 encoded byte array.
|
X500Name(com.tencent.kona.sun.security.util.DerInputStream in)
Constructs a name from an ASN.1 encoded input stream.
|
X500Name(com.tencent.kona.sun.security.util.DerValue value)
Constructs a name from an ASN.1 encoded value.
|
X500Name(RDN[] rdnArray)
Constructs a name from an array of relative distinguished names
|
X500Name(java.lang.String dname)
Constructs a name from a conventionally formatted string, such
as "CN=Dave, OU=JavaSoft, O=Sun Microsystems, C=US".
|
X500Name(java.lang.String dname,
java.util.Map<java.lang.String,java.lang.String> keywordMap)
Constructs a name from a conventionally formatted string, such
as "CN=Dave, OU=JavaSoft, O=Sun Microsystems, C=US".
|
X500Name(java.lang.String dname,
java.lang.String format)
Constructs a name from a string formatted according to format.
|
X500Name(java.lang.String commonName,
java.lang.String organizationUnit,
java.lang.String organizationName,
java.lang.String country)
Constructs a name from fields common in enterprise application
environments.
|
X500Name(java.lang.String commonName,
java.lang.String organizationUnit,
java.lang.String organizationName,
java.lang.String localityName,
java.lang.String stateName,
java.lang.String country)
Constructs a name from fields common in Internet application
environments.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.List<AVA> |
allAvas()
Return an immutable List of the AVAs contained in all the
RDNs of this X500Name.
|
static X500Name |
asX500Name(javax.security.auth.x500.X500Principal p)
Get the X500Name contained in the given X500Principal.
|
javax.security.auth.x500.X500Principal |
asX500Principal()
Get an X500Principal backed by this X500Name.
|
int |
avaSize()
Return the total number of AVAs contained in all the RDNs of
this X500Name.
|
X500Name |
commonAncestor(X500Name other)
Return lowest common ancestor of this name and other name
|
int |
constrains(GeneralNameInterface inputName)
Return constraint type:
NAME_DIFF_TYPE = -1: input name is different type from this name
(i.e.
|
void |
emit(com.tencent.kona.sun.security.util.DerOutputStream out)
Deprecated.
Use encode() instead
|
void |
encode(com.tencent.kona.sun.security.util.DerOutputStream out)
Encodes the name in DER-encoded form.
|
boolean |
equals(java.lang.Object obj)
Compares this name with another, for equality.
|
com.tencent.kona.sun.security.util.DerValue |
findMostSpecificAttribute(com.tencent.kona.sun.security.util.ObjectIdentifier attribute)
Find the most specific ("last") attribute of the given
type.
|
java.lang.String |
getCommonName()
Returns a "Common Name" component.
|
java.lang.String |
getCountry()
Returns a "Country" name component.
|
java.lang.String |
getDNQualifier()
Returns a "DN Qualifier" name component.
|
java.lang.String |
getDomain()
Returns a "Domain" name component.
|
byte[] |
getEncoded()
Gets the name in DER-encoded form.
|
byte[] |
getEncodedInternal()
Returned the encoding as an uncloned byte array.
|
java.lang.String |
getGeneration()
Returns a "Generation Qualifier" name component.
|
java.lang.String |
getGivenName()
Returns a "Given Name" name component.
|
java.lang.String |
getInitials()
Returns an "Initials" name component.
|
java.lang.String |
getIP()
Returns an "IP address" name component.
|
java.lang.String |
getLocality()
Returns a "Locality" name component.
|
java.lang.String |
getName()
Returns the value of toString().
|
java.lang.String |
getOrganization()
Returns an "Organization" name component.
|
java.lang.String |
getOrganizationalUnit()
Returns an "Organizational Unit" name component.
|
java.lang.String |
getRFC1779Name()
Returns a string form of the X.500 distinguished name
using the algorithm defined in RFC 1779.
|
java.lang.String |
getRFC1779Name(java.util.Map<java.lang.String,java.lang.String> oidMap)
Returns a string form of the X.500 distinguished name
using the algorithm defined in RFC 1779.
|
java.lang.String |
getRFC2253CanonicalName() |
java.lang.String |
getRFC2253Name()
Returns a string form of the X.500 distinguished name
using the algorithm defined in RFC 2253.
|
java.lang.String |
getRFC2253Name(java.util.Map<java.lang.String,java.lang.String> oidMap)
Returns a string form of the X.500 distinguished name
using the algorithm defined in RFC 2253.
|
java.lang.String |
getState()
Returns a "State" name component.
|
java.lang.String |
getSurname()
Returns a "Surname" name component.
|
int |
getType()
Return type of GeneralName.
|
int |
hashCode()
Calculates a hash code value for the object.
|
boolean |
isEmpty()
Return whether this X500Name is empty.
|
java.util.List<RDN> |
rdns()
Return an immutable List of all RDNs in this X500Name.
|
int |
size()
Return the number of RDNs in this X500Name.
|
int |
subtreeDepth()
Return subtree depth of this name for purposes of determining
NameConstraints minimum and maximum bounds and for calculating
path lengths in name subtrees.
|
java.lang.String |
toString()
Returns a string form of the X.500 distinguished name.
|
public static final com.tencent.kona.sun.security.util.ObjectIdentifier commonName_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier SURNAME_OID
public static final com.tencent.kona.sun.security.util.ObjectIdentifier SERIALNUMBER_OID
public static final com.tencent.kona.sun.security.util.ObjectIdentifier countryName_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier localityName_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier stateName_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier streetAddress_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier orgName_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier orgUnitName_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier title_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier GIVENNAME_OID
public static final com.tencent.kona.sun.security.util.ObjectIdentifier INITIALS_OID
public static final com.tencent.kona.sun.security.util.ObjectIdentifier GENERATIONQUALIFIER_OID
public static final com.tencent.kona.sun.security.util.ObjectIdentifier DNQUALIFIER_OID
public static final com.tencent.kona.sun.security.util.ObjectIdentifier ipAddress_oid
public static final com.tencent.kona.sun.security.util.ObjectIdentifier DOMAIN_COMPONENT_OID
public static final com.tencent.kona.sun.security.util.ObjectIdentifier userid_oid
public X500Name(java.lang.String dname)
throws java.io.IOException
dname - the X.500 Distinguished Namejava.io.IOExceptionpublic X500Name(java.lang.String dname,
java.util.Map<java.lang.String,java.lang.String> keywordMap)
throws java.io.IOException
dname - the X.500 Distinguished NamekeywordMap - an additional keyword/OID mapjava.io.IOExceptionpublic X500Name(java.lang.String dname,
java.lang.String format)
throws java.io.IOException
dname - the X.500 Distinguished Nameformat - the specified format of the String DNjava.io.IOExceptionpublic X500Name(java.lang.String commonName,
java.lang.String organizationUnit,
java.lang.String organizationName,
java.lang.String country)
throws java.io.IOException
NOTE: The behaviour when any of these strings contain characters outside the ASCII range is unspecified in currently relevant standards.
commonName - common name of a person, e.g. "Vivette Davis"organizationUnit - small organization name, e.g. "Purchasing"organizationName - large organization name, e.g. "Onizuka, Inc."country - two-letter country code, e.g. "CH"java.io.IOExceptionpublic X500Name(java.lang.String commonName,
java.lang.String organizationUnit,
java.lang.String organizationName,
java.lang.String localityName,
java.lang.String stateName,
java.lang.String country)
throws java.io.IOException
NOTE: The behaviour when any of these strings contain characters outside the ASCII range is unspecified in currently relevant standards.
commonName - common name of a person, e.g. "Vivette Davis"organizationUnit - small organization name, e.g. "Purchasing"organizationName - large organization name, e.g. "Onizuka, Inc."localityName - locality (city) name, e.g. "Palo Alto"stateName - state name, e.g. "California"country - two-letter country code, e.g. "CH"java.io.IOExceptionpublic X500Name(RDN[] rdnArray) throws java.io.IOException
rdnArray - array of relative distinguished namesjava.io.IOException - on errorpublic X500Name(com.tencent.kona.sun.security.util.DerValue value)
throws java.io.IOException
value - a DER-encoded value holding an X.500 name.java.io.IOExceptionpublic X500Name(com.tencent.kona.sun.security.util.DerInputStream in)
throws java.io.IOException
in - DER-encoded data holding an X.500 name.java.io.IOExceptionpublic X500Name(byte[] name)
throws java.io.IOException
name - DER-encoded byte array holding an X.500 name.java.io.IOExceptionpublic java.util.List<RDN> rdns()
public int size()
public java.util.List<AVA> allAvas()
public int avaSize()
public boolean isEmpty()
public int hashCode()
hashCode in interface java.security.PrincipalhashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in interface java.security.Principalequals in class java.lang.Objectpublic int getType()
getType in interface GeneralNameInterfacepublic java.lang.String getCountry()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getOrganization()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getOrganizationalUnit()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getCommonName()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getLocality()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getState()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getDomain()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getDNQualifier()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getSurname()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getGivenName()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getInitials()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getGeneration()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getIP()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in interface java.security.PrincipaltoString in class java.lang.Objectpublic java.lang.String getRFC1779Name()
public java.lang.String getRFC1779Name(java.util.Map<java.lang.String,java.lang.String> oidMap)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic java.lang.String getRFC2253Name()
public java.lang.String getRFC2253Name(java.util.Map<java.lang.String,java.lang.String> oidMap)
public java.lang.String getRFC2253CanonicalName()
public java.lang.String getName()
getName in interface java.security.Principalpublic com.tencent.kona.sun.security.util.DerValue findMostSpecificAttribute(com.tencent.kona.sun.security.util.ObjectIdentifier attribute)
@Deprecated
public void emit(com.tencent.kona.sun.security.util.DerOutputStream out)
throws java.io.IOException
out - where to put the DER-encoded X.500 namejava.io.IOExceptionpublic void encode(com.tencent.kona.sun.security.util.DerOutputStream out)
encode in interface com.tencent.kona.sun.security.util.DerEncoderout - where to put the DER-encoded X.500 namepublic byte[] getEncodedInternal()
throws java.io.IOException
java.io.IOExceptionpublic byte[] getEncoded()
throws java.io.IOException
java.io.IOExceptionpublic int constrains(GeneralNameInterface inputName) throws java.lang.UnsupportedOperationException
constrains in interface GeneralNameInterfaceinputName - to be checked for being constrainedjava.lang.UnsupportedOperationException - if name is not exact match, but
narrowing and widening are not supported for this name type.public int subtreeDepth()
throws java.lang.UnsupportedOperationException
subtreeDepth in interface GeneralNameInterfacejava.lang.UnsupportedOperationException - if not supported for this name typepublic X500Name commonAncestor(X500Name other)
other - another X500Namepublic javax.security.auth.x500.X500Principal asX500Principal()
public static X500Name asX500Name(javax.security.auth.x500.X500Principal p)