|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--iaik.asn1.structures.AVA
This class implements the ASN.1 type AttributeValueAssertion.
An AttributeValueAssertion gives one component of a RelativeDistinguishedName structure:
RelativeDistinguishedName ::= SET OF AttributeValueAssertion
AttributeValueAssertion ::= SEQUENCE {
AttributeType OBJECT IDENTIFIER,
AttributeValue ANY
}
When creating a new AVA object, the attribute type has to
be specified as ObjectID, and the value
has to be supplied as a Java object of matching type (i.e. compatible to
the type expected by the setValue method of the corresponding
ASN.1 type), e.g.:
AVA ava = new AVA(ObjectID.commonName, "John Doe");The example above will create an AVA for the X.500 attribute type commonName. Since, per default, the commonName value will be encoded as PrintableString, the value has to be specified as java.lang.String object since the
setValue
method of class PrintableString expects a String object. Alternatively immediately
a PrintableString ASN1Object may be supplied (and will be encoded unchanged):
AVA ava = new AVA(ObjectID.commonName, new PrintableString("John Doe"));
When DER encoding an AVA object where the value is not
immediately given as ASN1Object, the inherent value per
default will be encoded as ASN.1 character string of type
PrintableString, except for
the X.500 attribute type uniqueIdentifier and the PKCS#9
attribute type emailAddress which per default will be encoded as
BIT_STRING, and IA5String, respectively.
An application wishing to use another encoding type than PrintableString
for encoding some specific attribute value, may register the ASN.1
encoding type in mind by means of the static defineEncoding(ObjectID type, ASN encodingType)
method, e.g.:
AVA.defineEncoding(ObjectID.title, ASN.VisibleString);will enforce that any AVA value of X.500 attribute type title will be encoded as
VisibleString instead of
PrintableString}.
If you want to use a different encoding type only for one specific AVA object
you may use the non static setEncoding method, e.g.:
AVA ava = new AVA(ObjectID.commonName, "John Doe"); ava.setEncoding(ASN.IA5String);will enforce that the value of this specific AVA object will be encoded as IA5String.
Special care has to taken when using an attribute of type type
uniqueIdentifier. Since the uniqueIdentifier value has to be
encoded as BIT_STRING, per default the
value has to be specified as byte array as expected by the setValue method of the
BIT_STRING class:
byte[] value = ...; AVA ava = new AVA(ObjectID.uniqueIdentifier, value);However, since some certificates use a DER encoded PrintableString as value for the BIT_STRING uniqueIdentifier alternatively a string value may be supplied:
String s = ...; AVA ava = new AVA(ObjectID.uniqueIdentifier, s);In such cases, the AVA will encode the uniqueIdentifier value as BIT_STRING having a DER encoded PrintableString as its value.
| Constructor Summary | |
AVA(ASN1Object obj)
Creates an AttributeValueAssertion from an ASN1Object. |
|
AVA(ObjectID type,
java.lang.Object value)
Creates a new AttributeValueAssertion from a type and a value. |
|
AVA(java.lang.String avaName)
Creates a new AttributeValueAssertion from a string formatted version, such as cn=John Doe. |
|
| Method Summary | |
void |
decode(ASN1Object obj)
Decodes an AVA from the given ASN1Object. |
static void |
defineEncoding(ObjectID type,
ASN encodingType)
Defines the ASN.1 encoding for a specified Attribute type. |
boolean |
equals(java.lang.Object obj)
Compares two AttributeValueAssertions. |
ASN1Object |
getASN1Value()
Returns an ASN.1 representation of the value of this AttributeValueAssertion. |
ObjectID |
getType()
Returns the type of this AttributeValueAssertion. |
java.lang.Object |
getValue()
Returns the value of this AttributeValueAssertion. |
int |
hashCode()
Returns the hashcode for this AttributeValueAssertion. |
void |
setEncoding(ASN encodingType)
Sets the ASN.1 encoding for this AVA. |
ASN1Object |
toASN1Object()
Returns this AttributeValueAssertion as an ASN1Object. |
java.lang.String |
toString()
Returns a string that represents the contents of this RDN. |
java.lang.String |
toString(boolean detailed)
Returns a string that represents the contents of this AVA. |
| Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
| Constructor Detail |
public AVA(ObjectID type,
java.lang.Object value)
throws java.lang.IllegalArgumentException
setValue
method of the corresponding ASN.1 type), e.g.:
AVA ava = new AVA(ObjectID.commonName, "John Doe");The example above will create an AVA for the X.500 attribute type commonName. Since, per default, the commonName value will be encoded as PrintableString, the value has to be specified as java.lang.String object since the
setValue
method of class PrintableString expects a String object. Alternatively immediately
a PrintableString ASN1Object may be supplied:
AVA ava = new AVA(ObjectID.commonName, new PrintableString("John Doe"));
type - the attribute type as an ObjectIDvalue - the attribute value
public AVA(java.lang.String avaName)
throws java.lang.IllegalArgumentException
public AVA(ASN1Object obj)
throws CodingException
The supplied ASN1Object represents an already existing AVA
that may have been created by means of the toASN1Object method.
obj - the AttributeValueAssertion as ASN1Object| Method Detail |
public static void defineEncoding(ObjectID type,
ASN encodingType)
PrintableString, except for
the X.500 attribute type uniqueIdentifier and the PKCS#9
attribute type emailAddress which per default will be encoded as
BIT_STRING, and IA5String, respectively.
This method may be used to enforce another encoding scheme for some specific attribute type, e.g.:
AVA.defineEncoding(ObjectID.title, ASN.VisibleString);will enforce that any AVA value of X.500 attribute type title will be encoded as
VisibleString instead of
PrintableString}.type - the attribute type for which a new encoding scheme shall be definedencodingType - the ASN.1 type for encoding itpublic void setEncoding(ASN encodingType)
This method may be used to enforce a particular encoding for this AVA object, e.g.:
AVA ava = new AVA(ObjectID.commonName, "John Doe"); ava.setEncoding(ASN.IA5String);will enforce that the value of this specific AVA object will be encoded as IA5String.
encodingType - the ASN.1 type specifying the encoding to be used.
public void decode(ASN1Object obj)
throws CodingException
The supplied ASN1Object represents an already existing AVA object that
may have been created by means of the toASN1Object()
method.
obj - the AttributeValueAssertion as ASN1Objectpublic ASN1Object toASN1Object()
public ObjectID getType()
public java.lang.Object getValue()
public ASN1Object getASN1Value()
throws CodingException
public int hashCode()
public boolean equals(java.lang.Object obj)
obj - the other AttributeValueAssertiontrue, if the two AttributeValueAssertions are equal,
false otherwisepublic java.lang.String toString()
The string output is compatible to RFC 1779/2253 except for escaping. If desired, an application itself make take care for proper escaping.
Care has to be taken about attributes of type uniqueIdentifier. Since some certificates use a DER encoded PrintableString as value for the BIT_STRING uniqueIdentifier this method prints a string for such a uniqueIdentifier. Otherwise a binary string representation of the bit string value is printed, e.g.: "#'10010'B".
public java.lang.String toString(boolean detailed)
The string output is compatible to RFC 1779/2253 except for escaping. If desired, an application itself make take care for proper escaping.
Care has to be taken about attributes of type uniqueIdentifier. Since some certificates use a DER encoded PrintableString as value for the BIT_STRING uniqueIdentifier this method prints a string for such a uniqueIdentifier. Otherwise a binary string representation of the bit string value is printed, e.g.: "#'10010'B".
detailed - whether the short name of the full name of the
type shall be used
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||