general class for generating a pkcs7-signature message.
A simple example of usage.
CertStore certs...
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
gen.addSigner(privKey, cert, CMSSignedGenerator.DIGEST_SHA1);
gen.addCertificatesAndCRLs(certs);
CMSSignedData data = gen.generate(content, "BC");
addSigner
public void addSigner(PrivateKey key,
X509Certificate cert,
String digestOID)
throws IllegalArgumentException
add a signer - no attributes other than the default ones will be
provided here.
addSigner
public void addSigner(PrivateKey key,
X509Certificate cert,
String digestOID,
AttributeTable signedAttr,
AttributeTable unsignedAttr)
throws IllegalArgumentException
add a signer with extra signed/unsigned attributes.
addSigner
public void addSigner(PrivateKey key,
X509Certificate cert,
String digestOID,
CMSAttributeTableGenerator signedAttrGen,
CMSAttributeTableGenerator unsignedAttrGen)
throws IllegalArgumentException
add a signer with extra signed/unsigned attributes based on generators.
generate
public CMSSignedData generate(String signedContentType,
CMSProcessable content,
boolean encapsulate,
String sigProvider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
CMSException
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.
generate
public CMSSignedData generate(String signedContentType,
CMSProcessable content,
boolean encapsulate,
String sigProvider,
boolean addDefaultAttributes)
throws NoSuchAlgorithmException,
NoSuchProviderException,
CMSException
Similar method to the other generate methods. The additional argument
addDefaultAttributes indicates whether or not a default set of signed attributes
need to be added automatically. If the argument is set to false, no
attributes will get added at all.
generate
public CMSSignedData generate(CMSProcessable content,
String sigProvider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
CMSException
generate a signed object that for a CMS Signed Data
object using the given provider.
generate
public CMSSignedData generate(CMSProcessable content,
boolean encapsulate,
String sigProvider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
CMSException
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".
generateCounterSigners
public SignerInformationStore generateCounterSigners(SignerInformation signer,
String sigProvider)
throws NoSuchAlgorithmException,
NoSuchProviderException,
CMSException
generate a set of one or more SignerInformation objects representing counter signatures on
the passed in SignerInformation object.
signer
- the signer to be countersignedsigProvider
- the provider to be used for counter signing.
- a store containing the signers.