Package org.springframework.vault.config
Class AbstractVaultConfiguration
java.lang.Object
org.springframework.vault.config.AbstractVaultConfiguration
- All Implemented Interfaces:
Aware
,ApplicationContextAware
- Direct Known Subclasses:
AbstractReactiveVaultConfiguration
,EnvironmentVaultConfiguration
@Configuration(proxyBeanMethods=false)
public abstract class AbstractVaultConfiguration
extends Object
implements ApplicationContextAware
Base class for Spring Vault configuration using JavaConfig.
- Author:
- Spencer Gibb, Mark Paluch
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Wrapper forClientHttpRequestFactory
to not expose the bean globally.static class
Wrapper to keepThreadPoolTaskScheduler
local to Spring Vault and to not expose the bean globally. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract ClientAuthentication
Annotate withBean
in case you want to expose aClientAuthentication
instance to theApplicationContext
.Create aAbstractVaultConfiguration.ClientFactoryWrapper
containing aClientHttpRequestFactory
.protected BeanFactory
protected Environment
Return theEnvironment
to access property sources during Spring Vault bootstrapping.protected RestTemplateFactory
Return theRestTemplateFactory
.protected ThreadPoolTaskScheduler
Construct aRestOperations
object configured for Vault session management and authentication usage.protected RestTemplateBuilder
restTemplateBuilder
(VaultEndpointProvider endpointProvider, ClientHttpRequestFactory requestFactory) restTemplateFactory
(AbstractVaultConfiguration.ClientFactoryWrapper requestFactoryWrapper) Create aRestTemplateFactory
bean that is used to produceRestTemplate
.Construct aLifecycleAwareSessionManager
usingclientAuthentication()
.void
setApplicationContext
(ApplicationContext applicationContext) Create aAbstractVaultConfiguration.TaskSchedulerWrapper
used byLifecycleAwareSessionManager
andSecretLeaseContainer
wrappingThreadPoolTaskScheduler
.abstract VaultEndpoint
Create aVaultTemplate
.
-
Constructor Details
-
AbstractVaultConfiguration
public AbstractVaultConfiguration()
-
-
Method Details
-
vaultEndpoint
- Returns:
- Vault endpoint coordinates for HTTP/HTTPS communication, must not be null.
-
vaultEndpointProvider
- Returns:
- a
VaultEndpointProvider
returning the value ofvaultEndpoint()
. - Since:
- 1.1
-
clientAuthentication
Annotate withBean
in case you want to expose aClientAuthentication
instance to theApplicationContext
.- Returns:
- the
ClientAuthentication
to use. Must not be null.
-
restTemplateBuilder
protected RestTemplateBuilder restTemplateBuilder(VaultEndpointProvider endpointProvider, ClientHttpRequestFactory requestFactory) Create aRestTemplateBuilder
initialized withVaultEndpointProvider
andClientHttpRequestFactory
. May be overridden by subclasses.- Returns:
- the
RestTemplateBuilder
. - Since:
- 2.3
- See Also:
-
restTemplateFactory
@Bean public RestTemplateFactory restTemplateFactory(AbstractVaultConfiguration.ClientFactoryWrapper requestFactoryWrapper) Create aRestTemplateFactory
bean that is used to produceRestTemplate
.- Returns:
- the
RestTemplateFactory
. - Since:
- 2.3
- See Also:
-
vaultTemplate
Create aVaultTemplate
.- Returns:
- the
VaultTemplate
. - See Also:
-
sessionManager
Construct aLifecycleAwareSessionManager
usingclientAuthentication()
. ThisSessionManager
usesthreadPoolTaskScheduler()
.- Returns:
- the
SessionManager
for Vault session management. - See Also:
-
secretLeaseContainer
- Returns:
- the
SecretLeaseContainer
to allocate, renew and rotate secrets and their leases. - Throws:
Exception
- See Also:
-
threadPoolTaskScheduler
@Bean("vaultThreadPoolTaskScheduler") public AbstractVaultConfiguration.TaskSchedulerWrapper threadPoolTaskScheduler()Create aAbstractVaultConfiguration.TaskSchedulerWrapper
used byLifecycleAwareSessionManager
andSecretLeaseContainer
wrappingThreadPoolTaskScheduler
. Subclasses may override this method to reuse a different/existing scheduler.- Returns:
- the
AbstractVaultConfiguration.TaskSchedulerWrapper
to use. Must not be null. - See Also:
-
restOperations
Construct aRestOperations
object configured for Vault session management and authentication usage. Can be customized by providing aRestTemplateFactory
bean.- Returns:
- the
RestOperations
to be used for Vault access. - See Also:
-
clientHttpRequestFactoryWrapper
Create aAbstractVaultConfiguration.ClientFactoryWrapper
containing aClientHttpRequestFactory
.ClientHttpRequestFactory
is not exposed as root bean becauseClientHttpRequestFactory
is configured withClientOptions
andSslConfiguration
which are not necessarily applicable for the whole application.- Returns:
- the
AbstractVaultConfiguration.ClientFactoryWrapper
to wrap aClientHttpRequestFactory
instance. - See Also:
-
clientOptions
- Returns:
ClientOptions
to configure communication parameters.- See Also:
-
sslConfiguration
- Returns:
- SSL configuration options. Defaults to
SslConfiguration.unconfigured()
. - See Also:
-
getEnvironment
Return theEnvironment
to access property sources during Spring Vault bootstrapping. RequiresApplicationContext
to be set.- Returns:
- the
Environment
to access property sources during Spring Vault bootstrapping.
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
getRestTemplateFactory
Return theRestTemplateFactory
.- Returns:
- the
RestTemplateFactory
bean. - Since:
- 2.3
-
getVaultThreadPoolTaskScheduler
-
getBeanFactory
-