Package org.springframework.vault.client
Class VaultClients
java.lang.Object
org.springframework.vault.client.VaultClients
Vault Client factory to create
RestTemplate
configured to the needs of
accessing Vault.- Author:
- Mark Paluch
- See Also:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClientHttpRequestInterceptor
createNamespaceInterceptor
(String namespace) Create aClientHttpRequestInterceptor
that associates each request with aX-Vault-Namespace
header if the header is not present.static RestTemplate
Create aRestTemplate
for Vault interaction.static RestTemplate
createRestTemplate
(VaultEndpointProvider endpointProvider, ClientHttpRequestFactory requestFactory) static RestTemplate
createRestTemplate
(VaultEndpoint endpoint, ClientHttpRequestFactory requestFactory) static UriBuilderFactory
createUriBuilderFactory
(VaultEndpointProvider endpointProvider)
-
Constructor Details
-
VaultClients
public VaultClients()
-
-
Method Details
-
createRestTemplate
public static RestTemplate createRestTemplate(VaultEndpoint endpoint, ClientHttpRequestFactory requestFactory) Create aRestTemplate
configured withVaultEndpoint
andClientHttpRequestFactory
. The template accepts relative URIs without a leading slash that are expanded to useVaultEndpoint
.RestTemplate
is configured with aClientHttpRequestInterceptor
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 aHttpHeaders.CONTENT_LENGTH
request header. Otherwise, Vault will deny body processing.Requires Jackson 2 for Object-to-JSON mapping.
- Parameters:
endpoint
- must not be null.requestFactory
- must not be null.- Returns:
- the
RestTemplate
. - See Also:
-
createRestTemplate
public static RestTemplate createRestTemplate(VaultEndpointProvider endpointProvider, ClientHttpRequestFactory requestFactory) Create aRestTemplate
configured withVaultEndpointProvider
andClientHttpRequestFactory
. The template accepts relative URIs without a leading slash that are expanded to useVaultEndpoint
.RestTemplate
is configured with aClientHttpRequestInterceptor
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 aHttpHeaders.CONTENT_LENGTH
request header. Otherwise, Vault will deny body processing.Requires Jackson 2 for Object-to-JSON mapping.
- Parameters:
endpointProvider
- must not be null.requestFactory
- must not be null.- Returns:
- the
RestTemplate
. - Since:
- 1.1
- See Also:
-
createRestTemplate
Create aRestTemplate
for Vault interaction.RestTemplate
is configured with aClientHttpRequestInterceptor
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 aHttpHeaders.CONTENT_LENGTH
request header. Otherwise, Vault will deny body processing.Requires Jackson 2 for Object-to-JSON mapping.
- Returns:
- the
RestTemplate
. - See Also:
-
createNamespaceInterceptor
Create aClientHttpRequestInterceptor
that associates each request with aX-Vault-Namespace
header if the header is not present.- Parameters:
namespace
- the Vault namespace to use. Must not be null or empty.- Returns:
- the
ClientHttpRequestInterceptor
to register withRestTemplate
. - Since:
- 2.2
- See Also:
-
createUriBuilderFactory
-