public class Attribute extends java.lang.Object implements ASN1Type
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.ASN1Type| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
ASN1Object |
toASN1Object(boolean sorted)
Returns the Attribute as an ASN1Object.
|
java.lang.String |
toString()
Returns a string that represents the contents of this Attribute.
|
public Attribute()
public Attribute(ObjectID type, ASN1Object[] value)
type - the type of the attribute as ObjectIDvalue - the value of the attribute as array of ASN1Objectspublic Attribute(ASN1Object obj) throws CodingException
toASN1Object()
method.obj - the Attribute as ASN1ObjectCodingException - if this ASN1Object could not be parsedpublic void decode(ASN1Object obj) throws CodingException
toASN1Object()
method.decode in interface ASN1Typeobj - the ASN.1 type as ASN1ObjectCodingException - if the ASN1Object could not be parsedpublic ASN1Object toASN1Object()
toASN1Object in interface ASN1Typepublic ASN1Object toASN1Object(boolean sorted)
sorted - whether to sort the SET of AttributeValue according there
encoding (overrides the value that already may have been
set via constructorpublic ObjectID getType()
public ASN1Object[] getValue()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the other Attributetrue, if the two Attributes are equal, false otherwisepublic java.lang.String toString()
toString in class java.lang.Object