Class 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:
    Serialized Form
    • 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 String FUNCTIONS_CLAIM
      The name of the functions claim that provides the functions assigned to the user.
      static String NAME_CLAIM
      The name of the claim that provides the name of the user.
      static String ROLES_CLAIM
      The name of the roles claim that provides the roles assigned to the user.
      static String SCOPE_CLAIM
      The name of the scope claim.
      static String TENANTS_CLAIM
      The name of the tenants claim that provides the Universally Unique Identifiers (UUIDs) for the tenants the user is associated with.
      static String USER_DIRECTORY_ID_CLAIM
      The name of the user directory ID claim that provides the Universally Unique Identifier (UUID) 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.
    • Field Detail

      • FUNCTIONS_CLAIM

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

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

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

        public static final String TENANTS_CLAIM
        The name of the tenants claim that provides the Universally Unique Identifiers (UUIDs) for the tenants the user is associated with.
        See Also:
        Constant Field Values
      • USER_DIRECTORY_ID_CLAIM

        public static final String USER_DIRECTORY_ID_CLAIM
        The name of the user directory ID claim that provides the Universally Unique Identifier (UUID) for the user directory the user is associated with.
        See Also:
        Constant Field Values
    • Constructor Detail

      • 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 Detail

      • 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