Module org.mule.oauth.client.api
Package org.mule.oauth.client.api.state
Class ResourceOwnerOAuthContextWithRefreshState
- java.lang.Object
-
- org.mule.oauth.client.api.state.ResourceOwnerOAuthContextWithRefreshState
-
- All Implemented Interfaces:
Serializable,ResourceOwnerOAuthContext
public final class ResourceOwnerOAuthContextWithRefreshState extends Object implements ResourceOwnerOAuthContext, Serializable
OAuth state for a particular resource owner which typically represents an user.- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.mule.oauth.client.api.state.ResourceOwnerOAuthContext
DEFAULT_RESOURCE_OWNER_ID
-
-
Constructor Summary
Constructors Constructor Description ResourceOwnerOAuthContextWithRefreshState(String resourceOwnerId)ResourceOwnerOAuthContextWithRefreshState(ResourceOwnerOAuthContext original)Since the runtime can be upgraded when there are already contexts stored, previous versions must be migrated to the new one.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static LockcreateRefreshOAuthContextLock(String lockNamePrefix, org.mule.runtime.api.lock.LockFactory lockProvider, String resourceOwnerId)This utility method is needed for the cases where the context is being queried.StringgetAccessToken()DancerStategetDancerState()StringgetExpiresIn()LockgetRefreshOAuthContextLock(String lockNamePrefix, org.mule.runtime.api.lock.LockFactory lockProvider)Obtains a lock to avoid triggering a refresh of the context more than once simultaneously.StringgetRefreshToken()StringgetResourceOwnerId()StringgetState()Map<String,Object>getTokenResponseParameters()voidsetAccessToken(String accessToken)voidsetDancerState(DancerState dancerState)Updates the state of the dancer for this context.voidsetExpiresIn(String expiresIn)voidsetRefreshToken(String refreshToken)voidsetState(String state)voidsetTokenResponseParameters(Map<String,Object> tokenResponseParameters)
-
-
-
Constructor Detail
-
ResourceOwnerOAuthContextWithRefreshState
public ResourceOwnerOAuthContextWithRefreshState(String resourceOwnerId)
-
ResourceOwnerOAuthContextWithRefreshState
public ResourceOwnerOAuthContextWithRefreshState(ResourceOwnerOAuthContext original)
Since the runtime can be upgraded when there are already contexts stored, previous versions must be migrated to the new one. The newly added state cannot be added to the previous version because that would break the java serialization of those objects.- Parameters:
original- the context to migrate
-
-
Method Detail
-
getAccessToken
public String getAccessToken()
- Specified by:
getAccessTokenin interfaceResourceOwnerOAuthContext- Returns:
- access token of the oauth context retrieved by the token request
-
getRefreshToken
public String getRefreshToken()
- Specified by:
getRefreshTokenin interfaceResourceOwnerOAuthContext- Returns:
- refresh token of the oauth context retrieved by the token request
-
getState
public String getState()
- Specified by:
getStatein interfaceResourceOwnerOAuthContext- Returns:
- state of the oauth context send in the authorization request
-
setAccessToken
public void setAccessToken(String accessToken)
-
setRefreshToken
public void setRefreshToken(String refreshToken)
-
setExpiresIn
public void setExpiresIn(String expiresIn)
-
getExpiresIn
public String getExpiresIn()
- Specified by:
getExpiresInin interfaceResourceOwnerOAuthContext- Returns:
- expires in value retrieved by the token request.
-
setState
public void setState(String state)
-
getTokenResponseParameters
public Map<String,Object> getTokenResponseParameters()
- Specified by:
getTokenResponseParametersin interfaceResourceOwnerOAuthContext- Returns:
- custom token request response parameters configured for extraction.
-
setTokenResponseParameters
public void setTokenResponseParameters(Map<String,Object> tokenResponseParameters)
-
getResourceOwnerId
public String getResourceOwnerId()
- Specified by:
getResourceOwnerIdin interfaceResourceOwnerOAuthContext- Returns:
- id for the oauth state.
-
getDancerState
public DancerState getDancerState()
- Specified by:
getDancerStatein interfaceResourceOwnerOAuthContext- Returns:
- the state of the dance for the resource owner of this context.
-
setDancerState
public void setDancerState(DancerState dancerState)
Description copied from interface:ResourceOwnerOAuthContextUpdates the state of the dancer for this context.Note that calling this just updates the internal state of this object. Calling this method does not persist this change in any store. That has to be done explicitly after calling this method.
- Specified by:
setDancerStatein interfaceResourceOwnerOAuthContext- Parameters:
dancerState- the state of the dance for the resource owner of this context.
-
getRefreshOAuthContextLock
public Lock getRefreshOAuthContextLock(String lockNamePrefix, org.mule.runtime.api.lock.LockFactory lockProvider)
Description copied from interface:ResourceOwnerOAuthContextObtains a lock to avoid triggering a refresh of the context more than once simultaneously.- Specified by:
getRefreshOAuthContextLockin interfaceResourceOwnerOAuthContext- Parameters:
lockNamePrefix- a prefix to uniquely identify the locks in the providedlockFactory.lockProvider- the object to get the locks from. This will ensure that the same lock instance is used after serialization/deserialization of this context.- Returns:
- a lock that can be used to avoid concurrency problems trying to update oauth context.
-
createRefreshOAuthContextLock
public static Lock createRefreshOAuthContextLock(String lockNamePrefix, org.mule.runtime.api.lock.LockFactory lockProvider, String resourceOwnerId)
This utility method is needed for the cases where the context is being queried. There is still no context created, but the same lock that this context would use is required for querying thread-safely.
-
-