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
public abstract class TokenSchemeError extends ErrorObject
The base abstract class for token scheme errors. Concrete extending classes should be immutable.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTokenSchemeError(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 TokenSchemeErrorappendDescription(String text)Appends the specified text to the error description.StringgetRealm()Returns the realm.AccessTokenTypegetScheme()Returns the token scheme.ScopegetScope()Returns the required scope.static booleanisScopeWithValidChars(Scope scope)Returnstrueif the specified scope consists of valid characters.abstract TokenSchemeErrorsetDescription(String description)Sets the error description.abstract TokenSchemeErrorsetHTTPStatusCode(int httpStatusCode)Sets the HTTP status code.abstract TokenSchemeErrorsetRealm(String realm)Sets the realm.abstract TokenSchemeErrorsetScope(Scope scope)Sets the required scope.abstract TokenSchemeErrorsetURI(URI uri)Sets the error page URI.StringtoWWWAuthenticateHeader()Returns theWWW-AuthenticateHTTP 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, setCustomParams, 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,nullif not specified.description- The error description,nullif not specified.httpStatusCode- The HTTP status code, zero if not specified.uri- The error page URI,nullif not specified.realm- The realm,nullif not specified.scope- The required scope,nullif not specified.
-
-
Method Detail
-
isScopeWithValidChars
public static boolean isScopeWithValidChars(Scope scope)
Returnstrueif 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:
trueif 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,
nullif not specified.
-
setDescription
public abstract TokenSchemeError setDescription(String description)
Description copied from class:ErrorObjectSets the error description.- Overrides:
setDescriptionin classErrorObject- Parameters:
description- The error description,nullif not specified.- Returns:
- A copy of this error with the specified description.
-
appendDescription
public abstract TokenSchemeError appendDescription(String text)
Description copied from class:ErrorObjectAppends the specified text to the error description.- Overrides:
appendDescriptionin classErrorObject- Parameters:
text- The text to append to the error description,nullif not specified.- Returns:
- A copy of this error with the specified appended description.
-
setHTTPStatusCode
public abstract TokenSchemeError setHTTPStatusCode(int httpStatusCode)
Description copied from class:ErrorObjectSets the HTTP status code.- Overrides:
setHTTPStatusCodein 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:ErrorObjectSets the error page URI.- Overrides:
setURIin classErrorObject- Parameters:
uri- The error page URI,nullif 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,nullif 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,nullif not specified.- Returns:
- A copy of this error with the specified required scope.
-
toWWWAuthenticateHeader
public String toWWWAuthenticateHeader()
Returns theWWW-AuthenticateHTTP response header code for this token scheme error.Example:
Bearer realm="example.com", error="invalid_token", error_description="Invalid access token"
- Returns:
- The
Www-Authenticateheader value.
-
-