Package org.refcodes.net
Class OauthTokenImpl
- java.lang.Object
-
- org.refcodes.net.OauthTokenImpl
-
- All Implemented Interfaces:
org.refcodes.mixin.Disposable
,org.refcodes.mixin.Disposable.Disposedable
,org.refcodes.mixin.DisposedAccessor
,org.refcodes.mixin.ValidAccessor
,OauthToken
public class OauthTokenImpl extends java.lang.Object implements OauthToken
Implementation of theOauthToken
interface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.Disposable
org.refcodes.mixin.Disposable.Disposedable
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_accessToken
protected java.lang.Integer
_expiresIn
protected java.lang.String
_notBeforePolicy
protected java.lang.Integer
_refreshExpiresIn
protected java.lang.String
_refreshToken
protected java.lang.String
_scope
protected java.lang.String
_sessionState
protected java.lang.String
_tokenType
-
Constructor Summary
Constructors Constructor Description OauthTokenImpl(java.lang.String aAccessToken, java.lang.String aRefreshToken, java.lang.String aTokenType, java.lang.Integer aExpiresIn, java.lang.String aScope)
Creates a new instance of theOauthTokenImpl
with the current time being stored for determining validity of the access token viaisValid()
as ofgetExpiresIn()
.OauthTokenImpl(java.lang.String aAccessToken, java.lang.String aRefreshToken, java.lang.String aTokenType, java.lang.String aNotBeforePolicy, java.lang.Integer aExpiresIn, java.lang.Integer aRefreshExpiresIn, java.lang.String aScope, java.lang.String aSessionState)
Creates a new instance of theOauthTokenImpl
with the current time being stored for determining validity of the access token viaisValid()
as ofgetExpiresIn()
.OauthTokenImpl(HttpBodyMap aOauthToken)
Creates a new instance of theOauthTokenImpl
with the current time being stored for determining validity of the access token viaisValid()
as ofgetExpiresIn()
.OauthTokenImpl(OauthToken aOauthToken)
Creates a new instance of theOauthTokenImpl
with the current time being stored for determining validity of the access token viaisValid()
as ofgetExpiresIn()
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
protected void
fromHttpBodyMap(HttpBodyMap aOauthToken)
Sets the internal fields with the data from theHttpBodyMap
as of theOauthField
definitions.java.lang.String
getAccessToken()
Returns the access token.java.lang.Integer
getExpiresIn()
Returns the time in seconds till the access token (OauthToken.getAccessToken()
) expires.java.lang.String
getNotBeforePolicy()
Returns the not-before-policy.java.lang.Integer
getRefreshExpiresIn()
Returns the time in seconds till the refresh token (OauthToken.getRefreshToken()
) expires.java.lang.String
getRefreshToken()
Returns the refresh token.java.lang.String
getScope()
Returns the OAuth scope.java.lang.String
getSessionState()
Returns the session state.java.lang.String
getTokenType()
Returns the token type.boolean
isDisposed()
boolean
isValid()
Returns alwaystrue
if no "expires in" time (OauthToken.getExpiresIn()
) has been set!
-
-
-
Field Detail
-
_accessToken
protected java.lang.String _accessToken
-
_refreshToken
protected java.lang.String _refreshToken
-
_tokenType
protected java.lang.String _tokenType
-
_expiresIn
protected java.lang.Integer _expiresIn
-
_refreshExpiresIn
protected java.lang.Integer _refreshExpiresIn
-
_scope
protected java.lang.String _scope
-
_notBeforePolicy
protected java.lang.String _notBeforePolicy
-
_sessionState
protected java.lang.String _sessionState
-
-
Constructor Detail
-
OauthTokenImpl
public OauthTokenImpl(OauthToken aOauthToken)
Creates a new instance of theOauthTokenImpl
with the current time being stored for determining validity of the access token viaisValid()
as ofgetExpiresIn()
.- Parameters:
aOauthToken
- The OAuth data to use.
-
OauthTokenImpl
public OauthTokenImpl(java.lang.String aAccessToken, java.lang.String aRefreshToken, java.lang.String aTokenType, java.lang.Integer aExpiresIn, java.lang.String aScope)
Creates a new instance of theOauthTokenImpl
with the current time being stored for determining validity of the access token viaisValid()
as ofgetExpiresIn()
.- Parameters:
aAccessToken
- The access tokenaRefreshToken
- The refresh tokenaTokenType
- The token typeaExpiresIn
- The expires-time in secondsaScope
- The scope
-
OauthTokenImpl
public OauthTokenImpl(java.lang.String aAccessToken, java.lang.String aRefreshToken, java.lang.String aTokenType, java.lang.String aNotBeforePolicy, java.lang.Integer aExpiresIn, java.lang.Integer aRefreshExpiresIn, java.lang.String aScope, java.lang.String aSessionState)
Creates a new instance of theOauthTokenImpl
with the current time being stored for determining validity of the access token viaisValid()
as ofgetExpiresIn()
.- Parameters:
aAccessToken
- The access tokenaRefreshToken
- The refresh tokenaTokenType
- The token typeaNotBeforePolicy
- The not-before-policy.aExpiresIn
- The expires-time in secondsaRefreshExpiresIn
- The refresh's expires-time in secondsaScope
- The scopeaSessionState
- The session state.
-
OauthTokenImpl
public OauthTokenImpl(HttpBodyMap aOauthToken)
Creates a new instance of theOauthTokenImpl
with the current time being stored for determining validity of the access token viaisValid()
as ofgetExpiresIn()
.- Parameters:
aOauthToken
- TheHttpBodyMap
containing theOauthToken
data.
-
-
Method Detail
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-
isDisposed
public boolean isDisposed()
- Specified by:
isDisposed
in interfaceorg.refcodes.mixin.DisposedAccessor
-
getAccessToken
public java.lang.String getAccessToken()
Returns the access token. "The access token string as issued by the authorization server." See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"- Specified by:
getAccessToken
in interfaceOauthToken
- Returns:
- the access token.
-
getRefreshToken
public java.lang.String getRefreshToken()
Returns the refresh token. "The access token string as issued by the authorization server." See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"- Specified by:
getRefreshToken
in interfaceOauthToken
- Returns:
- the refresh token.
-
getScope
public java.lang.String getScope()
Returns the OAuth scope. "If the scope the user granted is identical to the scope the app requested, this parameter is optional. If the granted scope is different from the requested scope, such as if the user modified the scope, then this parameter is required." See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"- Specified by:
getScope
in interfaceOauthToken
- Returns:
- the OAuth scope.
-
getTokenType
public java.lang.String getTokenType()
Returns the token type. "The type of token this is, typically just the string bearer" See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"- Specified by:
getTokenType
in interfaceOauthToken
- Returns:
- the token type.
-
getExpiresIn
public java.lang.Integer getExpiresIn()
Returns the time in seconds till the access token (OauthToken.getAccessToken()
) expires. "If the access token expires, the server should reply with the duration of time the access token is granted for." See "https://www.oauth.com/oauth2-servers/access-tokens/access-token-response"- Specified by:
getExpiresIn
in interfaceOauthToken
- Returns:
- the Expires-In time in seconds
-
getNotBeforePolicy
public java.lang.String getNotBeforePolicy()
Returns the not-before-policy.- Specified by:
getNotBeforePolicy
in interfaceOauthToken
- Returns:
- the not-before-policy.
-
getSessionState
public java.lang.String getSessionState()
Returns the session state.- Specified by:
getSessionState
in interfaceOauthToken
- Returns:
- the session state.
-
getRefreshExpiresIn
public java.lang.Integer getRefreshExpiresIn()
Returns the time in seconds till the refresh token (OauthToken.getRefreshToken()
) expires.- Specified by:
getRefreshExpiresIn
in interfaceOauthToken
- Returns:
- the Expires-In time in seconds
-
isValid
public boolean isValid()
Returns alwaystrue
if no "expires in" time (OauthToken.getExpiresIn()
) has been set!- Specified by:
isValid
in interfaceOauthToken
- Specified by:
isValid
in interfaceorg.refcodes.mixin.ValidAccessor
-
fromHttpBodyMap
protected void fromHttpBodyMap(HttpBodyMap aOauthToken)
Sets the internal fields with the data from theHttpBodyMap
as of theOauthField
definitions.- Parameters:
aOauthToken
- TheHttpBodyMap
from which to gather the data.
-
-