public class ReactiveVaultTemplate extends Object implements ReactiveVaultOperations
ReactiveVaultTemplate
will log
into Vault on initialization and use the token throughout the whole lifetime.SessionManager
Constructor and Description |
---|
ReactiveVaultTemplate(VaultEndpoint vaultEndpoint,
ClientHttpConnector connector)
|
ReactiveVaultTemplate(VaultEndpoint vaultEndpoint,
ClientHttpConnector connector,
VaultTokenSupplier vaultTokenSupplier)
Create a new
ReactiveVaultTemplate with a VaultEndpoint ,
ClientHttpConnector and VaultTokenSupplier . |
ReactiveVaultTemplate(VaultEndpointProvider endpointProvider,
ClientHttpConnector connector)
|
ReactiveVaultTemplate(VaultEndpointProvider endpointProvider,
ClientHttpConnector connector,
VaultTokenSupplier vaultTokenSupplier)
Create a new
ReactiveVaultTemplate with a VaultEndpointProvider ,
ClientHttpConnector and VaultTokenSupplier . |
ReactiveVaultTemplate(WebClientBuilder webClientBuilder)
Create a new
ReactiveVaultTemplate through a WebClientBuilder . |
ReactiveVaultTemplate(WebClientBuilder webClientBuilder,
VaultTokenSupplier vaultTokenSupplier)
|
Modifier and Type | Method and Description |
---|---|
Mono<Void> |
delete(String path)
Delete a path.
|
protected WebClient |
doCreateSessionWebClient(VaultEndpointProvider endpointProvider,
ClientHttpConnector connector)
Create a session-bound
WebClient to be used by VaultTemplate for
Vault communication given VaultEndpointProvider and
ClientHttpConnector for calls that require an authenticated context. |
protected WebClient |
doCreateWebClient(VaultEndpointProvider endpointProvider,
ClientHttpConnector connector)
Create a
WebClient to be used by ReactiveVaultTemplate for Vault
communication given VaultEndpointProvider and ClientHttpConnector . |
<V,T extends org.reactivestreams.Publisher<V>> |
doWithSession(Function<WebClient,? extends T> sessionCallback)
Executes a Vault
RestOperationsCallback . |
<V,T extends org.reactivestreams.Publisher<V>> |
doWithVault(Function<WebClient,? extends T> clientCallback)
Executes a Vault
RestOperationsCallback . |
Flux<String> |
list(String path)
Enumerate keys from a Vault path.
|
Mono<VaultResponse> |
read(String path)
Read from a Vault path.
|
<T> Mono<VaultResponseSupport<T>> |
read(String path,
Class<T> responseType)
Read from a Vault path.
|
Mono<VaultResponse> |
write(String path,
Object body)
Write to a Vault path.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
write
public ReactiveVaultTemplate(VaultEndpoint vaultEndpoint, ClientHttpConnector connector)
ReactiveVaultTemplate
with a VaultEndpoint
,
ClientHttpConnector
. This constructor does not use a
VaultTokenSupplier
. 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.connector
- must not be null.public ReactiveVaultTemplate(VaultEndpoint vaultEndpoint, ClientHttpConnector connector, VaultTokenSupplier vaultTokenSupplier)
ReactiveVaultTemplate
with a VaultEndpoint
,
ClientHttpConnector
and VaultTokenSupplier
.vaultEndpoint
- must not be null.connector
- must not be null.vaultTokenSupplier
- must not be null.public ReactiveVaultTemplate(VaultEndpointProvider endpointProvider, ClientHttpConnector connector)
ReactiveVaultTemplate
with a VaultEndpointProvider
and
ClientHttpConnector
. This constructor does not use a
VaultTokenSupplier
. 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.connector
- must not be null.public ReactiveVaultTemplate(VaultEndpointProvider endpointProvider, ClientHttpConnector connector, VaultTokenSupplier vaultTokenSupplier)
ReactiveVaultTemplate
with a VaultEndpointProvider
,
ClientHttpConnector
and VaultTokenSupplier
.endpointProvider
- must not be null.connector
- must not be null.vaultTokenSupplier
- must not be null.public ReactiveVaultTemplate(WebClientBuilder webClientBuilder)
ReactiveVaultTemplate
through a WebClientBuilder
. This
constructor does not use a VaultTokenSupplier
. It is intended for usage
with Vault Agent to inherit Vault Agent's authentication without using the
authentication token header
.webClientBuilder
- must not be null.public ReactiveVaultTemplate(WebClientBuilder webClientBuilder, VaultTokenSupplier vaultTokenSupplier)
webClientBuilder
- must not be null.vaultTokenSupplier
- must not be nullprotected WebClient doCreateWebClient(VaultEndpointProvider endpointProvider, ClientHttpConnector connector)
WebClient
to be used by ReactiveVaultTemplate
for Vault
communication given VaultEndpointProvider
and ClientHttpConnector
.
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 WebClient
.endpointProvider
- must not be null.connector
- must not be null.WebClient
used for Vault communication.protected WebClient doCreateSessionWebClient(VaultEndpointProvider endpointProvider, ClientHttpConnector connector)
WebClient
to be used by VaultTemplate
for
Vault communication given VaultEndpointProvider
and
ClientHttpConnector
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 WebClient
.endpointProvider
- must not be null.connector
- must not be null.WebClient
used for Vault communication.public Mono<VaultResponse> read(String path)
ReactiveVaultOperations
read
in interface ReactiveVaultOperations
path
- must not be null.public <T> Mono<VaultResponseSupport<T>> read(String path, Class<T> responseType)
ReactiveVaultOperations
read
in interface ReactiveVaultOperations
path
- must not be null.responseType
- must not be null.public Flux<String> list(String path)
ReactiveVaultOperations
list
in interface ReactiveVaultOperations
path
- must not be null.public Mono<VaultResponse> write(String path, @Nullable Object body)
ReactiveVaultOperations
write
in interface ReactiveVaultOperations
path
- must not be null.body
- the body, may be null if absent.public Mono<Void> delete(String path)
ReactiveVaultOperations
delete
in interface ReactiveVaultOperations
path
- must not be null.public <V,T extends org.reactivestreams.Publisher<V>> T doWithVault(Function<WebClient,? extends T> clientCallback) throws VaultException, WebClientException
ReactiveVaultOperations
RestOperationsCallback
. Allows to interact with Vault
using RestOperations
without requiring a
session.doWithVault
in interface ReactiveVaultOperations
clientCallback
- the request.RestOperationsCallback
return value.VaultException
- when a
HttpStatusCodeException
occurs.WebClientException
- exceptions from
WebClient
.public <V,T extends org.reactivestreams.Publisher<V>> T doWithSession(Function<WebClient,? extends T> sessionCallback) throws VaultException, WebClientException
ReactiveVaultOperations
RestOperationsCallback
. Allows to interact with Vault in
an authenticated session.doWithSession
in interface ReactiveVaultOperations
sessionCallback
- the request.RestOperationsCallback
return value.VaultException
- when a
HttpStatusCodeException
occurs.WebClientException
- exceptions from
WebClient
.Copyright © 2016–2021 Pivotal Software, Inc.. All rights reserved.