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_NAME

    Fields inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport

    DEFAULT_PLACEHOLDER_PREFIX, DEFAULT_PLACEHOLDER_SUFFIX, DEFAULT_VALUE_SEPARATOR, ignoreUnresolvablePlaceholders, nullValue, placeholderPrefix, placeholderSuffix, trimValues, valueSeparator

    Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport

    localOverride, localProperties, logger

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    The default constructor uses the default base 64 encoded secret key for doing the encryption.
    This constructor uses a user specified base 64 encoded secret key for doing the encryption.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected String
    This method decrypts a base 64 encoded, AES-128 encrypted, property value that is prefixed with "{AES-128}".
    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
    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, setPropertySources

    Methods inherited from class org.springframework.beans.factory.config.PlaceholderConfigurerSupport

    setBeanFactory, setBeanName, setIgnoreUnresolvablePlaceholders, setNullValue, setPlaceholderPrefix, setPlaceholderSuffix, setTrimValues, setValueSeparator

    Methods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer

    convertProperties, convertProperty, getOrder, setOrder

    Methods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport

    loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesArray, setPropertiesPersister

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EncryptedPropertyConfigurer

      public EncryptedPropertyConfigurer()
      The default constructor uses the default base 64 encoded secret key for doing the encryption.
    • EncryptedPropertyConfigurer

      public EncryptedPropertyConfigurer(String encodedKey)
      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

      public String encryptPropertyValue(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.
      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:
      doProcessProperties in class org.springframework.beans.factory.config.PlaceholderConfigurerSupport
      Parameters:
      beanFactoryToProcess - The factory to be used for the processing.
      valueResolver - The value resolver to be used.
    • convertPropertyValue

      protected String convertPropertyValue(String propertyValue)
      This method decrypts a base 64 encoded, AES-128 encrypted, property value that is prefixed with "{AES-128}".
      Overrides:
      convertPropertyValue in class org.springframework.beans.factory.config.PropertyResourceConfigurer
      Parameters:
      propertyValue - The property value to be decrypted.
      Returns:
      The decrypted property value.