public class BasicAuthorizationInterceptor extends java.lang.Object implements ClientHttpRequestInterceptor
ClientHttpRequestInterceptor
to apply a BASIC authorization header.Modifier and Type | Field and Description |
---|---|
private java.lang.String |
password |
private java.lang.String |
username |
private static java.nio.charset.Charset |
UTF_8 |
Constructor and Description |
---|
BasicAuthorizationInterceptor(java.lang.String username,
java.lang.String password)
Create a new interceptor which adds a BASIC authorization header
for the given username and password.
|
Modifier and Type | Method and Description |
---|---|
ClientHttpResponse |
intercept(HttpRequest request,
byte[] body,
ClientHttpRequestExecution execution)
Intercept the given request, and return a response.
|
private static final java.nio.charset.Charset UTF_8
private final java.lang.String username
private final java.lang.String password
public BasicAuthorizationInterceptor(java.lang.String username, java.lang.String password)
username
- the username to usepassword
- the password to usepublic ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws java.io.IOException
ClientHttpRequestInterceptor
ClientHttpRequestExecution
allows the interceptor to pass on the
request and response to the next entity in the chain.
A typical implementation of this method would follow the following pattern:
ClientHttpRequestExecution.execute(org.springframework.http.HttpRequest, byte[])
,intercept
in interface ClientHttpRequestInterceptor
request
- the request, containing method, URI, and headersbody
- the body of the requestexecution
- the request executionjava.io.IOException
- in case of I/O errors