Package org.restlet.ext.crypto.internal
Class HttpDigestHelper
- java.lang.Object
-
- org.restlet.engine.Helper
-
- org.restlet.engine.security.AuthenticatorHelper
-
- org.restlet.ext.crypto.internal.HttpDigestHelper
-
public class HttpDigestHelper extends AuthenticatorHelper
Implements the HTTP DIGEST authentication.
-
-
Constructor Summary
Constructors Constructor Description HttpDigestHelper()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidformatRequest(ChallengeWriter cw, ChallengeRequest challenge, Response response, Series<Header> httpHeaders)Formats a challenge request as raw credentials.voidformatResponse(ChallengeWriter cw, ChallengeResponse challenge, Request request, Series<Header> httpHeaders)Formats a challenge response as raw credentials.char[]formatResponseDigest(ChallengeResponse challengeResponse, Request request)Formats the response digest.static booleanisNonceValid(java.lang.String nonce, java.lang.String secretKey, long lifespan)Checks whether the specified nonce is valid with respect to the specified secretKey, and further confirms that the nonce was generated less than lifespanMillis milliseconds agovoidparseRequest(ChallengeRequest challenge, Response response, Series<Header> httpHeaders)Parses an authenticate header into a challenge request.voidparseResponse(ChallengeResponse challenge, Request request, Series<Header> httpHeaders)Parses an authorization header into a challenge response.-
Methods inherited from class org.restlet.engine.security.AuthenticatorHelper
getChallengeScheme, getLogger, isClientSide, isServerSide, setChallengeScheme, setClientSide, setServerSide, updateReference
-
-
-
-
Method Detail
-
isNonceValid
public static boolean isNonceValid(java.lang.String nonce, java.lang.String secretKey, long lifespan) throws java.lang.ExceptionChecks whether the specified nonce is valid with respect to the specified secretKey, and further confirms that the nonce was generated less than lifespanMillis milliseconds ago- Parameters:
nonce- The nonce value.secretKey- The same secret value that was inserted into the nonce when it was generatedlifespan- The nonce lifespan in milliseconds.- Returns:
- True if the nonce was generated less than lifespan milliseconds ago, false otherwise.
- Throws:
java.lang.Exception- If the nonce does not match the specified secretKey, or if it can't be parsed
-
formatRequest
public void formatRequest(ChallengeWriter cw, ChallengeRequest challenge, Response response, Series<Header> httpHeaders) throws java.io.IOException
Description copied from class:AuthenticatorHelperFormats a challenge request as raw credentials.- Overrides:
formatRequestin classAuthenticatorHelper- Parameters:
cw- The header writer to update.challenge- The challenge request to format.response- The parent response.httpHeaders- The current request HTTP headers.- Throws:
java.io.IOException
-
formatResponse
public void formatResponse(ChallengeWriter cw, ChallengeResponse challenge, Request request, Series<Header> httpHeaders)
Description copied from class:AuthenticatorHelperFormats a challenge response as raw credentials.- Overrides:
formatResponsein classAuthenticatorHelper- Parameters:
cw- The header writer to update.challenge- The challenge response to format.request- The parent request.httpHeaders- The current request HTTP headers.
-
formatResponseDigest
public char[] formatResponseDigest(ChallengeResponse challengeResponse, Request request)
Formats the response digest.- Parameters:
challengeResponse- The challenge response.request- The request if available.- Returns:
- The formatted secret of a challenge response.
-
parseRequest
public void parseRequest(ChallengeRequest challenge, Response response, Series<Header> httpHeaders)
Description copied from class:AuthenticatorHelperParses an authenticate header into a challenge request. The header isHeaderConstants.HEADER_WWW_AUTHENTICATE.- Overrides:
parseRequestin classAuthenticatorHelper- Parameters:
challenge- The challenge request to update.response- The parent response.httpHeaders- The current response HTTP headers.
-
parseResponse
public void parseResponse(ChallengeResponse challenge, Request request, Series<Header> httpHeaders)
Description copied from class:AuthenticatorHelperParses an authorization header into a challenge response. The header isHeaderConstants.HEADER_AUTHORIZATION.- Overrides:
parseResponsein classAuthenticatorHelper- Parameters:
challenge- The challenge response to update.request- The parent request.httpHeaders- The current request HTTP headers.
-
-