Class AuthenticatorUtils


  • public class AuthenticatorUtils
    extends java.lang.Object
    Authentication utilities.
    Author:
    Jerome Louvel, Ray Waldin (ray@waldin.net)
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean anyNull​(java.lang.Object... objects)
      Indicates if any of the objects is null.
      static java.lang.String formatAuthenticationInfo​(org.restlet.data.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​(org.restlet.data.ChallengeRequest challenge, org.restlet.Response response, org.restlet.util.Series<org.restlet.data.Header> httpHeaders)
      Formats a challenge request as a HTTP header value.
      static java.lang.String formatResponse​(org.restlet.data.ChallengeResponse challenge, org.restlet.Request request, org.restlet.util.Series<org.restlet.data.Header> httpHeaders)
      Formats a challenge response as a HTTP header value.
      static org.restlet.data.AuthenticationInfo parseAuthenticationInfo​(java.lang.String header)
      Parses the "Authentication-Info" header.
      static java.util.List<org.restlet.data.ChallengeRequest> parseRequest​(org.restlet.Response response, java.lang.String header, org.restlet.util.Series<org.restlet.data.Header> httpHeaders)
      Parses an authenticate header into a list of challenge request.
      static org.restlet.data.ChallengeResponse parseResponse​(org.restlet.Request request, java.lang.String header, org.restlet.util.Series<org.restlet.data.Header> httpHeaders)
      Parses an authorization header into a challenge response.
      static void update​(org.restlet.data.ChallengeResponse challengeResponse, org.restlet.Request request, org.restlet.Response response)
      Updates a ChallengeResponse object according to given request and response.
      static org.restlet.data.Reference updateReference​(org.restlet.data.Reference resourceRef, org.restlet.data.ChallengeResponse challengeResponse, org.restlet.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​(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.
      • 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.
      • parseAuthenticationInfo

        public static org.restlet.data.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<org.restlet.data.ChallengeRequest> parseRequest​(org.restlet.Response response,
                                                                                     java.lang.String header,
                                                                                     org.restlet.util.Series<org.restlet.data.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 org.restlet.data.ChallengeResponse parseResponse​(org.restlet.Request request,
                                                                       java.lang.String header,
                                                                       org.restlet.util.Series<org.restlet.data.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​(org.restlet.data.ChallengeResponse challengeResponse,
                                  org.restlet.Request request,
                                  org.restlet.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 org.restlet.data.Reference updateReference​(org.restlet.data.Reference resourceRef,
                                                                 org.restlet.data.ChallengeResponse challengeResponse,
                                                                 org.restlet.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.