Interface SecretManager

All Known Implementing Classes:
EnvironmentSecretManager, ExecPassSecretManager, GnomeSecretManager, InMemorySecretManager, InsecureUnencryptedYamlFileSecretManager, JavaPropertySecretManager, PrefixingSecretManager, ReadOnlySecretManager, SecretManagerChain, SecretManagerTLC, TestSecretManager, UnavailableSecretManager, YamlSecretManager

public interface SecretManager
SecretManager is a "vault" of 🔑 Secrets.

You store(String, char[]), then getOptional(String) it; and maybe later delete(String) it again. There is very intentionally no Set<String> listKeys() sort of method here.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deletes a secret from the manager.
    default Secret
    get(String key)
    Retrieves a secret by its key; throws if not found.
    Retrieves a secret by its key, with optionality.
    void
    store(String key, char[] value)
    Stores a secret value associated with a unique key.
  • Method Details

    • store

      void store(String key, char[] value) throws IOException
      Stores a secret value associated with a unique key. The sensitive value is provided as a char array. Implementations will zero out the input value array immediately after calling this method for security. If a secret with the same key already exists, its value is overwritten.
      Parameters:
      key - The unique key (name) for the secret.
      value - The sensitive secret value as a character array.
      Throws:
      IOException - If an error occurs while storing the secret.
    • getOptional

      Retrieves a secret by its key, with optionality.
      Parameters:
      key - The unique key (name) of the secret to retrieve.
      Returns:
      An Optional containing the Secret, if found.
      Throws:
      IOException - If an error occurs while retrieving the secret.
    • get

      Retrieves a secret by its key; throws if not found.
      Parameters:
      key - The unique key (name) of the secret to retrieve.
      Returns:
      An Optional containing the Secret, if found.
      Throws:
      IllegalStateException - if the secret is not found.
      IOException - If an error occurs while retrieving the secret.
    • delete

      void delete(String key) throws IOException
      Deletes a secret from the manager.
      Parameters:
      key - The unique key (name) of the secret to delete.
      Throws:
      IOException - If an error occurs while deleting the secret.