java.lang.Object
org.springframework.boot.actuate.endpoint.Sanitizer

public class Sanitizer extends Object
Strategy that should be used by endpoint implementations to sanitize potentially sensitive keys.
Since:
2.0.0
Author:
Christian Dupuis, Toshiaki Maki, Phillip Webb, Nicolas Lejeune, Stephane Nicoll, HaiTao Zhang, Chris Bono, David Good, Madhura Bhave
  • Constructor Details

    • Sanitizer

      public Sanitizer()
      Create a new Sanitizer instance with a default set of keys to sanitize.
    • Sanitizer

      public Sanitizer(String... keysToSanitize)
      Create a new Sanitizer instance with specific keys to sanitize.
      Parameters:
      keysToSanitize - the keys to sanitize
    • Sanitizer

      public Sanitizer(Iterable<SanitizingFunction> sanitizingFunctions)
      Create a new Sanitizer instance with a default set of keys to sanitize and additional sanitizing functions.
      Parameters:
      sanitizingFunctions - the sanitizing functions to apply
      Since:
      2.6.0
    • Sanitizer

      public Sanitizer(Iterable<SanitizingFunction> sanitizingFunctions, String... keysToSanitize)
      Create a new Sanitizer instance with specific keys to sanitize and additional sanitizing functions.
      Parameters:
      sanitizingFunctions - the sanitizing functions to apply
      keysToSanitize - the keys to sanitize
      Since:
      2.6.0
  • Method Details

    • setKeysToSanitize

      public void setKeysToSanitize(String... keysToSanitize)
      Set the keys that should be sanitized, overwriting any existing configuration. Keys can be simple strings that the property ends with or regular expressions.
      Parameters:
      keysToSanitize - the keys to sanitize
    • keysToSanitize

      public void keysToSanitize(String... keysToSanitize)
      Adds keys that should be sanitized. Keys can be simple strings that the property ends with or regular expressions.
      Parameters:
      keysToSanitize - the keys to sanitize
      Since:
      2.5.0
    • sanitize

      public Object sanitize(String key, Object value)
      Sanitize the given value if necessary.
      Parameters:
      key - the key to sanitize
      value - the value
      Returns:
      the potentially sanitized value
    • sanitize

      public Object sanitize(SanitizableData data)
      Sanitize the value from the given SanitizableData using the available SanitizingFunctions.
      Parameters:
      data - the sanitizable data
      Returns:
      the potentially updated data
      Since:
      2.6.0