Package org.bouncycastle.cms
Class SignerInfoGeneratorBuilder
- java.lang.Object
-
- org.bouncycastle.cms.SignerInfoGeneratorBuilder
-
public class SignerInfoGeneratorBuilder extends java.lang.Object
Builder for SignerInfo generator objects.
-
-
Constructor Summary
Constructors Constructor Description SignerInfoGeneratorBuilder(org.bouncycastle.operator.DigestCalculatorProvider digestProvider)
Base constructor.SignerInfoGeneratorBuilder(org.bouncycastle.operator.DigestCalculatorProvider digestProvider, CMSSignatureEncryptionAlgorithmFinder sigEncAlgFinder)
Base constructor with a particular finder for signature algorithms.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SignerInfoGenerator
build(org.bouncycastle.operator.ContentSigner contentSigner, byte[] subjectKeyIdentifier)
Build a generator with the passed in subjectKeyIdentifier as the signerIdentifier.SignerInfoGenerator
build(org.bouncycastle.operator.ContentSigner contentSigner, X509CertificateHolder certHolder)
Build a generator with the passed in certHolder issuer and serial number as the signerIdentifier.SignerInfoGeneratorBuilder
setContentDigest(org.bouncycastle.asn1.x509.AlgorithmIdentifier contentDigest)
Set the algorithm identifier for the contentDigest to be used for processing the data.SignerInfoGeneratorBuilder
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.SignerInfoGeneratorBuilder
setSignedAttributeGenerator(CMSAttributeTableGenerator signedGen)
Provide a custom signed attribute generator.SignerInfoGeneratorBuilder
setUnsignedAttributeGenerator(CMSAttributeTableGenerator unsignedGen)
Provide a generator of unsigned attributes.
-
-
-
Constructor Detail
-
SignerInfoGeneratorBuilder
public SignerInfoGeneratorBuilder(org.bouncycastle.operator.DigestCalculatorProvider digestProvider)
Base constructor.- Parameters:
digestProvider
- a provider of digest calculators for the algorithms required in the signature and attribute calculations.
-
SignerInfoGeneratorBuilder
public SignerInfoGeneratorBuilder(org.bouncycastle.operator.DigestCalculatorProvider digestProvider, CMSSignatureEncryptionAlgorithmFinder sigEncAlgFinder)
Base constructor with a particular finder for signature algorithms.- Parameters:
digestProvider
- a provider of digest calculators for the algorithms required in the signature and attribute calculations.sigEncAlgFinder
- finder for algorithm IDs to store for the signature encryption/signature algorithm field.
-
-
Method Detail
-
setDirectSignature
public SignerInfoGeneratorBuilder 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.- Returns:
- the builder object
-
setContentDigest
public SignerInfoGeneratorBuilder setContentDigest(org.bouncycastle.asn1.x509.AlgorithmIdentifier contentDigest)
Set the algorithm identifier for the contentDigest to be used for processing the data.- Returns:
- the builder object
-
setSignedAttributeGenerator
public SignerInfoGeneratorBuilder setSignedAttributeGenerator(CMSAttributeTableGenerator signedGen)
Provide a custom signed attribute generator.- Parameters:
signedGen
- a generator of signed attributes.- Returns:
- the builder object
-
setUnsignedAttributeGenerator
public SignerInfoGeneratorBuilder setUnsignedAttributeGenerator(CMSAttributeTableGenerator unsignedGen)
Provide a generator of unsigned attributes.- Parameters:
unsignedGen
- a generator for signed attributes.- Returns:
- the builder object
-
build
public SignerInfoGenerator build(org.bouncycastle.operator.ContentSigner contentSigner, X509CertificateHolder certHolder) throws org.bouncycastle.operator.OperatorCreationException
Build a generator with the passed in certHolder issuer and serial number as the signerIdentifier.- Parameters:
contentSigner
- operator for generating the final signature in the SignerInfo with.certHolder
- carrier for the X.509 certificate related to the contentSigner.- Returns:
- a SignerInfoGenerator
- Throws:
org.bouncycastle.operator.OperatorCreationException
- if the generator cannot be built.
-
build
public SignerInfoGenerator build(org.bouncycastle.operator.ContentSigner contentSigner, byte[] subjectKeyIdentifier) throws org.bouncycastle.operator.OperatorCreationException
Build a generator with the passed in subjectKeyIdentifier as the signerIdentifier. If used you should try to follow the calculation described in RFC 5280 section 4.2.1.2.- Parameters:
contentSigner
- operator for generating the final signature in the SignerInfo with.subjectKeyIdentifier
- key identifier to identify the public key for verifying the signature.- Returns:
- a SignerInfoGenerator
- Throws:
org.bouncycastle.operator.OperatorCreationException
- if the generator cannot be built.
-
-