public class SignedAttributes
extends iaik.asn1.structures.Attributes
Provides an alternative way for getting the signed attributes from a
parsed SignerInfo
object:
SignerInfo signerInfo = ...; SignedAttributes signedAttributes = signerInfo.getSignedAttrs();
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(iaik.asn1.structures.Attribute attribute)
Adds the given attribute.
|
void |
addAttribute(iaik.asn1.structures.Attribute attribute,
boolean replace)
Adds the given attribute.
|
void |
addAttributes(iaik.asn1.structures.Attribute[] attributes)
Adds the given attributes.
|
void |
clearAll()
Clears all attributes included in the container.
|
void |
clearEncoded()
Clears the attributes encoding.
|
byte[] |
getEncoded()
Returns the DER encoded implicitly tagged signed attributes.
|
void |
insertAttributeAt(iaik.asn1.structures.Attribute attribute,
int index)
Inserts the given attribute.
|
boolean |
removeAttribute(iaik.asn1.structures.Attribute attribute)
Removes the first representative of the given attribute.
|
iaik.asn1.structures.Attribute |
removeAttribute(iaik.asn1.ObjectID type)
Removes the first attribute with the given type from the container
|
boolean |
removeAttributes(iaik.asn1.structures.Attribute attribute)
Removes all representatives of the given attribute from the container.
|
iaik.asn1.structures.Attribute[] |
removeAttributes(iaik.asn1.ObjectID type)
Removes all attributes with the given type from the container
|
int |
size()
Returns the number of attributes held by this Attributes object.
|
public void addAttribute(iaik.asn1.structures.Attribute attribute)
addAttribute
in class iaik.asn1.structures.Attributes
attribute
- the attribute to be added.public void addAttribute(iaik.asn1.structures.Attribute attribute, boolean replace)
addAttribute
in class iaik.asn1.structures.Attributes
attribute
- the attribute to be added.replace
- whether to replace any already existing attribute with the given
typepublic void addAttributes(iaik.asn1.structures.Attribute[] attributes)
addAttributes
in class iaik.asn1.structures.Attributes
attributes
- the attributes to be added.public void insertAttributeAt(iaik.asn1.structures.Attribute attribute, int index)
insertAttributeAt
in class iaik.asn1.structures.Attributes
attribute
- the attribute to be inserted.index
- the position at which to insert the attributepublic boolean removeAttribute(iaik.asn1.structures.Attribute attribute)
removeAttribute
in class iaik.asn1.structures.Attributes
attribute
- the attribute to be removedtrue
if the attribute has been removed,
false
if no such attribute was presentpublic iaik.asn1.structures.Attribute removeAttribute(iaik.asn1.ObjectID type)
removeAttribute
in class iaik.asn1.structures.Attributes
type
- the type of the attribute to be removednull
if no attribute
with this type was presentpublic boolean removeAttributes(iaik.asn1.structures.Attribute attribute)
removeAttributes
in class iaik.asn1.structures.Attributes
attribute
- the attribute to be removedtrue
if the attributes have been removed,
false
if no such attribute was presentpublic iaik.asn1.structures.Attribute[] removeAttributes(iaik.asn1.ObjectID type)
removeAttributes
in class iaik.asn1.structures.Attributes
type
- the type of the attributes to be removedpublic int size()
public byte[] getEncoded() throws iaik.asn1.CodingException
According to the CMS specification (RFC 5652) the SignerInfo signed attributes are encoded as SET of Attribute, implicitly tagged wrapped into a CON_SPEC with tag 0:
SignerInfo ::= SEQUENCE { ... signedAttrs [0] IMPLICIT Attributes OPTIONAL, ... } SignedAttributes ::= SET SIZE (1..MAX) OF AttributeNote that the attributes are not wrapped into a CON_SPEC when calling any of the
writeToAsn1SET
, writeToAsn1SEQUENCE
methods.
iaik.asn1.CodingException
- if an Encoding error occurspublic void clearEncoded()
getEncoded()
will build the
internal ASN.1 structure anew. This may be required when any attributes
have been added/removed/changed from outside.public void clearAll()
clearAll
in class iaik.asn1.structures.Attributes