Package 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
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 aChallengeResponse
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.
-
-
-
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.
-
formatAuthenticationInfo
public static java.lang.String formatAuthenticationInfo(org.restlet.data.AuthenticationInfo info)
Formats an authentication information as a HTTP header value. The header isHeaderConstants.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 isHeaderConstants.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(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. The header isHeaderConstants.HEADER_WWW_AUTHENTICATE
. The default implementation relies onAuthenticatorHelper.formatRequest(ChallengeWriter, ChallengeRequest, Response, Series)
to append all parameters fromChallengeMessage.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 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. The header isHeaderConstants.HEADER_AUTHORIZATION
. The default implementation relies onAuthenticatorHelper.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:
java.io.IOException
-
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 isHeaderConstants.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 isHeaderConstants.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 aChallengeResponse
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.
-
-