Interface OcspResponseBuilder
public interface OcspResponseBuilder
A fluent builder for unsigned OCSP
ResponseData or a successful,
signed OCSP response (RFC 6960) carrying a BasicOCSPResponse.
The tbsResponseData is signed by a caller supplied ContentSigner;
the result is the DER of the whole OCSPResponse with
responseStatus = successful.
Instances are single-use and not thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionaddResponse(CertId certId, CertStatus status, Instant thisUpdate, Instant nextUpdate) Adds a single certificate-status response.byte[]build(ContentSigner signer, List<X509Certificate> chain) Signs the assembledtbsResponseDataand returns the DER of the whole successfulOCSPResponse.byte[]buildTbs()Encodes the exact unsignedResponseDatathat a signer must sign.nonce(byte[] nonce) Adds a response nonce (echoing the request nonce).producedAt(Instant producedAt) SetsproducedAt(required).responderId(ResponderId responderId) Sets the responder identity (required).
-
Method Details
-
responderId
Sets the responder identity (required).- Parameters:
responderId- the responder id- Returns:
- this builder
-
producedAt
SetsproducedAt(required).- Parameters:
producedAt- the response production time- Returns:
- this builder
-
addResponse
OcspResponseBuilder addResponse(CertId certId, CertStatus status, Instant thisUpdate, Instant nextUpdate) Adds a single certificate-status response.- Parameters:
certId- the requested certificate idstatus- the certificate statusthisUpdate- the time the status is known to be correctnextUpdate- the time newer information will be available (nullable)- Returns:
- this builder
-
nonce
Adds a response nonce (echoing the request nonce).- Parameters:
nonce- the nonce bytes- Returns:
- this builder
-
buildTbs
byte[] buildTbs()Encodes the exact unsignedResponseDatathat a signer must sign. Preserves response insertion order, responder identity, status/time fields and the optional response nonce. The returned DER contains no signature, signature algorithm, outer response envelope or certificate chain. This method neither invokes a signer nor mutates the configured fields.The returned array is independently owned by the caller. Time and auxiliary memory are linear in the encoded response-data size. Response count and total response size retain the builder's existing caller-managed limits; this method adds no live-response size policy.
- Returns:
- freshly encoded unsigned
ResponseDataDER - Throws:
NullPointerException- if required responder, production time or response fields are missingIllegalStateException- if response data cannot be encoded
-
build
Signs the assembledtbsResponseDataand returns the DER of the whole successfulOCSPResponse.- Parameters:
signer- the content signer supplying the signature and algorithmchain- nonnull responder certificate chain in embedding order; empty omits the optional certificates field- Returns:
- the DER-encoded OCSP response
- Throws:
NullPointerException- if a required field, signer, chain or certificate is nullIllegalStateException- if encoding or signing fails
-