public class ChallengeAuthenticator extends Authenticator
ChallengeScheme
,
ChallengeRequest
,
ChallengeResponse
,
User Guide -
AuthenticationConstructor and Description |
---|
ChallengeAuthenticator(Context context,
boolean optional,
ChallengeScheme challengeScheme,
java.lang.String realm)
Constructor using the context's default verifier.
|
ChallengeAuthenticator(Context context,
boolean optional,
ChallengeScheme challengeScheme,
java.lang.String realm,
Verifier verifier)
Constructor.
|
ChallengeAuthenticator(Context context,
ChallengeScheme challengeScheme,
java.lang.String realm)
Constructor setting the optional property to false.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
authenticate(Request request,
Response response)
Authenticates the call, relying on the verifier to check the credentials
provided (in general an identifier + secret couple).
|
void |
challenge(Response response,
boolean stale)
Challenges the client by adding a challenge request to the response and
by setting the status to
Status.CLIENT_ERROR_UNAUTHORIZED . |
protected ChallengeRequest |
createChallengeRequest(boolean stale)
Creates a new challenge request.
|
void |
forbid(Response response)
Rejects the call due to a failed authentication or authorization.
|
java.lang.String |
getRealm()
Returns the authentication realm.
|
ChallengeScheme |
getScheme()
Returns the authentication challenge scheme.
|
Verifier |
getVerifier()
Returns the credentials verifier.
|
boolean |
isRechallenging()
Indicates if a new challenge should be sent when invalid credentials are
received (true by default to conform to HTTP recommendations).
|
void |
setRealm(java.lang.String realm)
Sets the authentication realm.
|
void |
setRechallenging(boolean rechallenging)
Indicates if a new challenge should be sent when invalid credentials are
received.
|
void |
setVerifier(Verifier verifier)
Sets the credentials verifier.
|
authenticated, beforeHandle, getEnroler, isMultiAuthenticating, isOptional, setEnroler, setMultiAuthenticating, setOptional, unauthenticated
afterHandle, doHandle, getNext, handle, hasNext, setNext, setNext, start, stop
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner
public ChallengeAuthenticator(Context context, boolean optional, ChallengeScheme challengeScheme, java.lang.String realm)
context
- The context.optional
- Indicates if the authentication success is optional.challengeScheme
- The authentication scheme to use.realm
- The authentication realm.ChallengeAuthenticator(Context, boolean, ChallengeScheme, String,
Verifier)
public ChallengeAuthenticator(Context context, boolean optional, ChallengeScheme challengeScheme, java.lang.String realm, Verifier verifier)
context
- The context.optional
- Indicates if the authentication success is optional.challengeScheme
- The authentication scheme to use.realm
- The authentication realm.verifier
- The credentials verifier.public ChallengeAuthenticator(Context context, ChallengeScheme challengeScheme, java.lang.String realm)
context
- The context.challengeScheme
- The authentication scheme to use.realm
- The authentication realm.ChallengeAuthenticator(Context, boolean, ChallengeScheme, String,
Verifier)
protected boolean authenticate(Request request, Response response)
challenge(Response, boolean)
is invoked.challenge(Response, boolean)
is invoked. Otherwise,
forbid(Response)
is invoked.challenge(Response, boolean)
is invoked with the "stale" parameter to true.ClientInfo.setAuthenticated(boolean)
method is invoked.authenticate
in class Authenticator
request
- The request sent.response
- The response to update.public void challenge(Response response, boolean stale)
Status.CLIENT_ERROR_UNAUTHORIZED
.response
- The response to update.stale
- Indicates if the new challenge is due to a stale response.protected ChallengeRequest createChallengeRequest(boolean stale)
stale
- Indicates if the new challenge is due to a stale response.public void forbid(Response response)
response
- The reject response.public java.lang.String getRealm()
public ChallengeScheme getScheme()
public Verifier getVerifier()
public boolean isRechallenging()
forbid(Response)
will be called.public void setRealm(java.lang.String realm)
realm
- The authentication realm.public void setRechallenging(boolean rechallenging)
rechallenging
- True if invalid credentials result in a new challenge.isRechallenging()
public void setVerifier(Verifier verifier)
verifier
- The credentials verifier.Copyright © 2005-2024 Restlet.