Bouncy Castle Cryptography Library 1.59

org.bouncycastle.cms
Class SignerInfoGeneratorBuilder

java.lang.Object
  extended byorg.bouncycastle.cms.SignerInfoGeneratorBuilder

public class SignerInfoGeneratorBuilder
extends java.lang.Object

Builder for SignerInfo generator objects.


Constructor Summary
SignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider)
          Base constructor.
SignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider, CMSSignatureEncryptionAlgorithmFinder sigEncAlgFinder)
          Base constructor with a particular finder for signature algorithms.
 
Method Summary
 SignerInfoGenerator build(ContentSigner contentSigner, byte[] subjectKeyIdentifier)
          Build a generator with the passed in subjectKeyIdentifier as the signerIdentifier.
 SignerInfoGenerator build(ContentSigner contentSigner, X509CertificateHolder certHolder)
          Build a generator with the passed in certHolder issuer and serial number as the signerIdentifier.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SignerInfoGeneratorBuilder

public SignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider)
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 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

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 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.

Bouncy Castle Cryptography Library 1.59