public class OAuth2Tokens
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
accessToken |
protected java.util.Date |
expiry |
protected java.lang.String |
refreshToken |
Constructor and Description |
---|
OAuth2Tokens(java.lang.String accessToken,
java.lang.String refreshToken)
Store token data without the expiry date of the access token.
|
OAuth2Tokens(java.lang.String accessToken,
java.lang.String refreshToken,
java.util.Date expiry)
Store token data including the expiry date of the access token.
|
Modifier and Type | Method and Description |
---|---|
static java.util.Date |
calculateExpiry(java.lang.Number expiresInSeconds)
Calculate a date timestamp a given number of seconds in the future.
|
void |
expireAccessToken()
Forcibly expire the access token by setting the expiry
timestamp to the epoch.
|
java.lang.String |
getAccessToken() |
java.util.Date |
getExpiry() |
java.lang.String |
getRefreshToken() |
boolean |
isAccessTokenExpired() |
java.lang.String |
toString() |
protected final java.lang.String accessToken
protected final java.lang.String refreshToken
protected java.util.Date expiry
public OAuth2Tokens(java.lang.String accessToken, java.lang.String refreshToken, java.util.Date expiry)
accessToken
- refreshToken
- expiry
- public OAuth2Tokens(java.lang.String accessToken, java.lang.String refreshToken)
accessToken
- refreshToken
- public java.lang.String getAccessToken()
public java.lang.String getRefreshToken()
public java.util.Date getExpiry()
public void expireAccessToken()
public boolean isAccessTokenExpired()
getExpiry()
is null) since the expiry time is unknown.public java.lang.String toString()
toString
in class java.lang.Object
public static java.util.Date calculateExpiry(java.lang.Number expiresInSeconds)
expiresInSeconds
- how many seconds in the future the result should be. May be null,
in which case the current date/time is returned.