Class SignResult

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

public final class SignResult extends Object
Immutable result returned by signing operations.

Value object returned by one of the following SDK operations:

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:

  1. Header: JSON object containing signature metadata such as alg (e.g. Falcon-1024) and kid (key identifier).
  2. Payload: the detached or embedded file content, depending on your configuration.
  3. 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();
 
Since:
3.0.0
See Also:
  • Method Details

    • getJwsToken

      public String getJwsToken()
      Returns the raw Compact JWS exactly as issued by the server.
      Returns:
      non-null Compact JWS string
    • getKeyRequested

      public String getKeyRequested()
      Returns the key identifier originally requested by the client.
      Returns:
      requested kid (may be null)
    • getMaterialVersion

      public Integer getMaterialVersion()
      Returns the key-material version (ank_kv) that performed the operation under the requested Stable KID; null when not resolvable (e.g. utility mode) — never 0.
      Returns:
      material version (may be null)
    • getAlgorithmUsed

      public String getAlgorithmUsed()
      Returns the signature algorithm negotiated by the service (e.g. SLH-DSA-256 or Falcon-1024).
      Returns:
      algorithm identifier (may be null)
    • getWarnings

      public List<CryptoWarning> 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

      public static SignResult.Builder builder()
      Creates a new builder for constructing SignResult instances.
      Returns:
      a new Builder instance