- java.lang.Object
-
- io.github.jopenlibs.vault.api.LogicalUtilities
-
public class LogicalUtilities extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
addQualifierToPath(java.util.List<java.lang.String> segments, int prefixPathDepth, java.lang.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.static java.lang.String
adjustPathForDelete(java.lang.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.static java.lang.String
adjustPathForList(java.lang.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.static java.lang.String
adjustPathForReadOrWrite(java.lang.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.static java.lang.String
adjustPathForVersionDelete(java.lang.String path, int prefixPathDepth)
When deleting secret versions, you must inject the path segment "delete" right after the lowest-level path segment.static java.lang.String
adjustPathForVersionDestroy(java.lang.String path, int prefixPathDepth)
When destroying secret versions, you must inject the path segment "destroy" right after the lowest-level path segment.static java.lang.String
adjustPathForVersionUnDelete(java.lang.String path, int prefixPathDepth)
When undeleting secret versions, you must inject the path segment "undelete" right after the lowest-level path segment.static JsonObject
jsonObjectToWriteFromEngineVersion(Logical.logicalOperations operation, JsonObject jsonObject)
In version two, when writing a secret, the JSONObject must be nested with "data" as the key.
-
-
-
Method Detail
-
addQualifierToPath
public static java.lang.String addQualifierToPath(java.util.List<java.lang.String> segments, int prefixPathDepth, java.lang.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 java.lang.String adjustPathForReadOrWrite(java.lang.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
- prefixPathLengthoperation
- The operation being performed, e.g. readV2 or writeV1.- Returns:
- The Vault path mutated based on the operation.
-
adjustPathForList
public static java.lang.String adjustPathForList(java.lang.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
- prefixPathDepthoperation
- The operation being performed, e.g. readV2 or writeV1.- Returns:
- The Vault path mutated based on the operation.
-
adjustPathForDelete
public static java.lang.String adjustPathForDelete(java.lang.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
- prefixPathDepthoperation
- The operation being performed, e.g. readV2 or writeV1.- Returns:
- The modified path
-
adjustPathForVersionDelete
public static java.lang.String adjustPathForVersionDelete(java.lang.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 java.lang.String adjustPathForVersionUnDelete(java.lang.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 java.lang.String adjustPathForVersionDestroy(java.lang.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)
In version two, when writing a secret, the JSONObject must be nested with "data" as the key.- Parameters:
operation
- The operation being performed, e.g. writeV1, or writeV2.jsonObject
- The jsonObject that is going to be written.- Returns:
- This jsonObject mutated for the operation.
-
-