Package com.iizix.server.oauth
Class AccessToken
- java.lang.Object
- com.iizix.server.oauth.AccessToken
public class AccessToken extends java.lang.Object
The access token wrapper for OAuth 2.0 and OAuth 1.0a access tokens.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description AccessToken(com.github.scribejava.core.model.OAuth1AccessToken accessToken1, com.github.scribejava.core.model.OAuth1RequestToken requestToken)
Constructs the access token for OAuth 1.0a.AccessToken(com.github.scribejava.core.model.OAuth2AccessToken accessToken2)
Constructs the access token for OAuth 2.0.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Returns if two access tokens are equal.java.lang.String
getAccessToken()
Returns the access token.long
getExpiresTime()
Gets the expiry date.int
hashCode()
Gets the hash code.boolean
isValid(long additionalTime)
Checks if the access token would expire within the requested additional time, e.g.java.lang.String
toString()
Gets a String.
Constructor Detail
AccessToken
public AccessToken(com.github.scribejava.core.model.OAuth2AccessToken accessToken2)
Constructs the access token for OAuth 2.0.- Parameters:
accessToken2
- The access token.- Throws:
java.lang.NullPointerException
- If the {code accessToken2} parameter is null.
AccessToken
public AccessToken(com.github.scribejava.core.model.OAuth1AccessToken accessToken1, com.github.scribejava.core.model.OAuth1RequestToken requestToken)
Constructs the access token for OAuth 1.0a.- Parameters:
accessToken1
- The access token.requestToken
- The request token used to get the access token.- Throws:
java.lang.NullPointerException
- If the {code accessToken1} or {code requestToken} parameter is null.
Method Detail
isValid
public boolean isValid(long additionalTime)
Checks if the access token would expire within the requested additional time, e.g. 20_000 ms (20 seconds) that an operation would require to run.- Returns:
- true If the access token has expired or would expire, false if it's OK to use it.
getExpiresTime
public long getExpiresTime()
Gets the expiry date.- Returns:
- The access token expiry time in milliseconds since the epoch, zero if unknown.
getAccessToken
public java.lang.String getAccessToken()
Returns the access token.- Returns:
- The access token String.
hashCode
public int hashCode()
Gets the hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code.
equals
public boolean equals(java.lang.Object obj)
Returns if two access tokens are equal.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- The other object to compare with.- Returns:
- The equality flag.
toString
public java.lang.String toString()
Gets a String.- Overrides:
toString
in classjava.lang.Object
- Returns:
- The string.