Package org.bouncycastle.cms
Class SignerInfoGeneratorBuilder
java.lang.Object
org.bouncycastle.cms.SignerInfoGeneratorBuilder
public class SignerInfoGeneratorBuilder extends Object
Builder for SignerInfo generator objects.
-
Constructor Summary
Constructors Constructor Description SignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider)Base constructor.SignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider, CMSSignatureEncryptionAlgorithmFinder sigEncAlgFinder)Base constructor. -
Method Summary
Modifier and Type Method Description SignerInfoGeneratorbuild(ContentSigner contentSigner, byte[] subjectKeyIdentifier)Build a generator with the passed in subjectKeyIdentifier as the signerIdentifier.SignerInfoGeneratorbuild(ContentSigner contentSigner, X509CertificateHolder certHolder)Build a generator with the passed in certHolder issuer and serial number as the signerIdentifier.SignerInfoGeneratorBuildersetDirectSignature(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.SignerInfoGeneratorBuildersetSignedAttributeGenerator(CMSAttributeTableGenerator signedGen)Provide a custom signed attribute generator.SignerInfoGeneratorBuildersetUnsignedAttributeGenerator(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.- Parameters:
digestProvider- a provider of digest calculators for the algorithms required in the signature and attribute calculations.
-
-
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
-
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(ContentSigner contentSigner, X509CertificateHolder certHolder) throws OperatorCreationExceptionBuild 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 OperatorCreationExceptionBuild 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.
-