com.noelios.restlet.authentication
Class AuthenticationUtils

java.lang.Object
  extended by com.noelios.restlet.authentication.AuthenticationUtils

public class AuthenticationUtils
extends java.lang.Object

Authentication utilities.

Author:
Jerome Louvel, Ray Waldin (ray@waldin.net)

Constructor Summary
AuthenticationUtils()
           
 
Method Summary
static boolean anyNull(java.lang.Object... objects)
          Indicates if any of the objects is null.
static int authenticate(Request request, Guard guard)
          Indicates if the request is properly authenticated.
static void challenge(Response response, boolean stale, Guard guard)
          Challenges the client by adding a challenge request to the response and by setting the status to CLIENT_ERROR_UNAUTHORIZED.
static java.lang.String format(ChallengeRequest request)
          Formats a challenge request as a HTTP header value.
static java.lang.String format(ChallengeResponse challenge, Request request, Series<Parameter> httpHeaders)
          Formats a challenge response as raw credentials.
static ChallengeRequest parseAuthenticateHeader(java.lang.String header)
          Parses an authenticate header into a challenge request.
static ChallengeResponse parseAuthorizationHeader(Request request, java.lang.String header)
          Parses an authorization header into a challenge response.
static void parseParameters(java.lang.String paramString, Series<Parameter> parameters)
          Parsed the parameters of a credientials string and updates the series of parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthenticationUtils

public AuthenticationUtils()
Method Detail

anyNull

public static boolean anyNull(java.lang.Object... objects)
Indicates if any of the objects is null.

Parameters:
objects - The objects to test.
Returns:
True if any of the objects is null.

authenticate

public static int authenticate(Request request,
                               Guard guard)
Indicates if the request is properly authenticated. By default, this delegates credential checking to checkSecret().

Parameters:
request - The request to authenticate.
guard - The associated guard to callback.
Returns:
-1 if the given credentials were invalid, 0 if no credentials were found and 1 otherwise.
See Also:
Guard.checkSecret(Request, String, char[])

challenge

public static void challenge(Response response,
                             boolean stale,
                             Guard guard)
Challenges the client by adding a challenge request to the response and by setting the status to CLIENT_ERROR_UNAUTHORIZED.

Parameters:
response - The response to update.
stale - Indicates if the new challenge is due to a stale response.
guard - The associated guard to callback.

format

public static java.lang.String format(ChallengeRequest request)
Formats a challenge request as a HTTP header value.

Parameters:
request - The challenge request to format.
Returns:
The authenticate header value.

format

public static java.lang.String format(ChallengeResponse challenge,
                                      Request request,
                                      Series<Parameter> httpHeaders)
Formats a challenge response as raw credentials.

Parameters:
challenge - The challenge response to format.
request - The parent request.
httpHeaders - The current request HTTP headers.
Returns:
The authorization header value.

parseAuthenticateHeader

public static ChallengeRequest parseAuthenticateHeader(java.lang.String header)
Parses an authenticate header into a challenge request.

Parameters:
header - The HTTP header value to parse.
Returns:
The parsed challenge request.

parseAuthorizationHeader

public static ChallengeResponse parseAuthorizationHeader(Request request,
                                                         java.lang.String header)
Parses an authorization header into a challenge response.

Parameters:
request - The request.
header - The header value to parse.
Returns:
The parsed challenge response.

parseParameters

public static void parseParameters(java.lang.String paramString,
                                   Series<Parameter> parameters)
Parsed the parameters of a credientials string and updates the series of parameters.

Parameters:
paramString - The parameters string to parse.
parameters - The series to update.


Copyright © 2005-2008 Noelios Technologies.