Class CAdESLongTermValuesUtil
id-aa-ets-certificateRefs(RFC 5126 sec. 6.2.1) — digest + IssuerSerial references for each non-signer cert.id-aa-ets-revocationRefs(RFC 5126 sec. 6.2.2) — digest references for each CRL (and/or OCSP response).id-aa-ets-certValues(RFC 5126 sec. 6.3.3) — the cert bytes themselves.id-aa-ets-revocationValues(RFC 5126 sec. 6.3.4) — the CRL / OCSP response bytes themselves.
Both CRL (X509CRLHolder) and OCSP (BasicOCSPResp) revocation
material are supported. An OCSP response contributes:
- An
OcspResponsesIDentry under therevocationRefsattribute'socspidsbranch, holding the responder identifier,producedAttimestamp and a digest of the BasicOCSPResponse bytes (RFC 5126 sec. 6.2.2). - A
BasicOCSPResponseentry under therevocationValuesattribute'socspValsbranch (RFC 5126 sec. 6.3.4).
Level detector ordering:
CAdESLevelDetector.attainedLevel(SignerInformation) only reports CAdESLevel.B_LT
when a signature time-stamp (CAdESLevel.B_T) is also present on the
signer; without it the detector keeps reporting CAdESLevel.B_B
regardless of the four LT attributes being attached. Apply the signature
time-stamp via CAdESSignatureTimestampUtil.applySignatureTimestamp(CMSSignedData, SignerId, TimeStampToken)
first if you want the detector to advance.
Reading LT material back:
getCertificateValues(SignerInformation),
getCertificateRevocationLists(SignerInformation) and
getOcspResponses(SignerInformation) expose the embedded trust
material as the corresponding holder / response types so a relying party
can plug them into JCA CertPathValidator / OCSP verification
directly. validateLongTermValues(SignerInformation, DigestCalculatorProvider)
checks the LT bundle is internally self-consistent (every reference's hash
matches the corresponding value bytes); a full chain / revocation
validation at the timestamp's genTime is the caller's
responsibility and is built on top of those holders.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CMSSignedDataapplyLongTermValues(CMSSignedData signed, SignerId signerId, List<X509CertificateHolder> additionalCerts, List<X509CRLHolder> crls, List<BasicOCSPResp> ocspResponses, org.bouncycastle.asn1.x509.AlgorithmIdentifier refDigestAlg, DigestCalculatorProvider digCalcProv) Attach the four CAdES B-LT unsigned attributes to the signer matched bysignerId.static CMSSignedDataapplyLongTermValues(CMSSignedData signed, SignerId signerId, List<X509CertificateHolder> additionalCerts, List<X509CRLHolder> crls, org.bouncycastle.asn1.x509.AlgorithmIdentifier refDigestAlg, DigestCalculatorProvider digCalcProv) Convenience overload that takes no OCSP responses — equivalent toapplyLongTermValues(CMSSignedData, SignerId, List, List, List, AlgorithmIdentifier, DigestCalculatorProvider)with an empty OCSP list.static List<X509CRLHolder> Extract the CRLs bundled into the signer'sid-aa-ets-revocationValuesattribute.static List<X509CertificateHolder> Extract the cert chain bundled into the signer'sid-aa-ets-certValuesattribute.static List<BasicOCSPResp> getOcspResponses(SignerInformation signer) Extract the OCSP responses bundled into the signer'sid-aa-ets-revocationValuesattribute.static voidvalidateLongTermValues(SignerInformation signer, DigestCalculatorProvider digCalcProv) Self-consistency check across the four B-LT attributes on the signer: All four attributes (id-aa-ets-certificateRefs,id-aa-ets-certValues,id-aa-ets-revocationRefs,id-aa-ets-revocationValues) must be present. For each cert incertValues, anOtherCertIDentry undercertificateRefsmust reference the same(issuer, serialNumber)and its hash must match the digest of the cert under the ref's hash algorithm. For each CRL / OCSP response underrevocationValues, a reference must exist underrevocationRefswith a matching hash (CRLs are matched positionally; OCSP responses are matched byOcspIdentifier).
-
Method Details
-
applyLongTermValues
public static CMSSignedData applyLongTermValues(CMSSignedData signed, SignerId signerId, List<X509CertificateHolder> additionalCerts, List<X509CRLHolder> crls, org.bouncycastle.asn1.x509.AlgorithmIdentifier refDigestAlg, DigestCalculatorProvider digCalcProv) throws CAdESException, OperatorCreationException, IOException Convenience overload that takes no OCSP responses — equivalent toapplyLongTermValues(CMSSignedData, SignerId, List, List, List, AlgorithmIdentifier, DigestCalculatorProvider)with an empty OCSP list. -
applyLongTermValues
public static CMSSignedData applyLongTermValues(CMSSignedData signed, SignerId signerId, List<X509CertificateHolder> additionalCerts, List<X509CRLHolder> crls, List<BasicOCSPResp> ocspResponses, org.bouncycastle.asn1.x509.AlgorithmIdentifier refDigestAlg, DigestCalculatorProvider digCalcProv) throws CAdESException, OperatorCreationException, IOException Attach the four CAdES B-LT unsigned attributes to the signer matched bysignerId. Long-term references userefDigestAlg(typically SHA-256); the corresponding values attributes hold the raw cert / CRL / OCSP-response bytes.- Parameters:
signed- the source CMSSignedData (unchanged).signerId- selector identifying which signer to upgrade.additionalCerts- certs to include incertValues(typically any intermediate / root not already in the SignedData.certificates field). Cannot be null; pass an empty list for none.crls- CRLs to include inrevocationValues/revocationRefs. Cannot be null; pass an empty list for none.ocspResponses- OCSP responses to include inrevocationValues/revocationRefs. Cannot be null; pass an empty list for none.refDigestAlg- digest algorithm for the cert / CRL / OCSP refs; null defaults to SHA-256.digCalcProv- source of digest calculators for the reference digests.- Returns:
- a new CMSSignedData with the B-LT attributes attached.
- Throws:
CAdESException- ifsignerIdmatches no signer, or a structure cannot be encoded.OperatorCreationExceptionIOException
-
getCertificateValues
Extract the cert chain bundled into the signer'sid-aa-ets-certValuesattribute. Returns an empty list when the attribute is absent — the signer is not (yet) B-LT. -
getCertificateRevocationLists
Extract the CRLs bundled into the signer'sid-aa-ets-revocationValuesattribute. Returns an empty list when the attribute is absent or carries only OCSP responses. -
getOcspResponses
Extract the OCSP responses bundled into the signer'sid-aa-ets-revocationValuesattribute. Returns an empty list when the attribute is absent or carries only CRLs. -
validateLongTermValues
public static void validateLongTermValues(SignerInformation signer, DigestCalculatorProvider digCalcProv) throws CAdESException, OperatorCreationException, IOException Self-consistency check across the four B-LT attributes on the signer:- All four attributes (
id-aa-ets-certificateRefs,id-aa-ets-certValues,id-aa-ets-revocationRefs,id-aa-ets-revocationValues) must be present. - For each cert in
certValues, anOtherCertIDentry undercertificateRefsmust reference the same(issuer, serialNumber)and its hash must match the digest of the cert under the ref's hash algorithm. - For each CRL / OCSP response under
revocationValues, a reference must exist underrevocationRefswith a matching hash (CRLs are matched positionally; OCSP responses are matched byOcspIdentifier).
What this method does not do: walk the cert chain to a trust anchor, check signing-time validity windows, verify the embedded CRL / OCSP signatures, or look up revocation status. Those steps are the caller's responsibility, built on
getCertificateValues(SignerInformation),getCertificateRevocationLists(SignerInformation)andgetOcspResponses(SignerInformation)plus a standard JCACertPathValidator.- Throws:
CAdESException- if the LT attributes are inconsistent, or any required attribute is missing.OperatorCreationExceptionIOException
- All four attributes (
-