Class LogicalUtilities

java.lang.Object
io.github.jopenlibs.vault.api.LogicalUtilities

public class LogicalUtilities extends Object
  • Method Details

    • addQualifierToPath

      public static String addQualifierToPath(List<String> segments, int prefixPathDepth, String qualifier)
      Injects the supplied qualifier (either "data" or "metadata") into the second-from-the-root segment position, for a Vault path to be converted for use with a Version 2 secret engine.
      Parameters:
      segments - The Vault path split into segments.
      prefixPathDepth - Number of path elements in the prefix part of the path (the part before the qualifier)
      qualifier - The String to add to the path, based on the operation.
      Returns:
      The final path with the needed qualifier.
    • adjustPathForReadOrWrite

      public static String adjustPathForReadOrWrite(String path, int prefixPathLength, Logical.logicalOperations operation)
      In version 1 style secret engines, the same path is used for all CRUD operations on a secret. In version 2 though, the path varies depending on the operation being performed. When reading or writing a secret, you must inject the path segment "data" right after the lowest-level path segment.
      Parameters:
      path - The Vault path to check or mutate, based on the operation.
      prefixPathLength - prefixPathLength
      operation - The operation being performed, e.g. readV2 or writeV1.
      Returns:
      The Vault path mutated based on the operation.
    • adjustPathForList

      public static String adjustPathForList(String path, int prefixPathDepth, Logical.logicalOperations operation)
      In version 1 style secret engines, the same path is used for all CRUD operations on a secret. In version 2 though, the path varies depending on the operation being performed. When listing secrets available beneath a path, you must inject the path segment "metadata" right after the lowest-level path segment.
      Parameters:
      path - The Vault path to check or mutate, based on the operation.
      prefixPathDepth - prefixPathDepth
      operation - The operation being performed, e.g. readV2 or writeV1.
      Returns:
      The Vault path mutated based on the operation.
    • adjustPathForDelete

      public static String adjustPathForDelete(String path, int prefixPathDepth, Logical.logicalOperations operation)
      In version 1 style secret engines, the same path is used for all CRUD operations on a secret. In version 2 though, the path varies depending on the operation being performed. When deleting secrets, you must inject the path segment "metadata" right after the lowest-level path segment.
      Parameters:
      path - The Vault path to check or mutate, based on the operation.
      prefixPathDepth - prefixPathDepth
      operation - The operation being performed, e.g. readV2 or writeV1.
      Returns:
      The modified path
    • adjustPathForVersionDelete

      public static String adjustPathForVersionDelete(String path, int prefixPathDepth)
      When deleting secret versions, you must inject the path segment "delete" right after the lowest-level path segment.
      Parameters:
      path - The Vault path to check or mutate, based on the operation.
      prefixPathDepth - prefixPathDepth
      Returns:
      The modified path
    • adjustPathForVersionUnDelete

      public static String adjustPathForVersionUnDelete(String path, int prefixPathDepth)
      When undeleting secret versions, you must inject the path segment "undelete" right after the lowest-level path segment.
      Parameters:
      path - The Vault path to check or mutate, based on the operation.
      prefixPathDepth - prefixPathDepth
      Returns:
      The path mutated depending on the operation.
    • adjustPathForVersionDestroy

      public static String adjustPathForVersionDestroy(String path, int prefixPathDepth)
      When destroying secret versions, you must inject the path segment "destroy" right after the lowest-level path segment.
      Parameters:
      path - The Vault path to check or mutate, based on the operation.
      prefixPathDepth - prefixPathDepth
      Returns:
      The path mutated depending on the operation.
    • jsonObjectToWriteFromEngineVersion

      public static JsonObject jsonObjectToWriteFromEngineVersion(Logical.logicalOperations operation, JsonObject jsonObject, JsonObject optionsJsonObject)
      In version two, when writing a secret, the JSONObject must be nested with "data" as the key and an "options" key may be optionally provided
      Parameters:
      operation - The operation being performed, e.g. writeV1, or writeV2.
      jsonObject - The jsonObject that is going to be written.
      optionsJsonObject - The options jsonObject that is going to be written or null if none
      Returns:
      This jsonObject mutated for the operation.