Package co.ankatech.ankasecure.sdk.model.warning


package co.ankatech.ankasecure.sdk.model.warning
Structured warning types for cryptographic operations.

This package provides a type-safe alternative to string-based warnings, enabling compile-time safety and pattern matching for warning handling.

Overview

All cryptographic operation results (EncryptResult, SignResult, etc.) return warnings as List<CryptoWarning>: a warning is identified by its type, never by parsing a message.

Core Types

Usage Example


 import co.ankatech.ankasecure.sdk.model.warning.*;

 EncryptResult result = sdk.encrypt("my-key", data);

 for (CryptoWarning warning : result.getWarnings()) {
     // Pattern matching with type safety
     switch (warning) {
         case KeyExpirationWarning kew when kew.severity() == WarningSeverity.CRITICAL -> {
             System.err.println("URGENT: " + kew.message());
             System.err.println("Action: " + kew.recommendedAction());
             triggerRotation();
         }
         case KeyExpirationWarning kew ->
             scheduleRotation(kew.daysRemaining());

         case UsageLimitWarning ulw when ulw.invocationsRemaining() <= 100 ->
             emergencyRotation();
         case UsageLimitWarning ulw ->
             logger.warn(ulw.message());

         case GenericWarning gw ->
             logger.info(gw.rawMessage());
     }
 }
 

Severity-Based Filtering


 // Find all critical warnings
 List<CryptoWarning> critical = result.getWarnings().stream()
     .filter(w -> w.severity() == WarningSeverity.CRITICAL)
     .toList();

 if (!critical.isEmpty()) {
     notifySecurityTeam(critical);
 }
 

Thread Safety

All warning types are immutable records, safe to share across threads. Warning lists returned by SDK are unmodifiable collections.