org.restlet.engine.security
Class AuthenticatorUtils

java.lang.Object
  extended by org.restlet.engine.security.AuthenticatorUtils

public class AuthenticatorUtils
extends Object

Authentication utilities.

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

Method Summary
static boolean anyNull(Object... objects)
          Indicates if any of the objects is null.
static String formatAuthenticationInfo(AuthenticationInfo info)
          Formats an authentication information as a HTTP header value.
static String formatNonceCount(int nonceCount)
          Formats a given nonce count as a HTTP header value.
static String formatRequest(ChallengeRequest challenge, Response response, Series<Header> httpHeaders)
          Formats a challenge request as a HTTP header value.
static String formatResponse(ChallengeResponse challenge, Request request, Series<Header> httpHeaders)
          Formats a challenge response as a HTTP header value.
static AuthenticationInfo parseAuthenticationInfo(String header)
          Parses the "Authentication-Info" header.
static List<ChallengeRequest> parseRequest(Response response, String header, Series<Header> httpHeaders)
          Parses an authenticate header into a list of challenge request.
static ChallengeResponse parseResponse(Request request, String header, Series<Header> httpHeaders)
          Parses an authorization header into a challenge response.
static void update(ChallengeResponse challengeResponse, Request request, Response response)
          Updates a ChallengeResponse object according to given request and response.
static Reference updateReference(Reference resourceRef, ChallengeResponse challengeResponse, Request request)
          Optionally updates the request with a challenge response before sending it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

anyNull

public static boolean anyNull(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.

formatAuthenticationInfo

public static String formatAuthenticationInfo(AuthenticationInfo info)
Formats an authentication information as a HTTP header value. The header is HeaderConstants.HEADER_AUTHENTICATION_INFO.

Parameters:
info - The authentication information to format.
Returns:
The HeaderConstants.HEADER_AUTHENTICATION_INFO header value.

formatNonceCount

public static String formatNonceCount(int nonceCount)
Formats a given nonce count as a HTTP header value. The header is HeaderConstants.HEADER_AUTHENTICATION_INFO.

Parameters:
nonceCount - The given nonce count.
Returns:
The formatted value of the given nonce count.

formatRequest

public static String formatRequest(ChallengeRequest challenge,
                                   Response response,
                                   Series<Header> httpHeaders)
Formats a challenge request as a HTTP header value. The header is HeaderConstants.HEADER_WWW_AUTHENTICATE. The default implementation relies on #formatRequest(ChallengeWriter, ChallengeRequest, Response, Series) to append all parameters from ChallengeMessage.getParameters().

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

formatResponse

public static String formatResponse(ChallengeResponse challenge,
                                    Request request,
                                    Series<Header> httpHeaders)
Formats a challenge response as a HTTP header value. The header is HeaderConstants.HEADER_AUTHORIZATION. The default implementation relies on #formatResponse(ChallengeWriter, ChallengeResponse, Request, Series) unless some custom credentials are provided via

Parameters:
challenge - The challenge response to format.
request - The parent request.
httpHeaders - The current request HTTP headers.
Returns:
The HeaderConstants.HEADER_AUTHORIZATION header value.
Throws:
IOException

parseAuthenticationInfo

public static AuthenticationInfo parseAuthenticationInfo(String header)
Parses the "Authentication-Info" header.

Parameters:
header - The header value to parse.
Returns:
The equivalent AuthenticationInfo instance.
Throws:
IOException

parseRequest

public static List<ChallengeRequest> parseRequest(Response response,
                                                  String header,
                                                  Series<Header> httpHeaders)
Parses an authenticate header into a list of challenge request. The header is HeaderConstants.HEADER_WWW_AUTHENTICATE.

Parameters:
header - The HTTP header value to parse.
httpHeaders - The current response HTTP headers.
Returns:
The list of parsed challenge request.

parseResponse

public static ChallengeResponse parseResponse(Request request,
                                              String header,
                                              Series<Header> httpHeaders)
Parses an authorization header into a challenge response. The header is HeaderConstants.HEADER_AUTHORIZATION.

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

update

public static void update(ChallengeResponse challengeResponse,
                          Request request,
                          Response response)
Updates a ChallengeResponse object according to given request and response.

Parameters:
challengeResponse - The challengeResponse to update.
request - The request.
response - The response.

updateReference

public static Reference updateReference(Reference resourceRef,
                                        ChallengeResponse challengeResponse,
                                        Request request)
Optionally updates the request with a challenge response before sending it. This is sometimes useful for authentication schemes that aren't based on the Authorization header but instead on URI query parameters or other headers. By default it returns the resource URI reference unchanged.

Parameters:
resourceRef - The resource URI reference to update.
challengeResponse - The challenge response provided.
request - The request to update.
Returns:
The original URI reference if unchanged or a new one if updated.


Copyright © 2005-2013 Restlet.