Enum Class KeyOrigin

java.lang.Object
java.lang.Enum<KeyOrigin>
co.ankatech.ankasecure.sdk.model.KeyOrigin
All Implemented Interfaces:
Serializable, Comparable<KeyOrigin>, Constable

public enum KeyOrigin extends Enum<KeyOrigin>
Indicates how a cryptographic key was created or acquired.

This enumeration tracks the provenance of cryptographic keys stored in the AnkaSecure platform, enabling different validation rules, operational restrictions, and lifecycle management based on key origin.

Origin Types:

  • GENERATED: Key natively created by AnkaSecure platform. Full operational capabilities, no restrictions.
  • IMPORTED: Key imported from external source (PKCS#12 keystore, JWK, etc.). May have operational restrictions if imported with expired certificate.
  • DERIVED: Key derived from another key (e.g., via key derivation function). Reserved for future use.

Relationship with Restricted Field:

The origin field works together with the restricted boolean to determine key operational capabilities:

Origin Restricted Capabilities Use Case
GENERATED false/null Full (encrypt, decrypt, sign, verify) Standard platform-generated key
IMPORTED false/null Full (all operations) Valid certificate import
IMPORTED true Read-only (decrypt, verify only) Expired certificate import (legacy data access)

Usage Example:


 KeyMetadata metadata = sdk.getKeyMetadata("my-key");

 // Check if key was imported
 if (metadata.getOrigin() == KeyOrigin.IMPORTED) {
     System.out.println("This key was imported from external source");

     // Check for restrictions
     if (Boolean.TRUE.equals(metadata.getRestricted())) {
         System.out.println("WARNING: Key restricted to decrypt/verify only");
     }
 } else if (metadata.getOrigin() == KeyOrigin.GENERATED) {
     System.out.println("This key was natively generated by AnkaSecure");
 }
 
Since:
3.0.0
See Also:
  • Enum Constant Details

    • GENERATED

      public static final KeyOrigin GENERATED
      Key natively created by AnkaSecure platform using generate-key endpoint. Full operational capabilities with no restrictions.
    • IMPORTED

      public static final KeyOrigin IMPORTED
      Key imported from external source (PKCS#12, JWK, PEM, etc.). May have operational restrictions depending on certificate validity.
    • DERIVED

      public static final KeyOrigin DERIVED
      Key derived from another key using key derivation functions. Reserved for future use in key hierarchy scenarios.
  • Method Details

    • values

      public static KeyOrigin[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static KeyOrigin valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null