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);
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private List |
| Access | Constructor and Description |
|---|---|
| public | |
| public | CMSSignedDataGenerator(DigestAlgorithmIdentifierFinder digestAlgIdFinder)
base constructor with a custom DigestAlgorithmIdentifierFinder |
| Modifier and Type | Method and Description |
|---|---|
| public CMSSignedData | generate(CMSTypedData
the content to be signed. content)Generate a CMS Signed Data object carrying a detached CMS signature. |
| public CMSSignedData | generate(CMSTypedData
the content to be signed. content, boolean true if the content should be encapsulated in the signature, false otherwise. encapsulate)Generate a CMS Signed Data object which can be carrying a detached CMS signature, or have encapsulated data, depending on the value of the encapsulated parameter. |
| public SignerInformationStore | Returns: a store containing the signers.the signer to be countersigned signer)generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object. |
| public void | setDefiniteLengthEncoding(boolean
true use definite length, false use indefinite (default false). isDefiniteLength)Specify use of definite length rather than indefinite length encoding. |
| isDefiniteLength | back to summary |
|---|---|
| private boolean isDefiniteLength | |
| signerInfs | back to summary |
|---|---|
| private List<E> signerInfs | |
| CMSSignedDataGenerator | back to summary |
|---|---|
| public CMSSignedDataGenerator() base constructor | |
| CMSSignedDataGenerator | back to summary |
|---|---|
| public CMSSignedDataGenerator(DigestAlgorithmIdentifierFinder digestAlgIdFinder) base constructor with a custom DigestAlgorithmIdentifierFinder | |
| generate | back to summary |
|---|---|
| public CMSSignedData generate(CMSTypedData content) throws CMSException Generate a CMS Signed Data object carrying a detached CMS signature.
| |
| generate | back to summary |
|---|---|
| public CMSSignedData generate(CMSTypedData content, boolean encapsulate) throws CMSException Generate a CMS Signed Data object which can be carrying a detached CMS signature, or have encapsulated data, depending on the value of the encapsulated parameter.
| |
| generateCounterSigners | back to summary |
|---|---|
| public SignerInformationStore generateCounterSigners(SignerInformation signer) throws CMSException generate a set of one or more SignerInformation objects representing counter signatures on the passed in SignerInformation object.
| |
| setDefiniteLengthEncoding | back to summary |
|---|---|
| public void setDefiniteLengthEncoding(boolean isDefiniteLength) Specify use of definite length rather than indefinite length encoding.
| |