C
- Actual connector object that represents a connectionpublic interface OAuth2Manager<C extends OAuth2Adapter> extends HttpCallbackAdapter, ProcessAdapter<OAuth2Adapter>, OnNoTokenPolicyAware, NamedObject
org.mule.api.annotations.oauth.OAuth2
annotated class that
will infuse it with access token management capabilities.
It can receive a PoolingProfile
which is a configuration
object used to define the OAuth access tokens pooling parameters.Modifier and Type | Method and Description |
---|---|
C |
acquireAccessToken(String accessTokenId)
Borrow an access token from the pool
|
String |
buildAuthorizeUrl(Map<String,String> extraParameters,
String authorizationUrl,
String redirectUri)
Generates the full URL of an authorization endpoint including query params
|
C |
createAdapter(String verifier)
Create a new adapter using the specified verifier and insert it into the pool.
|
void |
destroyAccessToken(String userId,
C connector)
Destroy an access token
|
void |
fetchAccessToken(OAuth2Adapter adapter,
String redirectUri)
Makes an http call to the adapter's accessTokenUrl and extracts the access
token, which is then set into the adapter
|
org.apache.commons.pool.KeyedPoolableObjectFactory<String,OAuth2Adapter> |
getAccessTokenPoolFactory()
Retrieves accessTokenPoolFactory
|
String |
getDefaultAccessTokenId() |
C |
getDefaultUnauthorizedConnector()
Retrieve default unauthorized connector
|
MuleContext |
getMuleContext()
Returns the mule context
|
<T> ProcessTemplate<T,OAuth2Adapter> |
getProcessTemplate() |
void |
hasBeenAuthorized(OAuth2Adapter adapter)
Validates that there's an access token for the given adapter.
|
void |
postAuth(OAuth2Adapter adapter,
String accessTokenId)
Calls the
org.mule.security.oauth.OAuth2Connector.postAuth() on the
adapter. |
void |
refreshAccessToken(OAuth2Adapter adapter,
String accessTokenId)
if refresh token is available, then it makes an http call to refresh the
access token.
|
void |
releaseAccessToken(String userId,
C connector)
Return an access token to the pool
|
MuleEvent |
restoreAuthorizationEvent(String eventId)
Recovers a MuleEvent from the object store.
|
void |
storeAuthorizationEvent(MuleEvent event)
This method is expected to receive the
MuleEvent corresponding to
the execution of an OAuth2 authorize processor. |
getAsync, getConnector, getDomain, getLocalPort, getPath, getRemotePort, setAsync, setConnector, setDomain, setLocalPort, setPath, setRemotePort
getOnNoTokenPolicy, setOnNoTokenPolicy
getName
C createAdapter(String verifier) throws Exception
verifier
- OAuth verifierException
- If the access token cannot be retrievedC acquireAccessToken(String accessTokenId) throws Exception
accessTokenId
- User identification used to borrow the access tokenException
- If the access token cannot be retrievedvoid releaseAccessToken(String userId, C connector) throws Exception
userId
- User identification used to borrow the access tokenconnector
- Authorized connector to be returned to the poolException
- If the access token cannot be returnedvoid destroyAccessToken(String userId, C connector) throws Exception
userId
- User identification used to borrow the access tokenconnector
- Authorized connector to the destroyedException
- If the access token could not be destroyed.C getDefaultUnauthorizedConnector()
org.apache.commons.pool.KeyedPoolableObjectFactory<String,OAuth2Adapter> getAccessTokenPoolFactory()
String buildAuthorizeUrl(Map<String,String> extraParameters, String authorizationUrl, String redirectUri)
extraParameters
- a map with non-standard query-param value pairsauthorizationUrl
- the url of the authorization endpoint per OAuth
specificationredirectUri
- the uri of the redirection endpointvoid refreshAccessToken(OAuth2Adapter adapter, String accessTokenId) throws org.mule.common.security.oauth.exception.UnableToAcquireAccessTokenException
org.mule.security.oauth.OAuth2Manager.postAuth(OAuth2Adapter, String)
is
invokedadapter
- the connector's adapteraccessTokenId
- the id of the token you're trying to refreshorg.mule.common.security.oauth.exception.UnableToAcquireAccessTokenException
IllegalArgumentException
- if accessTokenId is nullvoid fetchAccessToken(OAuth2Adapter adapter, String redirectUri) throws org.mule.common.security.oauth.exception.UnableToAcquireAccessTokenException
adapter
- the connector's adapterredirectUri
- the redirection URIorg.mule.common.security.oauth.exception.UnableToAcquireAccessTokenException
MuleContext getMuleContext()
void hasBeenAuthorized(OAuth2Adapter adapter) throws org.mule.common.security.oauth.exception.NotAuthorizedException
adapter
- the adapter which authorization you want to testorg.mule.common.security.oauth.exception.NotAuthorizedException
- if no access token available for this adaptervoid storeAuthorizationEvent(MuleEvent event) throws Exception
MuleEvent
corresponding to
the execution of an OAuth2 authorize processor. The event will be persisted in
this manager's object store following these rules:
String
that is then set as payload. Failure to
do this will result in exceptionSerializable
then an exception
will be thrown.org.mule.security.oauth.OAuthProperties.AUTHORIZATION_EVENT_KEY_TEMPLATE
event
- a mule eventException
MuleEvent restoreAuthorizationEvent(String eventId) throws ObjectStoreException, ObjectDoesNotExistException
org.mule.security.oauth.OAuthProperties.AUTHORIZATION_EVENT_KEY_TEMPLATE
eventId
- the id of the event to be restoredMuleEvent
ObjectStoreException
- if there was an error accessing the object storeObjectDoesNotExistException
- if there's no entry for the event id<T> ProcessTemplate<T,OAuth2Adapter> getProcessTemplate()
getProcessTemplate
in interface ProcessAdapter<OAuth2Adapter>
String getDefaultAccessTokenId()
void postAuth(OAuth2Adapter adapter, String accessTokenId) throws Exception
org.mule.security.oauth.OAuth2Connector.postAuth()
on the
adapter. If it fails due to access token expiration and accessTokenId is not
null, then the token is refresh and the operation is re-attempted. If token
refreshment fails or if accessTokenId is null, then the original exception is
thrownadapter
- the connector adapteraccessTokenId
- the id of the accessToken to be usedException
Copyright © 2003–2015 MuleSoft, Inc.. All rights reserved.