public class VaultPropertySource extends EnumerablePropertySource<VaultOperations>
PropertySource
that reads keys and values from a VaultTemplate
and
path
. Transforms properties after retrieving these from Vault using
PropertyTransformer
.PropertiesPropertySource
,
PropertyTransformer
,
PropertyTransformers
PropertySource.StubPropertySource
name, source
Constructor and Description |
---|
VaultPropertySource(String name,
VaultOperations vaultOperations,
String path)
|
VaultPropertySource(String name,
VaultOperations vaultOperations,
String path,
PropertyTransformer propertyTransformer)
|
VaultPropertySource(VaultOperations vaultOperations,
String path)
|
Modifier and Type | Method and Description |
---|---|
protected Map<String,Object> |
doGetProperties(String path)
Hook method to obtain properties from Vault.
|
protected Map<String,Object> |
doTransformProperties(Map<String,Object> properties)
Hook method to transform properties using
PropertyTransformer . |
protected Map<String,Object> |
flattenMap(Map<String,Object> data)
Utility method converting a
String/Object map to a flat
String/Object map. |
Object |
getProperty(String name) |
String[] |
getPropertyNames() |
protected void |
loadProperties()
Initialize property source and read properties from Vault.
|
protected Map<String,String> |
toStringMap(Map<String,Object> data)
Deprecated.
since 2.0, use
flattenMap(Map) to retain JSON data types. |
containsProperty
public VaultPropertySource(VaultOperations vaultOperations, String path)
VaultPropertySource
given a VaultTemplate
and
path
inside of Vault. This property source loads properties upon
construction.vaultOperations
- must not be null.path
- the path inside Vault (e.g. secret/myapp/myproperties
. Must not
be empty or null.public VaultPropertySource(String name, VaultOperations vaultOperations, String path)
VaultPropertySource
given a name
,
VaultTemplate
and path
inside of Vault. This property source loads
properties upon construction.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.public VaultPropertySource(String name, VaultOperations vaultOperations, String path, PropertyTransformer propertyTransformer)
VaultPropertySource
given a name
,
VaultTemplate
and path
inside of Vault. This property source loads
properties upon construction and transforms these by applying
PropertyTransformer
.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.PropertyTransformers
protected void loadProperties()
public Object getProperty(String name)
getProperty
in class PropertySource<VaultOperations>
public String[] getPropertyNames()
getPropertyNames
in class EnumerablePropertySource<VaultOperations>
@Nullable protected Map<String,Object> doGetProperties(String path) throws VaultException
path
- the path, must not be empty or null.Map
or null if properties were not found.VaultException
- on problems retrieving propertiesprotected Map<String,Object> doTransformProperties(Map<String,Object> properties)
PropertyTransformer
.properties
- must not be null.@Deprecated protected Map<String,String> toStringMap(Map<String,Object> data)
flattenMap(Map)
to retain JSON data types.String/Object
map to a flat
String/String
map.data
- the mapCopyright © 2016–2018 Pivotal Software, Inc.. All rights reserved.