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 a `ChallengeRequest` sent 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 and Description
`ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, char[] baseSecret)` Constructor.
`ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, char[] baseSecret, java.lang.String baseSecretAlgorithm)` Constructor.
`ChallengeResponse(ChallengeRequest challengeRequest, Response response, java.lang.String identifier, java.lang.String baseSecret)` Constructor.
`ChallengeResponse(ChallengeScheme scheme)` Constructor with no credentials.
`ChallengeResponse(ChallengeScheme scheme, java.lang.String credentials)` Deprecated. Use `ChallengeMessage.setRawValue(String)` instead.
`ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, char[] secret)` Constructor.
`ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, Series<Parameter> parameters)` Constructor.
`ChallengeResponse(ChallengeScheme scheme, java.lang.String identifier, java.lang.String secret)` Constructor.

### Method Summary

Methods
`boolean` `equals(java.lang.Object obj)`
`java.lang.String` `getClientNonce()` Returns the client nonce.
`java.lang.String` `getCredentials()` Deprecated. Use `ChallengeMessage.getRawValue()` instead.
`Reference` `getDigestRef()` Returns the `Request.getResourceRef()` value duplicated here in case a proxy changed it.
`java.lang.String` `getIdentifier()` Returns the user identifier, such as a login name or an access key.
`java.security.Principal` `getPrincipal()` Gets the principal associated to the identifier property.
`java.lang.String` `getQuality()` Returns the chosen quality of protection.
`char[]` `getSecret()` Returns the user secret, such as a password or a secret key.
`int` `getServerNounceCount()` Returns the server nonce count.
`java.lang.String` `getServerNounceCountAsHex()` Returns the server nonce count as an hexadecimal string of eight characters.
`int` `hashCode()`
`boolean` `isAuthenticated()` Deprecated. Use `ClientInfo.isAuthenticated()` instead.
`void` `setAuthenticated(boolean authenticated)` Deprecated. Use `ClientInfo.setAuthenticated(boolean)` instead.
`void` `setClientNonce(java.lang.String clientNonce)` Sets the client nonce.
`void` `setCredentials(java.lang.String credentials)` Deprecated. Use `ChallengeMessage.getRawValue()` instead.
`void` `setDigestRef(Reference digestRef)` Sets the digest URI reference.
`void` `setIdentifier(java.lang.String identifier)` Sets the user identifier, such as a login name or an access key.
`void` `setQuality(java.lang.String quality)` Sets the chosen quality of protection.
`void` `setSecret(char[] secret)` Sets the user secret, such as a password or a secret key.
`void` `setSecret(java.lang.String secret)` Sets the user secret, such as a password or a secret key.
`void` `setServerNounceCount(int serverNounceCount)` Sets the server nonce count.

### Methods inherited from class org.restlet.data.ChallengeMessage

`getDigestAlgorithm, getOpaque, getParameters, getRawValue, getRealm, getScheme, getServerNonce, setDigestAlgorithm, setOpaque, setParameters, setRawValue, setRealm, setScheme, setServerNonce`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ChallengeResponse

    public ChallengeResponse(ChallengeRequest challengeRequest,
                     Response response,
                     java.lang.String identifier,
                     char[] baseSecret)

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.
  `baseSecret` - The user secret, such as a password or a secret key.

#### ChallengeResponse

    public ChallengeResponse(ChallengeRequest challengeRequest,
                     Response response,
                     java.lang.String identifier,
                     java.lang.String baseSecret)

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.
  `baseSecret` - The user secret, such as a password or a secret key.

#### ChallengeResponse

    public ChallengeResponse(ChallengeRequest challengeRequest,
                     Response response,
                     java.lang.String identifier,
                     char[] baseSecret,
                     java.lang.String baseSecretAlgorithm)

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.
  `baseSecret` - The base secret used to compute the secret.
  `baseSecretAlgorithm` - The digest algorithm of the base secret (see `Digest` class).

#### ChallengeResponse

    public ChallengeResponse(ChallengeScheme scheme)

Constructor with no credentials.

Parameters:
  `scheme` - The challenge scheme.

#### ChallengeResponse

    @Deprecated
    public ChallengeResponse(ChallengeScheme scheme,
                                java.lang.String credentials)

Deprecated. Use `ChallengeMessage.setRawValue(String)` instead.
Constructor.

Parameters:
  `scheme` - The challenge scheme.
  `credentials` - The raw credentials for custom challenge schemes.

#### 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,
                     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:
  `equals` in class `java.lang.Object`

#### getClientNonce

    public java.lang.String getClientNonce()

Returns the client nonce.

Returns:
  The client nonce.

#### getCredentials

    @Deprecated
    public java.lang.String getCredentials()

Deprecated. Use `ChallengeMessage.getRawValue()` instead.
Returns the raw credentials.

Returns:
  The raw credentials.

#### getDigestRef

    public Reference getDigestRef()

Returns the `Request.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 use `String.String(char[])` for security reasons.

Returns:
  The user secret, such as a password or a secret key.

#### 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.

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `ChallengeMessage`

#### isAuthenticated

    @Deprecated
    public boolean isAuthenticated()

Deprecated. Use `ClientInfo.isAuthenticated()` instead.
Indicates if the identifier or principal has been authenticated. The application is responsible for updating this property, relying on a `Guard` or manually.

Returns:
  True if the identifier or principal has been authenticated.

#### setAuthenticated

    @Deprecated
    public void setAuthenticated(boolean authenticated)

Deprecated. Use `ClientInfo.setAuthenticated(boolean)` instead.
Indicates if the identifier or principal has been authenticated. The application is responsible for updating this property, relying on a `Guard` or manually.

Parameters:
  `authenticated` - True if the identifier or principal has been authenticated.

#### setClientNonce

    public void setClientNonce(java.lang.String clientNonce)

Sets the client nonce.

Parameters:
  `clientNonce` - The client nonce.

#### setCredentials

    @Deprecated
    public void setCredentials(java.lang.String credentials)

Deprecated. Use `ChallengeMessage.getRawValue()` instead.
Sets the raw credentials.

Parameters:
  `credentials` - The credentials.

#### 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.

#### setServerNounceCount

    public void setServerNounceCount(int serverNounceCount)

Sets the server nonce count.

Parameters:
  `serverNounceCount` - The server nonce count.