java.lang.Object
org.refcodes.web.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 Object implements OauthToken
Implementation of the
OauthToken interface.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.Disposable
org.refcodes.mixin.Disposable.DisposedableNested classes/interfaces inherited from interface org.refcodes.mixin.DisposedAccessor
org.refcodes.mixin.DisposedAccessor.DisposedMutator, org.refcodes.mixin.DisposedAccessor.DisposedPropertyNested classes/interfaces inherited from interface org.refcodes.mixin.ValidAccessor
org.refcodes.mixin.ValidAccessor.ValidBuilder<B extends org.refcodes.mixin.ValidAccessor.ValidBuilder<B>>, org.refcodes.mixin.ValidAccessor.ValidMutator, org.refcodes.mixin.ValidAccessor.ValidProperty -
Field Summary
Fields Modifier and Type Field Description protected String_accessTokenprotected Integer_expiresInprotected String_notBeforePolicyprotected Integer_refreshExpiresInprotected String_refreshTokenprotected String_scopeprotected String_sessionStateprotected String_tokenType -
Constructor Summary
Constructors Constructor Description OauthTokenImpl(String aAccessToken, String aRefreshToken, String aTokenType, Integer aExpiresIn, String aScope)Creates a new instance of theOauthTokenImplwith the current time being stored for determining validity of the access token viaisValid()as ofgetExpiresIn().OauthTokenImpl(String aAccessToken, String aRefreshToken, String aTokenType, String aNotBeforePolicy, Integer aExpiresIn, Integer aRefreshExpiresIn, String aScope, String aSessionState)Creates a new instance of theOauthTokenImplwith the current time being stored for determining validity of the access token viaisValid()as ofgetExpiresIn().OauthTokenImpl(HttpBodyMap aOauthToken)Creates a new instance of theOauthTokenImplwith the current time being stored for determining validity of the access token viaisValid()as ofgetExpiresIn().OauthTokenImpl(OauthToken aOauthToken)Creates a new instance of theOauthTokenImplwith the current time being stored for determining validity of the access token viaisValid()as ofgetExpiresIn(). -
Method Summary
Modifier and Type Method Description voiddispose()protected voidfromHttpBodyMap(HttpBodyMap aOauthToken)Sets the internal fields with the data from theHttpBodyMapas of theOauthFielddefinitions.StringgetAccessToken()Returns the access token.IntegergetExpiresIn()Returns the time in seconds till the access token (OauthToken.getAccessToken()) expires.StringgetNotBeforePolicy()Returns the not-before-policy.IntegergetRefreshExpiresIn()Returns the time in seconds till the refresh token (OauthToken.getRefreshToken()) expires.StringgetRefreshToken()Returns the refresh token.StringgetScope()Returns the OAuth scope.StringgetSessionState()Returns the session state.StringgetTokenType()Returns the token type.booleanisDisposed()booleanisValid()Returns alwaystrueif no "expires in" time (OauthToken.getExpiresIn()) has been set!
-
Field Details
-
_accessToken
-
_refreshToken
-
_tokenType
-
_expiresIn
-
_refreshExpiresIn
-
_scope
-
_notBeforePolicy
-
_sessionState
-
-
Constructor Details
-
OauthTokenImpl
Creates a new instance of theOauthTokenImplwith 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(String aAccessToken, String aRefreshToken, String aTokenType, Integer aExpiresIn, String aScope)Creates a new instance of theOauthTokenImplwith 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(String aAccessToken, String aRefreshToken, String aTokenType, String aNotBeforePolicy, Integer aExpiresIn, Integer aRefreshExpiresIn, String aScope, String aSessionState)Creates a new instance of theOauthTokenImplwith 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
Creates a new instance of theOauthTokenImplwith the current time being stored for determining validity of the access token viaisValid()as ofgetExpiresIn().- Parameters:
aOauthToken- TheHttpBodyMapcontaining theOauthTokendata.
-
-
Method Details
-
dispose
public void dispose()- Specified by:
disposein interfaceorg.refcodes.mixin.Disposable
-
isDisposed
public boolean isDisposed()- Specified by:
isDisposedin interfaceorg.refcodes.mixin.DisposedAccessor
-
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:
getAccessTokenin interfaceOauthToken- Returns:
- the access token.
-
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:
getRefreshTokenin interfaceOauthToken- Returns:
- the refresh token.
-
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:
getScopein interfaceOauthToken- Returns:
- the OAuth scope.
-
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:
getTokenTypein interfaceOauthToken- Returns:
- the token type.
-
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:
getExpiresInin interfaceOauthToken- Returns:
- the Expires-In time in seconds
-
getNotBeforePolicy
Returns the not-before-policy.- Specified by:
getNotBeforePolicyin interfaceOauthToken- Returns:
- the not-before-policy.
-
getSessionState
Returns the session state.- Specified by:
getSessionStatein interfaceOauthToken- Returns:
- the session state.
-
getRefreshExpiresIn
Returns the time in seconds till the refresh token (OauthToken.getRefreshToken()) expires.- Specified by:
getRefreshExpiresInin interfaceOauthToken- Returns:
- the Expires-In time in seconds
-
isValid
public boolean isValid()Returns alwaystrueif no "expires in" time (OauthToken.getExpiresIn()) has been set!- Specified by:
isValidin interfaceOauthToken- Specified by:
isValidin interfaceorg.refcodes.mixin.ValidAccessor
-
fromHttpBodyMap
Sets the internal fields with the data from theHttpBodyMapas of theOauthFielddefinitions.- Parameters:
aOauthToken- TheHttpBodyMapfrom which to gather the data.
-