Save This Page
Home » openjdk-7 » sun.security » x509 » [javadoc | source]
sun.security.x509
public class: X500Name [javadoc | source]
java.lang.Object
   sun.security.x509.X500Name

All Implemented Interfaces:
    Principal, GeneralNameInterface

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:

  1. attribute values encoded in different types (e.g., PrintableString and BMPString) may be assumed to represent different strings;

  2. attribute values in types other than PrintableString are case sensitive (this permits matching of attribute values as binary objects);

  3. attribute values in PrintableString are not case sensitive (e.g., "Marianne Swanson" is the same as "MARIANNE SWANSON"); and

  4. attribute values in PrintableString are compared after removing leading and trailing white space and converting internal substrings of one or more consecutive white space characters to a single space.

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.

Field Summary
public static final  ObjectIdentifier commonName_oid     
public static final  ObjectIdentifier countryName_oid     
public static final  ObjectIdentifier localityName_oid     
public static final  ObjectIdentifier orgName_oid     
public static final  ObjectIdentifier orgUnitName_oid     
public static final  ObjectIdentifier stateName_oid     
public static final  ObjectIdentifier streetAddress_oid     
public static final  ObjectIdentifier title_oid     
public static final  ObjectIdentifier DNQUALIFIER_OID     
public static final  ObjectIdentifier SURNAME_OID     
public static final  ObjectIdentifier GIVENNAME_OID     
public static final  ObjectIdentifier INITIALS_OID     
public static final  ObjectIdentifier GENERATIONQUALIFIER_OID     
public static final  ObjectIdentifier ipAddress_oid     
public static final  ObjectIdentifier DOMAIN_COMPONENT_OID     
public static final  ObjectIdentifier userid_oid     
public static final  ObjectIdentifier SERIALNUMBER_OID     
Constructor:
 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 or RFC 2253 style).
    Parameters:
    DN - X.500 Distinguished Name
 public X500Name(RDN[] rdnArray) throws IOException 
    Constructs a name from an array of relative distinguished names
    Parameters:
    rdnArray - array of relative distinguished names
    Throws:
    IOException - on error
 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).
    Parameters:
    value - a DER-encoded value holding an X.500 name.
 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).
    Parameters:
    in - DER-encoded data holding an X.500 name.
 public X500Name(byte[] name) throws IOException 
    Constructs a name from an ASN.1 encoded byte array.
    Parameters:
    name - DER-encoded byte array holding an X.500 name.
 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 or RFC 2253 style).
    Parameters:
    DN - X.500 Distinguished Name
    keywordMap - an additional keyword/OID map
 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 format strictly according to RFC2253 without extensions.
    Parameters:
    DN - X.500 Distinguished Name
 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.

    Parameters:
    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"
 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.

    Parameters:
    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"
Method from sun.security.x509.X500Name Summary:
allAvas,   asX500Name,   asX500Principal,   avaSize,   commonAncestor,   constrains,   countQuotes,   emit,   encode,   equals,   findMostSpecificAttribute,   getCommonName,   getCountry,   getDNQualifier,   getDomain,   getEncoded,   getEncodedInternal,   getGeneration,   getGivenName,   getIP,   getInitials,   getLocality,   getName,   getOrganization,   getOrganizationalUnit,   getRFC1779Name,   getRFC1779Name,   getRFC2253CanonicalName,   getRFC2253Name,   getRFC2253Name,   getState,   getSurname,   getType,   hashCode,   intern,   isEmpty,   rdns,   size,   subtreeDepth,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.security.x509.X500Name Detail:
 public List<AVA> allAvas() 
    Return an immutable List of the the AVAs contained in all the RDNs of this X500Name.
 public static X500Name asX500Name(X500Principal p) 
    Get the X500Name contained in the given X500Principal. Note that the X500Name is retrieved using reflection.
 public X500Principal asX500Principal() 
    Get an X500Principal backed by this X500Name. Note that we are using privileged reflection to access the hidden package private constructor in X500Principal.
 public int avaSize() 
    Return the total number of AVAs contained in all the RDNs of this X500Name.
 public X500Name commonAncestor(X500Name other) 
    Return lowest common ancestor of this name and other name
 public int constrains(GeneralNameInterface inputName) throws UnsupportedOperationException 
    Return constraint type:
    • NAME_DIFF_TYPE = -1: input name is different type from this name (i.e. does not constrain)
    • NAME_MATCH = 0: input name matches this name
    • NAME_NARROWS = 1: input name narrows this name
    • NAME_WIDENS = 2: input name widens this name
    • NAME_SAME_TYPE = 3: input name does not match or narrow this name, & but is same type
    . These results are used in checking NameConstraints during certification path verification.
 static int countQuotes(String string,
    int from,
    int to) 
 public  void emit(DerOutputStream out) throws IOException 
Deprecated! Use - encode() instead

    Encodes the name in DER-encoded form.
 public  void encode(DerOutputStream out) throws IOException 
    Encodes the name in DER-encoded form.
 public boolean equals(Object obj) 
    Compares this name with another, for equality.
 public DerValue findMostSpecificAttribute(ObjectIdentifier attribute) 
    Find the most specific ("last") attribute of the given type.
 public String getCommonName() throws IOException 
    Returns a "Common Name" component. If more than one such attribute exists, the topmost one is returned.
 public String getCountry() throws IOException 
    Returns a "Country" name component. If more than one such attribute exists, the topmost one is returned.
 public String getDNQualifier() throws IOException 
    Returns a "DN Qualifier" name component. If more than one such component exists, the topmost one is returned.
 public String getDomain() throws IOException 
    Returns a "Domain" name component. If more than one such component exists, the topmost one is returned.
 public byte[] getEncoded() throws IOException 
    Gets the name in DER-encoded form.
 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.
 public String getGeneration() throws IOException 
    Returns a "Generation Qualifier" name component. If more than one such component exists, the topmost one is returned.
 public String getGivenName() throws IOException 
    Returns a "Given Name" name component. If more than one such component exists, the topmost one is returned.
 public String getIP() throws IOException 
    Returns an "IP address" name component. If more than one such component exists, the topmost one is returned.
 public String getInitials() throws IOException 
    Returns an "Initials" name component. If more than one such component exists, the topmost one is returned.
 public String getLocality() throws IOException 
    Returns a "Locality" name component. If more than one such component exists, the topmost one is returned.
 public String getName() 
    Returns the value of toString(). This call is needed to implement the java.security.Principal interface.
 public String getOrganization() throws IOException 
    Returns an "Organization" name component. If more than one such attribute exists, the topmost one is returned.
 public String getOrganizationalUnit() throws IOException 
    Returns an "Organizational Unit" name component. If more than one such attribute exists, the topmost one is returned.
 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.
 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.
 public String getRFC2253CanonicalName() 
 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.
 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.
 public String getState() throws IOException 
    Returns a "State" name component. If more than one such component exists, the topmost one is returned.
 public String getSurname() throws IOException 
    Returns a "Surname" name component. If more than one such component exists, the topmost one is returned.
 public int getType() 
    Return type of GeneralName.
 public int hashCode() 
    Calculates a hash code value for the object. Objects which are equal will also have the same hashcode.
 static ObjectIdentifier intern(ObjectIdentifier oid) 
 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.
 public List<RDN> rdns() 
    Return an immutable List of all RDNs in this X500Name.
 public int size() 
    Return the number of RDNs in this X500Name.
 public int subtreeDepth() throws UnsupportedOperationException 
    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() 
    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 3280).