iaik.asn1.structures
Class Attribute

java.lang.Object
  |
  +--iaik.asn1.structures.Attribute

public class Attribute
extends java.lang.Object
implements ASN1Type

This class implements the ASN.1 type Attribute. An Attribute object consists of an attribute type (specified by an object identifier) and one or more attribute values:

 Attribute ::= SEQUENCE {
  type    AttributeType,
  values  SET OF AttributeValue
    -- at least one value is required -- 
 }

 AttributeType           ::=   OBJECT IDENTIFIER
 AttributeValue          ::=   ANY DEFINED BY type
 

When creating a new Attribute object, the attribute type has to be specified as ObjectID, and the attribute value(s) have to be supplied as array of ASN1Objects, e.g.:

 ChoiceOfTime choiceOfTime = new ChoiceOfTime();
 ASN1Object[] asn1Objects = new ASN1Object[] { choiceOfTime.toASN1Object() };
 Attribute attribute = new Attribute(ObjectID.signingTime, asn1Objects);
 
The example above creates a PKCS#9 SigningTime attribute to be used for specifying the time a signer has signed a PKCS#7 SignedData message.

See Also:
ASN1Type

Constructor Summary
Attribute()
          Creates an empty Attribute.
Attribute(ASN1Object obj)
          Creates an Attribute from an ASN1Object.
Attribute(ObjectID type, ASN1Object[] value)
          Creates an Attribute from attribute type (ObjectID) and attribute values.
 
Method Summary
 void decode(ASN1Object obj)
          Decodes an Attribute from the given ASN1Object.
 boolean equals(java.lang.Object obj)
          Compares two Attributes.
 ObjectID getType()
          Returns the type of this Attribute.
 ASN1Object[] getValue()
          Returns the value of this Attribute.
 ASN1Object toASN1Object()
          Returns the Attribute as an ASN1Object.
 java.lang.String toString()
          Returns a string that represents the contents of this Attribute.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute()
Creates an empty Attribute.

Attribute

public Attribute(ObjectID type,
                 ASN1Object[] value)
Creates an Attribute from attribute type (ObjectID) and attribute values.
Parameters:
type - the type of the attribute as ObjectID
value - the value of the attribute as array of ASN1Objects

Attribute

public Attribute(ASN1Object obj)
          throws CodingException
Creates an Attribute from an ASN1Object. The supplied ASN1Object represents an already existing Attribute object that may have been created by means of the toASN1Object() method.
Parameters:
obj - the Attribute as ASN1Object
Throws:
CodingException - if this ASN1Object could not be parsed
Method Detail

decode

public void decode(ASN1Object obj)
            throws CodingException
Decodes an Attribute from the given ASN1Object. The supplied ASN1Object represents an already existing Attribute object that may have been created by means of the toASN1Object() method.
Specified by:
decode in interface ASN1Type
Parameters:
obj - the ASN.1 type as ASN1Object
Throws:
CodingException - if the ASN1Object could not be parsed

toASN1Object

public ASN1Object toASN1Object()
Returns the Attribute as an ASN1Object.
Specified by:
toASN1Object in interface ASN1Type
Returns:
the Attribute as ASN1Object

getType

public ObjectID getType()
Returns the type of this Attribute.
Returns:
the type of this Attribute, as ObjectID

getValue

public ASN1Object[] getValue()
Returns the value of this Attribute.
Returns:
the value of this Attribute, as array of ASN1Objects

equals

public boolean equals(java.lang.Object obj)
Compares two Attributes.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the other Attribute
Returns:
true, if the two Attributes are equal, false otherwise

toString

public java.lang.String toString()
Returns a string that represents the contents of this Attribute.
Overrides:
toString in class java.lang.Object
Returns:
the string representation