Class SignerInfoGeneratorBuilder


  • public class SignerInfoGeneratorBuilder
    extends java.lang.Object
    Builder for SignerInfo generator objects.
    • 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.