Package craterdog.security
Class EncryptedPropertyConfigurer
java.lang.Object
org.springframework.core.io.support.PropertiesLoaderSupport
org.springframework.beans.factory.config.PropertyResourceConfigurer
org.springframework.beans.factory.config.PlaceholderConfigurerSupport
org.springframework.context.support.PropertySourcesPlaceholderConfigurer
craterdog.security.EncryptedPropertyConfigurer
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.config.BeanFactoryPostProcessor,org.springframework.context.EnvironmentAware,org.springframework.core.Ordered,org.springframework.core.PriorityOrdered
public class EncryptedPropertyConfigurer
extends org.springframework.context.support.PropertySourcesPlaceholderConfigurer
This class overrides the functionality of the Spring framework's PropertyPlaceHolderConfigurer
class to handle encrypted properties.
- Author:
- Derk Norton
-
Field Summary
Fields inherited from class org.springframework.context.support.PropertySourcesPlaceholderConfigurer
ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, LOCAL_PROPERTIES_PROPERTY_SOURCE_NAMEFields inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport
DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, trimValues, valueSeparatorFields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
localOverride, localProperties, loggerFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor uses the default base 64 encoded secret key for doing the encryption.EncryptedPropertyConfigurer(String encodedKey) This constructor uses a user specified base 64 encoded secret key for doing the encryption. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringconvertPropertyValue(String propertyValue) This method decrypts a base 64 encoded, AES-128 encrypted, property value that is prefixed with "{AES-128}".protected voiddoProcessProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactoryToProcess, org.springframework.util.StringValueResolver valueResolver) This is method is needed because of https://jira.springsource.org/browse/SPR-8928encryptPropertyValue(String propertyValue) This method encrypts a property value in such a way that it can be placed in a properties file and automatically decrypted using this placeholder configurer.Methods inherited from class org.springframework.context.support.PropertySourcesPlaceholderConfigurer
getAppliedPropertySources, postProcessBeanFactory, processProperties, processProperties, setEnvironment, setPropertySourcesMethods inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport
setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setTrimValues, setValueSeparatorMethods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer
convertProperties, convertProperty, getOrder, setOrderMethods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister
-
Constructor Details
-
EncryptedPropertyConfigurer
public EncryptedPropertyConfigurer()The default constructor uses the default base 64 encoded secret key for doing the encryption. -
EncryptedPropertyConfigurer
This constructor uses a user specified base 64 encoded secret key for doing the encryption.- Parameters:
encodedKey- The base 64 encoded string containing the AES-128 secret key for encryption.
-
-
Method Details
-
encryptPropertyValue
This method encrypts a property value in such a way that it can be placed in a properties file and automatically decrypted using this placeholder configurer.- Parameters:
propertyValue- The property value to be encrypted.- Returns:
- The encrypted property value.
-
doProcessProperties
protected void doProcessProperties(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactoryToProcess, org.springframework.util.StringValueResolver valueResolver) This is method is needed because of https://jira.springsource.org/browse/SPR-8928- Overrides:
doProcessPropertiesin classorg.springframework.beans.factory.config.PlaceholderConfigurerSupport- Parameters:
beanFactoryToProcess- The factory to be used for the processing.valueResolver- The value resolver to be used.
-
convertPropertyValue
This method decrypts a base 64 encoded, AES-128 encrypted, property value that is prefixed with "{AES-128}".- Overrides:
convertPropertyValuein classorg.springframework.beans.factory.config.PropertyResourceConfigurer- Parameters:
propertyValue- The property value to be decrypted.- Returns:
- The decrypted property value.
-