Class OAuth2AccessToken
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
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the functions claim that provides the functions assigned to the user.static final StringThe name of the claim that provides the name of the user.static final StringThe name of the roles claim that provides the roles assigned to the user.static final StringThe name of the scope claim.static final StringThe name of the tenants claim that provides the IDs for the tenants the user is associated with.static final StringThe name of the user directory ID claim that provides the ID for the user directory the user is associated with. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic OAuth2AccessTokenbuild(User user, List<String> roleCodes, List<String> functionCodes, List<UUID> tenantIds, Set<String> scopes, String issuer, int validFor, RSAPrivateKey rsaPrivateKey) Build a new OAuth2AccessToken.longReturns 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, getTokenTypeMethods inherited from class org.springframework.security.oauth2.core.AbstractOAuth2Token
equals, getExpiresAt, getIssuedAt, getTokenValue, hashCode
-
Field Details
-
FUNCTIONS_CLAIM
The name of the functions claim that provides the functions assigned to the user.- See Also:
-
NAME_CLAIM
The name of the claim that provides the name of the user.- See Also:
-
ROLES_CLAIM
The name of the roles claim that provides the roles assigned to the user.- See Also:
-
SCOPE_CLAIM
The name of the scope claim.- See Also:
-
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
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 typetokenValue- the token valuesubject- the subject for the tokenissuedAt- the time at which the token was issuedexpiresAt- the expiration time on or after which the token MUST NOT be acceptedscopes- 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 forroleCodes- the role codes for the user the token is being issued forfunctionCodes- the function codes for the user the token is being issued fortenantIds- the IDs for the tenants that the user the token is being issued for is associated withscopes- the optional scope(s) associated to the tokenissuer- the optional issuer of the token, which can be nullvalidFor- the number of seconds the token should be valid forrsaPrivateKey- 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
Returns the subject for the token.- Returns:
- the subject for the token
-