Package com.nimbusds.oauth2.sdk.token
Class TokenSchemeError
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.ErrorObject
-
- com.nimbusds.oauth2.sdk.token.TokenSchemeError
-
- Direct Known Subclasses:
BearerTokenError
,DPoPTokenError
public abstract class TokenSchemeError extends ErrorObject
The base abstract class for token scheme errors. Concrete extending classes should be immutable.
-
-
Constructor Summary
Constructors Modifier Constructor Description 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.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract TokenSchemeError
appendDescription(String text)
Appends the specified text to the error description.String
getRealm()
Returns the realm.AccessTokenType
getScheme()
Returns the token scheme.Scope
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
setRealm(String realm)
Sets the realm.abstract TokenSchemeError
setScope(Scope scope)
Sets the required scope.abstract TokenSchemeError
setURI(URI uri)
Sets the error page URI.String
toWWWAuthenticateHeader()
Returns theWWW-Authenticate
HTTP response header code for this token scheme error.-
Methods inherited from class com.nimbusds.oauth2.sdk.ErrorObject
equals, getCode, getDescription, getHTTPStatusCode, getURI, hashCode, isLegal, isLegal, parse, parse, parse, toHTTPResponse, toJSONObject, toParameters, toString
-
-
-
-
Constructor Detail
-
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 Detail
-
isScopeWithValidChars
public static boolean isScopeWithValidChars(Scope scope)
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:
ErrorObject.isLegal(String)
-
getScheme
public AccessTokenType getScheme()
Returns the token scheme.- Returns:
- The token scheme.
-
getScope
public Scope getScope()
Returns the required scope.- Returns:
- The required scope,
null
if not specified.
-
setDescription
public abstract TokenSchemeError setDescription(String description)
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
public abstract TokenSchemeError appendDescription(String text)
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
public abstract TokenSchemeError setHTTPStatusCode(int httpStatusCode)
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
public abstract TokenSchemeError setURI(URI uri)
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
public abstract TokenSchemeError setRealm(String realm)
Sets the realm.- Parameters:
realm
- realm,null
if not specified.- Returns:
- A copy of this error with the specified realm.
-
setScope
public abstract TokenSchemeError setScope(Scope scope)
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
public String 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.
-
-