Class PatchKeySpec.Builder

java.lang.Object
co.ankatech.ankasecure.sdk.model.PatchKeySpec.Builder
Enclosing class:
PatchKeySpec

public static class PatchKeySpec.Builder extends Object
Fluent builder for assembling a PatchKeySpec.

Each mutator sets one of the optional attributes that can be patched on a key. Attributes left null are omitted from the JSON Merge-Patch produced by PatchKeySpec.toMergePatch().

Example


 PatchKeySpec spec = new PatchKeySpec.Builder()
         .expiresAt(Instant.parse("2030-05-31T23:59:59Z"))
         .softUsageLimit(10_000)
         .build();
 
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • expiresAt

      public PatchKeySpec.Builder expiresAt(Instant t)
      Sets the hard expiration date of the key.
      Parameters:
      t - UTC instant (RFC 3339); must not be null
      Returns:
      this builder for chaining
      Throws:
      NullPointerException - if t is null
    • softLimitExpiration

      public PatchKeySpec.Builder softLimitExpiration(Instant t)
      Sets the soft-limit expiration date. The key remains usable after this instant, but a renewal reminder can be issued.
      Parameters:
      t - UTC instant (RFC 3339); must not be null
      Returns:
      this builder for chaining
      Throws:
      NullPointerException - if t is null
    • softUsageLimit

      public PatchKeySpec.Builder softUsageLimit(int limit)
      Sets the soft usage limit (number of allowed operations before the soft-limit warning).
      Parameters:
      limit - positive integer
      Returns:
      this builder for chaining
    • maxUsageLimit

      public PatchKeySpec.Builder maxUsageLimit(int limit)
      Sets the hard usage limit (absolute cap). When reached the key becomes invalid.
      Parameters:
      limit - positive integer
      Returns:
      this builder for chaining
    • build

      public PatchKeySpec build()
      Builds a PatchKeySpec instance.
      Returns:
      a new patch specification
      Throws:
      IllegalStateException - if every field is null