接口 SanitizingFunction
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
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.
- 从以下版本开始:
- 2.6.0
- 作者:
- Madhura Bhave, Phillip Webb
- 另请参阅:
-
方法概要
修饰符和类型方法说明apply
(SanitizableData data) Apply the sanitizing function to the given data.default SanitizableData
Apply the sanitizing function as long as the filter passes or there is no filter.default Predicate
<SanitizableData> filter()
Return an optional filter that determines if the sanitizing function applies.default SanitizingFunction
ifKeyContains
(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 SanitizingFunction
ifKeyEndsWith
(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 SanitizingFunction
ifKeyEquals
(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 SanitizingFunction
ifKeyMatches
(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 SanitizingFunction
ifKeyMatches
(Predicate<String> predicate) Return a new function with a filter that also applies if the data key matches any of the given predicate.default SanitizingFunction
ifKeyMatches
(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 SanitizingFunction
ifKeyMatches
(Pattern... patterns) Return a new function with a filter that also applies if the data key matches any of the given patterns.default 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.default SanitizingFunction
Return a new function with a filter that also applies if the data is likely to contain a credential.default SanitizingFunction
Return a new function with a filter that also applies if the data is likely to contain a sensitive value.default SanitizingFunction
Return a new function with a filter that also applies if the data is likely to contain a sensitive property value.default SanitizingFunction
Return a new function with a filter that also applies if the data is likely to contain a URI.default SanitizingFunction
ifMatches
(Predicate<SanitizableData> predicate) Return a new function with a filter that also applies if the data matches the given predicate.default SanitizingFunction
ifMatches
(List<Predicate<SanitizableData>> predicates) Return a new function with a filter that also applies if the data matches any of the given predicates.default SanitizingFunction
ifValueMatches
(Predicate<Object> predicate) Return a new function with a filter that also applies if the data value matches the given predicate.default SanitizingFunction
ifValueMatches
(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 SanitizingFunction
ifValueStringMatches
(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 SanitizingFunction
ifValueStringMatches
(Predicate<String> predicate) Return a new function with a filter that also applies if the data string value matches the given predicate.default SanitizingFunction
ifValueStringMatches
(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 SanitizingFunction
ifValueStringMatches
(Pattern... patterns) Return a new function with a filter that also applies if the data string value matches any of the given patterns.default SanitizingFunction
Return a new function with a filter that also applies if the data is for VCAP services.static SanitizingFunction
of
(SanitizingFunction sanitizingFunction) Helper method that can be used working with a sanitizingFunction as a lambda.static SanitizingFunction
Factory method to return aSanitizingFunction
that sanitizes the value.
-
方法详细资料
-
apply
Apply the sanitizing function to the given data.- 参数:
data
- the data to sanitize- 返回:
- the sanitized data or the original instance is no sanitization is applied
-
filter
Return an optional filter that determines if the sanitizing function applies.- 返回:
- a predicate used to filter functions or
null
if no filter is declared - 从以下版本开始:
- 3.5.0
- 另请参阅:
-
applyUnlessFiltered
Apply the sanitizing function as long as the filter passes or there is no filter.- 参数:
data
- the data to sanitize- 返回:
- the sanitized data or the original instance is no sanitization is applied
- 从以下版本开始:
- 3.5.0
-
ifLikelySensitive
Return 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.- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifLikelyCredential
Return 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.- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifLikelyUri
Return 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.- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifLikelySensitiveProperty
Return 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.- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifVcapServices
Return a new function with a filter that also applies if the data is for VCAP services.- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifKeyEquals
Return a new function with a filter that also applies if the data key is equal to any of the given values (ignoring case).- 参数:
values
- the case insensitive values that the key can equal- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifKeyEndsWith
Return a new function with a filter that also applies if the data key ends with any of the given values (ignoring case).- 参数:
suffixes
- the case insensitive suffixes that they key can end with- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifKeyContains
Return a new function with a filter that also applies if the data key contains any of the given values (ignoring case).- 参数:
values
- the case insensitive values that the key can contain- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifKeyMatchesIgnoringCase
default 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.- 参数:
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 casevalues
- the case insensitive values that the key can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifKeyMatches
Return a new function with a filter that also applies if the data key matches any of the given regex patterns (ignoring case).- 参数:
regexes
- the case insensitive regexes that the key can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifKeyMatches
Return a new function with a filter that also applies if the data key matches any of the given patterns.- 参数:
patterns
- the patterns that the key can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifKeyMatches
Return a new function with a filter that also applies if the data key matches any of the given predicates.- 参数:
predicates
- the predicates that the key can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifKeyMatches
Return a new function with a filter that also applies if the data key matches any of the given predicate.- 参数:
predicate
- the predicate that the key can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifValueStringMatches
Return a new function with a filter that also applies if the data string value matches any of the given regex patterns (ignoring case).- 参数:
regexes
- the case insensitive regexes that the values string can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifValueStringMatches
Return a new function with a filter that also applies if the data string value matches any of the given patterns.- 参数:
patterns
- the patterns that the value string can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifValueStringMatches
Return a new function with a filter that also applies if the data string value matches any of the given predicates.- 参数:
predicates
- the predicates that the value string can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifValueMatches
Return a new function with a filter that also applies if the data value matches any of the given predicates.- 参数:
predicates
- the predicates that the value can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifValueStringMatches
Return a new function with a filter that also applies if the data string value matches the given predicate.- 参数:
predicate
- the predicate that the value string can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifValueMatches
Return a new function with a filter that also applies if the data value matches the given predicate.- 参数:
predicate
- the predicate that the value can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifMatches
Return a new function with a filter that also applies if the data matches any of the given predicates.- 参数:
predicates
- the predicates that the data can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
ifMatches
Return a new function with a filter that also applies if the data matches the given predicate.- 参数:
predicate
- the predicate that the data can match- 返回:
- a new sanitizing function with an updated
filter()
- 从以下版本开始:
- 3.5.0
- 另请参阅:
-
sanitizeValue
Factory method to return aSanitizingFunction
that 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}$");
- 返回:
- a
SanitizingFunction
that sanitizes values.
-
of
Helper method that can be used working with a sanitizingFunction as a lambda. For example:SanitizingFunction.of((data) -> data.withValue("----")).ifKeyContains("password");
- 参数:
sanitizingFunction
- the sanitizing function lambda- 返回:
- a
SanitizingFunction
for further method calls - 从以下版本开始:
- 3.5.0
-