org.restlet.engine.security

## Class AuthenticatorUtils

- java.lang.Object
- - org.restlet.engine.security.AuthenticatorUtils

    public class AuthenticatorUtils
    extends java.lang.Object

Authentication utilities.

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

### Method Summary

Methods
`static boolean` `anyNull(java.lang.Object... objects)` Indicates if any of the objects is null.
`static int` `authenticate(Request request, Guard guard)` Deprecated. See new org.restlet.security package.
`static void` `challenge(Response response, boolean stale, Guard guard)` Deprecated. See new org.restlet.security package.
`static java.lang.String` `formatAuthenticationInfo(AuthenticationInfo info)` Formats an authentication information as a HTTP header value.
`static java.lang.String` `formatNonceCount(int nonceCount)` Formats a given nonce count as a HTTP header value.
`static java.lang.String` `formatRequest(ChallengeRequest challenge, Response response, Series<Parameter> httpHeaders)` Formats a challenge request as a HTTP header value.
`static java.lang.String` `formatResponse(ChallengeResponse challenge, Request request, Series<Parameter> httpHeaders)` Formats a challenge response as a HTTP header value.
`static AuthenticationInfo` `parseAuthenticationInfo(java.lang.String header)` Parses the "Authentication-Info" header.
`static java.util.List<ChallengeRequest>` `parseRequest(Response response, java.lang.String header, Series<Parameter> httpHeaders)` Parses an authenticate header into a list of challenge request.
`static ChallengeResponse` `parseResponse(Request request, java.lang.String header, Series<Parameter> 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.

### 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(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

    @Deprecated
    public static int authenticate(Request request,
                              Guard guard)

Deprecated. See new org.restlet.security package.
Indicates if the request is properly authenticated. By default, this delegates credentials 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

    @Deprecated
    public static void challenge(Response response,
                            boolean stale,
                            Guard guard)

Deprecated. See new org.restlet.security package.
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.

#### formatAuthenticationInfo

    public static java.lang.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 java.lang.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 java.lang.String formatRequest(ChallengeRequest challenge,
                                 Response response,
                                 Series<Parameter> httpHeaders)

Formats a challenge request as a HTTP header value. The header is `HeaderConstants.HEADER_WWW_AUTHENTICATE`.

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 java.lang.String formatResponse(ChallengeResponse challenge,
                                  Request request,
                                  Series<Parameter> httpHeaders)

Formats a challenge response as a HTTP header value. The header is `HeaderConstants.HEADER_AUTHORIZATION`.

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:
  `java.io.IOException`

#### parseAuthenticationInfo

    public static AuthenticationInfo parseAuthenticationInfo(java.lang.String header)

Parses the "Authentication-Info" header.

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

#### parseRequest

    public static java.util.List<ChallengeRequest> parseRequest(Response response,
                                                java.lang.String header,
                                                Series<Parameter> 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,
                                  java.lang.String header,
                                  Series<Parameter> 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.