Class VerifySignatureResult
VerifySignatureResult
Value object returned by signature verification operations
(verifySignature,
verifySignature(Path),
verifySignatureStream).
It conveys the outcome of a detached-signature verification together with
exhaustive metadata emitted by the ANKASecure platform.
Detached Compact JWS Structure
The service returns a Compact JWS in detached form: three Base64URL-encoded segments separated by dots, where the payload segment is empty:
BASE64URL(Header) .. BASE64URL(Signature)
- Header: JSON object containing signature metadata such
as
alg(e.g.Falcon-512or hybridRSA-3072+SHA256) andkid(key identifier). - Payload: omitted here (detached); the original file data is supplied separately and verified against the signature.
- Signature: computed over the header and external payload using the negotiated PQC, classical or hybrid algorithm.
Usage example
Path payload = Path.of("data/report.pdf");
Path signature = Path.of("data/report.pdf.sig");
VerifySignatureResult result = sdk.verifySignatureStream(payload, signature);
if (!result.isValid()) {
// Block the workflow or log warning
}
result.getWarnings().forEach(log::warn);
Outcome and Metadata
- Validity flag –
isValid()reports whether the detached signature matches the supplied payload and the key’s current status permits verification (revocation, expiry, usage caps). - Key metadata – the key initially requested by the caller and the key-material version that performed the verification under that Stable KID.
- Algorithm negotiated – post-quantum, classical or hybrid
algorithm chosen by the crypto-engine (e.g.
Falcon-512,RSA-3072+SHA256). - Warnings – non-fatal advisories such as usage caps,
nearing expiry or algorithm deprecation notices. May be
nullor empty if none.
Thread-safety
Instances are effectively immutable once created by the SDK. They may be shared across threads safely provided no setter is invoked.
Note: getWarnings() may be null or empty.
getMaterialVersion() may be null when the server could not
resolve the material version (e.g. utility mode).
- Since:
- 3.0.0
- Author:
- ANKATech Solutions Inc.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the embedded RFC 3161 qualified timestamp, when present.List<co.ankatech.secure.client.model.SignatureResult>Per-signature verification results — seesignatureResults.Returns structured warnings encountered during signature verification.inthashCode()booleanisValid()Indicates whether verification succeeded both cryptographically and against server-side policy checks.toString()
-
Constructor Details
-
VerifySignatureResult
public VerifySignatureResult()
-
-
Method Details
-
isValid
public boolean isValid()Indicates whether verification succeeded both cryptographically and against server-side policy checks.- Returns:
trueif valid;falseotherwise
-
getKeyRequested
- Returns:
- key identifier originally requested by the caller
-
getMaterialVersion
- Returns:
- key-material version (ank_kv) that performed the verification
under the requested Stable KID;
nullwhen not resolvable (e.g. utility mode) — never 0
-
getAlgorithmUsed
- Returns:
- algorithm negotiated by the crypto-engine
-
getWarnings
Returns structured warnings encountered during signature verification.Warnings are type-safe instances allowing pattern matching and programmatic handling:
VerifySignatureResult result = sdk.verifySignature(jwsToken); if (result.isValid()) { // Signature cryptographically valid, now check warnings if (result.getWarnings() != null && !result.getWarnings().isEmpty()) { for (CryptoWarning warning : result.getWarnings()) { switch (warning) { case KeyExpirationWarning kew when kew.daysRemaining() <= 7 -> logger.error("CRITICAL: Verification key expires in {} days", kew.daysRemaining()); case UsageLimitWarning ulw -> logger.warn("Usage limit approaching: {}", ulw.message()); case GenericWarning gw -> logger.info("Warning: {}", gw.rawMessage()); } } } } else { logger.error("Signature verification FAILED"); }Common warning types:
KeyExpirationWarning: Key approaching expirationUsageLimitWarning: Usage limits approachingGenericWarning: Other server warnings
- Returns:
- unmodifiable list of warnings (null if no warnings, never empty if non-null)
-
getSignatureResults
Per-signature verification results — seesignatureResults.- Returns:
- list with length 1 for SIMPLE keys, length N for COMPOSITE
hybrid keys; may be
nullif the server response omitted the field.
-
getQualifiedTimestamp
Returns the embedded RFC 3161 qualified timestamp, when present.Informational only — never affects
isValid(). Returnsnullwhen the verified JWS carried no qualified timestamp.- Returns:
- the qualified-timestamp view, or
nullwhen absent - Since:
- 3.0.0
-
toString
-
equals
-
hashCode
public int hashCode()
-