Class CAdESSignerInfoGeneratorBuilder
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild(ContentSigner contentSigner, X509CertificateHolder certHolder) setCommitmentType(org.bouncycastle.asn1.esf.CommitmentTypeIndication commitmentType) Set the optionalid-aa-ets-commitmentTypesigned attribute (RFC 5126 sec.setContentHints(org.bouncycastle.asn1.ess.ContentHints contentHints) Set the optionalid-aa-contentHintsigned attribute (RFC 5126 sec.setEssCertDigestAlgorithm(org.bouncycastle.asn1.x509.AlgorithmIdentifier digestAlgId) Override the digest algorithm used for the ESS signing-certificate-v2 reference.setSignaturePolicy(org.bouncycastle.asn1.esf.SignaturePolicyIdentifier signaturePolicy) Set the optionalid-aa-ets-sigPolicyIdsigned attribute (RFC 5126 sec.setSignerLocation(org.bouncycastle.asn1.esf.SignerLocation signerLocation) Set the optionalid-aa-ets-signerLocationsigned attribute (RFC 5126 sec.setUseSigningCertificateV1(boolean useV1) If set to true the builder emits the legacy ESS signing-certificate attribute (RFC 2634) with a SHA-1 digest instead of the modern signing-certificate-v2 attribute (RFC 5035).
-
Constructor Details
-
CAdESSignerInfoGeneratorBuilder
- Parameters:
digestProvider- provider used both for the signer's own message-digest calculations and for digesting the signing certificate.
-
-
Method Details
-
setUseSigningCertificateV1
If set to true the builder emits the legacy ESS signing-certificate attribute (RFC 2634) with a SHA-1 digest instead of the modern signing-certificate-v2 attribute (RFC 5035). Default is false (use the v2 form with SHA-256). -
setEssCertDigestAlgorithm
public CAdESSignerInfoGeneratorBuilder setEssCertDigestAlgorithm(org.bouncycastle.asn1.x509.AlgorithmIdentifier digestAlgId) Override the digest algorithm used for the ESS signing-certificate-v2 reference. Ignored whensetUseSigningCertificateV1(boolean)is true (v1 is fixed to SHA-1). -
setCommitmentType
public CAdESSignerInfoGeneratorBuilder setCommitmentType(org.bouncycastle.asn1.esf.CommitmentTypeIndication commitmentType) Set the optionalid-aa-ets-commitmentTypesigned attribute (RFC 5126 sec. 5.11.1). -
setSignaturePolicy
public CAdESSignerInfoGeneratorBuilder setSignaturePolicy(org.bouncycastle.asn1.esf.SignaturePolicyIdentifier signaturePolicy) Set the optionalid-aa-ets-sigPolicyIdsigned attribute (RFC 5126 sec. 5.8.1). -
setSignerLocation
public CAdESSignerInfoGeneratorBuilder setSignerLocation(org.bouncycastle.asn1.esf.SignerLocation signerLocation) Set the optionalid-aa-ets-signerLocationsigned attribute (RFC 5126 sec. 5.11.2). -
setContentHints
public CAdESSignerInfoGeneratorBuilder setContentHints(org.bouncycastle.asn1.ess.ContentHints contentHints) Set the optionalid-aa-contentHintsigned attribute (RFC 5126 sec. 5.10.2 / RFC 2634). -
build
public SignerInfoGenerator build(ContentSigner contentSigner, X509CertificateHolder certHolder) throws OperatorCreationException, CAdESException
-