Class LeaseAwareVaultPropertySource
java.lang.Object
org.springframework.core.env.PropertySource<T>
org.springframework.core.env.EnumerablePropertySource<VaultOperations>
org.springframework.vault.core.env.LeaseAwareVaultPropertySource
PropertySource
that requests renewable secrets from
SecretLeaseContainer
. Leases are renewed or rotated, depeding on
RequestedSecret.getMode()
. Contents of this PropertySource
is updated
from background threads and the content is mutable. Expiration and revocation removes
properties.- Author:
- Mark Paluch
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.core.env.PropertySource
PropertySource.StubPropertySource
-
Field Summary
Fields inherited from class org.springframework.core.env.PropertySource
name, source
-
Constructor Summary
ConstructorDescriptionLeaseAwareVaultPropertySource
(String name, SecretLeaseContainer secretLeaseContainer, RequestedSecret requestedSecret) LeaseAwareVaultPropertySource
(String name, SecretLeaseContainer secretLeaseContainer, RequestedSecret requestedSecret, PropertyTransformer propertyTransformer) LeaseAwareVaultPropertySource
(String name, SecretLeaseContainer secretLeaseContainer, RequestedSecret requestedSecret, PropertyTransformer propertyTransformer, boolean ignoreSecretNotFound) LeaseAwareVaultPropertySource
(SecretLeaseContainer secretLeaseContainer, RequestedSecret requestedSecret) -
Method Summary
Modifier and TypeMethodDescriptiondoTransformProperties
(Map<String, Object> properties) Hook method to transform properties usingPropertyTransformer
.flattenMap
(Map<String, Object> data) Utility method converting aString/Object
map to a flatString/Object
map.getProperty
(String name) String[]
protected void
handleLeaseErrorEvent
(SecretLeaseEvent leaseEvent, Exception exception) Hook method to handle aSecretLeaseEvent
errors.protected void
handleLeaseEvent
(SecretLeaseEvent leaseEvent, Map<String, Object> properties) Hook method to handle aSecretLeaseEvent
.Methods inherited from class org.springframework.core.env.EnumerablePropertySource
containsProperty
-
Constructor Details
-
LeaseAwareVaultPropertySource
public LeaseAwareVaultPropertySource(SecretLeaseContainer secretLeaseContainer, RequestedSecret requestedSecret) Create a newLeaseAwareVaultPropertySource
given aSecretLeaseContainer
andRequestedSecret
. This property source requests the secret upon initialization and receives secrets once they are emitted through events published bySecretLeaseContainer
.- Parameters:
secretLeaseContainer
- must not be null.requestedSecret
- must not be null.
-
LeaseAwareVaultPropertySource
public LeaseAwareVaultPropertySource(String name, SecretLeaseContainer secretLeaseContainer, RequestedSecret requestedSecret) Create a newLeaseAwareVaultPropertySource
given aname
,SecretLeaseContainer
andRequestedSecret
. This property source requests the secret upon initialization and receives secrets once they are emitted through events published bySecretLeaseContainer
.- Parameters:
name
- name of the property source, must not be null.secretLeaseContainer
- must not be null.requestedSecret
- must not be null.
-
LeaseAwareVaultPropertySource
public LeaseAwareVaultPropertySource(String name, SecretLeaseContainer secretLeaseContainer, RequestedSecret requestedSecret, PropertyTransformer propertyTransformer) Create a newLeaseAwareVaultPropertySource
given aname
,SecretLeaseContainer
andRequestedSecret
. This property source requests the secret upon initialization and receives secrets once they are emitted through events published bySecretLeaseContainer
.- Parameters:
name
- name of the property source, must not be null.secretLeaseContainer
- must not be null.requestedSecret
- must not be null.propertyTransformer
- object to transform properties.- See Also:
-
LeaseAwareVaultPropertySource
public LeaseAwareVaultPropertySource(String name, SecretLeaseContainer secretLeaseContainer, RequestedSecret requestedSecret, PropertyTransformer propertyTransformer, boolean ignoreSecretNotFound) Create a newLeaseAwareVaultPropertySource
given aname
,SecretLeaseContainer
andRequestedSecret
. This property source requests the secret upon initialization and receives secrets once they are emitted through events published bySecretLeaseContainer
.- Parameters:
name
- name of the property source, must not be null.secretLeaseContainer
- must not be null.requestedSecret
- must not be null.propertyTransformer
- object to transform properties.ignoreSecretNotFound
- indicate if failure to find a secret atpath
should be ignored.- Since:
- 2.2
- See Also:
-
-
Method Details
-
getRequestedSecret
-
getProperty
- Specified by:
getProperty
in classPropertySource<VaultOperations>
-
getPropertyNames
- Specified by:
getPropertyNames
in classEnumerablePropertySource<VaultOperations>
-
handleLeaseEvent
Hook method to handle aSecretLeaseEvent
.- Parameters:
leaseEvent
- must not be null.properties
- reference to property storage of this property source.
-
handleLeaseErrorEvent
Hook method to handle aSecretLeaseEvent
errors.- Parameters:
leaseEvent
- must not be null.exception
- offending exception.
-
doTransformProperties
Hook method to transform properties usingPropertyTransformer
.- Parameters:
properties
- must not be null.- Returns:
- the transformed properties.
-
flattenMap
Utility method converting aString/Object
map to a flatString/Object
map. Nested objects are represented with property path keys.- Parameters:
data
- the map- Returns:
- the flattened map.
- Since:
- 2.0
-