Package org.bouncycastle.cms
Class SignerInfoGeneratorBuilder
java.lang.Object
org.bouncycastle.cms.SignerInfoGeneratorBuilder
Builder for SignerInfo generator objects.
-
Constructor Summary
ConstructorsConstructorDescriptionSignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider) Base constructor.SignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider, CMSSignatureEncryptionAlgorithmFinder sigEncAlgFinder) Base constructor with a particular finder for signature algorithms. -
Method Summary
Modifier and TypeMethodDescriptionbuild(ContentSigner contentSigner, byte[] subjectKeyIdentifier) Build a generator with the passed in subjectKeyIdentifier as the signerIdentifier.build(ContentSigner contentSigner, X509CertificateHolder certHolder) Build a generator with the passed in certHolder issuer and serial number as the signerIdentifier.setContentDigest(org.bouncycastle.asn1.x509.AlgorithmIdentifier contentDigest) 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.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.Provide a custom signed attribute generator.setUnsignedAttributeGenerator(CMSAttributeTableGenerator unsignedGen) Provide a generator of unsigned attributes.
-
Constructor Details
-
SignerInfoGeneratorBuilder
Base constructor.- Parameters:
digestProvider- a provider of digest calculators for the algorithms required in the signature and attribute calculations.
-
SignerInfoGeneratorBuilder
public SignerInfoGeneratorBuilder(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 Details
-
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 SignerInfoGeneratorBuilder setContentDigest(org.bouncycastle.asn1.x509.AlgorithmIdentifier contentDigest) 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
-
setSignedAttributeGenerator
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(ContentSigner contentSigner, X509CertificateHolder certHolder) throws 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:
OperatorCreationException- if the generator cannot be built.
-
build
public SignerInfoGenerator build(ContentSigner contentSigner, byte[] subjectKeyIdentifier) throws 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:
OperatorCreationException- if the generator cannot be built.
-