public class VaultClients extends Object
RestTemplate
configured to the needs of
accessing Vault.VaultEndpoint
,
RestTemplate
Modifier and Type | Class and Description |
---|---|
static class |
VaultClients.PrefixAwareUriBuilderFactory |
static class |
VaultClients.PrefixAwareUriTemplateHandler |
Constructor and Description |
---|
VaultClients() |
Modifier and Type | Method and Description |
---|---|
static ClientHttpRequestInterceptor |
createNamespaceInterceptor(String namespace)
Create a
ClientHttpRequestInterceptor that associates each request with a
X-Vault-Namespace header if the header is not present. |
static RestTemplate |
createRestTemplate()
Create a
RestTemplate for Vault interaction. |
static RestTemplate |
createRestTemplate(VaultEndpoint endpoint,
ClientHttpRequestFactory requestFactory)
|
static RestTemplate |
createRestTemplate(VaultEndpointProvider endpointProvider,
ClientHttpRequestFactory requestFactory)
|
static UriBuilderFactory |
createUriBuilderFactory(VaultEndpointProvider endpointProvider) |
public static RestTemplate createRestTemplate(VaultEndpoint endpoint, ClientHttpRequestFactory requestFactory)
RestTemplate
configured with VaultEndpoint
and
ClientHttpRequestFactory
. The template accepts relative URIs without a
leading slash that are expanded to use VaultEndpoint
. RestTemplate
is configured with a ClientHttpRequestInterceptor
to enforce serialization
to a byte array prior continuing the request. Eager serialization leads to a known
request body size that is required to send a
HttpHeaders.CONTENT_LENGTH
request header.
Otherwise, Vault will deny body processing.
Requires Jackson 2 for Object-to-JSON mapping.
endpoint
- must not be null.requestFactory
- must not be null.RestTemplate
.Netty4ClientHttpRequestFactory
,
MappingJackson2HttpMessageConverter
public static RestTemplate createRestTemplate(VaultEndpointProvider endpointProvider, ClientHttpRequestFactory requestFactory)
RestTemplate
configured with VaultEndpointProvider
and
ClientHttpRequestFactory
. The template accepts relative URIs without a
leading slash that are expanded to use VaultEndpoint
. RestTemplate
is configured with a ClientHttpRequestInterceptor
to enforce serialization
to a byte array prior continuing the request. Eager serialization leads to a known
request body size that is required to send a
HttpHeaders.CONTENT_LENGTH
request header.
Otherwise, Vault will deny body processing.
Requires Jackson 2 for Object-to-JSON mapping.
endpointProvider
- must not be null.requestFactory
- must not be null.RestTemplate
.Netty4ClientHttpRequestFactory
,
MappingJackson2HttpMessageConverter
public static RestTemplate createRestTemplate()
RestTemplate
for Vault interaction. RestTemplate
is
configured with a ClientHttpRequestInterceptor
to enforce serialization to
a byte array prior continuing the request. Eager serialization leads to a known
request body size that is required to send a
HttpHeaders.CONTENT_LENGTH
request header.
Otherwise, Vault will deny body processing.
Requires Jackson 2 for Object-to-JSON mapping.
RestTemplate
.Netty4ClientHttpRequestFactory
,
MappingJackson2HttpMessageConverter
public static ClientHttpRequestInterceptor createNamespaceInterceptor(String namespace)
ClientHttpRequestInterceptor
that associates each request with a
X-Vault-Namespace
header if the header is not present.namespace
- the Vault namespace to use. Must not be null or empty.ClientHttpRequestInterceptor
to register with
RestTemplate
.VaultHttpHeaders.VAULT_NAMESPACE
public static UriBuilderFactory createUriBuilderFactory(VaultEndpointProvider endpointProvider)
Copyright © 2016–2021 Pivotal Software, Inc.. All rights reserved.