public class VaultTemplate extends Object implements org.springframework.beans.factory.InitializingBean, VaultOperations, org.springframework.beans.factory.DisposableBean
VaultTemplate will log into
Vault on initialization and use the token throughout the whole lifetime.SessionManager| Constructor and Description |
|---|
VaultTemplate(RestTemplateBuilder restTemplateBuilder)
|
VaultTemplate(RestTemplateBuilder restTemplateBuilder,
SessionManager sessionManager)
|
VaultTemplate(VaultEndpoint vaultEndpoint)
Create a new
VaultTemplate with a VaultEndpoint. |
VaultTemplate(VaultEndpoint vaultEndpoint,
ClientAuthentication clientAuthentication)
|
VaultTemplate(VaultEndpoint vaultEndpoint,
org.springframework.http.client.ClientHttpRequestFactory clientHttpRequestFactory)
|
VaultTemplate(VaultEndpoint vaultEndpoint,
org.springframework.http.client.ClientHttpRequestFactory clientHttpRequestFactory,
SessionManager sessionManager)
|
VaultTemplate(VaultEndpointProvider endpointProvider,
org.springframework.http.client.ClientHttpRequestFactory requestFactory)
Create a new
VaultTemplate with a VaultEndpointProvider,
ClientHttpRequestFactory and SessionManager. |
VaultTemplate(VaultEndpointProvider endpointProvider,
org.springframework.http.client.ClientHttpRequestFactory requestFactory,
SessionManager sessionManager)
Create a new
VaultTemplate with a VaultEndpointProvider,
ClientHttpRequestFactory and SessionManager. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
void |
delete(String path)
Delete a path.
|
void |
destroy() |
protected org.springframework.web.client.RestTemplate |
doCreateRestTemplate(VaultEndpointProvider endpointProvider,
org.springframework.http.client.ClientHttpRequestFactory requestFactory)
Create a
RestTemplate to be used by VaultTemplate for Vault
communication given VaultEndpointProvider and
ClientHttpRequestFactory. |
protected org.springframework.web.client.RestTemplate |
doCreateSessionTemplate(VaultEndpointProvider endpointProvider,
org.springframework.http.client.ClientHttpRequestFactory requestFactory)
Create a session-bound
RestTemplate to be used by VaultTemplate for
Vault communication given VaultEndpointProvider and
ClientHttpRequestFactory for calls that require an authenticated context. |
<T> T |
doWithSession(RestOperationsCallback<T> sessionCallback)
Executes a Vault
RestOperationsCallback. |
<T> T |
doWithVault(RestOperationsCallback<T> clientCallback)
Executes a Vault
RestOperationsCallback. |
List<String> |
list(String path)
Enumerate keys from a Vault path.
|
VaultKeyValueOperations |
opsForKeyValue(String path,
VaultKeyValueOperationsSupport.KeyValueBackend apiVersion)
Return
VaultKeyValueOperations. |
VaultPkiOperations |
opsForPki() |
VaultPkiOperations |
opsForPki(String path)
Return
VaultPkiOperations if the PKI backend is mounted on a different path
than pki. |
VaultSysOperations |
opsForSys() |
VaultTokenOperations |
opsForToken() |
VaultTransformOperations |
opsForTransform() |
VaultTransformOperations |
opsForTransform(String path)
Return
VaultTransformOperations if the transit backend is mounted on a
different path than transform. |
VaultTransitOperations |
opsForTransit() |
VaultTransitOperations |
opsForTransit(String path)
Return
VaultTransitOperations if the transit backend is mounted on a
different path than transit. |
VaultVersionedKeyValueOperations |
opsForVersionedKeyValue(String path)
Return
VaultVersionedKeyValueOperations. |
VaultWrappingOperations |
opsForWrapping() |
VaultResponse |
read(String path)
Read from a Vault path.
|
<T> VaultResponseSupport<T> |
read(String path,
Class<T> responseType)
Read from a secret backend.
|
void |
setSessionManager(SessionManager sessionManager)
Set the
SessionManager. |
VaultResponse |
write(String path,
Object body)
Write to a Vault path.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwritepublic VaultTemplate(VaultEndpoint vaultEndpoint)
VaultTemplate with a VaultEndpoint. This constructor
does not use a ClientAuthentication mechanism. It is intended for usage
with Vault Agent to inherit Vault Agent's authentication without using the
authentication token header.vaultEndpoint - must not be null.public VaultTemplate(VaultEndpoint vaultEndpoint, ClientAuthentication clientAuthentication)
vaultEndpoint - must not be null.clientAuthentication - must not be null.public VaultTemplate(VaultEndpoint vaultEndpoint, org.springframework.http.client.ClientHttpRequestFactory clientHttpRequestFactory)
VaultTemplate with a VaultEndpoint, and
ClientHttpRequestFactory. This constructor does not use a
ClientAuthentication mechanism. It is intended for usage with Vault Agent
to inherit Vault Agent's authentication without using the
authentication token header.vaultEndpoint - must not be null.clientHttpRequestFactory - must not be null.public VaultTemplate(VaultEndpoint vaultEndpoint, org.springframework.http.client.ClientHttpRequestFactory clientHttpRequestFactory, SessionManager sessionManager)
vaultEndpoint - must not be null.clientHttpRequestFactory - must not be null.sessionManager - must not be null.public VaultTemplate(VaultEndpointProvider endpointProvider, org.springframework.http.client.ClientHttpRequestFactory requestFactory)
VaultTemplate with a VaultEndpointProvider,
ClientHttpRequestFactory and SessionManager. This constructor does
not use a ClientAuthentication mechanism. It is intended for usage with
Vault Agent to inherit Vault Agent's authentication without using the
authentication token header.endpointProvider - must not be null.requestFactory - must not be null.public VaultTemplate(VaultEndpointProvider endpointProvider, org.springframework.http.client.ClientHttpRequestFactory requestFactory, SessionManager sessionManager)
VaultTemplate with a VaultEndpointProvider,
ClientHttpRequestFactory and SessionManager.endpointProvider - must not be null.requestFactory - must not be null.sessionManager - must not be null.public VaultTemplate(RestTemplateBuilder restTemplateBuilder)
VaultTemplate through a RestTemplateBuilder and
SessionManager. This constructor does not use a
ClientAuthentication mechanism. It is intended for usage with Vault Agent
to inherit Vault Agent's authentication without using the
authentication token header.restTemplateBuilder - must not be null.public VaultTemplate(RestTemplateBuilder restTemplateBuilder, SessionManager sessionManager)
restTemplateBuilder - must not be null.sessionManager - must not be null.protected org.springframework.web.client.RestTemplate doCreateRestTemplate(VaultEndpointProvider endpointProvider, org.springframework.http.client.ClientHttpRequestFactory requestFactory)
RestTemplate to be used by VaultTemplate for Vault
communication given VaultEndpointProvider and
ClientHttpRequestFactory. VaultEndpointProvider is used to
contribute host and port details for relative URLs typically used by the Template
API. Subclasses may override this method to customize the RestTemplate.endpointProvider - must not be null.requestFactory - must not be null.RestTemplate used for Vault communication.protected org.springframework.web.client.RestTemplate doCreateSessionTemplate(VaultEndpointProvider endpointProvider, org.springframework.http.client.ClientHttpRequestFactory requestFactory)
RestTemplate to be used by VaultTemplate for
Vault communication given VaultEndpointProvider and
ClientHttpRequestFactory for calls that require an authenticated context.
VaultEndpointProvider is used to contribute host and port details for
relative URLs typically used by the Template API. Subclasses may override this
method to customize the RestTemplate.endpointProvider - must not be null.requestFactory - must not be null.RestTemplate used for Vault communication.public void setSessionManager(SessionManager sessionManager)
SessionManager.sessionManager - must not be null.public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionpublic VaultKeyValueOperations opsForKeyValue(String path, VaultKeyValueOperationsSupport.KeyValueBackend apiVersion)
VaultOperationsVaultKeyValueOperations.opsForKeyValue in interface VaultOperationspath - the mount path, must not be empty or null.apiVersion - API version to use, must not be null.public VaultVersionedKeyValueOperations opsForVersionedKeyValue(String path)
VaultOperationsVaultVersionedKeyValueOperations.opsForVersionedKeyValue in interface VaultOperationspath - the mount pathpublic VaultPkiOperations opsForPki()
opsForPki in interface VaultOperationspublic VaultPkiOperations opsForPki(String path)
VaultOperationsVaultPkiOperations if the PKI backend is mounted on a different path
than pki.opsForPki in interface VaultOperationspath - the mount pathpublic VaultSysOperations opsForSys()
opsForSys in interface VaultOperationspublic VaultTokenOperations opsForToken()
opsForToken in interface VaultOperationspublic VaultTransformOperations opsForTransform()
opsForTransform in interface VaultOperationspublic VaultTransformOperations opsForTransform(String path)
VaultOperationsVaultTransformOperations if the transit backend is mounted on a
different path than transform.opsForTransform in interface VaultOperationspath - the mount pathpublic VaultTransitOperations opsForTransit()
opsForTransit in interface VaultOperationspublic VaultTransitOperations opsForTransit(String path)
VaultOperationsVaultTransitOperations if the transit backend is mounted on a
different path than transit.opsForTransit in interface VaultOperationspath - the mount pathpublic VaultWrappingOperations opsForWrapping()
opsForWrapping in interface VaultOperationspublic VaultResponse read(String path)
VaultOperationsread in interface VaultOperationspath - must not be null.@Nullable public <T> VaultResponseSupport<T> read(String path, Class<T> responseType)
VaultOperationsread in interface VaultOperationspath - must not be null.responseType - must not be null.@Nullable public List<String> list(String path)
VaultOperationslist in interface VaultOperationspath - must not be null.@Nullable public VaultResponse write(String path, @Nullable Object body)
VaultOperationswrite in interface VaultOperationspath - must not be null.body - the body, may be null if absent.public void delete(String path)
VaultOperationsdelete in interface VaultOperationspath - must not be null.public <T> T doWithVault(RestOperationsCallback<T> clientCallback)
VaultOperationsRestOperationsCallback. Allows to interact with Vault
using RestOperations without requiring a
session.doWithVault in interface VaultOperationsclientCallback - the request.RestOperationsCallback return value.public <T> T doWithSession(RestOperationsCallback<T> sessionCallback)
VaultOperationsRestOperationsCallback. Allows to interact with Vault in
an authenticated session.doWithSession in interface VaultOperationssessionCallback - the request.RestOperationsCallback return value.Copyright © 2016–2024 Pivotal Software, Inc.. All rights reserved.