SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Challenge handler for Basic authentication as defined in RFC 2617.
Constructor Summary | |
BasicChallengeHandler()
Challenge handler for Basic authentication as defined in RFC 2617. |
Method Summary | |
boolean
|
canHandle(challengeRequest)
Can the presented challenge be potentially handled by this challenge handler? |
void
|
handle(challengeRequest, callback)
Handle the presented challenge by invoking the callback function with a challenge response processed appropriately. |
void
|
loginHandler(callback)
handle HTTP 401 authentication challenge loginHandler will be called when a challenge is received from the server. |
void
|
setRealmLoginHandler(realm, loginHandler)
Set a Login Handler to be used if and only if a challenge request has a realm parameter matching the provided realm. |
Constructor Detail |
BasicChallengeHandler()
This BasicChallengeHandler can be instantiated using new BasicChallengeHandler()
,
and registered at a location using DispatchChallengeHandler.register(String, ChallengeHandler)
.
In addition, one can install general and realm-specific loginHandler
functions onto this
BasicChallengeHandler
to assist in handling challenges associated
with any or specific realms.
After instantiated a BasicChallengeHandler instance, loginHandler function must be implemented to handle challenge. by default, loginHandler will send an empty PasswordAuthentication.
The following example loads an instance of a BasicChallengeHandler
, sets a login
handler onto it and registers the basic handler at a URI location. In this way, all attempts to access
that URI for which the server issues "Basic" challenges are handled by the registered BasicChallengeHandler
.
Method Detail |
boolean canHandle(challengeRequest)
challengeRequest
- a challenge request object containing a challenge
boolean
true, if this challenge handler could potentially respond meaningfully to the challenge;
otherwise false
void handle(challengeRequest, callback)
By default, the implementation of this method invokes the callback function using a
null
challenge response and failing authentication.
challengeRequest
- a challenge object
callback
- function that is called when the challenge request handling is completed.
void
void loginHandler(callback)
callback
- the function to be invoked when the credentials are retrieved. To invoke the callback function,
use callback(new PasswordAuthentication(username, password));
to login
or callback(null)
to cancel
void
void setRealmLoginHandler(realm, loginHandler)
realm
- the realm upon which to apply the loginHandler
.
loginHandler
- the login handler to use for the provided realm.
void