Class OIDCTokens

java.lang.Object
com.nimbusds.oauth2.sdk.token.Tokens
com.nimbusds.openid.connect.sdk.token.OIDCTokens

public final class OIDCTokens extends Tokens
ID token, access token and optional refresh token.
  • Constructor Details

    • OIDCTokens

      public OIDCTokens(com.nimbusds.jwt.JWT idToken, AccessToken accessToken, RefreshToken refreshToken)
      Creates a new OpenID Connect tokens instance.
      Parameters:
      idToken - The ID token. Must not be null.
      accessToken - The access token. Must not be null.
      refreshToken - The refresh token, null if none.
    • OIDCTokens

      public OIDCTokens(com.nimbusds.jwt.JWT idToken, AccessToken accessToken, RefreshToken refreshToken, DeviceSecret deviceSecret)
      Creates a new OpenID Connect tokens instance.
      Parameters:
      idToken - The ID token. Must not be null.
      accessToken - The access token. Must not be null.
      refreshToken - The refresh token, null if none.
      deviceSecret - The device secret for OpenID Connect native SSO, null if not specified.
    • OIDCTokens

      public OIDCTokens(String idTokenString, AccessToken accessToken, RefreshToken refreshToken)
      Creates a new OpenID Connect tokens instance.
      Parameters:
      idTokenString - The ID token string. Must not be null.
      accessToken - The access token. Must not be null.
      refreshToken - The refresh token, null if none.
    • OIDCTokens

      public OIDCTokens(String idTokenString, AccessToken accessToken, RefreshToken refreshToken, DeviceSecret deviceSecret)
      Creates a new OpenID Connect tokens instance.
      Parameters:
      idTokenString - The ID token string. Must not be null.
      accessToken - The access token. Must not be null.
      refreshToken - The refresh token, null if none.
      deviceSecret - The device secret for OpenID Connect native SSO, null if not specified.
    • OIDCTokens

      public OIDCTokens(AccessToken accessToken, RefreshToken refreshToken)
      Creates a new OpenID Connect tokens instance without an ID token. Intended for token responses from a refresh token grant where the ID token is optional.
      Parameters:
      accessToken - The access token. Must not be null.
      refreshToken - The refresh token, null if none.
    • OIDCTokens

      public OIDCTokens(AccessToken accessToken, RefreshToken refreshToken, DeviceSecret deviceSecret)
      Creates a new OpenID Connect tokens instance without an ID token. Intended for token responses from a refresh token grant where the ID token is optional.
      Parameters:
      accessToken - The access token. Must not be null.
      refreshToken - The refresh token, null if none.
      deviceSecret - The device secret for OpenID Connect native SSO, null if not specified.
  • Method Details

    • getIDToken

      public com.nimbusds.jwt.JWT getIDToken()
      Gets the ID token.
      Returns:
      The ID token, null if none or if parsing to a JWT failed.
    • getIDTokenString

      Gets the ID token string.
      Returns:
      The ID token string, null if none or if serialisation to a string failed.
    • getDeviceSecret

      Returns the device secret for native SSO.
      Returns:
      The device secret, null if not specified.
    • getParameterNames

      Description copied from class: Tokens
      Returns the token parameter names for the included tokens.
      Overrides:
      getParameterNames in class Tokens
      Returns:
      The token parameter names.
    • toJSONObject

      public net.minidev.json.JSONObject toJSONObject()
      Description copied from class: Tokens
      Returns the JSON object representation of this token pair.

      Example JSON object:

       {
         "access_token"  : "dZdt8BlltORMTz5U",
         "refresh_token" : "E87zjAoeNXaSoF1U"
       }
       
      Overrides:
      toJSONObject in class Tokens
      Returns:
      The JSON object representation.
    • parse

      public static OIDCTokens parse(net.minidev.json.JSONObject jsonObject) throws ParseException
      Parses an OpenID Connect tokens instance from the specified JSON object.
      Parameters:
      jsonObject - The JSON object to parse. Must not be null.
      Returns:
      The OpenID Connect tokens.
      Throws:
      ParseException - If the JSON object couldn't be parsed to an OpenID Connect tokens instance.