Class DecryptResultMetadata

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

public class DecryptResultMetadata extends Object

DecryptResultMetadata

Value object returned by file decryption operations (decryptFile and decryptFileStream). It encapsulates:

  • Key metadata – the key requested by the caller and the key-material version that performed the operation under that Stable KID.
  • Algorithm negotiated – exact hybrid algorithm selected by the crypto‑engine (e.g. ML‑KEM‑768+A128GCM).
  • Warnings – non‑fatal conditions (usage threshold near, sunset scheduled, etc.) returned by the platform.

Thread‑safety: the class is a simple data carrier with no internal synchronisation. Treat instances as immutable once returned by the SDK and refrain from mutating them across threads.

Since:
3.0.0
Author:
ANKATech Solutions Inc.
See Also:
  • Constructor Details

    • DecryptResultMetadata

      public DecryptResultMetadata()
  • Method Details

    • getKeyRequested

      public String getKeyRequested()
      Returns:
      the key ID originally requested by the client
    • setKeyRequested

      public void setKeyRequested(String keyRequested)
      Parameters:
      keyRequested - the key ID originally requested by the client
    • 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
    • setMaterialVersion

      public void setMaterialVersion(Integer materialVersion)
      Parameters:
      materialVersion - the key-material version that performed the operation
    • getAlgorithmUsed

      public String getAlgorithmUsed()
      Returns:
      algorithm negotiated by the crypto‑engine
    • setAlgorithmUsed

      public void setAlgorithmUsed(String algorithmUsed)
      Parameters:
      algorithmUsed - algorithm negotiated by the crypto‑engine
    • getWarnings

      public List<CryptoWarning> getWarnings()
      Returns structured warnings encountered during the decryption operation.

      Warnings are type-safe instances allowing pattern matching:

      
       DecryptResult result = sdk.decrypt(jweToken);
       DecryptResultMetadata meta = result.getMeta();
      
       if (meta.getWarnings() != null && !meta.getWarnings().isEmpty()) {
           for (CryptoWarning warning : meta.getWarnings()) {
               switch (warning) {
                   case KeyExpirationWarning kew when kew.daysRemaining() <= 7 ->
                       logger.error("CRITICAL: Key {} expires in {} days",
                           meta.getKeyRequested(), kew.daysRemaining());
                   case UsageLimitWarning ulw ->
                       logger.warn("Usage limit approaching: {}", ulw.message());
                   case GenericWarning gw ->
                       logger.info("Warning: {}", gw.rawMessage());
               }
           }
       }
       
      Returns:
      list of structured warnings (null if no warnings, never empty if non-null)
    • setWarnings

      public void setWarnings(List<CryptoWarning> warnings)
      Parameters:
      warnings - list of non‑fatal warnings produced by the platform
    • 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