Class CMSSignedGenerator

java.lang.Object
org.bouncycastle.cms.CMSSignedGenerator
Direct Known Subclasses:
CMSSignedDataGenerator

public class CMSSignedGenerator
extends Object
  • Field Details

    • DATA

      public static final String DATA
      Default type for the signed data.
    • DIGEST_SHA1

      public static final String DIGEST_SHA1
    • DIGEST_SHA256

      public static final String DIGEST_SHA256
    • DIGEST_SHA384

      public static final String DIGEST_SHA384
    • DIGEST_SHA512

      public static final String DIGEST_SHA512
    • DIGEST_MD5

      public static final String DIGEST_MD5
    • ENCRYPTION_RSA

      public static final String ENCRYPTION_RSA
    • ENCRYPTION_DSA

      public static final String ENCRYPTION_DSA
    • ENCRYPTION_ECDSA

      public static final String ENCRYPTION_ECDSA
    • ENCRYPTION_RSA_PSS

      public static final String ENCRYPTION_RSA_PSS
    • certs

      protected List certs
    • crls

      protected List crls
    • _signers

      protected List _signers
    • signerGens

      protected List signerGens
    • digests

      protected Map digests
    • rand

      protected final SecureRandom rand
  • Constructor Details

    • CMSSignedGenerator

      protected CMSSignedGenerator()
      base constructor
    • CMSSignedGenerator

      protected CMSSignedGenerator​(SecureRandom rand)
      constructor allowing specific source of randomness
      Parameters:
      rand - instance of SecureRandom to use
  • Method Details

    • getEncOID

      protected String getEncOID​(PrivateKey key, String digestOID)
    • getBaseParameters

      protected Map getBaseParameters​(ASN1ObjectIdentifier contentType, AlgorithmIdentifier digAlgId, byte[] hash)
    • getAttributeSet

      protected ASN1Set getAttributeSet​(AttributeTable attr)
    • addCertificatesAndCRLs

      public void addCertificatesAndCRLs​(CertStore certStore) throws CertStoreException, CMSException
      Deprecated.
      use addCertificates and addCRLs
      add the certificates and CRLs contained in the given CertStore to the pool that will be included in the encoded signature block.

      Note: this assumes the CertStore will support null in the get methods.

      Parameters:
      certStore - CertStore containing the public key certificates and CRLs
      Throws:
      CertStoreException - if an issue occurs processing the CertStore
      CMSException - if an issue occurse transforming data from the CertStore into the message
    • addCertificate

      public void addCertificate​(X509CertificateHolder certificate) throws CMSException
      Add a certificate to the certificate set to be included with the generated SignedData message.
      Parameters:
      certificate - the certificate to be included.
      Throws:
      CMSException - if the certificate cannot be encoded for adding.
    • addCertificates

      public void addCertificates​(Store certStore) throws CMSException
      Add the certificates in certStore to the certificate set to be included with the generated SignedData message.
      Parameters:
      certStore - the store containing the certificates to be included.
      Throws:
      CMSException - if the certificates cannot be encoded for adding.
    • addCRL

      public void addCRL​(X509CRLHolder crl)
      Add a CRL to the CRL set to be included with the generated SignedData message.
      Parameters:
      crl - the CRL to be included.
    • addCRLs

      public void addCRLs​(Store crlStore) throws CMSException
      Add the CRLs in crlStore to the CRL set to be included with the generated SignedData message.
      Parameters:
      crlStore - the store containing the CRLs to be included.
      Throws:
      CMSException - if the CRLs cannot be encoded for adding.
    • addAttributeCertificate

      public void addAttributeCertificate​(X509AttributeCertificateHolder attrCert) throws CMSException
      Add the attribute certificates in attrStore to the certificate set to be included with the generated SignedData message.
      Parameters:
      attrCert - the store containing the certificates to be included.
      Throws:
      CMSException - if the attribute certificate cannot be encoded for adding.
    • addAttributeCertificates

      public void addAttributeCertificates​(Store attrStore) throws CMSException
      Add the attribute certificates in attrStore to the certificate set to be included with the generated SignedData message.
      Parameters:
      attrStore - the store containing the certificates to be included.
      Throws:
      CMSException - if the attribute certificate cannot be encoded for adding.
    • addAttributeCertificates

      public void addAttributeCertificates​(X509Store store) throws CMSException
      Deprecated.
      use basic Store method
      Add the attribute certificates contained in the passed in store to the generator.
      Parameters:
      store - a store of Version 2 attribute certificates
      Throws:
      CMSException - if an error occurse processing the store.
    • addSigners

      public void addSigners​(SignerInformationStore signerStore)
      Add a store of precalculated signers to the generator.
      Parameters:
      signerStore - store of signers
    • addSignerInfoGenerator

      public void addSignerInfoGenerator​(SignerInfoGenerator infoGen)
    • getGeneratedDigests

      public Map getGeneratedDigests()
      Return a map of oids and byte arrays representing the digests calculated on the content during the last generate.
      Returns:
      a map of oids (as String objects) and byte[] representing digests.