Class SecretStores

java.lang.Object
org.apache.juneau.commons.secret.SecretStores

public final class SecretStores extends Object
Resolution helpers for selecting the active SecretStore.

The active store is resolved from a BeanStore, defaulting to an InMemorySecretStore when none has been contributed — the same beanStore.getBean(...)-with-drop-in-default idiom other framework-owned components use. An explicit BeanStore contribution always wins.

fromServiceLoader() is the separate classpath-contribution path, mirroring Settings's opt-in useServiceLoader(). It is deliberately not consulted by resolve(BeanStore), so the no-contribution default stays a deterministic InMemorySecretStore rather than silently becoming whatever store happens to be on the classpath (which, for an environment-variable-backed provider, would quietly turn arbitrary env vars into secrets). A consumer that wants a classpath-contributed store can seed its BeanStore from fromServiceLoader().

Since:
10.0.0
  • Method Details

    • resolve

      public static SecretStore resolve(BeanStore beanStore)
      Resolves the active secret store from the specified bean store, defaulting to a new InMemorySecretStore when none is contributed.
      Parameters:
      beanStore - The bean store to resolve from. Can be null, in which case the default is returned.
      Returns:
      The resolved store. Never null.
    • fromServiceLoader

      Discovers a secret store contributed on the classpath via SecretStoreProvider and ServiceLoader.

      Providers are sorted by SecretStoreProvider.order() (lowest first) and the first one that yields a non-null store wins.

      Returns:
      The discovered store, or Optional.empty() if none is registered on the classpath.