Package co.ankatech.ankasecure.sdk.model
Class SignResult
java.lang.Object
co.ankatech.ankasecure.sdk.model.SignResult
Immutable result returned by signing operations.
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 Compact JWS produced by the Anka Secure platform when signing a file, along with exhaustive metadata about the key operations and any non-fatal warnings.
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 negotiated PQC or hybrid 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 signature algorithm negotiated by the service (e.g.Returns the raw Compact JWS exactly as issued by the server.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 not resolvable (e.g. utility mode) — never 0.Returns structured warnings encountered during the signing operation.
-
Method Details
-
getJwsToken
Returns the raw Compact JWS exactly as issued by the server.- Returns:
- non-null Compact JWS string
-
getKeyRequested
Returns the key identifier originally requested by the client.- Returns:
- requested kid (may be null)
-
getMaterialVersion
Returns the key-material version (ank_kv) that performed the operation under the requested Stable KID;nullwhen not resolvable (e.g. utility mode) — never 0.- Returns:
- material version (may be null)
-
getAlgorithmUsed
Returns the signature algorithm negotiated by the service (e.g. SLH-DSA-256 or Falcon-1024).- 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
-