Class HttpAuthenticationFilter
java.lang.Object
org.glassfish.jersey.client.authentication.HttpAuthenticationFilter
- All Implemented Interfaces:
javax.ws.rs.client.ClientRequestFilter, javax.ws.rs.client.ClientResponseFilter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classCredentials (username + password).(package private) static enumAuthentication type. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BasicAuthenticator(package private) static final CharsetEncoding used for authentication calculations.private final DigestAuthenticatorprivate static final intprivate final HttpAuthenticationFeature.Modeprivate static final Stringprivate static final Stringprivate final Map<String, HttpAuthenticationFilter.Type> Cache withURI:HTTP-METHODkeys and authentication type as values. -
Constructor Summary
ConstructorsConstructorDescriptionHttpAuthenticationFilter(HttpAuthenticationFeature.Mode mode, HttpAuthenticationFilter.Credentials basicCredentials, HttpAuthenticationFilter.Credentials digestCredentials, javax.ws.rs.core.Configuration configuration) Create a new filter instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate static HttpAuthenticationFilter.CredentialsextractCredentials(javax.ws.rs.client.ClientRequestContext request, HttpAuthenticationFilter.Type type) voidfilter(javax.ws.rs.client.ClientRequestContext request) voidfilter(javax.ws.rs.client.ClientRequestContext request, javax.ws.rs.client.ClientResponseContext response) private StringgetCacheKey(javax.ws.rs.client.ClientRequestContext request) (package private) static HttpAuthenticationFilter.CredentialsgetCredentials(javax.ws.rs.client.ClientRequestContext request, HttpAuthenticationFilter.Credentials defaultCredentials, HttpAuthenticationFilter.Type type) Get credentials actual for the current request.private intgetMaximumCacheLimit(javax.ws.rs.core.Configuration configuration) (package private) static booleanrepeatRequest(javax.ws.rs.client.ClientRequestContext request, javax.ws.rs.client.ClientResponseContext response, String newAuthorizationHeader) Repeat therequestwith providednewAuthorizationHeaderand update theresponsewith newest response data.private voidupdateCache(javax.ws.rs.client.ClientRequestContext request, boolean success, HttpAuthenticationFilter.Type operation)
-
Field Details
-
REQUEST_PROPERTY_FILTER_REUSED
- See Also:
-
REQUEST_PROPERTY_OPERATION
- See Also:
-
CHARACTER_SET
Encoding used for authentication calculations. -
mode
-
uriCache
Cache withURI:HTTP-METHODkeys and authentication type as values. Contains successful authentications already performed by the filter. -
digestAuth
-
basicAuth
-
MAXIMUM_DIGEST_CACHE_SIZE
private static final int MAXIMUM_DIGEST_CACHE_SIZE- See Also:
-
-
Constructor Details
-
HttpAuthenticationFilter
HttpAuthenticationFilter(HttpAuthenticationFeature.Mode mode, HttpAuthenticationFilter.Credentials basicCredentials, HttpAuthenticationFilter.Credentials digestCredentials, javax.ws.rs.core.Configuration configuration) Create a new filter instance.- Parameters:
mode- Mode.basicCredentials- Basic credentials (can benullif this filter does not work in the basic mode or if no default credentials are defined).digestCredentials- Digest credentials (can benullif this filter does not work in the digest mode or if no default credentials are defined).configuration- Configuration (non-null).
-
-
Method Details
-
getMaximumCacheLimit
private int getMaximumCacheLimit(javax.ws.rs.core.Configuration configuration) -
filter
- Specified by:
filterin interfacejavax.ws.rs.client.ClientRequestFilter- Throws:
IOException
-
filter
public void filter(javax.ws.rs.client.ClientRequestContext request, javax.ws.rs.client.ClientResponseContext response) throws IOException - Specified by:
filterin interfacejavax.ws.rs.client.ClientResponseFilter- Throws:
IOException
-
getCacheKey
-
updateCache
private void updateCache(javax.ws.rs.client.ClientRequestContext request, boolean success, HttpAuthenticationFilter.Type operation) -
repeatRequest
static boolean repeatRequest(javax.ws.rs.client.ClientRequestContext request, javax.ws.rs.client.ClientResponseContext response, String newAuthorizationHeader) Repeat therequestwith providednewAuthorizationHeaderand update theresponsewith newest response data.- Parameters:
request- Request context.response- Response context (will be updated with the new response data).newAuthorizationHeader-Authorizationheader that should be added to the new request.- Returns:
trueis the authentication was successful (trueif 401 response code was not returned;falseotherwise).
-
extractCredentials
private static HttpAuthenticationFilter.Credentials extractCredentials(javax.ws.rs.client.ClientRequestContext request, HttpAuthenticationFilter.Type type) -
getCredentials
static HttpAuthenticationFilter.Credentials getCredentials(javax.ws.rs.client.ClientRequestContext request, HttpAuthenticationFilter.Credentials defaultCredentials, HttpAuthenticationFilter.Type type) Get credentials actual for the current request. Priorities in credentials selection are the following:- Basic/digest specific credentials defined in the request properties
- Common credentials defined in the request properties
defaultCredentials
- Parameters:
request- Request from which credentials should be extracted.defaultCredentials- Default credentials (can benull).type- Type of requested credentials.- Returns:
- Credentials or
nullif no credentials are found anddefaultCredentialsarenull. - Throws:
RequestAuthenticationException- in case theusernameorpasswordis invalid.
-