java.lang.Object
org.springframework.security.oauth2.core.AbstractOAuth2Token
org.springframework.security.oauth2.core.OAuth2AccessToken
africa.absa.inception.oauth2.server.authorization.token.OAuth2AccessToken
All Implemented Interfaces:
Serializable, org.springframework.security.oauth2.core.OAuth2Token

public class OAuth2AccessToken extends org.springframework.security.oauth2.core.OAuth2AccessToken
The OAuth2AccessToken holds the information for an OAuth2 access token.
Author:
Marcus Portmann
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.security.oauth2.core.OAuth2AccessToken

    org.springframework.security.oauth2.core.OAuth2AccessToken.TokenType
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The name of the functions claim that provides the functions assigned to the user.
    static final String
    The name of the claim that provides the name of the user.
    static final String
    The name of the roles claim that provides the roles assigned to the user.
    static final String
    The name of the scope claim.
    static final String
    The name of the tenants claim that provides the IDs for the tenants the user is associated with.
    static final String
    The name of the user directory ID claim that provides the ID for the user directory the user is associated with.
  • Constructor Summary

    Constructors
    Constructor
    Description
    OAuth2AccessToken(org.springframework.security.oauth2.core.OAuth2AccessToken.TokenType tokenType, String tokenValue, String subject, Instant issuedAt, Instant expiresAt, Set<String> scopes)
    Constructs a new OAuth2AccessToken.
  • Method Summary

    Modifier and Type
    Method
    Description
    build(User user, List<String> roleCodes, List<String> functionCodes, List<UUID> tenantIds, Set<String> scopes, String issuer, int validFor, RSAPrivateKey rsaPrivateKey)
    Build a new OAuth2AccessToken.
    long
    Returns the lifetime in seconds of the access token.
    Returns the subject for the token.

    Methods inherited from class org.springframework.security.oauth2.core.OAuth2AccessToken

    getScopes, getTokenType

    Methods inherited from class org.springframework.security.oauth2.core.AbstractOAuth2Token

    equals, getExpiresAt, getIssuedAt, getTokenValue, hashCode

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FUNCTIONS_CLAIM

      public static final String FUNCTIONS_CLAIM
      The name of the functions claim that provides the functions assigned to the user.
      See Also:
    • NAME_CLAIM

      public static final String NAME_CLAIM
      The name of the claim that provides the name of the user.
      See Also:
    • ROLES_CLAIM

      public static final String ROLES_CLAIM
      The name of the roles claim that provides the roles assigned to the user.
      See Also:
    • SCOPE_CLAIM

      public static final String SCOPE_CLAIM
      The name of the scope claim.
      See Also:
    • TENANTS_CLAIM

      public static final String TENANTS_CLAIM
      The name of the tenants claim that provides the IDs for the tenants the user is associated with.
      See Also:
    • USER_DIRECTORY_ID_CLAIM

      public static final String USER_DIRECTORY_ID_CLAIM
      The name of the user directory ID claim that provides the ID for the user directory the user is associated with.
      See Also:
  • Constructor Details

    • OAuth2AccessToken

      public OAuth2AccessToken(org.springframework.security.oauth2.core.OAuth2AccessToken.TokenType tokenType, String tokenValue, String subject, Instant issuedAt, Instant expiresAt, Set<String> scopes)
      Constructs a new OAuth2AccessToken.
      Parameters:
      tokenType - the token type
      tokenValue - the token value
      subject - the subject for the token
      issuedAt - the time at which the token was issued
      expiresAt - the expiration time on or after which the token MUST NOT be accepted
      scopes - the scope(s) associated to the token
  • Method Details

    • build

      public static OAuth2AccessToken build(User user, List<String> roleCodes, List<String> functionCodes, List<UUID> tenantIds, Set<String> scopes, String issuer, int validFor, RSAPrivateKey rsaPrivateKey)
      Build a new OAuth2AccessToken.
      Parameters:
      user - the User the token is being issued for
      roleCodes - the role codes for the user the token is being issued for
      functionCodes - the function codes for the user the token is being issued for
      tenantIds - the IDs for the tenants that the user the token is being issued for is associated with
      scopes - the optional scope(s) associated to the token
      issuer - the optional issuer of the token, which can be null
      validFor - the number of seconds the token should be valid for
      rsaPrivateKey - the RSA private key used to sign the token
      Returns:
      the OAuth2 access token
    • getExpiresIn

      public long getExpiresIn()
      Returns the lifetime in seconds of the access token.
      Returns:
      the lifetime in seconds of the access token
    • getSubject

      public String getSubject()
      Returns the subject for the token.
      Returns:
      the subject for the token