public class VaultTemplate extends Object implements InitializingBean, VaultOperations, DisposableBean
VaultTemplate
will log into
Vault on initialization and use the token throughout the whole lifetime.VaultClientFactory
,
SessionManager
VaultOperations.ClientCallback<T>, VaultOperations.SessionCallback<T>, VaultOperations.VaultSession
Constructor and Description |
---|
VaultTemplate()
|
VaultTemplate(VaultClient vaultClient,
ClientAuthentication clientAuthentication)
|
VaultTemplate(VaultClientFactory vaultClientFactory,
SessionManager sessionManager)
|
public VaultTemplate()
public VaultTemplate(VaultClient vaultClient, ClientAuthentication clientAuthentication)
vaultClient
- must not be null.clientAuthentication
- must not be null.public VaultTemplate(VaultClientFactory vaultClientFactory, SessionManager sessionManager)
vaultClientFactory
- must not be null.sessionManager
- must not be null.public void setVaultClientFactory(VaultClientFactory vaultClientFactory)
VaultClientFactory
.vaultClientFactory
- must not be null.public void setSessionManager(SessionManager sessionManager)
SessionManager
.sessionManager
- must not be null.public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
public void destroy() throws Exception
destroy
in interface DisposableBean
Exception
public VaultSysOperations opsForSys()
opsForSys
in interface VaultOperations
public VaultTokenOperations opsForToken()
opsForToken
in interface VaultOperations
public VaultTransitOperations opsForTransit()
opsForTransit
in interface VaultOperations
public VaultTransitOperations opsForTransit(String path)
VaultOperations
VaultTransitOperations
if the transit backend is mounted on a
different path than transit
.opsForTransit
in interface VaultOperations
path
- the mount pathpublic VaultPkiOperations opsForPki()
opsForPki
in interface VaultOperations
public VaultPkiOperations opsForPki(String path)
VaultOperations
VaultPkiOperations
if the PKI backend is mounted on a different
path than pki
.opsForPki
in interface VaultOperations
path
- the mount pathpublic <T> T doWithVault(VaultOperations.ClientCallback<T> clientCallback)
VaultOperations
VaultOperations.ClientCallback
. Allows to interact with Vault using
VaultClient
without requiring a session.doWithVault
in interface VaultOperations
clientCallback
- the request.VaultOperations.ClientCallback
return value.public <T> T doWithVault(VaultOperations.SessionCallback<T> sessionCallback)
VaultOperations
VaultOperations.SessionCallback
. Allows to interact with Vault in an
authenticated session.doWithVault
in interface VaultOperations
sessionCallback
- the request.VaultOperations.SessionCallback
return value.public <T> T doWithRestTemplate(String pathTemplate, Map<String,?> uriVariables, VaultAccessor.RestTemplateCallback<T> callback)
VaultOperations
VaultAccessor.RestTemplateCallback
. Expands the pathTemplate
to an
URI
and allows low-level interaction with the underlying
RestTemplate
.doWithRestTemplate
in interface VaultOperations
pathTemplate
- the path of the resource, e.g. transit/ key
/foo}, must
not be empty or null.uriVariables
- the variables for expansion of the pathTemplate
, must not
be null.callback
- the request callback.VaultAccessor.RestTemplateCallback
return value.public VaultResponse read(String path)
VaultOperations
read
in interface VaultOperations
path
- must not be null.public <T> VaultResponseSupport<T> read(String path, Class<T> responseType)
VaultOperations
read
in interface VaultOperations
path
- must not be null.responseType
- must not be null.public List<String> list(String path)
VaultOperations
list
in interface VaultOperations
path
- must not be null.public VaultResponse write(String path, Object body)
VaultOperations
write
in interface VaultOperations
path
- must not be null.body
- the body, may be null if absent.public void delete(String path)
VaultOperations
delete
in interface VaultOperations
path
- must not be null.Copyright © 2016–2017 Pivotal Software, Inc.. All rights reserved.