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(SecureRandom rand)
constructor allowing specific source of randomness
|
Modifier and Type | Method and Description |
---|---|
void |
addSigner(PrivateKey key,
byte[] subjectKeyID,
String digestOID)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
byte[] subjectKeyID,
String digestOID,
AttributeTable signedAttr,
AttributeTable unsignedAttr)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
byte[] subjectKeyID,
String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
byte[] subjectKeyID,
String encryptionOID,
String digestOID)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
byte[] subjectKeyID,
String encryptionOID,
String digestOID,
AttributeTable signedAttr,
AttributeTable unsignedAttr)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
byte[] subjectKeyID,
String encryptionOID,
String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
X509Certificate cert,
String digestOID)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
X509Certificate cert,
String digestOID,
AttributeTable signedAttr,
AttributeTable unsignedAttr)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
X509Certificate cert,
String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
X509Certificate cert,
String encryptionOID,
String digestOID)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
X509Certificate cert,
String encryptionOID,
String digestOID,
AttributeTable signedAttr,
AttributeTable unsignedAttr)
Deprecated.
use addSignerInfoGenerator
|
void |
addSigner(PrivateKey key,
X509Certificate cert,
String encryptionOID,
String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
Deprecated.
use addSignerInfoGenerator
|
CMSSignedData |
generate(CMSProcessable content,
boolean encapsulate,
Provider sigProvider)
Deprecated.
use generate(CMSTypedData, boolean)
|
CMSSignedData |
generate(CMSProcessable content,
boolean encapsulate,
String sigProvider)
Deprecated.
use generate(CMSTypedData, boolean)
|
CMSSignedData |
generate(CMSProcessable content,
Provider sigProvider)
generate a signed object that for a CMS Signed Data
object using the given provider.
|
CMSSignedData |
generate(CMSProcessable content,
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(String eContentType,
CMSProcessable content,
boolean encapsulate,
Provider sigProvider)
Deprecated.
use generate(CMSTypedData, boolean)
|
CMSSignedData |
generate(String eContentType,
CMSProcessable content,
boolean encapsulate,
Provider sigProvider,
boolean addDefaultAttributes)
Similar method to the other generate methods.
|
CMSSignedData |
generate(String eContentType,
CMSProcessable content,
boolean encapsulate,
String sigProvider)
Deprecated.
use generate(CMSTypedData, boolean)
|
CMSSignedData |
generate(String eContentType,
CMSProcessable content,
boolean encapsulate,
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,
Provider sigProvider)
Deprecated.
use generateCounterSigners(SignerInformation)
|
SignerInformationStore |
generateCounterSigners(SignerInformation signer,
String sigProvider)
Deprecated.
use generateCounterSigners(SignerInformation)
|
addAttributeCertificates, addAttributeCertificates, addCertificates, addCertificatesAndCRLs, addCRLs, addSignerInfoGenerator, addSigners, getAttributeSet, getBaseParameters, getEncAlgorithmIdentifier, getEncOID, getGeneratedDigests
public CMSSignedDataGenerator()
public CMSSignedDataGenerator(SecureRandom rand)
rand
- instance of SecureRandom to usepublic void addSigner(PrivateKey key, X509Certificate cert, String digestOID) throws IllegalArgumentException
key
- signing key to usecert
- certificate containing corresponding public keydigestOID
- digest algorithm OIDIllegalArgumentException
public void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID) throws IllegalArgumentException
key
- signing key to usecert
- certificate containing corresponding public keyencryptionOID
- digest encryption algorithm OIDdigestOID
- digest algorithm OIDIllegalArgumentException
public void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID) throws IllegalArgumentException
IllegalArgumentException
public void addSigner(PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID) throws IllegalArgumentException
IllegalArgumentException
public void addSigner(PrivateKey key, X509Certificate cert, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr) throws 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 unsignedIllegalArgumentException
public void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr) throws 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 unsignedIllegalArgumentException
public void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr) throws 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 unsignedIllegalArgumentException
public void addSigner(PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, AttributeTable signedAttr, AttributeTable unsignedAttr) throws 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 unsignedIllegalArgumentException
public void addSigner(PrivateKey key, X509Certificate cert, String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen) throws IllegalArgumentException
IllegalArgumentException
public void addSigner(PrivateKey key, X509Certificate cert, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen) throws IllegalArgumentException
IllegalArgumentException
public void addSigner(PrivateKey key, byte[] subjectKeyID, String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen) throws IllegalArgumentException
IllegalArgumentException
public void addSigner(PrivateKey key, byte[] subjectKeyID, String encryptionOID, String digestOID, CMSAttributeTableGenerator signedAttrGen, CMSAttributeTableGenerator unsignedAttrGen) throws IllegalArgumentException
IllegalArgumentException
public CMSSignedData generate(CMSProcessable content, String sigProvider) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
public CMSSignedData generate(CMSProcessable content, Provider sigProvider) throws NoSuchAlgorithmException, CMSException
NoSuchAlgorithmException
CMSException
public CMSSignedData generate(String eContentType, CMSProcessable content, boolean encapsulate, String sigProvider) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
public CMSSignedData generate(String eContentType, CMSProcessable content, boolean encapsulate, Provider sigProvider) throws NoSuchAlgorithmException, CMSException
NoSuchAlgorithmException
CMSException
public CMSSignedData generate(String eContentType, CMSProcessable content, boolean encapsulate, String sigProvider, boolean addDefaultAttributes) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
public CMSSignedData generate(String eContentType, CMSProcessable content, boolean encapsulate, Provider sigProvider, boolean addDefaultAttributes) throws NoSuchAlgorithmException, CMSException
NoSuchAlgorithmException
CMSException
public CMSSignedData generate(CMSProcessable content, boolean encapsulate, String sigProvider) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
public CMSSignedData generate(CMSProcessable content, boolean encapsulate, Provider sigProvider) throws NoSuchAlgorithmException, CMSException
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, Provider sigProvider) throws NoSuchAlgorithmException, CMSException
signer
- the signer to be countersignedsigProvider
- the provider to be used for counter signing.NoSuchAlgorithmException
CMSException
public SignerInformationStore generateCounterSigners(SignerInformation signer, String sigProvider) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
signer
- the signer to be countersignedsigProvider
- the provider to be used for counter signing.NoSuchAlgorithmException
NoSuchProviderException
CMSException
public SignerInformationStore generateCounterSigners(SignerInformation signer) throws NoSuchAlgorithmException, NoSuchProviderException, CMSException
signer
- the signer to be countersignedNoSuchAlgorithmException
NoSuchProviderException
CMSException
Copyright © 2015. All rights reserved.