public class CMSSignedData extends Object implements Encodable
Store certStore = s.getCertificates(); SignerInformationStore signers = s.getSignerInfos(); Collection c = signers.getSigners(); Iterator it = c.iterator(); while (it.hasNext()) { SignerInformation signer = (SignerInformation)it.next(); Collection certCollection = certStore.getMatches(signer.getSID()); Iterator certIt = certCollection.iterator(); X509CertificateHolder cert = (X509CertificateHolder)certIt.next(); if (signer.verify(new JcaSimpleSignerInfoVerifierBuilder().setProvider("BC").build(cert))) { verified++; } }
Constructor and Description |
---|
CMSSignedData(byte[] sigBlock) |
CMSSignedData(CMSProcessable signedContent,
byte[] sigBlock) |
CMSSignedData(CMSProcessable signedContent,
ContentInfo sigData) |
CMSSignedData(CMSProcessable signedContent,
InputStream sigData)
base constructor - content with detached signature.
|
CMSSignedData(ContentInfo sigData) |
CMSSignedData(InputStream sigData)
base constructor - with encapsulated content
|
CMSSignedData(Map hashes,
byte[] sigBlock)
Content with detached signature, digests precomputed
|
CMSSignedData(Map hashes,
ContentInfo sigData) |
Modifier and Type | Method and Description |
---|---|
Store |
getAttributeCertificates()
Return any X.509 attribute certificate objects in this SignedData structure as a Store of X509AttributeCertificateHolder objects.
|
Store |
getCertificates()
Return any X.509 certificate objects in this SignedData structure as a Store of X509CertificateHolder objects.
|
Store |
getCRLs()
Return any X.509 CRL objects in this SignedData structure as a Store of X509CRLHolder objects.
|
Set<AlgorithmIdentifier> |
getDigestAlgorithmIDs()
Return the digest algorithm identifiers for the SignedData object
|
byte[] |
getEncoded()
return the ASN.1 encoded representation of this object.
|
Store |
getOtherRevocationInfo(ASN1ObjectIdentifier otherRevocationInfoFormat)
Return any OtherRevocationInfo OtherRevInfo objects of the type indicated by otherRevocationInfoFormat in
this SignedData structure.
|
CMSTypedData |
getSignedContent() |
String |
getSignedContentTypeOID()
Return the a string representation of the OID associated with the
encapsulated content info structure carried in the signed data.
|
SignerInformationStore |
getSignerInfos()
return the collection of signers that are associated with the
signatures for the message.
|
int |
getVersion()
Return the version number for this object
|
boolean |
isCertificateManagementMessage()
Return if this is object represents a certificate management message.
|
boolean |
isDetachedSignature()
Return if this is object represents a detached signature.
|
static CMSSignedData |
replaceCertificatesAndCRLs(CMSSignedData signedData,
Store certificates,
Store attrCerts,
Store revocations)
Replace the certificate and CRL information associated with this
CMSSignedData object with the new one passed in.
|
static CMSSignedData |
replaceSigners(CMSSignedData signedData,
SignerInformationStore signerInformationStore)
Replace the SignerInformation store associated with this
CMSSignedData object with the new one passed in.
|
ContentInfo |
toASN1Structure()
return the ContentInfo
|
boolean |
verifySignatures(SignerInformationVerifierProvider verifierProvider)
Verify all the SignerInformation objects and their associated counter signatures attached
to this CMS SignedData object.
|
boolean |
verifySignatures(SignerInformationVerifierProvider verifierProvider,
boolean ignoreCounterSignatures)
Verify all the SignerInformation objects and optionally their associated counter signatures attached
to this CMS SignedData object.
|
public CMSSignedData(byte[] sigBlock) throws CMSException
CMSException
public CMSSignedData(CMSProcessable signedContent, byte[] sigBlock) throws CMSException
CMSException
public CMSSignedData(Map hashes, byte[] sigBlock) throws CMSException
hashes
- a map of precomputed digests for content indexed by name of hash.sigBlock
- the signature object.CMSException
public CMSSignedData(CMSProcessable signedContent, InputStream sigData) throws CMSException
signedContent
- the content that was signed.sigData
- the signature object.CMSException
public CMSSignedData(InputStream sigData) throws CMSException
CMSException
public CMSSignedData(CMSProcessable signedContent, ContentInfo sigData) throws CMSException
CMSException
public CMSSignedData(Map hashes, ContentInfo sigData) throws CMSException
CMSException
public CMSSignedData(ContentInfo sigData) throws CMSException
CMSException
public int getVersion()
public SignerInformationStore getSignerInfos()
public boolean isDetachedSignature()
public boolean isCertificateManagementMessage()
public Store getCertificates()
public Store getCRLs()
public Store getAttributeCertificates()
public Store getOtherRevocationInfo(ASN1ObjectIdentifier otherRevocationInfoFormat)
otherRevocationInfoFormat
- OID of the format type been looked for.public Set<AlgorithmIdentifier> getDigestAlgorithmIDs()
public String getSignedContentTypeOID()
public CMSTypedData getSignedContent()
public ContentInfo toASN1Structure()
public byte[] getEncoded() throws IOException
getEncoded
in interface Encodable
IOException
public boolean verifySignatures(SignerInformationVerifierProvider verifierProvider) throws CMSException
verifierProvider
- a provider of SignerInformationVerifier objects.CMSException
- if an exception occurs during the verification process.public boolean verifySignatures(SignerInformationVerifierProvider verifierProvider, boolean ignoreCounterSignatures) throws CMSException
verifierProvider
- a provider of SignerInformationVerifier objects.ignoreCounterSignatures
- if true don't check counter signatures. If false check counter signatures as well.CMSException
- if an exception occurs during the verification process.public static CMSSignedData replaceSigners(CMSSignedData signedData, SignerInformationStore signerInformationStore)
signedData
- the signed data object to be used as a base.signerInformationStore
- the new signer information store to use.public static CMSSignedData replaceCertificatesAndCRLs(CMSSignedData signedData, Store certificates, Store attrCerts, Store revocations) throws CMSException
signedData
- the signed data object to be used as a base.certificates
- the new certificates to be used.attrCerts
- the new attribute certificates to be used.revocations
- the new CRLs to be used - a collection of X509CRLHolder objects, OtherRevocationInfoFormat, or both.CMSException
- if there is an error processing the CertStoreCopyright © 2018 BouncyCastle.org. All rights reserved.