public abstract class ExchangeFilterFunctions
extends java.lang.Object
ExchangeFilterFunction that provide various useful request filter
operations, such as basic authentication, error handling, etc.| Modifier and Type | Class and Description |
|---|---|
static class |
ExchangeFilterFunctions.Credentials
Represents a combination of username and password, as used by
basicAuthentication(). |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE
Name of the
ClientRequest attribute that contains the
ExchangeFilterFunctions.Credentials, as used by basicAuthentication(). |
| Constructor and Description |
|---|
ExchangeFilterFunctions() |
| Modifier and Type | Method and Description |
|---|---|
static ExchangeFilterFunction |
basicAuthentication()
Return a filter that adds an Authorization header for HTTP Basic Authentication, based on
the
ExchangeFilterFunctions.Credentials provided in the
request attributes. |
static ExchangeFilterFunction |
basicAuthentication(java.lang.String username,
java.lang.String password)
Return a filter that adds an Authorization header for HTTP Basic Authentication, based on
the given username and password.
|
static ExchangeFilterFunction |
statusError(java.util.function.Predicate<HttpStatus> statusPredicate,
java.util.function.Function<ClientResponse,? extends java.lang.Throwable> exceptionFunction)
Return a filter that returns a given
Throwable as response if the given
HttpStatus predicate matches. |
public static final java.lang.String BASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE
ClientRequest attribute that contains the
ExchangeFilterFunctions.Credentials, as used by basicAuthentication().public static ExchangeFilterFunction basicAuthentication(java.lang.String username, java.lang.String password)
Note that Basic Authentication only supports characters in the
ISO-8859-1 character set.
username - the username to usepassword - the password to useExchangeFilterFunction that adds the Authorization headerjava.lang.IllegalArgumentException - if either username or password contain
characters that cannot be encoded to ISO-8859-1public static ExchangeFilterFunction basicAuthentication()
ExchangeFilterFunctions.Credentials provided in the
request attributes. If the attribute is not found,
no authorization header is added.
Note that Basic Authentication only supports characters in the
ISO-8859-1 character set.
ExchangeFilterFunction that adds the Authorization headerBASIC_AUTHENTICATION_CREDENTIALS_ATTRIBUTE,
ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials(String, String)public static ExchangeFilterFunction statusError(java.util.function.Predicate<HttpStatus> statusPredicate, java.util.function.Function<ClientResponse,? extends java.lang.Throwable> exceptionFunction)
Throwable as response if the given
HttpStatus predicate matches.statusPredicate - the predicate that should match the
response statusexceptionFunction - the function that returns the exceptionExchangeFilterFunction that returns the given exception if the predicate
matches