public class OAuthRestConnection<O extends org.mule.runtime.extension.api.connectivity.oauth.OAuthState> extends DefaultRestConnection
DefaultRestConnection for resources protected with OAuth, regardless of the grant type.| Constructor and Description |
|---|
OAuthRestConnection(org.mule.runtime.http.api.client.HttpClient httpClient,
org.mule.runtime.http.api.client.HttpRequestOptions httpRequestOptions,
String baseUri,
O oauthState,
String resourceOwnerId) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
authenticate(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder httpRequestBuilder)
Allows to different type of connections to intercept the request before sending the HTTP call.
|
protected void |
authenticate(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder httpRequestBuilder,
O oauthState)
Allows to implement a custom signature for OAuth.
|
org.mule.runtime.http.api.domain.message.response.HttpResponse |
send(org.mule.runtime.http.api.domain.message.request.HttpRequest request)
Synchronous invocation of the
HttpRequest against the connection. |
CompletableFuture<org.mule.runtime.http.api.domain.message.response.HttpResponse> |
sendAsync(org.mule.runtime.http.api.domain.message.request.HttpRequest request)
Asynchronous invocation of the
HttpRequest against this connection. |
protected void |
throwAccessTokenExpiredExceptionIfNeedsRefreshToken(int statusCode,
String resourceOwnerId)
Template method to allow custom code for server that are not complaint with HTTP status codes to trigger a refresh token.
|
org.mule.runtime.api.connection.ConnectionValidationResult |
validate(org.mule.runtime.http.api.domain.message.request.HttpRequest request,
Function<org.mule.runtime.http.api.domain.message.response.HttpResponse,org.mule.runtime.api.connection.ConnectionValidationResult> whenComplete,
Function<Exception,org.mule.runtime.api.connection.ConnectionValidationResult> onError)
Executes the
HttpRequest and validates the response to generate the corresponding ConnectionValidationResult. |
getBaseUriprotected final void authenticate(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder httpRequestBuilder)
DefaultRestConnectionauthenticate in class DefaultRestConnectionhttpRequestBuilder - HttpRequestBuilder populated with the values from the original HttpRequest.protected void authenticate(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder httpRequestBuilder,
O oauthState)
httpRequestBuilder - HttpRequestBuilder to sign the request.oauthState - OAuthState to get access to the access token.public CompletableFuture<org.mule.runtime.http.api.domain.message.response.HttpResponse> sendAsync(org.mule.runtime.http.api.domain.message.request.HttpRequest request)
RestConnectionHttpRequest against this connection. Allows non-blocking operations to fulfil the SDK
contract for non-blocking support in connectors.sendAsync in interface RestConnectionsendAsync in class DefaultRestConnectionrequest - to be executed.CompletableFuture to handle the async response.public org.mule.runtime.http.api.domain.message.response.HttpResponse send(org.mule.runtime.http.api.domain.message.request.HttpRequest request)
throws IOException,
TimeoutException
RestConnectionHttpRequest against the connection. Used for design operations like value providers or
even for paging operations where non-blocking is not supported by SDK.send in interface RestConnectionsend in class DefaultRestConnectionrequest - to be executed.HttpResponse the server response.IOExceptionTimeoutExceptionpublic org.mule.runtime.api.connection.ConnectionValidationResult validate(org.mule.runtime.http.api.domain.message.request.HttpRequest request,
Function<org.mule.runtime.http.api.domain.message.response.HttpResponse,org.mule.runtime.api.connection.ConnectionValidationResult> whenComplete,
Function<Exception,org.mule.runtime.api.connection.ConnectionValidationResult> onError)
RestConnectionHttpRequest and validates the response to generate the corresponding ConnectionValidationResult.validate in interface RestConnectionvalidate in class DefaultRestConnectionrequest - to be executed.whenComplete - to process an HttpResponse and return a ConnectionValidationResult.onError - to process an Exception, that happened from client side before calling the server, and return a
ConnectionValidationResult.ConnectionValidationResult.protected void throwAccessTokenExpiredExceptionIfNeedsRefreshToken(int statusCode,
String resourceOwnerId)
HttpConstants.HttpStatus.UNAUTHORIZED status code to
throw the AccessTokenExpiredException so Mule Runtime/SDK will refresh the access token. statusCode - the HttpResponse from the server.resourceOwnerId - the oauth resource owner id to be provided by the AccessTokenExpiredException or null.Copyright © 2022. All rights reserved.