Interface SanitizingFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Function that takes a 
SanitizableData and applies sanitization to the value, if
necessary. Can be used by a Sanitizer to determine the sanitized value.
This interface also provides convenience methods that can help build a
SanitizingFunction instances, for example to return from a @Bean
method. See sanitizeValue() for an example.
- Since:
- 2.6.0
- Author:
- Madhura Bhave, Phillip Webb
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionapply(SanitizableData data) Apply the sanitizing function to the given data.default SanitizableDataApply the sanitizing function as long as the filter passes or there is no filter.default @Nullable Predicate<SanitizableData> filter()Return an optional filter that determines if the sanitizing function applies.default SanitizingFunctionifKeyContains(String... values) Return a new function with a filter that also applies if the data key contains any of the given values (ignoring case).default SanitizingFunctionifKeyEndsWith(String... suffixes) Return a new function with a filter that also applies if the data key ends with any of the given values (ignoring case).default SanitizingFunctionifKeyEquals(String... values) Return a new function with a filter that also applies if the data key is equal to any of the given values (ignoring case).default SanitizingFunctionifKeyMatches(String... regexes) Return a new function with a filter that also applies if the data key matches any of the given regex patterns (ignoring case).default SanitizingFunctionifKeyMatches(Predicate<String> predicate) Return a new function with a filter that also applies if the data key matches any of the given predicate.default SanitizingFunctionifKeyMatches(List<Predicate<String>> predicates) Return a new function with a filter that also applies if the data key matches any of the given predicates.default SanitizingFunctionifKeyMatches(Pattern... patterns) Return a new function with a filter that also applies if the data key matches any of the given patterns.default SanitizingFunctionifKeyMatchesIgnoringCase(BiPredicate<String, String> predicate, String... values) Return a new function with a filter that also applies if the data key and any of the values match the given predicate.default SanitizingFunctionReturn a new function with a filter that also applies if the data is likely to contain a credential.default SanitizingFunctionReturn a new function with a filter that also applies if the data is likely to contain a sensitive value.default SanitizingFunctionReturn a new function with a filter that also applies if the data is likely to contain a sensitive property value.default SanitizingFunctionReturn a new function with a filter that also applies if the data is likely to contain a URI.default SanitizingFunctionifMatches(Predicate<SanitizableData> predicate) Return a new function with a filter that also applies if the data matches the given predicate.default SanitizingFunctionifMatches(List<Predicate<SanitizableData>> predicates) Return a new function with a filter that also applies if the data matches any of the given predicates.default SanitizingFunctionifValueMatches(Predicate<@Nullable Object> predicate) Return a new function with a filter that also applies if the data value matches the given predicate.default SanitizingFunctionifValueMatches(List<Predicate<Object>> predicates) Return a new function with a filter that also applies if the data value matches any of the given predicates.default SanitizingFunctionifValueStringMatches(String... regexes) Return a new function with a filter that also applies if the data string value matches any of the given regex patterns (ignoring case).default SanitizingFunctionifValueStringMatches(Predicate<String> predicate) Return a new function with a filter that also applies if the data string value matches the given predicate.default SanitizingFunctionifValueStringMatches(List<Predicate<String>> predicates) Return a new function with a filter that also applies if the data string value matches any of the given predicates.default SanitizingFunctionifValueStringMatches(Pattern... patterns) Return a new function with a filter that also applies if the data string value matches any of the given patterns.default SanitizingFunctionReturn a new function with a filter that also applies if the data is for VCAP services.static SanitizingFunctionof(SanitizingFunction sanitizingFunction) Helper method that can be used working with a sanitizingFunction as a lambda.static SanitizingFunctionFactory method to return aSanitizingFunctionthat sanitizes the value.
- 
Method Details- 
applyApply the sanitizing function to the given data.- Parameters:
- data- the data to sanitize
- Returns:
- the sanitized data or the original instance is no sanitization is applied
 
- 
filterReturn an optional filter that determines if the sanitizing function applies.- Returns:
- a predicate used to filter functions or nullif no filter is declared
- Since:
- 3.5.0
- See Also:
 
- 
applyUnlessFilteredApply the sanitizing function as long as the filter passes or there is no filter.- Parameters:
- data- the data to sanitize
- Returns:
- the sanitized data or the original instance is no sanitization is applied
- Since:
- 3.5.0
 
- 
ifLikelySensitiveReturn a new function with a filter that also applies if the data is likely to contain a sensitive value. This method can help construct a useful sanitizing function, but may not catch all sensitive data so care should be taken to test the results for your specific environment.- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifLikelyCredentialReturn a new function with a filter that also applies if the data is likely to contain a credential. This method can help construct a useful sanitizing function, but may not catch all sensitive data so care should be taken to test the results for your specific environment.- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifLikelyUriReturn a new function with a filter that also applies if the data is likely to contain a URI. This method can help construct a useful sanitizing function, but may not catch all sensitive data so care should be taken to test the results for your specific environment.- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifLikelySensitivePropertyReturn a new function with a filter that also applies if the data is likely to contain a sensitive property value. This method can help construct a useful sanitizing function, but may not catch all sensitive data so care should be taken to test the results for your specific environment.- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifVcapServicesReturn a new function with a filter that also applies if the data is for VCAP services.- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifKeyEqualsReturn a new function with a filter that also applies if the data key is equal to any of the given values (ignoring case).- Parameters:
- values- the case insensitive values that the key can equal
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifKeyEndsWithReturn a new function with a filter that also applies if the data key ends with any of the given values (ignoring case).- Parameters:
- suffixes- the case insensitive suffixes that they key can end with
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifKeyContainsReturn a new function with a filter that also applies if the data key contains any of the given values (ignoring case).- Parameters:
- values- the case insensitive values that the key can contain
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifKeyMatchesIgnoringCasedefault SanitizingFunction ifKeyMatchesIgnoringCase(BiPredicate<String, String> predicate, String... values) Return a new function with a filter that also applies if the data key and any of the values match the given predicate. The predicate is only called with lower case values.- Parameters:
- predicate- the predicate used to check the key against a value. The key is the first argument and the value is the second. Both are converted to lower case
- values- the case insensitive values that the key can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifKeyMatchesReturn a new function with a filter that also applies if the data key matches any of the given regex patterns (ignoring case).- Parameters:
- regexes- the case insensitive regexes that the key can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifKeyMatchesReturn a new function with a filter that also applies if the data key matches any of the given patterns.- Parameters:
- patterns- the patterns that the key can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifKeyMatchesReturn a new function with a filter that also applies if the data key matches any of the given predicates.- Parameters:
- predicates- the predicates that the key can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifKeyMatchesReturn a new function with a filter that also applies if the data key matches any of the given predicate.- Parameters:
- predicate- the predicate that the key can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifValueStringMatchesReturn a new function with a filter that also applies if the data string value matches any of the given regex patterns (ignoring case).- Parameters:
- regexes- the case insensitive regexes that the values string can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifValueStringMatchesReturn a new function with a filter that also applies if the data string value matches any of the given patterns.- Parameters:
- patterns- the patterns that the value string can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifValueStringMatchesReturn a new function with a filter that also applies if the data string value matches any of the given predicates.- Parameters:
- predicates- the predicates that the value string can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifValueMatchesReturn a new function with a filter that also applies if the data value matches any of the given predicates.- Parameters:
- predicates- the predicates that the value can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifValueStringMatchesReturn a new function with a filter that also applies if the data string value matches the given predicate.- Parameters:
- predicate- the predicate that the value string can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifValueMatchesReturn a new function with a filter that also applies if the data value matches the given predicate.- Parameters:
- predicate- the predicate that the value can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifMatchesReturn a new function with a filter that also applies if the data matches any of the given predicates.- Parameters:
- predicates- the predicates that the data can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
ifMatchesReturn a new function with a filter that also applies if the data matches the given predicate.- Parameters:
- predicate- the predicate that the data can match
- Returns:
- a new sanitizing function with an updated filter()
- Since:
- 3.5.0
- See Also:
 
- 
sanitizeValueFactory method to return aSanitizingFunctionthat sanitizes the value. This method is often chained with one or moreif...methods. For example:return SanitizingFunction.sanitizeValue() .ifKeyContains("password", "secret") .ifValueStringMatches("^gh._[a-zA-Z0-9]{36}$");- Returns:
- a SanitizingFunctionthat sanitizes values.
 
- 
ofHelper method that can be used working with a sanitizingFunction as a lambda. For example:SanitizingFunction.of((data) -> data.withValue("----")).ifKeyContains("password");- Parameters:
- sanitizingFunction- the sanitizing function lambda
- Returns:
- a SanitizingFunctionfor further method calls
- Since:
- 3.5.0
 
 
-