public abstract class ChallengeHandler extends Object
ChallengeRequest
and sent to a
registered ChallengeHandler for authentication challenge responses. The ChallengeResponse
credentials
generated by a registered challenge handler are included in a replay of the original HTTP request to the server, which
(assuming the credentials are sufficient) allows access to the resource.
Public subclasses of ChallengeHandler can be loaded and instantiated using ChallengeHandlers
,
and registered to handle server challenges for specific URI locations
using DispatchChallengeHandler.register(String, ChallengeHandler)
.
Any 401 responses to requests matching the registered location may be handled by the registered ChallengeHandler
as long as canHandle(ChallengeRequest)
returns true. In the case where multiple registered challenge handlers
could respond to a challenge request, the earliest challenge handler registered at the most specific location matching
the protected URI is selected.Constructor and Description |
---|
ChallengeHandler() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
canHandle(ChallengeRequest challengeRequest)
Can the presented challenge be potentially handled by this challenge handler?
|
protected static <T extends ChallengeHandler> |
create(Class<T> clazz)
Creates a new instance of the corresponding sub-class of
ChallengeHandler |
protected static <T extends ChallengeHandler> |
create(Class<T> clazz,
ClassLoader clazzLoader)
Creates a new instance of the corresponding sub-class of
ChallengeHandler with
specified ClassLoader |
abstract ChallengeResponse |
handle(ChallengeRequest challengeRequest)
Handle the presented challenge by creating a challenge response or returning
null . |
protected static <T extends ChallengeHandler> T create(Class<T> clazz)
ChallengeHandler
T
- sub-class of ChallengeHandlerclazz
- Class object of the sub-typeprotected static <T extends ChallengeHandler> T create(Class<T> clazz, ClassLoader clazzLoader)
ChallengeHandler
with
specified ClassLoader
T
- sub-type of ChallengeHandlerclazz
- Class object of the sub-typeclassLoader
- ClassLoader to be used to instantiatepublic abstract boolean canHandle(ChallengeRequest challengeRequest)
challengeRequest
- a challenge request object containing a challengepublic abstract ChallengeResponse handle(ChallengeRequest challengeRequest)
null
.
This responsibility is usually achieved
by using the associated LoginHandler
to obtain user credentials, and transforming those credentials
into a ChallengeResponse
.
When it is not possible to create a ChallengeResponse
, this method MUST return null
.challengeRequest
- a challenge objectnull
if no response is possible.Copyright © 2015. All Rights Reserved.