Class SecretKeys

java.lang.Object
io.smallrye.config.SecretKeys
All Implemented Interfaces:
Serializable

public final class SecretKeys extends Object implements Serializable
Provide a way to control the access to Secret Keys.

A Secret Key is a plain configuration name that modifies the behaviour of the config system by:

  1. Omitting the name of the secret in SmallRyeConfig.getPropertyNames()
  2. Omitting the name and value of the secret in the mapping toString method
  3. Throwing a SecurityException when trying to retrieve the value via SmallRyeConfig programmatic API
A Secret Key is defined by either adding the configuration name with SmallRyeConfigBuilder.withSecretKeys(String...) or by wrapping a member type of a ConfigMapping with Secret.

Secret Keys are locked by default. Locking and unlocking keys is a local operation to the current executing thread.

See Also:
  • Constructor Details

    • SecretKeys

      public SecretKeys()
  • Method Details

    • isLocked

      public static boolean isLocked()
      Check if the Secret Keys are locked.
      Returns:
      true if the Secret Keys are locked or false otherwise.
    • doUnlocked

      public static void doUnlocked(Runnable runnable)
      Executes a Runnable with full access to the Secret Keys.
      Parameters:
      runnable - the code to execute
    • doUnlocked

      public static <T> T doUnlocked(Supplier<T> supplier)
      Get the result of a Supplier with full access to the Secret Keys.
      Type Parameters:
      T - the type of results
      Parameters:
      supplier - a Supplier to retrieve the results
      Returns:
      the result
    • doLocked

      public static void doLocked(Runnable runnable)
      Executes a Runnable with no access to the Secret Keys.
      Parameters:
      runnable - the code to execute
    • doLocked

      public static <T> T doLocked(Supplier<T> supplier)
      Get the result of a Supplier with no access to the Secret Keys.
      Type Parameters:
      T - the type of results
      Parameters:
      supplier - a Supplier to retrieve the results
      Returns:
      the result