Module org.mule.oauth.client.api
Package org.mule.oauth.client.api
Interface ClientCredentialsOAuthDancer
-
@NoImplement public interface ClientCredentialsOAuthDancerImplementations provide OAuth dance support for client-credentials grant-type.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CompletableFuture<String>accessToken()Will query the internal state (thetokensStoreparameter passed to the service to build theClientCredentialsOAuthDancer) to get the appropriate accessToken.voidaddListener(ClientCredentialsListener listener)Adds thelistener.ResourceOwnerOAuthContextgetContext()Retrieves the oauth context.voidinvalidateContext()Clears the oauth context.CompletableFuture<Void>refreshToken()Performs the refresh of the access token.voidremoveListener(ClientCredentialsListener listener)Removes thelistener.
-
-
-
Method Detail
-
accessToken
CompletableFuture<String> accessToken() throws RequestAuthenticationException
Will query the internal state (thetokensStoreparameter passed to the service to build theClientCredentialsOAuthDancer) to get the appropriate accessToken. This requires that the authorization has been performed beforehand, otherwise, aRequestAuthenticationExceptionwill be thrown.- 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()
Performs the refresh of the access token.- Returns:
- a completable future that is complete when the token has been refreshed.
-
invalidateContext
void invalidateContext()
Clears the oauth context.
-
getContext
ResourceOwnerOAuthContext getContext()
Retrieves the oauth context. If there's no state, a new state is retrieved so never returns null.- Returns:
- oauth state
-
addListener
void addListener(ClientCredentialsListener listener)
Adds thelistener. Listeners will be invoked in the same order as they were added- Parameters:
listener- theClientCredentialsListenerto be added- Throws:
IllegalArgumentException- if thelistenerisnull
-
removeListener
void removeListener(ClientCredentialsListener listener)
Removes thelistener. Nothing happens if it wasn't part ofthisdancer.- Parameters:
listener- theClientCredentialsListenerto be removed- Throws:
IllegalArgumentException- if thelistenerisnull
-
-