diff --git a/nifi-commons/nifi-vault-utils/src/main/java/org/apache/nifi/vault/hashicorp/HashiCorpVaultCommunicationService.java b/nifi-commons/nifi-vault-utils/src/main/java/org/apache/nifi/vault/hashicorp/HashiCorpVaultCommunicationService.java
index 8e9f8c5594..840db72ffa 100644
--- a/nifi-commons/nifi-vault-utils/src/main/java/org/apache/nifi/vault/hashicorp/HashiCorpVaultCommunicationService.java
+++ b/nifi-commons/nifi-vault-utils/src/main/java/org/apache/nifi/vault/hashicorp/HashiCorpVaultCommunicationService.java
@@ -46,39 +46,39 @@ public interface HashiCorpVaultCommunicationService {
byte[] decrypt(String transitPath, String cipherText);
/**
- * Writes a single secret value using Vault's unversioned Key/Value Secrets Engine.
+ * Writes a single secret value using Vault's Key/Value Secrets Engine.
*
- * @see https://www.vaultproject.io/api-docs/secret/kv/kv-v1
- * @param keyValuePath The Vault path to use for the configured Key/Value v1 Secrets Engine
+ * @see https://www.vaultproject.io/api-docs/secret/kv
+ * @param keyValuePath The Vault path to use for the configured Key/Value Secrets Engine
* @param secretKey The secret key
* @param value The secret value
*/
void writeKeyValueSecret(String keyValuePath, String secretKey, String value);
/**
- * Reads a single secret value from Vault's unversioned Key/Value Secrets Engine.
+ * Reads a single secret value from Vault's Key/Value Secrets Engine.
*
- * @see https://www.vaultproject.io/api-docs/secret/kv/kv-v1
- * @param keyValuePath The Vault path to use for the configured Key/Value v1 Secrets Engine
+ * @see https://www.vaultproject.io/api-docs/secret/kv
+ * @param keyValuePath The Vault path to use for the configured Key/Value Secrets Engine
* @param secretKey The secret key
* @return The secret value, or empty if not found
*/
Optional readKeyValueSecret(String keyValuePath, String secretKey);
/**
- * Writes a secret with multiple key/value pairs using Vault's unversioned Key/Value Secrets Engine.
+ * Writes a secret with multiple key/value pairs using Vault's Key/Value Secrets Engine.
*
- * @see https://www.vaultproject.io/api-docs/secret/kv/kv-v1
- * @param keyValuePath The Vault path to use for the configured Key/Value v1 Secrets Engine
+ * @see https://www.vaultproject.io/api-docs/secret/kv
+ * @param keyValuePath The Vault path to use for the configured Key/Value Secrets Engine
* @param keyValues A map from key to value for keys/values that should be stored in the secret
*/
void writeKeyValueSecretMap(String keyValuePath, String secretKey, Map keyValues);
/**
- * Reads a secret with multiple key/value pairs from Vault's unversioned Key/Value Secrets Engine.
+ * Reads a secret with multiple key/value pairs from Vault's Key/Value Secrets Engine.
*
- * @see https://www.vaultproject.io/api-docs/secret/kv/kv-v1
- * @param keyValuePath The Vault path to use for the configured Key/Value v1 Secrets Engine
+ * @see https://www.vaultproject.io/api-docs/secret/kv
+ * @param keyValuePath The Vault path to use for the configured Key/Value Secrets Engine
* @param secretKey The secret key
* @return A map from key to value from the secret key/values, or an empty map if not found
*/
diff --git a/nifi-commons/nifi-vault-utils/src/main/java/org/apache/nifi/vault/hashicorp/StandardHashiCorpVaultCommunicationService.java b/nifi-commons/nifi-vault-utils/src/main/java/org/apache/nifi/vault/hashicorp/StandardHashiCorpVaultCommunicationService.java
index 34508436d3..a407b85eed 100644
--- a/nifi-commons/nifi-vault-utils/src/main/java/org/apache/nifi/vault/hashicorp/StandardHashiCorpVaultCommunicationService.java
+++ b/nifi-commons/nifi-vault-utils/src/main/java/org/apache/nifi/vault/hashicorp/StandardHashiCorpVaultCommunicationService.java
@@ -25,6 +25,7 @@ import org.springframework.core.env.PropertySource;
import org.springframework.vault.authentication.SimpleSessionManager;
import org.springframework.vault.client.ClientHttpRequestFactoryFactory;
import org.springframework.vault.core.VaultKeyValueOperations;
+import org.springframework.vault.core.VaultKeyValueOperationsSupport.KeyValueBackend;
import org.springframework.vault.core.VaultTemplate;
import org.springframework.vault.core.VaultTransitOperations;
import org.springframework.vault.support.Ciphertext;
@@ -37,8 +38,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-import static org.springframework.vault.core.VaultKeyValueOperationsSupport.KeyValueBackend.KV_1;
-
/**
* Implements the VaultCommunicationService using Spring Vault
*/
@@ -46,6 +45,7 @@ public class StandardHashiCorpVaultCommunicationService implements HashiCorpVaul
private final VaultTemplate vaultTemplate;
private final VaultTransitOperations transitOperations;
private final Map keyValueOperationsMap;
+ private final KeyValueBackend keyValueBackend;
/**
* Creates a VaultCommunicationService that uses Spring Vault.
@@ -60,6 +60,7 @@ public class StandardHashiCorpVaultCommunicationService implements HashiCorpVaul
new SimpleSessionManager(vaultConfiguration.clientAuthentication()));
transitOperations = vaultTemplate.opsForTransit();
+ keyValueBackend = vaultConfiguration.getKeyValueBackend();
keyValueOperationsMap = new HashMap<>();
}
@@ -94,7 +95,7 @@ public class StandardHashiCorpVaultCommunicationService implements HashiCorpVaul
Objects.requireNonNull(secretKey, "Secret secretKey must be specified");
Objects.requireNonNull(value, "Secret value must be specified");
final VaultKeyValueOperations keyValueOperations = keyValueOperationsMap
- .computeIfAbsent(keyValuePath, path -> vaultTemplate.opsForKeyValue(path, KV_1));
+ .computeIfAbsent(keyValuePath, path -> vaultTemplate.opsForKeyValue(path, keyValueBackend));
keyValueOperations.put(secretKey, new SecretData(value));
}
@@ -109,7 +110,7 @@ public class StandardHashiCorpVaultCommunicationService implements HashiCorpVaul
Objects.requireNonNull(keyValuePath, "Vault K/V path must be specified");
Objects.requireNonNull(secretKey, "Secret secretKey must be specified");
final VaultKeyValueOperations keyValueOperations = keyValueOperationsMap
- .computeIfAbsent(keyValuePath, path -> vaultTemplate.opsForKeyValue(path, KV_1));
+ .computeIfAbsent(keyValuePath, path -> vaultTemplate.opsForKeyValue(path, keyValueBackend));
final VaultResponseSupport response = keyValueOperations.get(secretKey, SecretData.class);
return response == null ? Optional.empty() : Optional.ofNullable(response.getRequiredData().getValue());
}
@@ -123,14 +124,14 @@ public class StandardHashiCorpVaultCommunicationService implements HashiCorpVaul
return;
}
final VaultKeyValueOperations keyValueOperations = keyValueOperationsMap
- .computeIfAbsent(keyValuePath, path -> vaultTemplate.opsForKeyValue(path, KV_1));
+ .computeIfAbsent(keyValuePath, path -> vaultTemplate.opsForKeyValue(path, keyValueBackend));
keyValueOperations.put(secretKey, keyValues);
}
@Override
public Map readKeyValueSecretMap(final String keyValuePath, final String key) {
final VaultKeyValueOperations keyValueOperations = keyValueOperationsMap
- .computeIfAbsent(keyValuePath, path -> vaultTemplate.opsForKeyValue(path, KV_1));
+ .computeIfAbsent(keyValuePath, path -> vaultTemplate.opsForKeyValue(path, keyValueBackend));
final VaultResponseSupport