Package com.nimbusds.oauth2.sdk.token
Class RefreshToken
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.id.Identifier
-
- com.nimbusds.oauth2.sdk.token.Token
-
- com.nimbusds.oauth2.sdk.token.RefreshToken
-
- All Implemented Interfaces:
Serializable
,Comparable<Identifier>
,net.minidev.json.JSONAware
@Immutable public final class RefreshToken extends Token
Refresh token.Related specifications:
- OAuth 2.0 (RFC 6749), section 1.5.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.nimbusds.oauth2.sdk.id.Identifier
DEFAULT_BYTE_LENGTH, secureRandom
-
-
Constructor Summary
Constructors Constructor Description RefreshToken()
Creates a new refresh token with a randomly generated 256-bit (32-byte) value, Base64URL-encoded.RefreshToken(int byteLength)
Creates a new refresh token with a randomly generated value of the specified length, Base64URL-encoded.RefreshToken(String value)
Creates a new refresh token with the specified value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object object)
Set<String>
getParameterNames()
Returns the token parameter names included in the JSON object, as required for the composition of an access token response.static RefreshToken
parse(net.minidev.json.JSONObject jsonObject)
Parses a refresh token from a JSON object access token response.net.minidev.json.JSONObject
toJSONObject()
Returns the token parameters as a JSON object, as required for the composition of an access token response.-
Methods inherited from class com.nimbusds.oauth2.sdk.id.Identifier
compareTo, getValue, hashCode, toJSONString, toString, toStringList
-
-
-
-
Constructor Detail
-
RefreshToken
public RefreshToken()
Creates a new refresh token with a randomly generated 256-bit (32-byte) value, Base64URL-encoded.
-
RefreshToken
public RefreshToken(int byteLength)
Creates a new refresh token with a randomly generated value of the specified length, Base64URL-encoded.- Parameters:
byteLength
- The byte length of the value to generate. Must be greater than one.
-
RefreshToken
public RefreshToken(String value)
Creates a new refresh token with the specified value.- Parameters:
value
- The refresh token value. Must not benull
or empty string.
-
-
Method Detail
-
getParameterNames
public Set<String> getParameterNames()
Description copied from class:Token
Returns the token parameter names included in the JSON object, as required for the composition of an access token response. See OAuth 2.0 (RFC 6749), section 5.1.- Specified by:
getParameterNames
in classToken
- Returns:
- The token parameter names.
-
toJSONObject
public net.minidev.json.JSONObject toJSONObject()
Description copied from class:Token
Returns the token parameters as a JSON object, as required for the composition of an access token response. See OAuth 2.0 (RFC 6749), section 5.1.Note that JSONObject implements Map<String,Object>.
Example:
{ "access_token" : "2YotnFZFEjr1zCsicMWpAA", "token_type" : "example", "expires_in" : 3600, "example_parameter" : "example_value" }
- Specified by:
toJSONObject
in classToken
- Returns:
- The token parameters as a JSON object.
-
parse
public static RefreshToken parse(net.minidev.json.JSONObject jsonObject) throws ParseException
Parses a refresh token from a JSON object access token response.- Parameters:
jsonObject
- The JSON object to parse. Must not benull
.- Returns:
- The refresh token,
null
if not found. - Throws:
ParseException
- If the JSON object couldn't be parsed to a refresh token.
-
equals
public boolean equals(Object object)
- Overrides:
equals
in classIdentifier
-
-