Package org.restlet.data
Class ChallengeResponse
- java.lang.Object
-
- org.restlet.data.ChallengeMessage
-
- org.restlet.data.ChallengeResponse
-
public final class ChallengeResponse extends ChallengeMessage
Authentication response sent by client to an origin server. This is typically following aChallengeRequestsent by the origin server to the client.
Sometimes, it might be faster to preemptively issue a challenge response if the client knows for sure that the target resource will require authentication.
Note that when used with HTTP connectors, this class maps to the "Authorization" header.- Author:
- Jerome Louvel
-
-
Field Summary
-
Fields inherited from class org.restlet.data.ChallengeMessage
QUALITY_AUTHENTICATION, QUALITY_AUTHENTICATION_INTEGRITY
-
-
Constructor Summary
Constructors Constructor Description ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, char[] secret)Constructor.ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, char[] secret, java.lang.String secretAlgorithm)Constructor.ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, java.lang.String secret)Constructor.ChallengeResponse(ChallengeScheme scheme)Constructor with no credentials.ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, char[] secret)Constructor.ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, char[] secret, Series<Parameter> parameters)Constructor.ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, java.lang.String secret)Constructor.ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, Series<Parameter> parameters)Constructor.ChallengeResponse(ChallengeScheme scheme, Series<Parameter> parameters, java.lang.String identifier, char[] secret, java.lang.String secretAlgorithm, java.lang.String realm, java.lang.String quality, Reference digestRef, java.lang.String digestAlgorithm, java.lang.String opaque, java.lang.String clientNonce, java.lang.String serverNonce, int serverNounceCount, long timeIssued)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)java.lang.StringgetClientNonce()Returns the client nonce.ReferencegetDigestRef()Returns theRequest.getResourceRef()value duplicated here in case a proxy changed it.java.lang.StringgetIdentifier()Returns the user identifier, such as a login name or an access key.java.security.PrincipalgetPrincipal()Gets the principal associated to the identifier property.java.lang.StringgetQuality()Returns the chosen quality of protection.char[]getSecret()Returns the user secret, such as a password or a secret key.java.lang.StringgetSecretAlgorithm()Returns the digest algorithm name optionally applied on the user secret.intgetServerNounceCount()Returns the server nonce count.java.lang.StringgetServerNounceCountAsHex()Returns the server nonce count as an hexadecimal string of eight characters.longgetTimeIssued()Returns the time when the response was issued, as returned bySystem.currentTimeMillis().inthashCode()voidsetClientNonce(java.lang.String clientNonce)Sets the client nonce.voidsetDigestRef(Reference digestRef)Sets the digest URI reference.voidsetIdentifier(java.lang.String identifier)Sets the user identifier, such as a login name or an access key.voidsetQuality(java.lang.String quality)Sets the chosen quality of protection.voidsetSecret(char[] secret)Sets the user secret, such as a password or a secret key.voidsetSecret(java.lang.String secret)Sets the user secret, such as a password or a secret key.voidsetSecretAlgorithm(java.lang.String secretDigestAlgorithm)Sets the digest algorithm name optionally applied on the user secret.voidsetServerNounceCount(int serverNounceCount)Sets the server nonce count.voidsetTimeIssued(long timeIssued)Sets the time when the response was issued, as returned bySystem.currentTimeMillis().-
Methods inherited from class org.restlet.data.ChallengeMessage
getDigestAlgorithm, getOpaque, getParameters, getRawValue, getRealm, getScheme, getServerNonce, setDigestAlgorithm, setOpaque, setParameters, setRawValue, setRealm, setScheme, setServerNonce
-
-
-
-
Constructor Detail
-
ChallengeResponse
public ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, char[] secret)
Constructor. It leverages the latest server response and challenge request in order to compute the credentials.- Parameters:
challengeRequest- The challenge request sent by the origin server.response- The latest server response.identifier- The user identifier, such as a login name or an access key.secret- The user secret, such as a password or a secret key, with no digest applied.
-
ChallengeResponse
public ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, char[] secret, java.lang.String secretAlgorithm)
Constructor. It leverages the latest server response and challenge request in order to compute the credentials.- Parameters:
challengeRequest- The challenge request sent by the origin server.response- The latest server response.identifier- The user identifier, such as a login name or an access key.secret- The user secret used to compute the secret, with an optional digest applied.secretAlgorithm- The digest algorithm of the user secret (seeDigestclass).
-
ChallengeResponse
public ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, java.lang.String secret)
Constructor. It leverages the latest server response and challenge request in order to compute the credentials.- Parameters:
challengeRequest- The challenge request sent by the origin server.response- The latest server response.identifier- The user identifier, such as a login name or an access key.secret- The user secret, such as a password or a secret key.
-
ChallengeResponse
public ChallengeResponse(ChallengeScheme scheme)
Constructor with no credentials.- Parameters:
scheme- The challenge scheme.
-
ChallengeResponse
public ChallengeResponse(ChallengeScheme scheme, Series<Parameter> parameters, java.lang.String identifier, char[] secret, java.lang.String secretAlgorithm, java.lang.String realm, java.lang.String quality, Reference digestRef, java.lang.String digestAlgorithm, java.lang.String opaque, java.lang.String clientNonce, java.lang.String serverNonce, int serverNounceCount, long timeIssued)
Constructor.- Parameters:
scheme- The challenge scheme.parameters- The additional scheme parameters.identifier- The user identifier, such as a login name or an access key.secret- The user secret, such as a password or a secret key.secretAlgorithm- The digest algorithm name optionally applied on the user secret.realm- The authentication realm.quality- The chosen quality of protection.digestRef- TheRequest.getResourceRef()value duplicated here in case a proxy changed it.digestAlgorithm- The digest algorithm.opaque- An opaque string of data which should be returned by the client unchanged.clientNonce- The client nonce value.serverNonce- The server nonce.serverNounceCount- The server nonce count.timeIssued- The time when the response was issued, as returned bySystem.currentTimeMillis().
-
ChallengeResponse
public ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, char[] secret)
Constructor.- Parameters:
scheme- The challenge scheme.identifier- The user identifier, such as a login name or an access key.secret- The user secret, such as a password or a secret key.
-
ChallengeResponse
public ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, char[] secret, Series<Parameter> parameters)
Constructor.- Parameters:
scheme- The challenge scheme.identifier- The user identifier, such as a login name or an access key.parameters- The additional scheme parameters.
-
ChallengeResponse
public ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, Series<Parameter> parameters)
Constructor.- Parameters:
scheme- The challenge scheme.identifier- The user identifier, such as a login name or an access key.parameters- The additional scheme parameters.
-
ChallengeResponse
public ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, java.lang.String secret)
Constructor.- Parameters:
scheme- The challenge scheme.identifier- The user identifier, such as a login name or an access key.secret- The user secret, such as a password or a secret key.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classChallengeMessage
-
getClientNonce
public java.lang.String getClientNonce()
Returns the client nonce.- Returns:
- The client nonce.
-
getDigestRef
public Reference getDigestRef()
Returns theRequest.getResourceRef()value duplicated here in case a proxy changed it.- Returns:
- The digest URI reference.
-
getIdentifier
public java.lang.String getIdentifier()
Returns the user identifier, such as a login name or an access key.- Returns:
- The user identifier, such as a login name or an access key.
-
getPrincipal
public java.security.Principal getPrincipal()
Gets the principal associated to the identifier property.- Returns:
- The principal associated to the identifier property.
-
getQuality
public java.lang.String getQuality()
Returns the chosen quality of protection.- Returns:
- The chosen quality of protection.
-
getSecret
public char[] getSecret()
Returns the user secret, such as a password or a secret key. It is not recommended to useString(char[])for security reasons.- Returns:
- The user secret, such as a password or a secret key.
-
getSecretAlgorithm
public java.lang.String getSecretAlgorithm()
Returns the digest algorithm name optionally applied on the user secret.- Returns:
- The digest algorithm name optionally applied on the user secret.
-
getServerNounceCount
public int getServerNounceCount()
Returns the server nonce count.- Returns:
- The server nonce count.
-
getServerNounceCountAsHex
public java.lang.String getServerNounceCountAsHex()
Returns the server nonce count as an hexadecimal string of eight characters.- Returns:
- The server nonce count as an hexadecimal string.
-
getTimeIssued
public long getTimeIssued()
Returns the time when the response was issued, as returned bySystem.currentTimeMillis().- Returns:
- The time when the response was issued.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classChallengeMessage
-
setClientNonce
public void setClientNonce(java.lang.String clientNonce)
Sets the client nonce.- Parameters:
clientNonce- The client nonce.
-
setDigestRef
public void setDigestRef(Reference digestRef)
Sets the digest URI reference.- Parameters:
digestRef- The digest URI reference.
-
setIdentifier
public void setIdentifier(java.lang.String identifier)
Sets the user identifier, such as a login name or an access key.- Parameters:
identifier- The user identifier, such as a login name or an access key.
-
setQuality
public void setQuality(java.lang.String quality)
Sets the chosen quality of protection.- Parameters:
quality- The chosen quality of protection.
-
setSecret
public void setSecret(char[] secret)
Sets the user secret, such as a password or a secret key.- Parameters:
secret- The user secret, such as a password or a secret key.
-
setSecret
public void setSecret(java.lang.String secret)
Sets the user secret, such as a password or a secret key.- Parameters:
secret- The user secret, such as a password or a secret key.
-
setSecretAlgorithm
public void setSecretAlgorithm(java.lang.String secretDigestAlgorithm)
Sets the digest algorithm name optionally applied on the user secret.- Parameters:
secretDigestAlgorithm- The digest algorithm name optionally applied on the user secret.
-
setServerNounceCount
public void setServerNounceCount(int serverNounceCount)
Sets the server nonce count.- Parameters:
serverNounceCount- The server nonce count.
-
setTimeIssued
public void setTimeIssued(long timeIssued)
Sets the time when the response was issued, as returned bySystem.currentTimeMillis().- Parameters:
timeIssued- The time when the response was issued.
-
-