Class CAdESSignerInfoGeneratorBuilder

java.lang.Object
org.bouncycastle.cades.CAdESSignerInfoGeneratorBuilder

public class CAdESSignerInfoGeneratorBuilder extends Object
Builds a SignerInfoGenerator for a CAdES B-B signature (ETSI EN 319 122-1 / RFC 5126 BES).

The builder injects the mandatory ESS signing-certificate reference into the signed-attribute table and (optionally) any of the four signed attributes defined by RFC 5126 sec. 5.11: commitment-type, signature-policy, signer-location and content-hints. The default ESS reference uses the v2 form (RFC 5035) with a SHA-256 digest; callers stuck with legacy interop can opt back into v1 via setUseSigningCertificateV1(boolean), which forces a SHA-1 digest per the v1 schema.

The class wraps the JCA-free SignerInfoGeneratorBuilder; the DigestCalculatorProvider supplied to the constructor is used both for the signer's own message-digest calculations and for digesting the signing certificate for the ESS reference, so callers can plug in either the Jca or Bc flavour of provider as they prefer.

     CAdESSignerInfoGeneratorBuilder b = new CAdESSignerInfoGeneratorBuilder(
         new JcaDigestCalculatorProviderBuilder().setProvider("BC").build());
     b.setCommitmentType(new CommitmentTypeIndication(
         CommitmentTypeIdentifier.proofOfOrigin));
     SignerInfoGenerator sig = b.build(contentSigner, signingCertHolder);

     CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
     gen.addSignerInfoGenerator(sig);
     gen.addCertificate(signingCertHolder);
     CMSSignedData signed = gen.generate(new CMSProcessableByteArray(payload), true);
  • Constructor Details

    • CAdESSignerInfoGeneratorBuilder

      public CAdESSignerInfoGeneratorBuilder(DigestCalculatorProvider digestProvider)
      Parameters:
      digestProvider - provider used both for the signer's own message-digest calculations and for digesting the signing certificate.
  • Method Details