Package org.bouncycastle.cms.jcajce
Class JcaSimpleSignerInfoGeneratorBuilder
java.lang.Object
org.bouncycastle.cms.jcajce.JcaSimpleSignerInfoGeneratorBuilder
Use this class if you are using a provider that has all the facilities you
need.
For example:
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));becomes:
CMSSignedDataGenerator gen = new CMSSignedDataGenerator(); gen.addSignerInfoGenerator( new JcaSimpleSignerInfoGeneratorBuilder() .setProvider("BC") .build("SHA1withRSA", signKP.getPrivate(), signCert));
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild
(String algorithmName, PrivateKey privateKey, byte[] keyIdentifier) build
(String algorithmName, PrivateKey privateKey, X509Certificate certificate) build
(String algorithmName, PrivateKey privateKey, X509CertificateHolder certificate) setContentDigest
(org.bouncycastle.asn1.x509.AlgorithmIdentifier contentDigest) setDirectSignature
(boolean hasNoSignedAttributes) If the passed in flag is true, the signer signature will be based on the data, not a collection of signed attributes, and no signed attributes will be included.setProvider
(String providerName) setProvider
(Provider provider) setSignedAttributeGenerator
(org.bouncycastle.asn1.cms.AttributeTable attrTable) set up a DefaultSignedAttributeTableGenerator primed with the passed in AttributeTable.setUnsignedAttributeGenerator
(CMSAttributeTableGenerator unsignedGen)
-
Constructor Details
-
JcaSimpleSignerInfoGeneratorBuilder
- Throws:
OperatorCreationException
-
-
Method Details
-
setProvider
public JcaSimpleSignerInfoGeneratorBuilder setProvider(String providerName) throws OperatorCreationException - Throws:
OperatorCreationException
-
setProvider
public JcaSimpleSignerInfoGeneratorBuilder setProvider(Provider provider) throws OperatorCreationException - Throws:
OperatorCreationException
-
setDirectSignature
If the passed in flag is true, the signer signature will be based on the data, not a collection of signed attributes, and no signed attributes will be included.- Returns:
- the builder object
-
setContentDigest
public JcaSimpleSignerInfoGeneratorBuilder setContentDigest(org.bouncycastle.asn1.x509.AlgorithmIdentifier contentDigest) -
setSignedAttributeGenerator
public JcaSimpleSignerInfoGeneratorBuilder setSignedAttributeGenerator(CMSAttributeTableGenerator signedGen) -
setSignedAttributeGenerator
public JcaSimpleSignerInfoGeneratorBuilder setSignedAttributeGenerator(org.bouncycastle.asn1.cms.AttributeTable attrTable) set up a DefaultSignedAttributeTableGenerator primed with the passed in AttributeTable.- Parameters:
attrTable
- table of attributes for priming generator- Returns:
- this.
-
setUnsignedAttributeGenerator
public JcaSimpleSignerInfoGeneratorBuilder setUnsignedAttributeGenerator(CMSAttributeTableGenerator unsignedGen) -
build
public SignerInfoGenerator build(String algorithmName, PrivateKey privateKey, X509CertificateHolder certificate) throws OperatorCreationException - Throws:
OperatorCreationException
-
build
public SignerInfoGenerator build(String algorithmName, PrivateKey privateKey, X509Certificate certificate) throws OperatorCreationException, CertificateEncodingException -
build
public SignerInfoGenerator build(String algorithmName, PrivateKey privateKey, byte[] keyIdentifier) throws OperatorCreationException - Throws:
OperatorCreationException
-