All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.vault.runtime.VaultKvManager Maven / Gradle / Ivy

There is a newer version: 3.0.0.Beta1
Show newest version
package io.quarkus.vault.runtime;

import java.util.Map;

import io.quarkus.vault.VaultKVSecretEngine;
import io.quarkus.vault.runtime.client.VaultClient;
import io.quarkus.vault.runtime.config.VaultRuntimeConfig;

public class VaultKvManager implements VaultKVSecretEngine {

    private VaultAuthManager vaultAuthManager;
    private VaultClient vaultClient;
    private VaultRuntimeConfig serverConfig;

    public VaultKvManager(VaultAuthManager vaultAuthManager, VaultClient vaultClient, VaultRuntimeConfig serverConfig) {
        this.vaultAuthManager = vaultAuthManager;
        this.vaultClient = vaultClient;
        this.serverConfig = serverConfig;
    }

    @Override
    public Map readSecret(String path) {

        String clientToken = vaultAuthManager.getClientToken();
        String mount = serverConfig.kvSecretEngineMountPath;

        if (serverConfig.kvSecretEngineVersion == 1) {
            return vaultClient.getSecretV1(clientToken, mount, path).data;
        } else {
            return vaultClient.getSecretV2(clientToken, mount, path).data.data;
        }
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy