Top Description Fields Constructors Methods
org.bouncycastle.cms

public Class SignerInfoGeneratorBuilder

extends Object
Class Inheritance
Imports
org.bouncycastle.asn1.DEROctetString, org.bouncycastle.asn1.cms.IssuerAndSerialNumber, .SignerIdentifier, org.bouncycastle.asn1.x509.AlgorithmIdentifier, org.bouncycastle.cert.X509CertificateHolder, org.bouncycastle.operator.ContentSigner, .DefaultDigestAlgorithmIdentifierFinder, .DigestAlgorithmIdentifierFinder, .DigestCalculator, .DigestCalculatorProvider, .OperatorCreationException

Builder for SignerInfo generator objects.

Field Summary

Modifier and TypeField and Description
private AlgorithmIdentifier
private final DigestAlgorithmIdentifierFinder
private DigestCalculatorProvider
private boolean
private CMSSignatureEncryptionAlgorithmFinder
private CMSAttributeTableGenerator
private CMSAttributeTableGenerator

Constructor Summary

AccessConstructor and Description
public
SignerInfoGeneratorBuilder(DigestCalculatorProvider
a provider of digest calculators for the algorithms required in the signature and attribute calculations.
digestProvider
)

Base constructor.

public
SignerInfoGeneratorBuilder(DigestCalculatorProvider
a provider of digest calculators for the algorithms required in the signature and attribute calculations.
digestProvider
,
CMSSignatureEncryptionAlgorithmFinder
finder for algorithm IDs to store for the signature encryption/signature algorithm field.
sigEncAlgFinder
)

Base constructor with a particular finder for signature algorithms.

Method Summary

Modifier and TypeMethod and Description
public SignerInfoGenerator

Returns:

a SignerInfoGenerator
build
(ContentSigner
operator for generating the final signature in the SignerInfo with.
contentSigner
,
X509CertificateHolder
carrier for the X.509 certificate related to the contentSigner.
certHolder
)

Build a generator with the passed in certHolder issuer and serial number as the signerIdentifier.

public SignerInfoGenerator

Returns:

a SignerInfoGenerator
build
(ContentSigner
operator for generating the final signature in the SignerInfo with.
contentSigner
,
byte[]
key identifier to identify the public key for verifying the signature.
subjectKeyIdentifier
)

Build a generator with the passed in subjectKeyIdentifier as the signerIdentifier.

private SignerInfoGenerator
public SignerInfoGeneratorBuilder

Returns:

the builder object
setContentDigest
(AlgorithmIdentifier contentDigest)

Set the algorithm identifier for the contentDigest to be used for processing the data.

public SignerInfoGeneratorBuilder

Returns:

the builder object
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.

public SignerInfoGeneratorBuilder

Returns:

the builder object
setSignedAttributeGenerator
(CMSAttributeTableGenerator
a generator of signed attributes.
signedGen
)

Provide a custom signed attribute generator.

public SignerInfoGeneratorBuilder

Returns:

the builder object
setUnsignedAttributeGenerator
(CMSAttributeTableGenerator
a generator for signed attributes.
unsignedGen
)

Provide a generator of unsigned attributes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

contentDigestback to summary
private AlgorithmIdentifier contentDigest
digAlgFinderback to summary
private final DigestAlgorithmIdentifierFinder digAlgFinder
digestProviderback to summary
private DigestCalculatorProvider digestProvider
directSignatureback to summary
private boolean directSignature
sigEncAlgFinderback to summary
private CMSSignatureEncryptionAlgorithmFinder sigEncAlgFinder
signedGenback to summary
private CMSAttributeTableGenerator signedGen
unsignedGenback to summary
private CMSAttributeTableGenerator unsignedGen

Constructor Detail

SignerInfoGeneratorBuilderback to summary
public SignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider)

Base constructor.

Parameters
digestProvider:DigestCalculatorProvider

a provider of digest calculators for the algorithms required in the signature and attribute calculations.

SignerInfoGeneratorBuilderback to summary
public SignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider, CMSSignatureEncryptionAlgorithmFinder sigEncAlgFinder)

Base constructor with a particular finder for signature algorithms.

Parameters
digestProvider:DigestCalculatorProvider

a provider of digest calculators for the algorithms required in the signature and attribute calculations.

sigEncAlgFinder:CMSSignatureEncryptionAlgorithmFinder

finder for algorithm IDs to store for the signature encryption/signature algorithm field.

Method Detail

buildback to summary
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:ContentSigner

operator for generating the final signature in the SignerInfo with.

certHolder:X509CertificateHolder

carrier for the X.509 certificate related to the contentSigner.

Returns:SignerInfoGenerator

a SignerInfoGenerator

Exceptions
OperatorCreationException:
if the generator cannot be built.
buildback to summary
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:ContentSigner

operator for generating the final signature in the SignerInfo with.

subjectKeyIdentifier:byte[]

key identifier to identify the public key for verifying the signature.

Returns:SignerInfoGenerator

a SignerInfoGenerator

Exceptions
OperatorCreationException:
if the generator cannot be built.
createGeneratorback to summary
private SignerInfoGenerator createGenerator(ContentSigner contentSigner, SignerIdentifier sigId) throws OperatorCreationException
setContentDigestback to summary
public SignerInfoGeneratorBuilder setContentDigest(AlgorithmIdentifier contentDigest)

Set the algorithm identifier for the contentDigest to be used for processing the data.

Returns:SignerInfoGeneratorBuilder

the builder object

setDirectSignatureback to summary
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:SignerInfoGeneratorBuilder

the builder object

setSignedAttributeGeneratorback to summary
public SignerInfoGeneratorBuilder setSignedAttributeGenerator(CMSAttributeTableGenerator signedGen)

Provide a custom signed attribute generator.

Parameters
signedGen:CMSAttributeTableGenerator

a generator of signed attributes.

Returns:SignerInfoGeneratorBuilder

the builder object

setUnsignedAttributeGeneratorback to summary
public SignerInfoGeneratorBuilder setUnsignedAttributeGenerator(CMSAttributeTableGenerator unsignedGen)

Provide a generator of unsigned attributes.

Parameters
unsignedGen:CMSAttributeTableGenerator

a generator for signed attributes.

Returns:SignerInfoGeneratorBuilder

the builder object