Package co.ankatech.ankasecure.sdk.auth
Class AuthSettings.Builder
java.lang.Object
co.ankatech.ankasecure.sdk.auth.AuthSettings.Builder
- Enclosing interface:
- AuthSettings
Assembles an immutable
AuthSettings. Not thread-safe; build once and share.-
Method Summary
Modifier and TypeMethodDescriptionbuild()environment(UnaryOperator<String> lookup) Replaces the environment lookup.overlay(Properties source) Uses these properties as the middle precedence tier.put(AuthSetting setting, String value) Supplies a value directly, taking precedence over properties and the environment.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.putSecret(AuthSetting setting, SecretChars value) Supplies a credential directly.
-
Method Details
-
put
Supplies a value directly, taking precedence over properties and the environment.- Parameters:
setting- the setting; must not benullvalue- the value; anullor 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
Supplies a credential directly. Copied, so the caller may close theirs immediately.- Parameters:
setting- the setting; must not benullvalue- the credential;nullor empty is ignored- Returns:
- this builder
-
putLazySecret
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)reportstruefor 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 benullsupplier- produces the credential when it is genuinely needed; must not benull- Returns:
- this builder
-
overlay
Uses these properties as the middle precedence tier.- Parameters:
source- the properties; must not benull- Returns:
- this builder
-
environment
Replaces the environment lookup. The production default isSystem.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 benull- Returns:
- this builder
-
build
- Returns:
- an immutable settings view over what has been supplied
-