Interface ManagedSecret.SecretAccessor

All Known Subinterfaces:
ManagedSecret.UsernamePassword
Enclosing class:
ManagedSecret

public static interface ManagedSecret.SecretAccessor
Interface to access secrets obtained from Vault.
  • Method Details

    • getInt

      default int getInt(String key) throws NoSuchElementException
      Return the required int value for the given key or throw NoSuchElementException.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped.
      Throws:
      NoSuchElementException - if the key is not present or its value was null.
    • getInt

      default int getInt(String key, int defaultValue)
      Return the int value for the given key or defaultValue if the key is not present or its value was null.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped or defaultValue.
    • getInt

      default int getInt(String key, IntSupplier defaultValue)
      Return the int value for the given key or the value of IntSupplier.getAsInt() if the key is not present or its value was null.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped or IntSupplier.getAsInt().
    • getLong

      default long getLong(String key) throws NoSuchElementException
      Return the required long value for the given key or throw NoSuchElementException.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped.
      Throws:
      NoSuchElementException - if the key is not present or its value was null.
    • getLong

      default long getLong(String key, long defaultValue)
      Return the long value for the given key or defaultValue if the key is not present or its value was null.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped or defaultValue.
    • getLong

      default long getLong(String key, LongSupplier defaultValue)
      Return the long value for the given key or the value of LongSupplier.getAsLong() if the key is not present or its value was null.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped or LongSupplier.getAsLong().
    • getString

      default @Nullable String getString(String key)
      Return the String value for the given key.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped, can be null.
    • getRequiredString

      default String getRequiredString(String key) throws NoSuchElementException
      Return the required String value for the given key or throw NoSuchElementException.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped.
      Throws:
      NoSuchElementException - if the key is not present or its value was null.
    • getString

      default String getString(String key, String defaultValue)
      Return the String value for the given key or defaultValue if the key is not present or its value was null.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped or defaultValue.
    • getString

      default String getString(String key, Supplier<String> defaultValue)
      Return the String value for the given key or the value of Supplier.get() if the key is not present or its value was null.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped or Supplier.get().
    • getRequired

      default <T> T getRequired(String key, Class<T> expectedType) throws NoSuchElementException
      Return the required value for the given key or throw NoSuchElementException.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped.
      Throws:
      NoSuchElementException - if the key is not present or its value was null.
    • get

      @Nullable Object get(String key)
      Return the value for the given key.
      Parameters:
      key - the key whose associated value is to be returned.
      Returns:
      the value to which the specified key is mapped, can be null.
    • get

      <T> @Nullable T get(String key, Class<T> expectedType)
      Return the value for the given key.
      Parameters:
      key - the key whose associated value is to be returned.
      expectedType - the expected data type.
      Returns:
      the value to which the specified key is mapped, can be null.
    • as

      default <P> P as(Function<? super ManagedSecret.SecretAccessor,P> transformer)
      Transform this ManagedSecret.SecretAccessor into a target type.
       accessor.as(UsernamePassword::from) 
       
      Type Parameters:
      P - the returned instance type
      Parameters:
      transformer - the Function to map this SecretsAccessor into a target type instance.
      Returns:
      the SecretsAccessor transformed to an instance of P