Class ImportKeySpec

Object
ImportKeySpec

public class ImportKeySpec extends Object

ImportKeySpec is a streamlined DTO used by integrators to import an existing cryptographic key (public, private or both) into Anka Secure without exposing the full OpenAPI class.
It purposefully mirrors just the subset of attributes that callers typically control: kid, kty, alg, publicKey, privateKey, keyOps, exportable, expiry metadata and usage limits.

Lifecycle

  1. The caller populates an instance, leaving modelVersion untouched (optional).
  2. AnkaSecureSdk#importKey serialises the instance to JSON and invokes POST /keys/import.
  3. The service validates the JSON, persists the material in a secure HSM-backed store and returns a 201 Created status.

Thread-safety & mutability

This class is not immutable; it is intended for request building only. Do not share a mutable instance across threads once handed to the SDK.

Example


 ImportKeySpec spec = new ImportKeySpec()
         .setKid("partner-rsa-2025")
         .setKty("RSA")
         .setAlg("RSA-2048")
         .setPublicKey(rsaPubPem)
         .setPrivateKey(rsaPrivPem)
         .setKeyOps(List.of("encrypt","decrypt","sign","verify"))
         .setExportable(Boolean.TRUE)
         .setExpiresAt(ZonedDateTime.parse("2030-12-31T23:59:59Z"))
         .setMaxUsageLimit(100_000);

 sdk.importKey(spec);
 
Since:
1.0
Author:
Javier Galindo