Package com.nimbusds.oauth2.sdk.token
Class TokenSchemeError
java.lang.Object
com.nimbusds.oauth2.sdk.ErrorObject
com.nimbusds.oauth2.sdk.token.TokenSchemeError
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BearerTokenError
,DPoPTokenError
The base abstract class for token scheme errors. Concrete extending classes
should be immutable.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TokenSchemeError
(AccessTokenType scheme, String code, String description, int httpStatusCode, URI uri, String realm, Scope scope) Creates a new token error with the specified code, description, HTTP status code, page URI, realm and scope. -
Method Summary
Modifier and TypeMethodDescriptionabstract TokenSchemeError
appendDescription
(String text) Appends the specified text to the error description.getRealm()
Returns the realm.Returns the token scheme.getScope()
Returns the required scope.static boolean
isScopeWithValidChars
(Scope scope) Returnstrue
if the specified scope consists of valid characters.abstract TokenSchemeError
setDescription
(String description) Sets the error description.abstract TokenSchemeError
setHTTPStatusCode
(int httpStatusCode) Sets the HTTP status code.abstract TokenSchemeError
Sets the realm.abstract TokenSchemeError
Sets the required scope.abstract TokenSchemeError
Sets the error page URI.Returns theWWW-Authenticate
HTTP response header code for this token scheme error.Methods inherited from class com.nimbusds.oauth2.sdk.ErrorObject
equals, getCode, getCustomParams, getDescription, getHTTPStatusCode, getURI, hashCode, isLegal, isLegal, parse, parse, parse, removeIllegalChars, setCustomParams, toHTTPResponse, toJSONObject, toParameters, toString
-
Constructor Details
-
TokenSchemeError
protected TokenSchemeError(AccessTokenType scheme, String code, String description, int httpStatusCode, URI uri, String realm, Scope scope) Creates a new token error with the specified code, description, HTTP status code, page URI, realm and scope.- Parameters:
scheme
- The token scheme. Must not benull
.code
- The error code,null
if not specified.description
- The error description,null
if not specified.httpStatusCode
- The HTTP status code, zero if not specified.uri
- The error page URI,null
if not specified.realm
- The realm,null
if not specified.scope
- The required scope,null
if not specified.
-
-
Method Details
-
isScopeWithValidChars
Returnstrue
if the specified scope consists of valid characters. Values for the "scope" attributes must not include characters outside the [0x20, 0x21] | [0x23 - 0x5B] | [0x5D - 0x7E] range. See RFC 6750, section 3.- Parameters:
scope
- The scope.- Returns:
true
if the scope contains valid characters, elsefalse
.- See Also:
-
getScheme
Returns the token scheme.- Returns:
- The token scheme.
-
getRealm
Returns the realm.- Returns:
- The realm,
null
if not specified.
-
getScope
Returns the required scope.- Returns:
- The required scope,
null
if not specified.
-
setDescription
Description copied from class:ErrorObject
Sets the error description.- Overrides:
setDescription
in classErrorObject
- Parameters:
description
- The error description,null
if not specified.- Returns:
- A copy of this error with the specified description.
-
appendDescription
Description copied from class:ErrorObject
Appends the specified text to the error description.- Overrides:
appendDescription
in classErrorObject
- Parameters:
text
- The text to append to the error description,null
if not specified.- Returns:
- A copy of this error with the specified appended description.
-
setHTTPStatusCode
Description copied from class:ErrorObject
Sets the HTTP status code.- Overrides:
setHTTPStatusCode
in classErrorObject
- Parameters:
httpStatusCode
- The HTTP status code, zero if not specified.- Returns:
- A copy of this error with the specified HTTP status code.
-
setURI
Description copied from class:ErrorObject
Sets the error page URI.- Overrides:
setURI
in classErrorObject
- Parameters:
uri
- The error page URI,null
if not specified.- Returns:
- A copy of this error with the specified page URI.
-
setRealm
Sets the realm.- Parameters:
realm
- realm,null
if not specified.- Returns:
- A copy of this error with the specified realm.
-
setScope
Sets the required scope.- Parameters:
scope
- The required scope,null
if not specified.- Returns:
- A copy of this error with the specified required scope.
-
toWWWAuthenticateHeader
Returns theWWW-Authenticate
HTTP response header code for this token scheme error.Example:
Bearer realm="example.com", error="invalid_token", error_description="Invalid access token"
- Returns:
- The
Www-Authenticate
header value.
-