Module org.mule.oauth.client.api
Package org.mule.oauth.client.api
Interface AuthorizationCodeOAuthDancer
-
@NoImplement public interface AuthorizationCodeOAuthDancerImplementations provide OAuth dance support for authorization-code grant-type.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description CompletableFuture<String>accessToken(String resourceOwner)Will query the internal state (thetokensStoreparameter passed to the service to build theAuthorizationCodeOAuthDancer) to get the appropriate accessToken.default voidaddListener(String resourceOwnerId, AuthorizationCodeListener listener)Adds thelistener.voidaddListener(AuthorizationCodeListener listener)Deprecated.since 1.1, 1.0.2.ResourceOwnerOAuthContextgetContextForResourceOwner(String resourceOwnerId)Retrieves the oauth context for a particular user.voidhandleLocalAuthorizationRequest(org.mule.runtime.http.api.domain.message.request.HttpRequest request, org.mule.runtime.http.api.server.async.HttpResponseReadyCallback responseCallback)Handles an http request that will redirect to the access page inauthorizationUrlwith the configured credentials.voidinvalidateContext(String resourceOwnerId)Clears the oauth context for a given user.CompletableFuture<Void>refreshToken(String resourceOwner)Performs the refresh of the access token.default CompletableFuture<Void>refreshToken(String resourceOwner, boolean useQueryParameters)Performs the refresh of the access token.default voidremoveListener(String resourceOwnerId, AuthorizationCodeListener listener)Removes thelistener.voidremoveListener(AuthorizationCodeListener listener)Deprecated.since 1.1, 1.0.2.
-
-
-
Method Detail
-
accessToken
CompletableFuture<String> accessToken(String resourceOwner) throws RequestAuthenticationException
Will query the internal state (thetokensStoreparameter passed to the service to build theAuthorizationCodeOAuthDancer) to get the appropriate accessToken. This requires that the authorization has been performed beforehand, otherwise, aRequestAuthenticationExceptionwill be thrown.- Parameters:
resourceOwner- The resource owner to get the token for.- Returns:
- a future with the token to send on the authorized request. This will be immediately available unless a refresh has to be made.
- Throws:
RequestAuthenticationException- if called for aresourceOwnerthat has not yet been authorized.
-
refreshToken
CompletableFuture<Void> refreshToken(String resourceOwner)
Performs the refresh of the access token.- Parameters:
resourceOwner- The resource owner to get the token for.- Returns:
- a completable future that is complete when the token has been refreshed.
-
refreshToken
default CompletableFuture<Void> refreshToken(String resourceOwner, boolean useQueryParameters)
Performs the refresh of the access token.- Parameters:
resourceOwner- The resource owner to get the token for.useQueryParameters- If the parameters needed to refresh the token should be sent as query parameters. If false, they will be sent encoded in the body of the message.- Returns:
- a completable future that is complete when the token has been refreshed.
-
invalidateContext
void invalidateContext(String resourceOwnerId)
Clears the oauth context for a given user.- Parameters:
resourceOwnerId- id of the user.
-
getContextForResourceOwner
ResourceOwnerOAuthContext getContextForResourceOwner(String resourceOwnerId)
Retrieves the oauth context for a particular user. If there's no state for that user a new state is retrieved so never returns null.- Parameters:
resourceOwnerId- id of the user.- Returns:
- oauth state
-
handleLocalAuthorizationRequest
void handleLocalAuthorizationRequest(org.mule.runtime.http.api.domain.message.request.HttpRequest request, org.mule.runtime.http.api.server.async.HttpResponseReadyCallback responseCallback)Handles an http request that will redirect to the access page inauthorizationUrlwith the configured credentials.- Parameters:
request- the request from the user to login and/or authorize the applicationresponseCallback- the callback where the response with the redirection to the login/authorization page will be sent
-
addListener
@Deprecated void addListener(AuthorizationCodeListener listener)
Deprecated.since 1.1, 1.0.2. UseaddListener(String, AuthorizationCodeListener)instead to properly handle the events corresponding to a resource ownerAdds thelistener. Listeners will be invoked in the same order as they were added- Parameters:
listener- theAuthorizationCodeListenerto be added- Throws:
IllegalArgumentException- if thelistenerisnull
-
removeListener
@Deprecated void removeListener(AuthorizationCodeListener listener)
Deprecated.since 1.1, 1.0.2. UseaddListener(String, AuthorizationCodeListener)insteadRemoves thelistener. Nothing happens if it wasn't part ofthisdancer.- Parameters:
listener- theAuthorizationCodeListenerto be removed- Throws:
IllegalArgumentException- if thelistenerisnull
-
addListener
default void addListener(String resourceOwnerId, AuthorizationCodeListener listener)
Adds thelistener. Listeners will be invoked in the same order as they were added- Parameters:
resourceOwnerId- id of the user who the listener corresponds tolistener- theAuthorizationCodeListenerto be added- Throws:
IllegalArgumentException- if thelistenerisnull- Since:
- 1.1, 1.0.2
-
removeListener
default void removeListener(String resourceOwnerId, AuthorizationCodeListener listener)
Removes thelistener. Nothing happens if it wasn't part ofthisdancer.- Parameters:
resourceOwnerId- id of the user who the listener corresponds tolistener- theAuthorizationCodeListenerto be removed- Throws:
IllegalArgumentException- if thelistenerisnull- Since:
- 1.1, 1.0.2
-
-