Class QualifiedTimestampInfo

java.lang.Object
co.ankatech.ankasecure.sdk.model.QualifiedTimestampInfo

public final class QualifiedTimestampInfo extends Object
Informational view of an embedded RFC 3161 qualified timestamp (JAdES sigTst) reported by a verification operation.

This block is purely informational: its presence, trust status, or absence never affects the signature validity verdict (valid). A stamped signature that verifies cryptographically is valid == true whatever the timestamp's trust status.

Trust status. getTrustStatus() carries one of six values. The server runs its checks in a fixed order and the first check that fails decides the value:

  1. UNTRUSTED — the token does not parse, or carries no certificate for its signer;
  2. SIGNATURE_INVALID — the token's own signature does not verify, or a certificate identifier it carries does not name the certificate that verified it;
  3. UNTRUSTED — the token's message imprint declares an unsupported hash, parameters other than absent or NULL, or a digest of the wrong length;
  4. IMPRINT_MISMATCH — the token's message imprint is not the digest of the verified signature value: the token time-stamps other bytes;
  5. UNTRUSTED — the signer's certificate does not carry id-kp-timeStamping as its sole, critical purpose;
  6. EXPIRED — the signer's certificate was not valid at genTime: expired, or not yet valid, when the token was made;
  7. UNTRUSTED — no trust anchor is configured;
  8. the certificate path is validated at genTime: EXPIRED when a certificate in it, a CA's included, was not valid at genTime; UNTRUSTED for every other path failure: it does not end at a configured trust anchor, a certificate signature does not verify, or a name or basic constraint is violated. A signer that is itself a configured self-signed anchor passes this step and the revocation step does not run for it;
  9. only when the deployment checks revocation (the default): REVOKED when a certificate in the path is revoked in the sense of RFC 3161 section 4; UNTRUSTED when the revocation status of a certificate in the path could not be determined while the deployment's revocation posture is hard-fail (the default), or when the revocation evaluation itself failed;
  10. VALID — every check passed.

From step 5 on, a certificate check that cannot be completed at all, for a reason not listed above (a certificate that cannot be read, for example), is UNTRUSTED.

A certificate that expired after genTime does not make a stamp EXPIRED: the certificate path is judged as it stood at genTime. The token's age is not judged, so a stamp verifies VALID however long ago it was issued.

Absent fields. getGenTime(), getSerialNumber() and getPolicyOid() are reported only for a value decided by the certificate checks (steps 5 to 10 above). They are null for steps 1 to 4: a token that does not parse, a token without its signer's certificate, SIGNATURE_INVALID, a malformed message imprint, and IMPRINT_MISMATCH. Callers must not treat a null value as an error.

Instances are immutable and thread-safe. They are populated from the server verify response only when a qualified timestamp is present in the verified JWS; otherwise the enclosing result's timestamp accessor returns null.

  • Field Details

    • TRUST_STATUS_UNKNOWN

      public static final String TRUST_STATUS_UNKNOWN
      The getTrustStatus() value for a trust outcome the server returned that this SDK release does not know. Upgrade the SDK to interpret it. It is never VALID.
      See Also:
  • Constructor Details

    • QualifiedTimestampInfo

      public QualifiedTimestampInfo(boolean present, String trustStatus, String genTime, String serialNumber, String policyOid)
      Creates an immutable qualified-timestamp view.
      Parameters:
      present - whether a qualified timestamp was present in the JWS
      trustStatus - the TSA trust outcome as the server sent it: one of VALID, SIGNATURE_INVALID, IMPRINT_MISMATCH, UNTRUSTED, REVOKED, EXPIRED, or one a later server added, verbatim; may be null
      genTime - TSA-asserted generation time (ISO-8601); null under the absent-field rule in the class description
      serialNumber - timestamp token serial number (decimal); null under the same rule
      policyOid - TSA policy OID (dotted-decimal); null under the same rule
  • Method Details

    • from

      public static QualifiedTimestampInfo from(co.ankatech.secure.client.model.QualifiedTimestamp src)
      Maps a generated OpenAPI QualifiedTimestamp to this public view.
      Parameters:
      src - the generated wire model; may be null
      Returns:
      the mapped view, or null when src is null
    • isPresent

      public boolean isPresent()
      Returns:
      true if a qualified timestamp was present in the JWS
    • getTrustStatus

      public String getTrustStatus()
      Returns:
      typed TSA trust outcome, independent of the signature verdict: one of VALID, SIGNATURE_INVALID, IMPRINT_MISMATCH, UNTRUSTED, REVOKED, EXPIRED, or TRUST_STATUS_UNKNOWN for an outcome this SDK release does not know; may be null
    • getTrustStatusAsString

      public String getTrustStatusAsString()
      Returns the TSA trust outcome as the server sent it.

      For a declared outcome, the same value as getTrustStatus(). For one a later server added, the server's value verbatim, while getTrustStatus() reads TRUST_STATUS_UNKNOWN.

      Server-supplied and unrendered: display it through InertText.text(String).

      Returns:
      the wire value, or null when the server sent none
    • getGenTime

      public String getGenTime()

      Server-supplied and unrendered: display it through InertText.text(String).

      Returns:
      TSA-asserted generation time (ISO-8601); null unless the token is authenticated and covers the verified signature
    • getSerialNumber

      public String getSerialNumber()

      Server-supplied and unrendered: display it through InertText.text(String).

      Returns:
      timestamp token serial number (decimal); null under the same rule as getGenTime()
    • getPolicyOid

      public String getPolicyOid()

      Server-supplied and unrendered: display it through InertText.text(String).

      Returns:
      TSA policy OID (dotted-decimal); null under the same rule as getGenTime()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object