Class StandardEncryptableServletEnvironment

java.lang.Object
org.springframework.core.env.AbstractEnvironment
org.springframework.core.env.StandardEnvironment
org.springframework.web.context.support.StandardServletEnvironment
com.ulisesbocchio.jasyptspringboot.environment.StandardEncryptableServletEnvironment
All Implemented Interfaces:
EncryptableEnvironment, org.springframework.core.env.ConfigurableEnvironment, org.springframework.core.env.ConfigurablePropertyResolver, org.springframework.core.env.Environment, org.springframework.core.env.PropertyResolver, org.springframework.web.context.ConfigurableWebEnvironment

public class StandardEncryptableServletEnvironment extends org.springframework.web.context.support.StandardServletEnvironment implements org.springframework.core.env.ConfigurableEnvironment, EncryptableEnvironment
A custom ConfigurableEnvironment that is useful for early access of encrypted properties on bootstrap. While not required in most scenarios could be useful when customizing Spring Boot's init behavior or integrating with certain capabilities that are configured very early, such as Logging configuration. For a concrete example, this method of enabling encryptable properties is the only one that works with Spring Properties replacement in logback-spring.xml files, using the springProperty tag
Version:
$Id: $Id
Author:
Sergio.U.Bocchio
  • Field Summary

    Fields inherited from class org.springframework.web.context.support.StandardServletEnvironment

    JNDI_PROPERTY_SOURCE_NAME, SERVLET_CONFIG_PROPERTY_SOURCE_NAME, SERVLET_CONTEXT_PROPERTY_SOURCE_NAME

    Fields inherited from class org.springframework.core.env.StandardEnvironment

    SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME

    Fields inherited from class org.springframework.core.env.AbstractEnvironment

    ACTIVE_PROFILES_PROPERTY_NAME, DEFAULT_PROFILES_PROPERTY_NAME, IGNORE_GETENV_PROPERTY_NAME, logger, RESERVED_DEFAULT_PROFILE_NAME
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for StandardEncryptableServletEnvironment.
    StandardEncryptableServletEnvironment(InterceptionMode interceptionMode, InterceptionMode propertySourcesInterceptionMode, List<Class<org.springframework.core.env.PropertySource<?>>> skipPropertySourceClasses, EncryptablePropertyResolver resolver, EncryptablePropertyFilter filter, org.jasypt.encryption.StringEncryptor encryptor, EncryptablePropertyDetector detector)
    Create a new Encryptable Environment.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.springframework.core.env.ConfigurablePropertyResolver
    createPropertyResolver(org.springframework.core.env.MutablePropertySources propertySources)
    protected void
    customizePropertySources(org.springframework.core.env.MutablePropertySources propertySources)
    org.springframework.core.env.MutablePropertySources
    getOriginalPropertySources.
    org.springframework.core.env.MutablePropertySources
    void
    merge(org.springframework.core.env.ConfigurableEnvironment parent)
     
    void
    setEncryptablePropertySources(org.springframework.core.env.MutablePropertySources propertySources)
    setEncryptablePropertySources.

    Methods inherited from class org.springframework.web.context.support.StandardServletEnvironment

    initPropertySources

    Methods inherited from class org.springframework.core.env.AbstractEnvironment

    acceptsProfiles, acceptsProfiles, addActiveProfile, containsProperty, doGetActiveProfiles, doGetActiveProfilesProperty, doGetDefaultProfiles, doGetDefaultProfilesProperty, getActiveProfiles, getConversionService, getDefaultProfiles, getProperty, getProperty, getProperty, getProperty, getPropertyResolver, getRequiredProperty, getRequiredProperty, getReservedDefaultProfiles, getSystemEnvironment, getSystemProperties, isProfileActive, resolvePlaceholders, resolveRequiredPlaceholders, setActiveProfiles, setConversionService, setDefaultProfiles, setEscapeCharacter, setIgnoreUnresolvableNestedPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, suppressGetenvAccess, toString, validateProfile, validateRequiredProperties

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.core.env.ConfigurableEnvironment

    addActiveProfile, getSystemEnvironment, getSystemProperties, setActiveProfiles, setDefaultProfiles

    Methods inherited from interface org.springframework.core.env.ConfigurablePropertyResolver

    getConversionService, setConversionService, setEscapeCharacter, setIgnoreUnresolvableNestedPlaceholders, setPlaceholderPrefix, setPlaceholderSuffix, setRequiredProperties, setValueSeparator, validateRequiredProperties

    Methods inherited from interface org.springframework.core.env.Environment

    acceptsProfiles, acceptsProfiles, getActiveProfiles, getDefaultProfiles, matchesProfiles

    Methods inherited from interface org.springframework.core.env.PropertyResolver

    containsProperty, getProperty, getProperty, getProperty, getProperty, getRequiredProperty, getRequiredProperty, resolvePlaceholders, resolveRequiredPlaceholders
  • Constructor Details

    • StandardEncryptableServletEnvironment

      public StandardEncryptableServletEnvironment()

      Constructor for StandardEncryptableServletEnvironment.

    • StandardEncryptableServletEnvironment

      public StandardEncryptableServletEnvironment(InterceptionMode interceptionMode, InterceptionMode propertySourcesInterceptionMode, List<Class<org.springframework.core.env.PropertySource<?>>> skipPropertySourceClasses, EncryptablePropertyResolver resolver, EncryptablePropertyFilter filter, org.jasypt.encryption.StringEncryptor encryptor, EncryptablePropertyDetector detector)
      Create a new Encryptable Environment. All arguments are optional, provide null if default value is desired.
      Parameters:
      interceptionMode - The interception method to utilize, or null (Default is InterceptionMode.WRAPPER)
      propertySourcesInterceptionMode - The interception method to utilize for wrapping the MutablePropertySources, or null (Default is InterceptionMode.WRAPPER)
      skipPropertySourceClasses - A list of PropertySource classes to skip from interception, or null (Default is empty)
      resolver - The property resolver to utilize, or null (Default is DefaultLazyPropertyResolver which will resolve to specified configuration)
      filter - The property filter to utilize, or null (Default is DefaultLazyPropertyFilter which will resolve to specified configuration)
      encryptor - The string encryptor to utilize, or null (Default is DefaultLazyEncryptor which will resolve to specified configuration)
      detector - The property detector to utilize, or null (Default is DefaultLazyPropertyDetector which will resolve to specified configuration)
  • Method Details

    • merge

      public void merge(org.springframework.core.env.ConfigurableEnvironment parent)
      Specified by:
      merge in interface org.springframework.core.env.ConfigurableEnvironment
      Overrides:
      merge in class org.springframework.core.env.AbstractEnvironment
    • customizePropertySources

      protected void customizePropertySources(org.springframework.core.env.MutablePropertySources propertySources)
      Overrides:
      customizePropertySources in class org.springframework.web.context.support.StandardServletEnvironment
    • getPropertySources

      public org.springframework.core.env.MutablePropertySources getPropertySources()
      Specified by:
      getPropertySources in interface org.springframework.core.env.ConfigurableEnvironment
      Overrides:
      getPropertySources in class org.springframework.core.env.AbstractEnvironment
    • getOriginalPropertySources

      public org.springframework.core.env.MutablePropertySources getOriginalPropertySources()

      getOriginalPropertySources.

      Specified by:
      getOriginalPropertySources in interface EncryptableEnvironment
      Returns:
      a MutablePropertySources object
    • setEncryptablePropertySources

      public void setEncryptablePropertySources(org.springframework.core.env.MutablePropertySources propertySources)

      setEncryptablePropertySources.

      Specified by:
      setEncryptablePropertySources in interface EncryptableEnvironment
      Parameters:
      propertySources - a MutablePropertySources object
    • createPropertyResolver

      protected org.springframework.core.env.ConfigurablePropertyResolver createPropertyResolver(org.springframework.core.env.MutablePropertySources propertySources)
      Overrides:
      createPropertyResolver in class org.springframework.core.env.AbstractEnvironment