Class AuthSettings.Builder

java.lang.Object
co.ankatech.ankasecure.sdk.auth.AuthSettings.Builder
Enclosing interface:
AuthSettings

public static final class AuthSettings.Builder extends Object
Assembles an immutable AuthSettings. Not thread-safe; build once and share.
  • Method Details

    • put

      public AuthSettings.Builder put(AuthSetting setting, String value)
      Supplies a value directly, taking precedence over properties and the environment.
      Parameters:
      setting - the setting; must not be null
      value - the value; a null or blank value is ignored rather than stored, so an absent optional from a caller does not shadow a configured file entry
      Returns:
      this builder
    • putSecret

      public AuthSettings.Builder putSecret(AuthSetting setting, SecretChars value)
      Supplies a credential directly. Copied, so the caller may close theirs immediately.
      Parameters:
      setting - the setting; must not be null
      value - the credential; null or empty is ignored
      Returns:
      this builder
    • putLazySecret

      public AuthSettings.Builder putLazySecret(AuthSetting setting, Supplier<SecretChars> supplier)
      Registers a credential that is EXPENSIVE or FALLIBLE to produce - one that has to be decrypted, unsealed or fetched - so that it is produced only if something actually needs it.

      AuthSettings.isPresent(AuthSetting) reports true for a lazily registered setting without invoking the supplier. That is what lets a status command say which credential a deployment uses without being able to read it, and what stops an unreadable store from turning an inspection into a crash.

      Parameters:
      setting - the setting; must not be null
      supplier - produces the credential when it is genuinely needed; must not be null
      Returns:
      this builder
    • overlay

      public AuthSettings.Builder overlay(Properties source)
      Uses these properties as the middle precedence tier.
      Parameters:
      source - the properties; must not be null
      Returns:
      this builder
    • environment

      public AuthSettings.Builder environment(UnaryOperator<String> lookup)
      Replaces the environment lookup. The production default is System.getenv(java.lang.String).

      This is a test seam and nothing more. In particular it does NOT reach the opt-in that gates command execution: that one reads the process environment directly and takes no argument, precisely so no caller can supply its own answer to it.

      Parameters:
      lookup - the lookup; must not be null
      Returns:
      this builder
    • build

      public AuthSettings build()
      Returns:
      an immutable settings view over what has been supplied