Top Description Fields Constructors Methods
org.bouncycastle.cms

public Class CMSSignedDataGenerator

extends CMSSignedGenerator
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .OutputStream, java.util.ArrayList, .Iterator, .LinkedHashSet, .List, .Set, org.bouncycastle.asn1.ASN1EncodableVector, .ASN1ObjectIdentifier, .ASN1OctetString, .ASN1Set, .BEROctetString, .DEROctetString, .DERSet, org.bouncycastle.asn1.cms.CMSObjectIdentifiers, .ContentInfo, .SignedData, .SignerInfo, org.bouncycastle.asn1.x509.AlgorithmIdentifier, org.bouncycastle.operator.DigestAlgorithmIdentifierFinder

general class for generating a pkcs7-signature message.

A simple example of usage, generating a detached signature.

     List             certList = new ArrayList();
     CMSTypedData     msg = new CMSProcessableByteArray("Hello world!".getBytes());

     certList.add(signCert);

     Store           certs = new JcaCertStore(certList);

     CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
     ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(signKP.getPrivate());

     gen.addSignerInfoGenerator(
               new JcaSignerInfoGeneratorBuilder(
                    new JcaDigestCalculatorProviderBuilder().setProvider("BC").build())
                    .build(sha1Signer, signCert));

     gen.addCertificates(certs);

     CMSSignedData sigData = gen.generate(msg, false);

Field Summary

Modifier and TypeField and Description
private boolean
private List<E>
Inherited from org.bouncycastle.cms.CMSSignedGenerator:
_signerscertscrlsDATADIGEST_GOST3411DIGEST_MD5DIGEST_RIPEMD128DIGEST_RIPEMD160DIGEST_RIPEMD256DIGEST_SHA1DIGEST_SHA224DIGEST_SHA256DIGEST_SHA384DIGEST_SHA512digestAlgIdFinderdigestsENCRYPTION_DSAENCRYPTION_ECDSAENCRYPTION_ECGOST3410ENCRYPTION_ECGOST3410_2012_256ENCRYPTION_ECGOST3410_2012_512ENCRYPTION_GOST3410ENCRYPTION_RSAENCRYPTION_RSA_PSSsignerGens

Constructor Summary

AccessConstructor and Description
public
CMSSignedDataGenerator()

base constructor

public
CMSSignedDataGenerator(DigestAlgorithmIdentifierFinder digestAlgIdFinder)

base constructor with a custom DigestAlgorithmIdentifierFinder

Method Summary

Modifier and TypeMethod and Description
public CMSSignedData
generate(CMSTypedData
the content to be signed.
content
)

Generate a CMS Signed Data object carrying a detached CMS signature.

public CMSSignedData
generate(CMSTypedData
the content to be signed.
content
,
boolean
true if the content should be encapsulated in the signature, false otherwise.
encapsulate
)

Generate a CMS Signed Data object which can be carrying a detached CMS signature, or have encapsulated data, depending on the value of the encapsulated parameter.

public SignerInformationStore

Returns:

a store containing the signers.
generateCounterSigners
(SignerInformation
the signer to be countersigned
signer
)

generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object.

public void
setDefiniteLengthEncoding(boolean
true use definite length, false use indefinite (default false).
isDefiniteLength
)

Specify use of definite length rather than indefinite length encoding.

Inherited from org.bouncycastle.cms.CMSSignedGenerator:
addAttributeCertificateaddAttributeCertificatesaddCertificateaddCertificatesaddCRLaddCRLsaddOtherRevocationInfoaddOtherRevocationInfoaddSignerInfoGeneratoraddSignersgetBaseParametersgetGeneratedDigests

Field Detail

isDefiniteLengthback to summary
private boolean isDefiniteLength
signerInfsback to summary
private List<E> signerInfs

Constructor Detail

CMSSignedDataGeneratorback to summary
public CMSSignedDataGenerator()

base constructor

CMSSignedDataGeneratorback to summary
public CMSSignedDataGenerator(DigestAlgorithmIdentifierFinder digestAlgIdFinder)

base constructor with a custom DigestAlgorithmIdentifierFinder

Method Detail

generateback to summary
public CMSSignedData generate(CMSTypedData content) throws CMSException

Generate a CMS Signed Data object carrying a detached CMS signature.

Parameters
content:CMSTypedData

the content to be signed.

generateback to summary
public CMSSignedData generate(CMSTypedData content, boolean encapsulate) throws CMSException

Generate a CMS Signed Data object which can be carrying a detached CMS signature, or have encapsulated data, depending on the value of the encapsulated parameter.

Parameters
content:CMSTypedData

the content to be signed.

encapsulate:boolean

true if the content should be encapsulated in the signature, false otherwise.

generateCounterSignersback to summary
public SignerInformationStore generateCounterSigners(SignerInformation signer) throws CMSException

generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object.

Parameters
signer:SignerInformation

the signer to be countersigned

Returns:SignerInformationStore

a store containing the signers.

setDefiniteLengthEncodingback to summary
public void setDefiniteLengthEncoding(boolean isDefiniteLength)

Specify use of definite length rather than indefinite length encoding.

Parameters
isDefiniteLength:boolean

true use definite length, false use indefinite (default false).