public class

CMSSignedDataStreamGenerator

extends CMSSignedGenerator
java.lang.Object
   ↳ org.bouncycastle.cms.CMSSignedGenerator
     ↳ org.bouncycastle.cms.CMSSignedDataStreamGenerator

Class Overview

General class for generating a pkcs7-signature message stream.

A simple example of usage.

      X509Certificate signCert = ...
      certList.add(signCert);

      Store           certs = new JcaCertStore(certList);
      ContentSigner sha1Signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(signKP.getPrivate());

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

      gen.addCertificates(certs);
  
      OutputStream sigOut = gen.open(bOut);
  
      sigOut.write("Hello World!".getBytes());
      
      sigOut.close();
 

Summary

[Expand]
Inherited Fields
From class org.bouncycastle.cms.CMSSignedGenerator
Public Constructors
CMSSignedDataStreamGenerator()
base constructor
CMSSignedDataStreamGenerator(SecureRandom rand)
constructor allowing specific source of randomness
Public Methods
void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, String sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, String sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider)
This method is deprecated. use addSignerInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID, Provider sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, Provider sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, Provider sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider)
This method is deprecated. use addSignerInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String digestOID, Provider sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String digestOID, String sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider, Provider digProvider)
This method is deprecated. use addSignerInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, String sigProvider)
This method is deprecated. use addSignerInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, Provider sigProvider)
This method is deprecated. use addSignerInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider, Provider digProvider)
This method is deprecated. use addSignerInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, String sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, Provider sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID, String sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, String sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, String sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, String sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, Provider sigProvider)
This method is deprecated. use addSignerInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, String sigProvider)
This method is deprecated. use addSignerInfoGenerator
void addSigner(PrivateKey key, X509Certificate cert, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider)
This method is deprecated. use addSignedInfoGenerator
void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, String sigProvider)
This method is deprecated. use addSignerInfoGenerator
OutputStream open(ASN1ObjectIdentifier eContentType, 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.
OutputStream open(OutputStream out)
generate a signed object that for a CMS Signed Data object using the given provider.
OutputStream open(OutputStream out, String eContentType, boolean encapsulate, OutputStream dataOutputStream)
This method is deprecated. use open(ASN1ObjectIdenfier, OutputStream, boolean, OutputStream)
OutputStream open(ASN1ObjectIdentifier eContentType, OutputStream out, boolean encapsulate, OutputStream dataOutputStream)
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.
OutputStream open(OutputStream out, boolean encapsulate, OutputStream dataOutputStream)
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".
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".
OutputStream open(OutputStream out, String eContentType, boolean encapsulate)
This method is deprecated. use open(ASN1ObjectIdentifier, OutputStream, boolean)
void setBufferSize(int bufferSize)
Set the underlying string size for encapsulated data
[Expand]
Inherited Methods
From class org.bouncycastle.cms.CMSSignedGenerator
From class java.lang.Object

Public Constructors

public CMSSignedDataStreamGenerator ()

base constructor

public CMSSignedDataStreamGenerator (SecureRandom rand)

constructor allowing specific source of randomness

Parameters
rand instance of SecureRandom to use

Public Methods

public void addSigner (PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, String sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer, specifying the digest encryption algorithm - no attributes other than the default ones will be provided here.

Throws
NoSuchProviderException
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

public void addSigner (PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, String sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer - no attributes other than the default ones will be provided here.

Throws
NoSuchProviderException
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

public void addSigner (PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider)

This method is deprecated.
use addSignerInfoGenerator

public void addSigner (PrivateKey key, byte[] subjectKeyID, String digestOID, Provider sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer - no attributes other than the default ones will be provided here.

Throws
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

public void addSigner (PrivateKey key, X509Certificate cert, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, Provider sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer with extra signed/unsigned attributes.

Throws
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException

public void addSigner (PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, Provider sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer, specifying digest encryptionOID - no attributes other than the default ones will be provided here.

Throws
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

public void addSigner (PrivateKey key, byte[] subjectKeyID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider)

This method is deprecated.
use addSignerInfoGenerator

public void addSigner (PrivateKey key, X509Certificate cert, String digestOID, Provider sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer - no attributes other than the default ones will be provided here.

Throws
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

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

This method is deprecated.
use addSignedInfoGenerator

add a signer - no attributes other than the default ones will be provided here.

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

This method is deprecated.
use addSignerInfoGenerator

public void addSigner (PrivateKey key, byte[] subjectKeyID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, String sigProvider)

This method is deprecated.
use addSignerInfoGenerator

add a signer with extra signed/unsigned attributes.

Throws
NoSuchProviderException
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

public void addSigner (PrivateKey key, byte[] subjectKeyID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, Provider sigProvider)

This method is deprecated.
use addSignerInfoGenerator

add a signer with extra signed/unsigned attributes.

Throws
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException

public void addSigner (PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, Provider sigProvider, Provider digProvider)

This method is deprecated.
use addSignerInfoGenerator

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

This method is deprecated.
use addSignedInfoGenerator

public void addSigner (PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, Provider sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer with extra signed/unsigned attributes and the digest encryption algorithm.

Throws
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException

public void addSigner (PrivateKey key, byte[] subjectKeyID, String digestOID, String sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer - no attributes other than the default ones will be provided here.

Throws
NoSuchProviderException
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

public void addSigner (PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, String sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer with extra signed/unsigned attributes - specifying digest encryption algorithm.

Throws
NoSuchProviderException
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

public void addSigner (PrivateKey key, X509Certificate cert, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr, String sigProvider)

This method is deprecated.
use addSignedInfoGenerator

add a signer with extra signed/unsigned attributes.

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

This method is deprecated.
use addSignedInfoGenerator

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

This method is deprecated.
use addSignedInfoGenerator

public void addSigner (PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, Provider sigProvider)

This method is deprecated.
use addSignerInfoGenerator

add a signer - no attributes other than the default ones will be provided here, specifying the digest encryption algorithm.

Throws
NoSuchAlgorithmException
InvalidKeyException
InvalidKeyException
NoSuchAlgorithmException
NoSuchProviderException

public void addSigner (PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, String sigProvider)

This method is deprecated.
use addSignerInfoGenerator

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

This method is deprecated.
use addSignedInfoGenerator

public void addSigner (PrivateKey key, byte[] subjectKeyID, String digestOID, CMSAttributeTableGenerator signedAttrGenerator, CMSAttributeTableGenerator unsignedAttrGenerator, String sigProvider)

This method is deprecated.
use addSignerInfoGenerator

public OutputStream open (ASN1ObjectIdentifier eContentType, 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. The content type is set according to the OID represented by the string signedContentType.

Throws
IOException

public OutputStream open (OutputStream out)

generate a signed object that for a CMS Signed Data object using the given provider.

Throws
IOException

public OutputStream open (OutputStream out, String eContentType, boolean encapsulate, OutputStream dataOutputStream)

This method is deprecated.
use open(ASN1ObjectIdenfier, OutputStream, boolean, OutputStream)

Throws
IOException

public OutputStream open (ASN1ObjectIdentifier eContentType, OutputStream out, boolean encapsulate, OutputStream dataOutputStream)

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.

Parameters
eContentType OID for data to be signed.
out stream the CMS object is to be written to.
encapsulate true if data should be encapsulated.
dataOutputStream output stream to copy the data being signed to.
Throws
IOException

public OutputStream open (OutputStream out, boolean encapsulate, OutputStream dataOutputStream)

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". If dataOutputStream is non null the data being signed will be written to the stream as it is processed.

Parameters
out stream the CMS object is to be written to.
encapsulate true if data should be encapsulated.
dataOutputStream output stream to copy the data being signed to.
Throws
IOException

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".

Throws
IOException

public OutputStream open (OutputStream out, String eContentType, boolean encapsulate)

This method is deprecated.
use open(ASN1ObjectIdentifier, OutputStream, boolean)

Throws
IOException

public void setBufferSize (int bufferSize)

Set the underlying string size for encapsulated data

Parameters
bufferSize length of octet strings to buffer the data.