Package com.authlete.common.dto
Class AccessToken
- java.lang.Object
-
- com.authlete.common.dto.AccessToken
-
- All Implemented Interfaces:
Serializable
public class AccessToken extends Object implements Serializable
Information about an access token.- Since:
- 2.22
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AccessToken()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getAccessTokenExpiresAt()
Get the timestamp at which the access token will expire.String
getAccessTokenHash()
Get the hash of the access token.long
getClientId()
Get the ID of the client associated with the access token.long
getCreatedAt()
Get the timestamp at which the access token was first created.GrantType
getGrantType()
Get the grant type of the access token when the access token was created.long
getLastRefreshedAt()
Get the timestamp at which the access token was last refreshed using the refresh token.Property[]
getProperties()
Get the properties associated with the access token.long
getRefreshTokenExpiresAt()
Get the timestamp at which the refresh token will expire.String
getRefreshTokenHash()
Get the hash of the refresh token.String[]
getRefreshTokenScopes()
Get the scopes associated with the refresh token.String[]
getScopes()
Get the scopes associated with the access token.String
getSubject()
Get the subject (= unique user ID) associated with the access token.AccessToken
setAccessTokenExpiresAt(long expiresAt)
Set the timestamp at which the access token will expire.AccessToken
setAccessTokenHash(String hash)
Set the hash of the access token.AccessToken
setClientId(long clientId)
Set the ID of the client associated with the access token.AccessToken
setCreatedAt(long createdAt)
Set the timestamp at which the access token was first created.AccessToken
setGrantType(GrantType grantType)
Set the grant type of the access token when the access token was created.AccessToken
setLastRefreshedAt(long lastRefreshedAt)
Set the timestamp at which the access token was last refreshed using the refresh token.AccessToken
setProperties(Property[] properties)
Set the properties associated with the access token.AccessToken
setRefreshTokenExpiresAt(long expiresAt)
Set the timestamp at which the refresh token will expire.AccessToken
setRefreshTokenHash(String hash)
Set the hash of the refresh token.AccessToken
setRefreshTokenScopes(String[] refreshTokenScopes)
Set the scopes associated with the refresh token.AccessToken
setScopes(String[] scopes)
Set the scopes associated with the access token.AccessToken
setSubject(String subject)
Set the subject (= unique user ID) associated with the access token.
-
-
-
Method Detail
-
getAccessTokenHash
public String getAccessTokenHash()
Get the hash of the access token.- Returns:
- The hash of the access token.
-
setAccessTokenHash
public AccessToken setAccessTokenHash(String hash)
Set the hash of the access token.- Parameters:
hash
- The hash of the access token.- Returns:
this
object.
-
getRefreshTokenHash
public String getRefreshTokenHash()
Get the hash of the refresh token.null
may be returned.- Returns:
- The hash of the refresh token or
null
.
-
setRefreshTokenHash
public AccessToken setRefreshTokenHash(String hash)
Set the hash of the refresh token.- Parameters:
hash
- The hash of the refresh token.- Returns:
this
object.
-
getClientId
public long getClientId()
Get the ID of the client associated with the access token.- Returns:
- The ID of the client associated with the access token.
-
setClientId
public AccessToken setClientId(long clientId)
Set the ID of the client associated with the access token.- Parameters:
clientId
- The ID of the client associated with the access token.- Returns:
this
object.
-
getSubject
public String getSubject()
Get the subject (= unique user ID) associated with the access token.null
is returned if the access token was created using the Client Credentials flow.- Returns:
- The subject (= unique user ID) associated with the access token or
null
if the access token was created using the Client Credentials flow.
-
setSubject
public AccessToken setSubject(String subject)
Set the subject (= unique user ID) associated with the access token.- Parameters:
subject
- The subject (= unique user ID) associated with the access token.- Returns:
this
object.
-
getGrantType
public GrantType getGrantType()
Get the grant type of the access token when the access token was created. Note that the value of the grant type is not changed when the access token is refreshed using the refresh token.- Returns:
- The grant type of the access token when the access token was created.
-
setGrantType
public AccessToken setGrantType(GrantType grantType)
Set the grant type of the access token when the access token was created.- Parameters:
grantType
- The grant type of the access token when the access token was created.- Returns:
this
object.
-
getScopes
public String[] getScopes()
Get the scopes associated with the access token.- Returns:
- The scopes associated with the access token.
-
setScopes
public AccessToken setScopes(String[] scopes)
Set the scopes associated with the access token.- Parameters:
scopes
- The scopes associated with the access token.- Returns:
this
object.
-
getAccessTokenExpiresAt
public long getAccessTokenExpiresAt()
Get the timestamp at which the access token will expire.- Returns:
- The expiration timestamp in milliseconds since the Unix epoch (1970-01-01).
-
setAccessTokenExpiresAt
public AccessToken setAccessTokenExpiresAt(long expiresAt)
Set the timestamp at which the access token will expire.- Parameters:
expiresAt
- The expiration timestamp in milliseconds since the Unix epoch (1970-01-01).- Returns:
this
object.
-
getRefreshTokenExpiresAt
public long getRefreshTokenExpiresAt()
Get the timestamp at which the refresh token will expire.0
is returned ifgetRefreshTokenHash()
returnsnull
.- Returns:
- The expiration timestamp in milliseconds since the Unix epoch (1970-01-01).
-
setRefreshTokenExpiresAt
public AccessToken setRefreshTokenExpiresAt(long expiresAt)
Set the timestamp at which the refresh token will expire.- Parameters:
expiresAt
- The expiration timestamp in milliseconds since the Unix epoch (1970-01-01).- Returns:
this
object.
-
getCreatedAt
public long getCreatedAt()
Get the timestamp at which the access token was first created. Note that the value of the timestamp is not changed when the access token is refreshed with the refresh token.- Returns:
- The timestamp at which the access token was first created in milliseconds since the Unix epoch (1970-01-01).
-
setCreatedAt
public AccessToken setCreatedAt(long createdAt)
Set the timestamp at which the access token was first created.- Parameters:
createdAt
- The timestamp at which the access token was first created in milliseconds since the Unix epoch (1970-01-01).- Returns:
this
object.
-
getLastRefreshedAt
public long getLastRefreshedAt()
Get the timestamp at which the access token was last refreshed using the refresh token.0
is returned if it has never been refreshed.- Returns:
- The timestamp at which the access token was last refreshed using
the refreshed token in milliseconds since the Unix epoch (1970-01-01).
0
is returned if it has never been refreshed.
-
setLastRefreshedAt
public AccessToken setLastRefreshedAt(long lastRefreshedAt)
Set the timestamp at which the access token was last refreshed using the refresh token.- Parameters:
lastRefreshedAt
- The timestamp at which the access token was last refreshed using the refreshed token in milliseconds since the Unix epoch (1970-01-01).- Returns:
this
object.
-
getProperties
public Property[] getProperties()
Get the properties associated with the access token.- Returns:
- The properties associated with the access token.
-
setProperties
public AccessToken setProperties(Property[] properties)
Set the properties associated with the access token.- Parameters:
properties
- The properties associated with the access token.- Returns:
this
object.
-
getRefreshTokenScopes
public String[] getRefreshTokenScopes()
Get the scopes associated with the refresh token.- Returns:
- The scopes associated with the refresh token. May be
null
. - Since:
- 3.89, Authlete API 3.0
-
setRefreshTokenScopes
public AccessToken setRefreshTokenScopes(String[] refreshTokenScopes)
Set the scopes associated with the refresh token.- Parameters:
refreshTokenScopes
- The scopes associated with the refresh token.- Returns:
this
object.- Since:
- 3.89, Authlete API 3.0
-
-