public class CMSSignedDataGenerator extends CMSSignedGenerator
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);
_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, rand, signerGens
Constructor and Description |
---|
CMSSignedDataGenerator()
base constructor
|
CMSSignedDataGenerator(java.security.SecureRandom rand)
constructor allowing specific source of randomness
|
Modifier and Type | Method and Description |
---|---|
void |
addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String digestOID)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String digestOID,
org.bouncycastle.asn1.cms.AttributeTable signedAttr,
org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String encryptionOID,
java.lang.String digestOID)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String encryptionOID,
java.lang.String digestOID,
org.bouncycastle.asn1.cms.AttributeTable signedAttr,
org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String encryptionOID,
java.lang.String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String digestOID)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String digestOID,
org.bouncycastle.asn1.cms.AttributeTable signedAttr,
org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String encryptionOID,
java.lang.String digestOID)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String encryptionOID,
java.lang.String digestOID,
org.bouncycastle.asn1.cms.AttributeTable signedAttr,
org.bouncycastle.asn1.cms.AttributeTable unsignedAttr)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(java.security.PrivateKey key,
java.security.cert.X509Certificate cert,
java.lang.String encryptionOID,
java.lang.String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
Deprecated.
use addSignerInfoGenerator
|
CMSSignedData |
generate(CMSProcessable content,
boolean encapsulate,
java.security.Provider sigProvider)
Deprecated.
use generate(CMSTypedData, boolean)
|
CMSSignedData |
generate(CMSProcessable content,
boolean encapsulate,
java.lang.String sigProvider)
Deprecated.
use generate(CMSTypedData, boolean)
|
CMSSignedData |
generate(CMSProcessable content,
java.security.Provider sigProvider)
generate a signed object that for a CMS Signed Data
object using the given provider.
|
CMSSignedData |
generate(CMSProcessable content,
java.lang.String sigProvider)
generate a signed object that for a CMS Signed Data
object using the given provider.
|
CMSSignedData |
generate(CMSTypedData content) |
CMSSignedData |
generate(CMSTypedData content,
boolean encapsulate) |
CMSSignedData |
generate(java.lang.String eContentType,
CMSProcessable content,
boolean encapsulate,
java.security.Provider sigProvider)
Deprecated.
use generate(CMSTypedData, boolean)
|
CMSSignedData |
generate(java.lang.String eContentType,
CMSProcessable content,
boolean encapsulate,
java.security.Provider sigProvider,
boolean addDefaultAttributes)
Similar method to the other generate methods.
|
CMSSignedData |
generate(java.lang.String eContentType,
CMSProcessable content,
boolean encapsulate,
java.lang.String sigProvider)
Deprecated.
use generate(CMSTypedData, boolean)
|
CMSSignedData |
generate(java.lang.String eContentType,
CMSProcessable content,
boolean encapsulate,
java.lang.String sigProvider,
boolean addDefaultAttributes)
Deprecated.
use generate(CMSTypedData, boolean)
|
SignerInformationStore |
generateCounterSigners(SignerInformation signer)
generate a set of one or more SignerInformation objects representing counter signatures on
the passed in SignerInformation object.
|
SignerInformationStore |
generateCounterSigners(SignerInformation signer,
java.security.Provider sigProvider)
Deprecated.
use generateCounterSigners(SignerInformation)
|
SignerInformationStore |
generateCounterSigners(SignerInformation signer,
java.lang.String sigProvider)
Deprecated.
use generateCounterSigners(SignerInformation)
|
addAttributeCertificates, addAttributeCertificates, addCertificates, addCertificatesAndCRLs, addCRLs, addSignerInfoGenerator, addSigners, getAttributeSet, getBaseParameters, getEncAlgorithmIdentifier, getEncOID, getGeneratedDigests
public CMSSignedDataGenerator()
public CMSSignedDataGenerator(java.security.SecureRandom rand)
rand
- instance of SecureRandom to usepublic void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID) throws java.lang.IllegalArgumentException
key
- signing key to usecert
- certificate containing corresponding public keydigestOID
- digest algorithm OIDjava.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID) throws java.lang.IllegalArgumentException
key
- signing key to usecert
- certificate containing corresponding public keyencryptionOID
- digest encryption algorithm OIDdigestOID
- digest algorithm OIDjava.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr) throws java.lang.IllegalArgumentException
key
- signing key to usecert
- certificate containing corresponding public keydigestOID
- digest algorithm OIDsignedAttr
- table of attributes to be included in signatureunsignedAttr
- table of attributes to be included as unsignedjava.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr) throws java.lang.IllegalArgumentException
key
- signing key to usecert
- certificate containing corresponding public keyencryptionOID
- digest encryption algorithm OIDdigestOID
- digest algorithm OIDsignedAttr
- table of attributes to be included in signatureunsignedAttr
- table of attributes to be included as unsignedjava.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr) throws java.lang.IllegalArgumentException
key
- signing key to usesubjectKeyID
- subjectKeyID of corresponding public keydigestOID
- digest algorithm OIDsignedAttr
- table of attributes to be included in signatureunsignedAttr
- table of attributes to be included as unsignedjava.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID, org.bouncycastle.asn1.cms.AttributeTable signedAttr, org.bouncycastle.asn1.cms.AttributeTable unsignedAttr) throws java.lang.IllegalArgumentException
key
- signing key to usesubjectKeyID
- subjectKeyID of corresponding public keyencryptionOID
- digest encryption algorithm OIDdigestOID
- digest algorithm OIDsignedAttr
- table of attributes to be included in signatureunsignedAttr
- table of attributes to be included as unsignedjava.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, java.security.cert.X509Certificate cert, java.lang.String encryptionOID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void addSigner(java.security.PrivateKey key, byte[] subjectKeyID, java.lang.String encryptionOID, java.lang.String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public CMSSignedData generate(CMSProcessable content, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException
public CMSSignedData generate(CMSProcessable content, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, CMSException
java.security.NoSuchAlgorithmException
CMSException
public CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException
public CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, CMSException
java.security.NoSuchAlgorithmException
CMSException
public CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.lang.String sigProvider, boolean addDefaultAttributes) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException
public CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider, boolean addDefaultAttributes) throws java.security.NoSuchAlgorithmException, CMSException
java.security.NoSuchAlgorithmException
CMSException
public CMSSignedData generate(CMSProcessable content, boolean encapsulate, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException
public CMSSignedData generate(CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, CMSException
java.security.NoSuchAlgorithmException
CMSException
public CMSSignedData generate(CMSTypedData content) throws CMSException
CMSException
public CMSSignedData generate(CMSTypedData content, boolean encapsulate) throws CMSException
CMSException
public SignerInformationStore generateCounterSigners(SignerInformation signer, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, CMSException
signer
- the signer to be countersignedsigProvider
- the provider to be used for counter signing.java.security.NoSuchAlgorithmException
CMSException
public SignerInformationStore generateCounterSigners(SignerInformation signer, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
signer
- the signer to be countersignedsigProvider
- the provider to be used for counter signing.java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException
public SignerInformationStore generateCounterSigners(SignerInformation signer) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
signer
- the signer to be countersignedjava.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
CMSException