org.bouncycastle.cms

Class CMSSignedDataStreamGenerator

public class CMSSignedDataStreamGenerator extends CMSSignedGenerator

General class for generating a pkcs7-signature message stream.

A simple example of usage.

      CertStore                    certs...
      CMSSignedDataStreamGenerator gen = new CMSSignedDataStreamGenerator();
  
      gen.addSigner(privateKey, cert, CMSSignedDataStreamGenerator.DIGEST_SHA1, "BC");
  
      gen.addCertificatesAndCRLs(certs);
  
      OutputStream sigOut = gen.open(bOut);
  
      sigOut.write("Hello World!".getBytes());
      
      sigOut.close();
 
Constructor Summary
CMSSignedDataStreamGenerator()
base constructor
Method Summary
voidaddSigner(PrivateKey key, X509Certificate cert, String digestOID, String sigProvider)
add a signer - no attributes other than the default ones will be provided here.
voidaddSigner(PrivateKey key, X509Certificate cert, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, String sigProvider)
add a signer with extra signed/unsigned attributes.
voidaddSigner(PrivateKey key, X509Certificate cert, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, String sigProvider)
OutputStreamopen(OutputStream out)
generate a signed object that for a CMS Signed Data object using the given provider.
OutputStreamopen(OutputStream out, boolean encapsulate)
generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data".
OutputStreamopen(OutputStream out, String signedContentType, boolean encapsulate)
generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature.
voidsetBufferSize(int bufferSize)
Set the underlying string size for encapsulated data

Constructor Detail

CMSSignedDataStreamGenerator

public CMSSignedDataStreamGenerator()
base constructor

Method Detail

addSigner

public void addSigner(PrivateKey key, X509Certificate cert, String digestOID, String sigProvider)
add a signer - no attributes other than the default ones will be provided here.

Throws: NoSuchProviderException NoSuchAlgorithmException InvalidKeyException

addSigner

public void addSigner(PrivateKey key, X509Certificate cert, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, String sigProvider)
add a signer with extra signed/unsigned attributes.

Throws: NoSuchProviderException NoSuchAlgorithmException InvalidKeyException

addSigner

public void addSigner(PrivateKey key, X509Certificate cert, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, String sigProvider)

open

public OutputStream open(OutputStream out)
generate a signed object that for a CMS Signed Data object using the given provider.

open

public OutputStream open(OutputStream out, boolean encapsulate)
generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature with the default content type "data".

open

public OutputStream open(OutputStream out, String signedContentType, boolean encapsulate)
generate a signed object that for a CMS Signed Data object using the given provider - if encapsulate is true a copy of the message will be included in the signature. The content type is set according to the OID represented by the string signedContentType.

setBufferSize

public void setBufferSize(int bufferSize)
Set the underlying string size for encapsulated data

Parameters: bufferSize length of octet strings to buffer the data.