|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.cms.SignerInfo
public class SignerInfo
This class implements the CMS SignerInfo
type.
The Cryptographic Message Syntax (CMS) (RFC 5652)
specifies the SignerInfo
type for collecting all signer-related information about some particular
signer intending to build a digital signature on the content of a CMS
SignedData
object. Content of any type may be
signed by any number of signers in parallel. For each signer, a message
digest is computed on the content (and any additional authenticating
information) with a signer-specific message-digest algorithm. Subsequently,
again for each signer, the corresponding message digest from the previous
step is signed with the particular signer private key and - together with
some signer-specific information - collected into a SignerInfo
value. Finally all created SignerInfo
values are collected
together with the content for forming a SignedData
structure
(when.
The SignerInfo
structure collecting all signer-related
information is defined as ASN.1 SEQUENCE type containing the following
components (see
RFC 5652):
SignerInfo ::= SEQUENCE { version CMSVersion, sid SignerIdentifier, digestAlgorithm DigestAlgorithmIdentifier, signedAttrs [0] IMPLICIT Attributes OPTIONAL, signatureAlgorithm SignatureAlgorithmIdentifier, signature SignatureValue, unsignedAttributes [1] IMPLICIT Attributes OPTIONAL }
SignerIdentifier ::= CHOICE { issuerAndSerialNumber IssuerAndSerialNumber, subjectKeyIdentifier [0] SubjectKeyIdentifier }
SignatureValue ::= OCTET STRING
SignedAttributes ::= SET SIZE (1..MAX) OF Attribute UnsignedAttributes ::= SET SIZE (1..MAX) OF Attribute
The digestAlgorithm
and signatureAlgorithm
fields identify the algorithms used for digesting the content and any
signed attributes, respectively signing the message digest and
associated information with the signer private key. The
signerIdentifier
field specifies the signer certificate by
issuer distinguished name and issuer-specific serial number.
SignedAttributes
and
unsignedAttributes
are optional fields giving some
attributes that are signed (respectively not signed) by the signer.
Attributes that may be used here, are defined in PKCS #9. The
signature
field finally contains the result of the
signature calculation process. It is derived by signing the
message digest on the content and associated information with the signer
private key.
For more information see RFC 5652.
This class provides several constructors and methods for creating a
SignerInfo
object, setting some attributes, obtaining
the component values, and signing (respectively verifying) the
signature value.
Assuming that certificate
represents the X509v3 certificate
of some signer, a SignerInfo
object may be created by supplying
the certificate issuer distinguished
name and the issuer-specific serial number
, the signer message digest
algorithm ID, and the signer private key:
IssuerAndSerialNumber issuerAndSerialNr = new IssuerAndSerialNumber(certificate); SignerInfo signerInfo = new SignerInfo(issuerAndSerialNr, AlgorithmID.sha256, privateKey);
Instead of identifying the signer certificate by issuer distinguished name and
issuer-specific serial number the SubjectKeyIdentifier
extension my be used, if appropriate:
SubjectKeyID subjectKeyId = new SubjectKeyID(certificate); SignerInfo signerInfo = new SignerInfo(subjectKeyId, AlgorithmID.sha256, privateKey);
Attributes may be added using the setSignedAttributes
respectively
setUnsignedAttributes
methods, e.g.:
Attribute[] attributes = new Attribute[2]; // PKCS#9ContentType
attribute specifying, e.g. the Data content type: attributes[0] = new Attribute(ObjectID.contentType, new ASN1Object[] {ObjectID.cms_data}); // PKCS#9SigningTime
attribute specifying the signing time (e.g. current time): attributes[1] = new Attribute(ObjectID.signingTime, new ASN1Object[] {new ChoiceOfTime().toASN1Object()}); // add the attributes to the SignerInfo: signerInfo.setSignedAttributes(attributes);
Add a SignerInfo to a SignedData object by calling the addSignerInfo
method of the SignedData(Stream)
class.
SignedData
,
SignedDataStream
,
CertificateIdentifier
,
IssuerAndSerialNumber
,
SubjectKeyID
Constructor Summary | |
---|---|
SignerInfo()
Default constructor. |
|
SignerInfo(ASN1Object obj)
Creates a CMS SignerInfo from an ASN1Object. |
|
SignerInfo(CertificateIdentifier signerIdentifier,
AlgorithmID digestAlgorithm,
AlgorithmID signatureAlgorithm,
java.security.PrivateKey privateKey)
Creates a new SignerInfo from given signerIdentifier, and digestAlgorithm ID, signature algorithmID, and the signer private key. |
|
SignerInfo(CertificateIdentifier signerIdentifier,
AlgorithmID digestAlgorithm,
java.security.PrivateKey privateKey)
Creates a new SignerInfo from given SignerIdentifier, digestAlgorithm ID, and the signer private key. |
|
SignerInfo(java.io.InputStream is)
Reads and parses a encoded SignerInfo from an InputStream. |
|
SignerInfo(X509Certificate signerCertificate,
AlgorithmID digestAlgorithm,
AlgorithmID signatureAlgorithm,
java.security.PrivateKey privateKey)
Creates a new SignerInfo from given signer certificate, digest algorithm ID, signature algorithm ID, and the signer private key. |
|
SignerInfo(X509Certificate signerCertificate,
AlgorithmID digestAlgorithm,
java.security.PrivateKey privateKey)
Creates a new SignerInfo from given signer certificate, digest algorithm ID and the signer private key. |
Method Summary | |
---|---|
void |
addSignedAttribute(Attribute attribute)
Adds the given attribute to the set of signed attributes. |
void |
addSignedAttributes(Attribute[] attributes)
Adds the given attributes to the set of signed attributes. |
void |
addUnsignedAttribute(Attribute attribute)
Adds the given attribute to the set of unsigned attributes. |
void |
addUnSignedAttribute(Attribute attribute)
Deprecated. use addUnsignedAttribute(iaik.asn1.structures.Attribute) |
void |
addUnsignedAttributes(Attribute[] attributes)
Adds the given attributes to the set of unsigned attributes. |
void |
decode(ASN1Object obj)
Decodes the given ASN.1 SignerInfo object for parsing
the internal structure. |
CMSVersion |
getCMSVersion()
Returns the syntax version number (1 or 3). |
byte[] |
getDigest()
Returns the message digest calculated on the content. |
AlgorithmID |
getDigestAlgorithm()
Returns the AlgorithmID of the message-digest algorithm that has been used for digesting the content and any signed attributes. |
SecurityProvider |
getSecurityProvider()
Gets the SecurityProvider installed for this SignerInfo. |
AlgorithmID |
getSignatureAlgorithm()
Returns the signature algorithm used for calculating the signature and associated information with the signer private key. |
byte[] |
getSignatureValue()
Returns the signature value. |
Attribute |
getSignedAttribute(ObjectID oid)
Returns the first signed attribute matching to the given ObjectID, if included in this SignerInfo object. |
Attribute[] |
getSignedAttributes()
Returns a set of attributes that are signed by the signer. |
Attribute[] |
getSignedAttributes(ObjectID oid)
Returns all signed attributes matching to the given attribute type, if included in this SignerInfo object. |
AttributeValue |
getSignedAttributeValue(ObjectID oid)
Returns the attribute value of a single valued signed attribute with the given type. |
SignedAttributes |
getSignedAttrs()
Returns a set of attributes that are signed by the signer. |
byte[] |
getSignedDigest()
Returns the value of the MessageDigest attribute. |
SignerIdentifier |
getSignerId()
Returns information about the signer certificate. |
CertificateIdentifier |
getSignerIdentifier()
Returns information about the signer certificate. |
SigningCertificate |
getSigningCertificateAttribute()
Gets the SigningCertificate attribute, if included. |
SigningCertificateV2 |
getSigningCertificateV2Attribute()
Gets the SigningCertificateV2 attribute, if included. |
SignatureValue |
getSigValue()
Returns the signature value as SignatureValue object. |
Attribute |
getUnsignedAttribute(ObjectID oid)
Returns the first unsigned attribute matching to the given ObjectID, if included in this SignerInfo object. |
Attribute[] |
getUnsignedAttributes()
Returns a set of attributes that are not signed by the signer. |
Attribute[] |
getUnsignedAttributes(ObjectID oid)
Returns all unsigned attributes matching to the given attribute type, if included in this SignerInfo object. |
AttributeValue |
getUnsignedAttributeValue(ObjectID oid)
Returns the attribute value of a single valued unsigned attribute with the given type. |
int |
getVersion()
Returns the syntax version number (1 or 3). |
boolean |
isSignerCertificate(X509Certificate cert)
Checks whether the supplied certificate actually is the certificate of the signer. |
void |
removeSignedAttribute(ObjectID attributeType)
Removes all signed attributes with the given attribute type. |
void |
removeUnsignedAttribute(ObjectID attributeType)
Removes all unsigned attributes with the given attribute type. |
void |
removeUnSignedAttribute(ObjectID attributeType)
Deprecated. use removeUnsignedAttribute(iaik.asn1.ObjectID) |
void |
setEncryptedDigest(byte[] signatureValue)
Deprecated. use method setSignatureValue
to set the signature value (this method does exactly the same
as method setEncryptedDigest ) |
void |
setSecurityProvider(SecurityProvider securityProvider)
Sets the SecurityProvider for this SignerInfo. |
void |
setSignatureValue(byte[] signatureValue)
Sets the signature value. |
void |
setSignedAttributes(Attribute[] attributes)
Sets a set of attributes to be signed along with the content to be signed. |
void |
setUnsignedAttributes(Attribute[] attributes)
Sets a set of attributes that are not signed by the signer. |
ASN1Object |
toASN1Object()
Returns this SignerInfo as ASN1Object. |
java.lang.String |
toString()
Returns a string giving some information about this SignerInfo object. |
java.lang.String |
toString(boolean detailed)
Returns a string giving some - if requested - detailed information about this SignerInfo object. |
boolean |
verifySignature(byte[] contentHash,
java.security.PublicKey publicKey)
Verifies the signature with the given public key. |
boolean |
verifySignature(java.security.PublicKey publicKey)
Verifies the signature with the given public key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SignerInfo()
SignerInfo
object and sets the version number to 1, and the signature
algorithm ID to rsaEncryption.
public SignerInfo(CertificateIdentifier signerIdentifier, AlgorithmID digestAlgorithm, java.security.PrivateKey privateKey)
The signerIdentifier
identifies the signer certificate either
by issuer distinguished name and
issuer-specific serial number
or by SubjectKeyIdentifier
. The digestAlgorithm ID specifies the message digest
algorithm used for calculating the digest of the content and any signed
information. The private key is used for calculating the signature.
This constructor tries to derive the signature algorithm to be used
from the private key algorithm (by default -- if the signature algorithm
cannot be derived from the key -- the PKCS#1 rsaEncryption method
is used for signature calculation). If the given digest algorithm is
null
it is set according the private key algorithm
(default: SHA-256).
signerIdentifier
- information about the signer certificate.digestAlgorithm
- the algorithm to be used for message-digest calculationprivateKey
- the signer private key to be used for signing
java.lang.IllegalArgumentException
- if the supplied signerIdentifier is not a
SubjectKeyID or IssuerAndSerialNumberpublic SignerInfo(CertificateIdentifier signerIdentifier, AlgorithmID digestAlgorithm, AlgorithmID signatureAlgorithm, java.security.PrivateKey privateKey)
The signerIdentifier
identifies the signer certificate either
by issuer distinguished name and
issuer-specific serial number
or by SubjectKeyIdentifier
. The digestAlgorithm ID specifies the message digest
algorithm used for calculating the digest of the content and any signed
information. The private key is used for calculating the signature with
the given signature algorithm.
If the given digest or signature algorithm are null
this
constructor tries to set digest and/or signature algorithm according
to the private key algorithm (by default -- if the digest/signature algorithm
cannot be derived from the key -- SHA-256 is used as digest algorithm and
the PKCS#1 rsaEncryption method is used for signature calculation).
signerIdentifier
- information about the signer certificate.digestAlgorithm
- the algorithm to be used for message-digest calculationsignatureAlgorithm
- the algorithm to be used for signature calculationprivateKey
- the signer private key to be used for signing
java.lang.IllegalArgumentException
- if the supplied signerIdentifier is not a SubjectKeyID or
IssuerAndSerialNumberpublic SignerInfo(X509Certificate signerCertificate, AlgorithmID digestAlgorithm, java.security.PrivateKey privateKey)
The signer will be identified by issuer distinguished name and issuer-specific serial number
.
The digestAlgorithm ID specifies the message digest
algorithm used for calculating the digest of the content and any signed
information. The private key is used for calculating the signature with
the given signature algorithm.
This constructor tries to derive the signature algorithm to be used
from the certificate public key algorithm (by default -- if the signature algorithm
cannot be derived from the key -- the PKCS#1 rsaEncryption method
is used for signature calculation). If the given digest algorithm is
null
it is set according the private key algorithm
(default: SHA-256).
signerCertificate
- the signer certificate.digestAlgorithm
- the algorithm to be used for message-digest calculationprivateKey
- the signer private key to be used for signingpublic SignerInfo(X509Certificate signerCertificate, AlgorithmID digestAlgorithm, AlgorithmID signatureAlgorithm, java.security.PrivateKey privateKey)
The signer will be identified by issuer distinguished name and issuer-specific serial number
.
The digestAlgorithm ID specifies the message digest
algorithm used for calculating the digest of the content and any signed
information. The private key is used for calculating the signature with
the given signature algorithm.
If the given digest or signature algorithm are null
this
constructor tries to set digest and/or signature algorithm according
to the certificate public key algorithm (by default -- if the digest/signature
algorithm cannot be derived from the key -- SHA-256 is used as digest algorithm and
the PKCS#1 rsaEncryption method is used for signature calculation).
signerCertificate
- the signer certificate.digestAlgorithm
- the algorithm to be used for message-digest calculationsignatureAlgorithm
- the algorithm to be used for signature calculationprivateKey
- the signer private key to be used for signingpublic SignerInfo(ASN1Object obj) throws CodingException
SignerInfo
from an ASN1Object.
The ASN1Object supplied to this constructor represents an
already exisiting SignerInfo
object that may
have been created by calling toASN1Object
.
obj
- the CMS SignerInfo as ASN1Object
CodingException
- if the object can not be parsedpublic SignerInfo(java.io.InputStream is) throws java.io.IOException
SignerInfo
from an InputStream.
is
- the stream from which to read the encoded SignerInfo
java.io.IOException
- if the SignerInfo can not be parsedMethod Detail |
---|
public void setSecurityProvider(SecurityProvider securityProvider)
This method allows to explicitly set a SecurityProvider for this SignerInfo. If no explicit SecurityProvider is set, the default system wide installed SecurityProvider will be used for the required cryptographic operations.
This class may use the following method(s) of the SecurityProvider
, which may be overriden by an application, if required:
calculateSignatureFromSignedAttributes()
to calculate the signature value from the encoding of the signed attributes
calculateSignatureFromHash()
to calculate the signature value from the message hash
verifySignatureFromSignedAttributes()
to verify the signature value calculated from the encoding of the signed attributes
verifySignatureFromHash()
to verify the signature value calculated from the message hash
getHash()
as may be required for cert hash calculation when querying for included SigningCertificate
or SigningCertificateV2
attributes
securityProvider
- the SecurityProvider to be setpublic SecurityProvider getSecurityProvider()
This class uses the following method(s) of the SecurityProvider
, which may be overriden by an application, if required:
calculateSignatureFromSignedAttributes()
to calculate the signature value from the encoding of the signed attributes
calculateSignatureFromHash()
to calculate the signature value from the message hash
verifySignatureFromSignedAttributes()
to verify the signature value calculated from the encoding of the signed attributes
verifySignatureFromHash()
to verify the signature value calculated from the message hash
getHash()
as may be required for cert hash calculation when querying for included SigningCertificate
or SigningCertificateV2
attributes
set
for this object,
the default system wide installed SecurityProvider will be used for the required cryptographic
operations. However, this method will return null
if it does not have its own
SecurityProvider.
null
if
this object does not have its own SecurityProviderpublic void decode(ASN1Object obj) throws CodingException
SignerInfo
object for parsing
the internal structure.
This method internally is called when creating a CMS SignerInfo
object from an already existing SignerInfo
object,
supplied as ASN1Object.
decode
in interface ASN1Type
obj
- the CMS SignerInfo as ASN1Object
CodingException
- if the object can not be parsedpublic ASN1Object toASN1Object() throws CodingException
SignerInfo
as ASN1Object.
toASN1Object
in interface ASN1Type
CodingException
- if the ASN1Object could not be createdpublic void setSignedAttributes(Attribute[] attributes)
The signedAttributes
field is optional, but must be
present if the content type of the EncypsulatedContentInfo
value
being signed is not the Data
type.
If the signedAttributes
field is present, it must include
the PKCS#9 content-type attribute and the PKCS#9 message-digest attribute.
If the message-digest attribute is not included in the supplied signed attributes
it is automatically calculated and set. If the content-type attribute is not
included it is automatically added and set to id-data when adding
the SignerInfo to a SignedData object.
A further attribute type specified by PKCS#9 may be used for specifying the time at which the signer has performed the signing process, e.g.:
Attribute[] attributes = new Attribute[2]; // PKCS#9ContentType
attribute specifying, e.g. the Data content type: attributes[0] = new Attribute(ObjectID.contentType, new ASN1Object[] {ObjectID.cms_data}); // PKCS#9SigningTime
attribute specifying the signing time (e.g. current time): attributes[1] = new Attribute(ObjectID.signingTime, new ASN1Object[] {new ChoiceOfTime().toASN1Object()}); // add the attributes to the SignerInfo: signerInfo.setSignedAttributes(attributes);
attributes
- a set of attributes to be signed along with the content
to be signed.public void addSignedAttributes(Attribute[] attributes)
The signedAttributes
field is optional, but must be
present if the content type of the EncypsulatedContentInfo
value
being signed is not the Data
type.
If the signedAttributes
field is present, it must include
the PKCS#9 content-type attribute and the PKCS#9 message-digest attribute.
If the message-digest attribute is not included in the supplied signed attributes
it is automatically calculated and set. If the content-type attribute is not
included it is automatically added and set to the eContentType of
the SignedData EncapsulatedContentInfo when adding
the SignerInfo to the SignedData object.
attributes
- the attributes to be added to the signed attributespublic void addSignedAttribute(Attribute attribute)
The signedAttributes
field is optional, but must be
present if the content type of the EncypsulatedContentInfo
value
being signed is not the Data
type.
If the signedAttributes
field is present, it must include
the PKCS#9 content-type attribute and the PKCS#9 message-digest attribute.
If the message-digest attribute is not added it is automatically calculated
and set. If the content-type attribute is not added it is automatically added
and set to the eContentType of the SignedData EncapsulatedContentInfo when
adding
the SignerInfo to the SignedData object.
attribute
- the attribute to be added to the signed attributespublic void removeSignedAttribute(ObjectID attributeType)
attributeType
- the OID identifying the attribute to be removedpublic SigningCertificate getSigningCertificateAttribute() throws CMSException
null
if
not included
CMSException
- if an error occurs while parsing for the
SigningCertificate attributepublic SigningCertificateV2 getSigningCertificateV2Attribute() throws CMSException
null
if
not included
CMSException
- if an error occurs while parsing for the
SigningCertificateV2 attributepublic boolean verifySignature(java.security.PublicKey publicKey) throws CMSSignatureException
When using this method, the content hash required for verification is supplied
by the digest provider (
or SignedDataStream
) object to which this SignerInfo
belongs to.
SignedData
Note that
cannot be used as
digest provider when having to verify RFC 8419 EdDSA signatures (curve25519, curve448)
with missing signed attributes because in this case the whole content must be available
when actually verifying the signature value. For that reason an application shall use the
non-stream SignedDataStream
implementation for verifying
EdDSA signatures without signed attributes. However, when signed attributes are
included, both SignedData
or SignedDataStream
maybe used.
SignedData
publicKey
- the public key of the signer
true
if the signature verifies, false
if not
InvalidContentHashException
- if the signature verification process fails because the
content hash does not match to value of the included MessageDigest
attribute
InvalidContentTypeException
- if the ContentType attribute is not included in the signed
attributes or the ContentType attribute does not match the
encapsulated content type
CMSSignatureException
- signature verification process fails for some other reason than an
invalid content hash or invalid content type (e.g. wrong signature value)public boolean verifySignature(byte[] contentHash, java.security.PublicKey publicKey) throws CMSSignatureException
When using this method for verifying the signature, you have to supply the hash calculated over the content. Any signed attribute hashing will be done automatically by this method if required.
contentHash
- the digest calculated over the contentpublicKey
- the public key of the signer
true
if the signature verifies, false
if not
CMSSignatureException
- if the signature verification process fails for some reason
InvalidContentHashException
- if the signature verification process fails because the
content hash does not match to value of the included MessageDigest
attribute
InvalidContentTypeException
- if the ContentType attribute is not included in the signed
attributes or the ContentType attribute does not match the
encapsulated content typepublic byte[] getDigest() throws CMSException
getSignedDigest
(however, has to be the same value: the
digest value calculated over the content has to be the same as the value
of the MessageDigest attribute).
CMSException
- if the digest calculation fails for some reason (e.g. the
digest algorihtm used by this SignerInfo is not supported)public byte[] getSignedDigest() throws CMSException
CMSException
- if no MessageDigest attribute is included in the
set of signed attributespublic void setUnsignedAttributes(Attribute[] attributes)
attributes
- a set of attributes that are not signed by the signerpublic void addUnsignedAttributes(Attribute[] attributes)
attributes
- the attributes to be added to the unsigned attributespublic void addUnSignedAttribute(Attribute attribute)
addUnsignedAttribute(iaik.asn1.structures.Attribute)
attribute
- the attribute to be added to the unsigned attributespublic void addUnsignedAttribute(Attribute attribute)
attribute
- the attribute to be added to the unsigned attributespublic void removeUnSignedAttribute(ObjectID attributeType)
removeUnsignedAttribute(iaik.asn1.ObjectID)
attributeType
- the OID identifying the attribute to be removedpublic void removeUnsignedAttribute(ObjectID attributeType)
attributeType
- the OID identifying the attribute to be removedpublic int getVersion()
public CMSVersion getCMSVersion()
CMSVersion
objectpublic CertificateIdentifier getSignerIdentifier()
The information is returned as CertificateIdentifier
object specifying the signer certificate either
by issuer distinguished name and
issuer-specific serial number
or by SubjectKeyIdentifier
.
public SignerIdentifier getSignerId()
The information is returned as SignerIdentifier
object representing a choice of
IssuerAndSerialNumber
or by SubjectKeyIdentifier
:
SignerIdentifier ::= CHOICE { issuerAndSerialNumber IssuerAndSerialNumber, subjectKeyIdentifier [0] SubjectKeyIdentifier }To get the inherent
IssuerAndSerialNumber
or by SubjectKeyIdentifier
CertificateIdentifier call method getCertificateIdentifier()
:
SignerIdentifier signerId = signerInfo.getSignerId(); CertificateIdentifier certId = signerId.getCertificateIdentifier();Or immediately call method
getSignerIdentifier()
:
CertificateIdentifier certId = signerInfo.getSignerIdentifier();
public boolean isSignerCertificate(X509Certificate cert) throws CMSException
This method first checks if the signerIdentifier of this SignerInfo
identifies the supplied certificate via IssuerAndSerialNumber or
SubjectKeyIdentifier. If this check is successful, this method then looks
if the SigningCertificate
and/or the SigningCertificateV2
are
present and identify the given certificate as cert of the signer. If both
SigningCertificate attributes are present this method accepts the
given certificate as signer certificate only if it is identified by
both SigningCertificate attributes.
cert
- the certificate to be checked of being the one of the signer
true
if the supplied certificate is the signer
certificate, false
if not
CMSException
- if the check cannot be completed because an error occurs
when parsing the SigningCertificate or SigningCertificateV2 attribute
or a hash algorithm (required for calculating the cert hash) is not
supported by the installed cryptographic providerspublic AlgorithmID getDigestAlgorithm()
public Attribute[] getSignedAttributes()
signedAttributes
field is optional, but must
be present if the content type of the EncypsulatedContentInfo
value being signed is not the Data
type.
setSignedAttributes(iaik.asn1.structures.Attribute[])
public SignedAttributes getSignedAttrs()
signedAttributes
field is optional, but must
be present if the content type of the EncypsulatedContentInfo
value being signed is not the Data
type.
SignedAttributes
objectsetSignedAttributes(iaik.asn1.structures.Attribute[])
public Attribute getSignedAttribute(ObjectID oid)
oid
- the attribute type to look for
null
if there is no attribute for the given OID.public Attribute[] getSignedAttributes(ObjectID oid)
oid
- the attribute type to look for
null
if there is no attribute for the given OID.public AttributeValue getSignedAttributeValue(ObjectID oid) throws CMSException
This method provides the possibility to immediately access the value of a signed
attribute with the given type. This method may be used for getting the value
of the first included signed attribute of requested type or -- more appropriate --
the only one value of a single valued signed attribute of requested type. In this way,
this method can be seen as an alternative to method getSignedAttribute
for providing immediate access to the attribute value, e.g.:
SigningCertificate signingCertificate = (SigningCertificate)signerInfo.getSignedAttributeValue(Signingcertificate.oid); if (signingCertificate != null) { ... }
oid
- the object identifier representing the type of the attribute for which to get the value
null
if no attribute of given type is included
if
- the ASN.1 representation of the attribute value cannot be parsed
CMSException
public AlgorithmID getSignatureAlgorithm()
public byte[] getSignatureValue()
public SignatureValue getSigValue()
SignatureValue
object.
Provides an alternative way to get the signature value from a SignerInfo
object got from a SignedDataInOutStream
object during parsing:
SignedDataInOutStream signedData = ...; SignerInfo signerInfo = signedData.getSignerInfos()[0]; SignatureValue signatureValue = signerInfo.getSigValue(); byte[] signature = signatureValue.getValue();Usually it is more convenient to get the signature value immediately by calling method
getSignatureValue
:
... byte[] signature = signatureValue.getSignatureValue();The only purpose of class
SignatureValue
is to get the parsed
encoded representation of the signature value OCTET STRING:
... SignatureValue signatureValue = signerInfo.getSigValue(); byte[] encodedSignatureValue = signatureValue.getEncoded();
SignatureValue
objectpublic void setEncryptedDigest(byte[] signatureValue)
setSignatureValue
to set the signature value (this method does exactly the same
as method setEncryptedDigest
)
signatureValue
- the signature value, calculated from outsidepublic void setSignatureValue(byte[] signatureValue)
This method may be used for calculating the signature value outside and explicitly setting it.
signatureValue
- the signature value, calculated from outsidepublic Attribute[] getUnsignedAttributes()
setUnsignedAttributes(iaik.asn1.structures.Attribute[])
public Attribute getUnsignedAttribute(ObjectID oid)
oid
- the attribute type to look for
null
if there is no attribute for the given OID.public Attribute[] getUnsignedAttributes(ObjectID oid)
oid
- the attribute type to look for
null
if there is no attribute for the given OID.public AttributeValue getUnsignedAttributeValue(ObjectID oid) throws CMSException
This method provides the possibility to immediately access the value of an unsigned
attribute with the given type. This method may be used for getting the value
of the first included unsigned attribute of requested type or -- more appropriate --
the only one value of a single valued unsigned attribute of requested type. In this way,
this method can be seen as an alternative to method getUnsignedAttribute
for providing immediate access to the attribute value, e.g.:
SignatureTimeStampToken signatureTimeStampToken = (SignatureTimeStampToken)signer_info.getUnsignedAttributeValue(SignatureTimeStampToken.oid); if (signatureTimeStampToken != null) { ... }
oid
- the object identifier representing the type of the attribute for which to get the value
null
if no attribute of given type is included
if
- the ASN.1 representation of the attribute value cannot be parsed
CMSException
public java.lang.String toString()
SignerInfo
object.
toString
in class java.lang.Object
public java.lang.String toString(boolean detailed)
SignerInfo
object.
detailed
- - whether or not to give detailed information
|
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 |