@Priority(value=1000)
class HttpAuthenticationFilter
extends java.lang.Object
implements javax.ws.rs.client.ClientRequestFilter, javax.ws.rs.client.ClientResponseFilter
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
HttpAuthenticationFilter.Credentials
Credentials (username + password).
|
(package private) static class |
HttpAuthenticationFilter.Type
Authentication type.
|
| Modifier and Type | Field and Description |
|---|---|
private BasicAuthenticator |
basicAuth |
(package private) static java.nio.charset.Charset |
CHARACTER_SET
Encoding used for authentication calculations.
|
private DigestAuthenticator |
digestAuth |
private static int |
MAXIMUM_DIGEST_CACHE_SIZE |
private HttpAuthenticationFeature.Mode |
mode |
private static java.lang.String |
REQUEST_PROPERTY_FILTER_REUSED |
private static java.lang.String |
REQUEST_PROPERTY_OPERATION |
private java.util.Map<java.lang.String,HttpAuthenticationFilter.Type> |
uriCache
Cache with
URI:HTTP-METHOD keys and authentication type as values. |
| Constructor and Description |
|---|
HttpAuthenticationFilter(HttpAuthenticationFeature.Mode mode,
HttpAuthenticationFilter.Credentials basicCredentials,
HttpAuthenticationFilter.Credentials digestCredentials,
javax.ws.rs.core.Configuration configuration)
Create a new filter instance.
|
| Modifier and Type | Method and Description |
|---|---|
private static HttpAuthenticationFilter.Credentials |
extractCredentials(javax.ws.rs.client.ClientRequestContext request,
HttpAuthenticationFilter.Type type) |
void |
filter(javax.ws.rs.client.ClientRequestContext request) |
void |
filter(javax.ws.rs.client.ClientRequestContext request,
javax.ws.rs.client.ClientResponseContext response) |
private java.lang.String |
getCacheKey(javax.ws.rs.client.ClientRequestContext request) |
(package private) static HttpAuthenticationFilter.Credentials |
getCredentials(javax.ws.rs.client.ClientRequestContext request,
HttpAuthenticationFilter.Credentials defaultCredentials,
HttpAuthenticationFilter.Type type)
Get credentials actual for the current request.
|
private int |
getMaximumCacheLimit(javax.ws.rs.core.Configuration configuration) |
(package private) static boolean |
repeatRequest(javax.ws.rs.client.ClientRequestContext request,
javax.ws.rs.client.ClientResponseContext response,
java.lang.String newAuthorizationHeader)
Repeat the
request with provided newAuthorizationHeader
and update the response with newest response data. |
private void |
updateCache(javax.ws.rs.client.ClientRequestContext request,
boolean success,
HttpAuthenticationFilter.Type operation) |
private static final java.lang.String REQUEST_PROPERTY_FILTER_REUSED
private static final java.lang.String REQUEST_PROPERTY_OPERATION
static final java.nio.charset.Charset CHARACTER_SET
private final HttpAuthenticationFeature.Mode mode
private final java.util.Map<java.lang.String,HttpAuthenticationFilter.Type> uriCache
URI:HTTP-METHOD keys and authentication type as values. Contains successful
authentications already performed by the filter.private final DigestAuthenticator digestAuth
private final BasicAuthenticator basicAuth
private static final int MAXIMUM_DIGEST_CACHE_SIZE
HttpAuthenticationFilter(HttpAuthenticationFeature.Mode mode, HttpAuthenticationFilter.Credentials basicCredentials, HttpAuthenticationFilter.Credentials digestCredentials, javax.ws.rs.core.Configuration configuration)
mode - Mode.basicCredentials - Basic credentials (can be null if this filter does not work in the
basic mode or if no default credentials are defined).digestCredentials - Digest credentials (can be null if this filter does not work in the
digest mode or if no default credentials are defined).configuration - Configuration (non-null).private int getMaximumCacheLimit(javax.ws.rs.core.Configuration configuration)
public void filter(javax.ws.rs.client.ClientRequestContext request)
throws java.io.IOException
filter in interface javax.ws.rs.client.ClientRequestFilterjava.io.IOExceptionpublic void filter(javax.ws.rs.client.ClientRequestContext request,
javax.ws.rs.client.ClientResponseContext response)
throws java.io.IOException
filter in interface javax.ws.rs.client.ClientResponseFilterjava.io.IOExceptionprivate java.lang.String getCacheKey(javax.ws.rs.client.ClientRequestContext request)
private void updateCache(javax.ws.rs.client.ClientRequestContext request,
boolean success,
HttpAuthenticationFilter.Type operation)
static boolean repeatRequest(javax.ws.rs.client.ClientRequestContext request,
javax.ws.rs.client.ClientResponseContext response,
java.lang.String newAuthorizationHeader)
request with provided newAuthorizationHeader
and update the response with newest response data.request - Request context.response - Response context (will be updated with the new response data).newAuthorizationHeader - Authorization header that should be added to the new request.true is the authentication was successful (true if 401 response code was not returned;
false otherwise).private static HttpAuthenticationFilter.Credentials extractCredentials(javax.ws.rs.client.ClientRequestContext request, HttpAuthenticationFilter.Type type)
static HttpAuthenticationFilter.Credentials getCredentials(javax.ws.rs.client.ClientRequestContext request, HttpAuthenticationFilter.Credentials defaultCredentials, HttpAuthenticationFilter.Type type)
defaultCredentialsrequest - Request from which credentials should be extracted.defaultCredentials - Default credentials (can be null).type - Type of requested credentials.null if no credentials are found and defaultCredentials are null.RequestAuthenticationException - in case the username or password is invalid.