Skip to content

Instantly share code, notes, and snippets.

@Mishco
Created June 2, 2022 07:41
Show Gist options
  • Save Mishco/9422229e473079e69259c20fd45932b7 to your computer and use it in GitHub Desktop.
Save Mishco/9422229e473079e69259c20fd45932b7 to your computer and use it in GitHub Desktop.
@Service
public class CredentialsService {
private VaultTemplate vaultTemplate;
public void secureCredentials(String storagePlace, Credentials credentials) {
initVaultTemplate();
vaultTemplate.write("kv/" + storagePlace, credentials);
}
public Credentials accessCredentials(String nameOfsecrets) {
initVaultTemplate();
VaultResponseSupport<Credentials> response = vaultTemplate.read("kv/" + nameOfsecrets, Credentials.class);
return response.getData();
}
public void deleteCredentials(String name) {
initVaultTemplate();
vaultTemplate.delete("kv/" + name);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment