CMSSignedDataGenerator (Bouncy Castle Library 1.52 API Specification)
Date: 2015-03-01

org.bouncycastle.cms

## Class CMSSignedDataGenerator

- java.lang.Object
- - org.bouncycastle.cms.CMSSignedGenerator
  - - org.bouncycastle.cms.CMSSignedDataGenerator

-     public class CMSSignedDataGenerator
      extends CMSSignedGenerator

  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

    - ### Fields inherited from class org.bouncycastle.cms.CMSSignedGenerator

      `_signers, certs, crls, DATA, DIGEST_GOST3411, DIGEST_MD5, DIGEST_RIPEMD128, DIGEST_RIPEMD160, DIGEST_RIPEMD256, DIGEST_SHA1, DIGEST_SHA224, DIGEST_SHA256, DIGEST_SHA384, DIGEST_SHA512, digests, ENCRYPTION_DSA, ENCRYPTION_ECDSA, ENCRYPTION_ECGOST3410, ENCRYPTION_GOST3410, ENCRYPTION_RSA, ENCRYPTION_RSA_PSS, signerGens`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CMSSignedDataGenerator()` base constructor

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `CMSSignedData` | `generate(CMSTypedData content)` Generate a CMS Signed Data object carrying a detached CMS signature.
    `CMSSignedData` | `generate(CMSTypedData content, boolean 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.
    `SignerInformationStore` | `generateCounterSigners(SignerInformation signer)` generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object.

    - ### Methods inherited from class org.bouncycastle.cms.CMSSignedGenerator

      `addAttributeCertificate, addAttributeCertificates, addCertificate, addCertificates, addCRL, addCRLs, addOtherRevocationInfo, addOtherRevocationInfo, addSignerInfoGenerator, addSigners, getBaseParameters, getGeneratedDigests`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### CMSSignedDataGenerator

          public CMSSignedDataGenerator()

      base constructor

  - ### Method Detail

    - #### generate

          public CMSSignedData generate(CMSTypedData content)
                                 throws CMSException

      Generate a CMS Signed Data object carrying a detached CMS signature.
      Parameters:
        `content` - the content to be signed.
      Throws:
        `CMSException`

    - #### generate

          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` - the content to be signed.
        `encapsulate` - true if the content should be encapsulated in the signature, false otherwise.
      Throws:
        `CMSException`

    - #### generateCounterSigners

          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` - the signer to be countersigned
      Returns:
        a store containing the signers.
      Throws:
        `CMSException`