Class VaultPropertySource
java.lang.Object
org.springframework.core.env.PropertySource<T>
org.springframework.core.env.EnumerablePropertySource<VaultOperations>
org.springframework.vault.core.env.VaultPropertySource
PropertySource that reads keys and values from a VaultTemplate and
path. Transforms properties after retrieving these from Vault using
PropertyTransformer.- 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
ConstructorsConstructorDescriptionVaultPropertySource(String name, VaultOperations vaultOperations, String path) VaultPropertySource(String name, VaultOperations vaultOperations, String path, PropertyTransformer propertyTransformer) VaultPropertySource(String name, VaultOperations vaultOperations, String path, PropertyTransformer propertyTransformer, boolean ignoreSecretNotFound) VaultPropertySource(VaultOperations vaultOperations, String path) -
Method Summary
Modifier and TypeMethodDescriptiondoGetProperties(String path) Hook method to obtain properties from Vault.doTransformProperties(Map<String, Object> properties) Hook method to transform properties usingPropertyTransformer.flattenMap(Map<String, Object> data) Utility method converting aString/Objectmap to a flatString/Objectmap.@Nullable ObjectgetProperty(String name) String[]protected voidInitialize property source and read properties from Vault.Methods inherited from class org.springframework.core.env.EnumerablePropertySource
containsProperty
-
Constructor Details
-
VaultPropertySource
Create a newVaultPropertySourcegiven aVaultTemplateandpathinside of Vault. This property source loads properties upon construction.- Parameters:
vaultOperations- must not be null.path- the path inside Vault (e.g.secret/myapp/myproperties. Must not be empty or null.
-
VaultPropertySource
Create a newVaultPropertySourcegiven aname,VaultTemplateandpathinside of Vault. This property source loads properties upon construction.- Parameters:
name- name of the property source, must not be null.vaultOperations- must not be null.path- the path inside Vault (e.g.secret/myapp/myproperties. Must not be empty or null.
-
VaultPropertySource
public VaultPropertySource(String name, VaultOperations vaultOperations, String path, PropertyTransformer propertyTransformer) Create a newVaultPropertySourcegiven aname,VaultTemplateandpathinside of Vault. This property source loads properties upon construction and transforms these by applyingPropertyTransformer.- Parameters:
name- name of the property source, must not be null.vaultOperations- must not be null.path- the path inside Vault (e.g.secret/myapp/myproperties. Must not be empty or null.propertyTransformer- object to transform properties.- See Also:
-
VaultPropertySource
public VaultPropertySource(String name, VaultOperations vaultOperations, String path, PropertyTransformer propertyTransformer, boolean ignoreSecretNotFound) Create a newVaultPropertySourcegiven aname,VaultTemplateandpathinside of Vault. This property source loads properties upon construction and transforms these by applyingPropertyTransformer.- Parameters:
name- name of the property source, must not be null.vaultOperations- must not be null.path- the path inside Vault (e.g.secret/myapp/myproperties. Must not be empty or null.propertyTransformer- object to transform properties.ignoreSecretNotFound- indicate if failure to find a secret atpathshould be ignored.- Since:
- 2.2
- See Also:
-
-
Method Details
-
loadProperties
protected void loadProperties()Initialize property source and read properties from Vault. -
getProperty
- Specified by:
getPropertyin classPropertySource<VaultOperations>
-
getPropertyNames
- Specified by:
getPropertyNamesin classEnumerablePropertySource<VaultOperations>
-
doGetProperties
Hook method to obtain properties from Vault.- Parameters:
path- the path, must not be empty or null.- Returns:
- the resulting
Mapor null if properties were not found. - Throws:
VaultException- on problems retrieving properties
-
doTransformProperties
Hook method to transform properties usingPropertyTransformer.- Parameters:
properties- must not be null.- Returns:
- the transformed properties.
-
flattenMap
Utility method converting aString/Objectmap to a flatString/Objectmap. Nested objects are represented with property path keys.- Parameters:
data- the map- Returns:
- the flattened map.
- Since:
- 2.0
-