Class SecretDocument

java.lang.Object
org.springframework.vault.repository.convert.SecretDocument

public class SecretDocument extends Object
Vault database exchange object containing data before/after it's exchanged with Vault. A SecretDocument is basically an object with an id and a body represented as Map of String and Object. It can be created from an Id and VaultResponse.

A secret document can hold simple properties, list properties and nested objects as Maps.

Since:
2.0
Author:
Mark Paluch
  • Constructor Details

    • SecretDocument

      public SecretDocument()
      Create a new, empty SecretDocument.
    • SecretDocument

      public SecretDocument(Map<String,Object> body)
      Create a new SecretDocument given a body map.
      Parameters:
      body - must not be null.
    • SecretDocument

      public SecretDocument(@Nullable String id, Map<String,Object> body)
      Create a new SecretDocument given an id and body map.
      Parameters:
      id - may be null.
      body - must not be null.
    • SecretDocument

      public SecretDocument(@Nullable String id, @Nullable Integer version, Map<String,Object> body)
      Create a new SecretDocument given an id and body map.
      Parameters:
      id - may be null.
      version - for versioned secrets, may be null if not available.
      body - must not be null.
      Since:
      2.4
    • SecretDocument

      public SecretDocument(String id)
  • Method Details

    • from

      public static SecretDocument from(@Nullable String id, VaultResponse vaultResponse)
      Factory method to create a SecretDocument from an id and VaultResponse.
      Parameters:
      id - must not be null.
      vaultResponse - must not be null.
      Returns:
      the SecretDocument.
    • getId

      public @Nullable String getId()
      Returns:
      the identifier or null if the identifier is not set.
    • getRequiredId

      public String getRequiredId()
      Return the required Id or throw IllegalStateException if the Id is not set.
      Returns:
      the required Id.
      Throws:
      IllegalStateException - if the Id is not set.
      Since:
      2.4
    • setId

      public void setId(@Nullable String id)
      Set the identifier value.
      Parameters:
      id - may be null.
    • getVersion

      public @Nullable Integer getVersion()
      Returns:
      the version number, may be null if absent.
      Since:
      2.4
    • setVersion

      public void setVersion(@Nullable Integer version)
      Parameters:
      version -
      Since:
      2.4
    • getBody

      public Map<String,Object> getBody()
      Returns:
      the body of this SecretDocument
    • get

      public @Nullable Object get(String key)
      Retrieve a value from the secret document by its key.
      Parameters:
      key - must not be null.
      Returns:
      the value or null, if the value is not present.
    • put

      public void put(String key, Object value)
      Set a value in the secret document.
      Parameters:
      key - must not be null.
      value - must not be null.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object