Class SignResult
Value object returned by one of the following SDK operations:
AuthenticatedSdk.sign(String, byte[])AuthenticatedSdk.signFile(String, java.nio.file.Path, java.nio.file.Path)AuthenticatedSdk.signFileStream(String, java.nio.file.Path, java.nio.file.Path)
This class bundles the full JWS produced by the ANKASecure platform when signing a file, along with exhaustive metadata about the key operations and any non-fatal warnings. It is the Compact JWS described below, or the RFC 7515 §7.2 JWS JSON Serialization when the result carries more than Compact can (a JAdES qualified timestamp).
Compact JWS Structure
A Compact JWS consists of three Base64URL-encoded segments separated by dots:
- Header: JSON object containing signature metadata such
as
alg(e.g.Falcon-1024) andkid(key identifier). - Payload: the detached or embedded file content, depending on your configuration.
- Signature: the digital signature computed over the header and payload, using the signing key's PQC or composite algorithm.
Thread Safety
Instances are immutable and thread-safe. All fields are final and collections are unmodifiable. Instances can be safely shared across threads without synchronization.
Usage Example
SignResult result = sdk.sign("my-signing-key", data);
// Access immutable data
String jws = result.getJwsToken();
Integer materialVersion = result.getMaterialVersion();
// Inspect the key-material version that performed the operation
if (materialVersion != null) {
System.out.println("Signed with material version " + materialVersion);
}
// Check warnings
if (result.getWarnings() != null) {
result.getWarnings().forEach(System.out::println);
}
Builder Pattern
SignResult result = SignResult.builder()
.jwsToken("eyJhbGc...")
.keyRequested("my-signing-key")
.materialVersion(2)
.algorithmUsed("ML-DSA-87")
.addWarning("KEY_ROTATED")
.build();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for constructing immutable SignResult instances. -
Method Summary
Modifier and TypeMethodDescriptionstatic SignResult.Builderbuilder()Creates a new builder for constructing SignResult instances.Returns the catalogue algorithm of the key that signed (e.g.Returns the JWS as persisted: the Compact Serialization, or the JWS JSON Serialization when the result carries more than Compact can (a JAdES qualified timestamp).Returns the key identifier originally requested by the client.Returns the key-material version (ank_kv) that performed the operation under the requested Stable KID;nullwhen the key has no resolvable PRIMARY material version — never 0.Returns structured warnings encountered during the signing operation.
-
Method Details
-
getJwsToken
Returns the JWS as persisted: the Compact Serialization, or the JWS JSON Serialization when the result carries more than Compact can (a JAdES qualified timestamp).Server-supplied and unrendered: display it through
InertText.text(String).- Returns:
- non-null JWS string
-
getKeyRequested
Returns the key identifier originally requested by the client.Server-supplied and unrendered: display it through
InertText.text(String).- Returns:
- requested kid (may be null)
-
getMaterialVersion
Returns the key-material version (ank_kv) that performed the operation under the requested Stable KID;nullwhen the key has no resolvable PRIMARY material version — never 0.- Returns:
- material version (may be null)
-
getAlgorithmUsed
Returns the catalogue algorithm of the key that signed (e.g. ML-DSA-65, FALCON-1024 or Ed25519+ML-DSA-65).Server-supplied and unrendered: display it through
InertText.text(String).- Returns:
- algorithm identifier (may be null)
-
getWarnings
Returns structured warnings encountered during the signing operation.Warnings are type-safe instances allowing pattern matching:
for (CryptoWarning warning : result.getWarnings()) { switch (warning) { case KeyExpirationWarning kew when kew.daysRemaining() <= 7 -> System.err.println("CRITICAL: " + kew.message()); case UsageLimitWarning ulw -> logWarning(ulw.message(), ulw.recommendedAction()); case GenericWarning gw -> System.out.println(gw.rawMessage()); } }The returned list is unmodifiable. Attempts to modify it will throw
UnsupportedOperationException.- Returns:
- unmodifiable list of warnings (null if no warnings, never empty if non-null)
-
builder
Creates a new builder for constructing SignResult instances.- Returns:
- a new Builder instance
-