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

public class Sanitizer extends Object
Borrowed from https://github.com/spring-projects/spring-boot/blob/2.7.x/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/Sanitizer.java as Sanitizer in Spring Boot 3 is not backward compatible with the version shipped in Spring Boot 2
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new Sanitizer instance with a default set of keys to sanitize.
    Sanitizer(Iterable<org.springframework.boot.actuate.endpoint.SanitizingFunction> sanitizingFunctions)
    Create a new Sanitizer instance with a default set of keys to sanitize and additional sanitizing functions.
    Sanitizer(Iterable<org.springframework.boot.actuate.endpoint.SanitizingFunction> sanitizingFunctions, String... keysToSanitize)
    Create a new Sanitizer instance with specific keys to sanitize and additional sanitizing functions.
    Sanitizer(String... keysToSanitize)
    Create a new Sanitizer instance with specific keys to sanitize.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    keysToSanitize(String... keysToSanitize)
    Adds keys that should be sanitized.
    sanitize(String key, Object value)
    Sanitize the given value if necessary.
    sanitize(org.springframework.boot.actuate.endpoint.SanitizableData data)
    Sanitize the value from the given SanitizableData using the available SanitizingFunctions.
    void
    setKeysToSanitize(String... keysToSanitize)
    Set the keys that should be sanitized, overwriting any existing configuration.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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<org.springframework.boot.actuate.endpoint.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<org.springframework.boot.actuate.endpoint.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(org.springframework.boot.actuate.endpoint.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