|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iaik.asn1.structures.Name
This class represents a X.500 Name structure (Distinguished Name). A distinguished name is defined as a sequence of Relative Distinguished Names:
Name ::= SEQUENCE OF RelativeDistinguishedName
A Name
object may be used for specifying, e.g. issuer and
subject within a X.509 certificate. For creating a Name
structure, use a proper constructor. You later may supply the
relative distinguished names constituting your actual Name
object by repeatedly calling the addRDN
method, e.g.:
This class also allows to add more than one RDN of the same attribute type.Name subject = new Name(); subject.addRDN(ObjectID.country, "AT"); subject.addRDN(ObjectID.locality, "Graz"); subject.addRDN(ObjectID.organization ,"TU Graz"); subject.addRDN(ObjectID.organizationalUnit ,"IAIK"); subject.addRDN(ObjectID.commonName ,"TestUser");
Constructor Summary | |
Name()
The default constructor. |
|
Name(ASN1Object obj)
Constructs a Name from an ASN1Object. |
|
Name(byte[] name)
Creates a name from a DER encoded byte array. |
Method Summary | |
void |
addRDN(ObjectID oid,
Object value)
Adds a RelativeDistinguishedName with given attribute type and value to this Name. |
void |
addRDN(RDN rdn)
Adds a RelativeDistinguishedName to this Name. |
void |
decode(ASN1Object obj)
Decodes a Name from the given ASN1Object. |
Enumeration |
elements()
Returns an enumeration of all RDNs included in this Name. |
boolean |
equals(Object obj)
Compares this Name to the specified object. |
byte[] |
getEncoded()
Returns this Name as DER encoded byte array. |
String |
getName()
Returns a string that represents this Name. |
String |
getRDN(ObjectID oid)
Returns the RDN value assigned to a given ObjectID. |
String[] |
getRDNs(ObjectID oid)
Returns the values of all RDNs assigned to a given ObjectID. |
Object |
getRDNValue(ObjectID oid)
Returns the RDN value assigned to a given ObjectID. |
Object[] |
getRDNValues(ObjectID oid)
Returns the values of all RDNs assigned to a given ObjectID. |
String |
getRFC2253String()
Returns a string representation of this Name according to RFC 2253. |
int |
hashCode()
Returns a hashcode for this Name. |
boolean |
isEmpty()
Checks if there are any RDNs included in this Name. |
boolean |
removeRDN(ObjectID oid)
Removes all RelativeDistinguishedNames with the given attribute type (oid) from this Name. |
ASN1Object |
toASN1Object()
Returns this Name as ASN1Object. |
String |
toString()
Returns a string that represents this Name. |
String |
toString(boolean detailed)
Returns a string that represents this Name. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Name()
public Name(byte[] name) throws CodingException
name
- a DER encoded Namepublic Name(ASN1Object obj) throws CodingException
obj
- the Name as ASN1ObjectCodingException
- if the ASN1Object has the wrong formatMethod Detail |
public void decode(ASN1Object obj) throws CodingException
decode
in interface ASN1Type
obj
- the Name as ASN1ObjectCodingException
- if the ASN1Object has the wrong formatpublic String getRDN(ObjectID oid)
null
is returned.
Attention! This method only may be used for querying for a String RDN value.
If you expect a non-string value (e.g. when searching for a uniqueIdentifier), use
method getRDNValue
which returns the value as
Java object.
oid
- the ObjectID of the RDN (attribute) type to be searched fornull
if no RDN of the requested type (oid) is
includedpublic String[] getRDNs(ObjectID oid)
Some CAs support certificates where the subject name may have multiple RDNs
of same attribute type (ObjectID), e.g. two organizationalUnit entries.
More than one RDN of same attribute type may be added to a Name
structure by repeatedly calling the addRDN
method with the same objectID (attribute type), e.g.:
name.addRDN(ObjectID.organizationalUnit,"..."); name.addRDN(ObjectID.organizationalUnit,"..."); ...When calling this
getRDNs
method, all the inherent RDN objects
are searched for the given objectID (attribute type). Any detected value
contributes to a String array returning the values of all included RDN
objects with the requested attribute type (oid).
If no RDN with such an ObjectID (attribute type) is included, null
is returned.
Attention! This method only may be used for querying for String RDN values.
If you expect non-string values (e.g. when searching for a uniqueIdentifier), use
method getRDNValues
which returns the values as
an array of Java objects.
oid
- the ObjectID of the RDN (attribute) type to be searched fornull
if no RDN of the requested type (oid) is
includedpublic Object getRDNValue(ObjectID oid)
null
is returned.oid
- the ObjectID of the RDN (attribute) type to be searched fornull
if no RDN of the requested type (oid) is
includedpublic Object[] getRDNValues(ObjectID oid)
Some CAs support certificates where the subject name may have multiple RDNs
of same attribute type (ObjectID), e.g. two organizationalUnit entries.
More than one RDN of same attribute type may be added to a Name
structure by repeatedly calling the addRDN
method with the same objectID (attribute type), e.g.:
name.addRDN(ObjectID.organizationalUnit,"..."); name.addRDN(ObjectID.organizationalUnit,"..."); ...When calling this
getRDNs
method, all the inherent RDN objects
are searched for the given objectID (attribute type). Any detected value
contributes to a String array returning the values of all included RDN
objects with the requested attribute type (oid).
If no RDN with such an ObjectID (attribute type) is included, null
is returned.
oid
- the ObjectID of the RDN (attribute) type to be searched fornull
if no RDN of the requested type (oid) is
includedpublic Enumeration elements()
public boolean isEmpty()
true
if there are no RDNs, false
otherwisepublic void addRDN(ObjectID oid, Object value)
oid
- the ObjectID (attribute type) of the RDN to be addedvalue
- the value of the RDN to be addedpublic void addRDN(RDN rdn)
rdn
- the RDN to be addedpublic boolean removeRDN(ObjectID oid)
oid
- the ObjectID (attribute type) of the RDN which shall be removedtrue
if some RDN(s) have been removed; false
if no RDN has been removed, since no RDN of the requested type is
included in this Namepublic ASN1Object toASN1Object()
toASN1Object
in interface ASN1Type
public byte[] getEncoded()
public int hashCode()
hashCode
in interface Principal
hashCode
in class Object
public boolean equals(Object obj)
equals
in interface Principal
equals
in class Object
obj
- - the object to compare this Name against.true
, if the object represents the same Name
false
otherwisepublic String getName()
getName
in interface Principal
public String toString()
toString
in interface Principal
toString
in class Object
public String toString(boolean detailed)
detailed
- true
if no shortNames shall be used when
printing the attribute types of the AVAspublic String getRFC2253String() throws RFC2253NameParserException
RFC 2253 specifies a string representation of Distinguished Names as used for LDAP lookups.
The included RDNs are represented in reversed order starting with the last element and moving to the first. Adjoining RDNs are separated by a comma (",").
The AttributeTypeAndValues of each included RDN
are represented as specified in
sections 2.3, 2.4 of RFC 2253 (adjoining AttributeTypeAndValues
(or AVA
s) are separated by a plus ("+")
character):
The attribute type is represented as described in section 2.3 of RFC 2253. If there is no known name string for the attribute type a dotted-decimal encoding of the attribute type´s identifier.
The string representation of the attribute value is either a hexadecimal represenation of its BER encoding (introduced by a "#" character) or based on the algorithm given in section 2.4 of RFC 2253 applying the following escaping mechanisms:
RFC2253NameParserException
- if the AVA cannot be represented
according to the rules above
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |