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)
Deprecated.
rand ignored in new API, use base constructor.
|
| 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)
Deprecated.
use generate() method not taking provider.
|
CMSSignedData |
generate(CMSProcessable content,
java.lang.String sigProvider)
Deprecated.
use generate() method not taking 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)
Deprecated.
use setDirectSignature() on SignerInformationGenerator.
|
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)
|
addAttributeCertificate, addAttributeCertificates, addAttributeCertificates, addCertificate, addCertificates, addCertificatesAndCRLs, addCRL, addCRLs, addOtherRevocationInfo, addOtherRevocationInfo, addSignerInfoGenerator, addSigners, getAttributeSet, getBaseParameters, getEncOID, getGeneratedDigestspublic 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.IllegalArgumentExceptionpublic 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.IllegalArgumentExceptionpublic void addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String digestOID)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic void addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String encryptionOID,
java.lang.String digestOID)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic 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.IllegalArgumentExceptionpublic 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.IllegalArgumentExceptionpublic 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.IllegalArgumentExceptionpublic 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.IllegalArgumentExceptionpublic 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.IllegalArgumentExceptionpublic 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.IllegalArgumentExceptionpublic void addSigner(java.security.PrivateKey key,
byte[] subjectKeyID,
java.lang.String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionpublic 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.IllegalArgumentExceptionpublic CMSSignedData generate(CMSProcessable content, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionCMSExceptionpublic CMSSignedData generate(CMSProcessable content, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, CMSException
java.security.NoSuchAlgorithmExceptionCMSExceptionpublic CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionCMSExceptionpublic CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, CMSException
java.security.NoSuchAlgorithmExceptionCMSExceptionpublic 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.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionCMSExceptionpublic CMSSignedData generate(java.lang.String eContentType, CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider, boolean addDefaultAttributes) throws java.security.NoSuchAlgorithmException, CMSException
java.security.NoSuchAlgorithmExceptionCMSExceptionpublic CMSSignedData generate(CMSProcessable content, boolean encapsulate, java.lang.String sigProvider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException, CMSException
java.security.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionCMSExceptionpublic CMSSignedData generate(CMSProcessable content, boolean encapsulate, java.security.Provider sigProvider) throws java.security.NoSuchAlgorithmException, CMSException
java.security.NoSuchAlgorithmExceptionCMSExceptionpublic CMSSignedData generate(CMSTypedData content) throws CMSException
CMSExceptionpublic CMSSignedData generate(CMSTypedData content, boolean encapsulate) throws CMSException
CMSExceptionpublic 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.NoSuchAlgorithmExceptionCMSExceptionpublic 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.NoSuchAlgorithmExceptionjava.security.NoSuchProviderExceptionCMSExceptionpublic SignerInformationStore generateCounterSigners(SignerInformation signer) throws CMSException
signer - the signer to be countersignedCMSException