Class X500Name
java.lang.Object
org.mozilla.jss.netscape.security.x509.X500Name
- All Implemented Interfaces:
Serializable
,Principal
,GeneralNameInterface
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.
This class exposes only partial X.500 name functionality. Most notably, it works best if Relative Distinguished Names only have one (unique) attribute each, and if only the most common attributes need to be visible to applications. This limitation, and others, will be lifted over time.
- Version:
- 1.35
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ObjectIdentifier
OID for the "CN=" attribute, denoting a person's common name.static final ObjectIdentifier
OID for the "C=" attribute, denoting a country.private String
static final ObjectIdentifier
OID for the "E=" attribute, denoting a person's email address.private static final int[]
static final ObjectIdentifier
OID for "IP=" IP address attributes, used with SKIP.static final ObjectIdentifier
OID for the "L=" attribute, denoting a locality (such as a city)private RDN[]
static final ObjectIdentifier
OID for the "O=" attribute, denoting an organization namestatic final ObjectIdentifier
OID for the "OU=" attribute, denoting an organizational unit nameprivate static final long
static final ObjectIdentifier
OID for the "S=" attribute, denoting a state (such as Delaware)static final ObjectIdentifier
OID for the "STREET=" attribute, denoting a street address.static final ObjectIdentifier
OID for the "T=" attribute, denoting a person's title.static final ObjectIdentifier
OID for the "UID=" attribute, denoting a person's ID.Fields inherited from interface org.mozilla.jss.netscape.security.x509.GeneralNameInterface
NAME_ANY, NAME_DIRECTORY, NAME_DNS, NAME_EDI, NAME_IP, NAME_OID, NAME_RFC822, NAME_URI, NAME_X400
-
Constructor Summary
ConstructorsConstructorDescriptionX500Name
(byte[] name) Constructs a name from an ASN.1 encoded byte array.Constructs a name from a Ldap DN string, such as "CN=Dave, OU=JavaSoft, O=Sun Microsystems, C=US".Constructs a X500Name from fields common in enterprise application environments.X500Name
(String commonName, String organizationUnit, String organizationName, String localityName, String stateName, String country) Constructs a X500Name from fields common in Internet application environments.X500Name
(String ldapDNString, LdapDNStrConverter ldapDNStrConverter) Constructs a X500Name from a Ldap DN String using the specified LdapDNStrConverter.X500Name
(String ldapDNString, LdapDNStrConverter ldapDNStrConverter, byte[] tags) Constructs a X500Name from a Ldap DN String using the specified LdapDNStrConverter.convenience method.Constructs a name from an ASN.1 encoded input stream.Constructs a name from an ASN.1 encoded value.Constructs a X500Name from array of RDN. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
clear()
Sets private data to a null statevoid
encode
(DerOutputStream out) Encodes the name in DER-encoded form.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.private void
generateDN
(LdapDNStrConverter ldapDNStrConverter) Return a list of attributes of the given type.Returns a "Common Name" component.Returns a "Country" name component.getEmail()
Returns a "Email" name component.byte[]
Gets the name in DER-encoded form.Returns a "Locality" name component.getName()
Returns the value of toString().RDN[]
getNames()
Returns an array of RDN in the X500Name.int
Returns the number of RDNs in the X500Name.Returns an "Organization" name component.Returns an "Organizational Unit" name component.getRDNs()
Returns an enumerator of RDNs in the X500Name.getState()
Returns a "State" name component.private String
Returns the name component as a Java string, regardless of its encoding restrictions.int
getType()
Return type of GeneralName.Returns a "UID" component.int
hashCode()
(package private) static ObjectIdentifier
intern
(ObjectIdentifier oid) private void
Returns a Ldap DN String from the X500Name using the global default LdapDNStrConvertertoLdapDNString
(LdapDNStrConverter ldapDNStrConverter) Returns a Ldap DN String from the X500Name using the specified LdapDNStrconverter.toString()
Returns a Ldap DN string, using the global default LdapDNStrConverter or null if an error occurs in the conversion.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.mozilla.jss.netscape.security.x509.GeneralNameInterface
validSingle, validSubtree
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
dn
-
names
-
commonName_oid
OID for the "CN=" attribute, denoting a person's common name. -
uidName_oid
OID for the "UID=" attribute, denoting a person's ID. -
countryName_oid
OID for the "C=" attribute, denoting a country. -
localityName_oid
OID for the "L=" attribute, denoting a locality (such as a city) -
orgName_oid
OID for the "O=" attribute, denoting an organization name -
orgUnitName_oid
OID for the "OU=" attribute, denoting an organizational unit name -
stateName_oid
OID for the "S=" attribute, denoting a state (such as Delaware) -
streetAddress_oid
OID for the "STREET=" attribute, denoting a street address. -
title_oid
OID for the "T=" attribute, denoting a person's title. -
email_oid
OID for the "E=" attribute, denoting a person's email address. -
ipAddress_data
private static final int[] ipAddress_data -
ipAddress_oid
OID for "IP=" IP address attributes, used with SKIP.
-
-
Constructor Details
-
X500Name
Constructs a name from a Ldap DN string, such as "CN=Dave, OU=JavaSoft, O=Sun Microsystems, C=US". The older "/C=US/O=Sun Microsystems, Inc/OU=JavaSoft/CN=Dave" syntax is not currently supported. (The former is RFC 1779 style.)- Parameters:
ldapDNString
- a Ldap DN String e.g. as defined in RFC1779- Throws:
IOException
-
X500Name
public X500Name(String ldapDNString, LdapDNStrConverter ldapDNStrConverter, byte[] tags) throws IOException Constructs a X500Name from a Ldap DN String using the specified LdapDNStrConverter. Also use the input tags.- Parameters:
ldapDNString
- a Ldap DN String e.g. as defined in RFC1779.ldapDNStrConverter
- A LdapDNStrConverter- Throws:
IOException
- See Also:
-
X500Name
- Throws:
IOException
-
X500Name
Constructs a X500Name from a Ldap DN String using the specified LdapDNStrConverter.- Parameters:
ldapDNString
- a Ldap DN String e.g. as defined in RFC1779.ldapDNStrConverter
- A LdapDNStrConverter- Throws:
IOException
- See Also:
-
X500Name
public X500Name(String commonName, String organizationUnit, String organizationName, String country) throws IOException Constructs a X500Name from fields common in enterprise application environments.- 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"- Throws:
IOException
-
X500Name
public X500Name(String commonName, String organizationUnit, String organizationName, String localityName, String stateName, String country) throws IOException Constructs a X500Name from fields common in Internet application environments.- 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"- Throws:
IOException
-
X500Name
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.- Throws:
IOException
-
X500Name
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.- Throws:
IOException
-
X500Name
Constructs a name from an ASN.1 encoded byte array.- Parameters:
name
- DER-encoded byte array holding an X.500 name.- Throws:
IOException
-
X500Name
Constructs a X500Name from array of RDN. The RDNs are expected to be in big endian order i.e. most significant first.- Parameters:
rdns
- an array of RDN.
-
X500Name
convenience method.- Parameters:
rdnVector
- a vector of rdns.
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
clear
private void clear()Sets private data to a null state -
getString
Returns the name component as a Java string, regardless of its encoding restrictions.- Throws:
IOException
-
getType
public int getType()Return type of GeneralName.- Specified by:
getType
in interfaceGeneralNameInterface
-
getCountry
Returns a "Country" name component. If more than one such attribute exists, the topmost one is returned.- Returns:
- "C=" component of the name, if any.
- Throws:
IOException
-
getOrganization
Returns an "Organization" name component. If more than one such attribute exists, the topmost one is returned.- Returns:
- "O=" component of the name, if any.
- Throws:
IOException
-
getOrganizationalUnit
Returns an "Organizational Unit" name component. If more than one such attribute exists, the topmost one is returned.- Returns:
- "OU=" component of the name, if any.
- Throws:
IOException
-
getCommonName
Returns a "Common Name" component. If more than one such attribute exists, the topmost one is returned.- Returns:
- "CN=" component of the name, if any.
- Throws:
IOException
-
getUserID
Returns a "UID" component. If more than one such attribute exists, the topmost one is returned.- Returns:
- "UID=" component of the name, if any.
- Throws:
IOException
-
getLocality
Returns a "Locality" name component. If more than one such component exists, the topmost one is returned.- Returns:
- "L=" component of the name, if any.
- Throws:
IOException
-
getState
Returns a "State" name component. If more than one such component exists, the topmost one is returned.- Returns:
- "S=" component of the name, if any.
- Throws:
IOException
-
getEmail
Returns a "Email" name component. If more than one such component exists, the topmost one is returned.- Returns:
- "E=" component of the name, if any.
- Throws:
IOException
-
toLdapDNString
Returns a Ldap DN String from the X500Name using the global default LdapDNStrConverter- Returns:
- Ldap DN string of this X500Name using the default converter.
- Throws:
IOException
- See Also:
-
getAttributesForOid
Return a list of attributes of the given type. The "most specific" value comes last. If there are no name attributes of the given type, an empty list is returned.- Throws:
IOException
-
toLdapDNString
Returns a Ldap DN String from the X500Name using the specified LdapDNStrconverter. For example, RFC1779String converter can be passed to convert the DN to RFC1779 string syntax.- Parameters:
ldapDNStrConverter
- a LdapDNStrConverter- Returns:
- Ldap DN string of the X500Name
- Throws:
IOException
- See Also:
-
toString
Returns a Ldap DN string, using the global default LdapDNStrConverter or null if an error occurs in the conversion. -
getName
Returns the value of toString(). This call is needed to implement the java.security.Principal interface. -
findAttribute
Find the first instance of this attribute in a "top down" search of all the attributes in the name. -
getRDNs
Returns an enumerator of RDNs in the X500Name.- Returns:
- enumeration of rdns in this X500Name.
-
getNames
Returns an array of RDN in the X500Name.- Returns:
- array of RDN in this X500name.
-
getNamesLength
public int getNamesLength()Returns the number of RDNs in the X500Name.- Returns:
- number of RDNs in this X500Name.
-
parseDER
- Throws:
IOException
-
encode
Encodes the name in DER-encoded form.- Specified by:
encode
in interfaceGeneralNameInterface
- Parameters:
out
- where to put the DER-encoded X.500 name- Throws:
IOException
- thrown if the GeneralName could not be encoded.
-
getEncoded
Gets the name in DER-encoded form.- Returns:
- the DER encoded byte array of this name, null if no names are present.
- Throws:
IOException
-
generateDN
- Throws:
IOException
-
intern
- Throws:
IOException
-