Package org.restlet.engine.security
Class AuthenticatorUtils
java.lang.Object
org.restlet.engine.security.AuthenticatorUtils
Authentication utilities.
- Author:
- Jerome Louvel, Ray Waldin (ray@waldin.net)
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanIndicates if any of the objects is null.static StringFormats authentication information as an HTTP header value.static StringformatNonceCount(int nonceCount) Formats a given nonce count as an HTTP header value.static StringformatRequest(ChallengeRequest challenge, Response response, Series<Header> httpHeaders) Formats a challenge request as an HTTP header value.static StringformatResponse(ChallengeResponse challenge, Request request, Series<Header> httpHeaders) Formats a challenge response as an HTTP header value.static AuthenticationInfoparseAuthenticationInfo(String header) Parses the "Authentication-Info" header.static List<ChallengeRequest>parseRequest(Response response, String header, Series<Header> httpHeaders) Parses an WWW-Authenticate header into a list of challenge request.static ChallengeResponseparseResponse(Request request, String header, Series<Header> httpHeaders) Parses an authorization header into a challenge response.static voidupdate(ChallengeResponse challengeResponse, Request request, Response response) Updates aChallengeResponseobject according to given request and response.static ReferenceupdateReference(Reference resourceRef, ChallengeResponse challengeResponse, Request request) Optionally updates the request with a challenge response before sending it.
-
Method Details
-
anyNull
Indicates if any of the objects is null.- Parameters:
objects- The objects to test.- Returns:
- True if any of the objects is null.
-
formatAuthenticationInfo
Formats authentication information as an HTTP header value. The header isHeaderConstants.HEADER_AUTHENTICATION_INFO.- Parameters:
info- The authentication information to format.- Returns:
- The
HeaderConstants.HEADER_AUTHENTICATION_INFOheader value.
-
formatNonceCount
Formats a given nonce count as an 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 String formatRequest(ChallengeRequest challenge, Response response, Series<Header> httpHeaders) Formats a challenge request as an 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_AUTHENTICATEheader value.
-
formatResponse
public static String formatResponse(ChallengeResponse challenge, Request request, Series<Header> httpHeaders) Formats a challenge response as an 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_AUTHORIZATIONheader value.
-
parseAuthenticationInfo
Parses the "Authentication-Info" header.- Parameters:
header- The header value to parse.- Returns:
- The equivalent
AuthenticationInfoinstance.
-
parseRequest
public static List<ChallengeRequest> parseRequest(Response response, String header, Series<Header> httpHeaders) Parses an WWW-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 ChallengeResponse parseResponse(Request request, String header, Series<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
Updates aChallengeResponseobject 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.
-