Package com.nimbusds.oauth2.sdk.token
Class Tokens
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.token.Tokens
-
- Direct Known Subclasses:
OIDCTokens
public class Tokens extends Object
Access and optional refresh token.
-
-
Constructor Summary
Constructors Constructor Description Tokens(AccessToken accessToken, RefreshToken refreshToken)
Creates a new tokens instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessToken
getAccessToken()
Returns the access token.BearerAccessToken
getBearerAccessToken()
Returns the access token as type bearer.Map<String,Object>
getMetadata()
Returns the optional modifiable token metadata.Set<String>
getParameterNames()
Returns the token parameter names for the included tokens.RefreshToken
getRefreshToken()
Returns the optional refresh token.static Tokens
parse(net.minidev.json.JSONObject jsonObject)
Parses an access and optional refresh token from the specified JSON object.net.minidev.json.JSONObject
toJSONObject()
Returns the JSON object representation of this token pair.OIDCTokens
toOIDCTokens()
Casts to OpenID Connect tokens.String
toString()
-
-
-
Constructor Detail
-
Tokens
public Tokens(AccessToken accessToken, RefreshToken refreshToken)
Creates a new tokens instance.- Parameters:
accessToken
- The access token. Must not benull
.refreshToken
- The refresh token. If nonenull
.
-
-
Method Detail
-
getAccessToken
public AccessToken getAccessToken()
Returns the access token.- Returns:
- The access token.
-
getBearerAccessToken
public BearerAccessToken getBearerAccessToken()
Returns the access token as type bearer.- Returns:
- The bearer access token,
null
if the type is different.
-
getRefreshToken
public RefreshToken getRefreshToken()
Returns the optional refresh token.- Returns:
- The refresh token,
null
if none.
-
getParameterNames
public Set<String> getParameterNames()
Returns the token parameter names for the included tokens.- Returns:
- The token parameter names.
-
getMetadata
public Map<String,Object> getMetadata()
Returns the optional modifiable token metadata. Intended for server environments.- Returns:
- The token metadata.
-
toJSONObject
public net.minidev.json.JSONObject toJSONObject()
Returns the JSON object representation of this token pair.Example JSON object:
{ "access_token" : "dZdt8BlltORMTz5U", "refresh_token" : "E87zjAoeNXaSoF1U" }
- Returns:
- The JSON object representation.
-
toOIDCTokens
public OIDCTokens toOIDCTokens()
Casts to OpenID Connect tokens.- Returns:
- The OpenID Connect tokens (including an ID token).
-
parse
public static Tokens parse(net.minidev.json.JSONObject jsonObject) throws ParseException
Parses an access and optional refresh token from the specified JSON object.- Parameters:
jsonObject
- The JSON object to parse. Must not benull
.- Returns:
- The tokens.
- Throws:
ParseException
- If the JSON object couldn't be parsed to a tokens instance.
-
-