|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.asn1.structures.Attribute iaik.cms.CMSAttribute
public class CMSAttribute
Extends class Attribute
to keep the encoding when parsing an
attribute from an InputStream.
This class does not have any public constructor. Instances of this class are only created from within the CMS library when parsing attributes.
To get the attribute encoding call method getEncoded
, e.g.:
ObjectID attributeType = ...; SignerInfo signerInfo = ...; CMSAttribute cmsAttribute = (CMSAttribute)signerInfo.getUnsignedAttribute(attributeType); byte[] encodedAttribute = cmsAttribute.getEncoded();If some value of the attribute has been changed from outside it might be necessary to clear the kept attribute encoding to ensure that the (changed) attribute is encoded anew:
cmsAttribute.clearEncoded();Alternatively a new Attribute object may be created (and used) with the changed attribute value(s), e.g. (for a single-valued attribute):
ObjectID attributeType = ...; SignerInfo signerInfo = ...; CMSAttribute cmsAttribute = (CMSAttribute)signerInfo.getUnsignedAttribute(attributeType); AttributeValue value = cmsAttribute.getAttributeValue(); // change value and create new attribute Attribute changedAttribute = new Attribute(value); // remove old attribute signerInfo.removeUnSignedAttribute(attributeType); // add new (changed) attribute signerInfo.addUnSignedAttribute(changedAttribute);
Method Summary | |
---|---|
void |
addAttributeValue(AttributeValue attributeValue)
Adds an AttributeValue to the set of attribute values. |
void |
clearEncoded()
Clears the attribute encoding. |
void |
clearEncoded(boolean clearEncodedValues)
Clears the attribute encoding. |
AttributeValue |
getAttributeValue()
Returns the value of this (single valued) Attribute. |
AttributeValue[] |
getAttributeValues()
Returns the values of this (maybe multi-valued) Attribute. |
byte[] |
getEncoded()
Gets the encoded attribute. |
EncodedAttributeValue[] |
getEncodedAttributeValues()
Returns the value(s) of this (maybe multi-valued) Attribute as array of EncodedAttributeValue objects. |
ASN1Object[] |
getValue()
Returns the value of this Attribute. |
void |
setAttributeValue(AttributeValue attributeValue)
Sets the AttributeValue to this single-valued attribute. |
ASN1Object |
toASN1Object(boolean sorted)
Returns the Attribute as an ASN1Object. |
java.lang.String |
toString()
Returns a string that represents the contents of this Attribute. |
Methods inherited from class iaik.asn1.structures.Attribute |
---|
create, decode, equals, getType, hashCode, register, toASN1Object |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public AttributeValue getAttributeValue() throws CodingException
This method preferably may be called for getting the value of an Attribute
having only one single value. For getting all the values of an multi-valued
Attribute call method getAttributeValues
or
method getValue()
.
This method looks if there exists an registered
implementation of the attribute value belonging to the attribute type this
Attribute object represents. If an AttributeValue
implementation exists, this method returns the attribute value
as corresponding AttributeValue
descendant. If no implementation
exists, this method returns an UnknownAttributeValue
object to may be parsed for its ASN.1 representation.
getAttributeValue
in class Attribute
null
if no attribute value has been set
CodingException
- if an error occurs when internally decoding the attribute
value for parsing its structurepublic AttributeValue[] getAttributeValues() throws CodingException
This method preferably may be called for getting the values of an Attribute having more than only one single value.
For each included attribute value this method looks if there exists an registered
implementation of the attribute value
belonging to the attribute type this Attribute object represents. If an AttributeValue
implementation exists, this
method returns the attribute values as corresponding AttributeValue
descendants. If no implementation exists, this method returns an array of UnknownAttributeValue
objects to may
be parsed for their ASN.1 representation.
getAttributeValues
in class Attribute
CodingException
- if an error occurs when internally decoding any attribute
value for parsing its structurepublic EncodedAttributeValue[] getEncodedAttributeValues() throws CodingException
The EncodedAttributeValue
objects returned by
this method maybe queried for their value
or encoded
representation.
When not needing the parsed encoded attribute value representation it is more
convenient to call method getAttributeValues()
.
CodingException
- if an error occurs when internally decoding any attribute
value for parsing its structurepublic ASN1Object toASN1Object(boolean sorted)
toASN1Object
in class Attribute
sorted
- whether to sort the SET of AttributeValue according there
encoding; maybe ignored if calling toASN1Object
for an parsed Attribute; in this case the original encoding
-- if kept -- is written (maybe cleared
)
to build the ASN.1 structure anew
public void addAttributeValue(AttributeValue attributeValue) throws CodingException, java.lang.IllegalArgumentException
addAttributeValue
in class Attribute
attributeValue
- the attribute value to be added
CodingException
- since attribute values internally are maintained as ASN1Object
a CodingException might be thrown when getting the ASN.1
representation of the given AttributeValue
java.lang.IllegalArgumentException
- if the attributValue is of a type not matching to the type
of this Attributepublic void setAttributeValue(AttributeValue attributeValue) throws CodingException, java.lang.IllegalArgumentException
setAttributeValue
in class Attribute
attributeValue
- the attribute value to be set for this attribute
CodingException
- since attribute values internally are maintained as ASN1Object
a CodingException might be thrown when getting the ASN.1
representation of the given AttributeValue
java.lang.IllegalArgumentException
- if the attributValue is of a type not matching to the type
of this Attributepublic byte[] getEncoded()
public void clearEncoded()
toASN1Object()
or
getEncoded()
will build the internal ASN.1 structure
anew. This may be required when any of the values of the parsed
attribute has be changed from outside.
public void clearEncoded(boolean clearEncodedValues)
toASN1Object()
or
getEncoded()
will build the internal ASN.1 structure
anew. This may be required when any of the values of the parsed
attribute has be changed from outside.
clearEncodedValues
- whether to also clear the encodings of the
attribute values of this attribute (true
) or to
only clear the attribute encoding but not the encoding of
the attribute values (false
)public ASN1Object[] getValue()
getValue
in class Attribute
public java.lang.String toString()
toString
in class Attribute
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |