Top Description Fields Constructors Methods
com.oracle.bmc.util.internal

public abstract Class RefreshAuthTokenWrappingAsyncHandler<REQUEST, RESPONSE>

extends Object
implements AsyncHandler<REQUEST, RESPONSE>
Class Inheritance
All Implemented Interfaces
com.oracle.bmc.responses.AsyncHandler
Type Parameters
<REQUEST>
The request type.
<RESPONSE>
The response type.
Imports
com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider, com.oracle.bmc.model.BmcException, com.oracle.bmc.responses.AsyncHandler, org.slf4j.Logger

Deprecated

in favor of RefreshAuthTokenWrapper -- versions after 1.25.1 do not use RefreshAuthTokenWrappingAsyncHandler anymore

Callbacks for asynchronous requests intended to work with some authenticated calls, like instance principals. This handler wraps a base AsyncHandler and has additional logic so that if a call fails with a 401, we'll refresh the auth token and then try again up to a given number of retries (it is recommended that we only do one retry).

This is to account for scenarios where we have a valid/non-expired token but the permissions for the instance have changed since the token was issued and so on the server-side the presented token is considered invalid.

Field Summary

Modifier and TypeField and Description
private final RefreshableOnNotAuthenticatedProvider<?>
private int
private final AsyncHandler<REQUEST, RESPONSE>
private static final Logger
private static final int

Constructor Summary

AccessConstructor and Description
public
RefreshAuthTokenWrappingAsyncHandler(RefreshableOnNotAuthenticatedProvider<?> authDetailsProvider, AsyncHandler<REQUEST, RESPONSE> innerHandler)

Method Summary

Modifier and TypeMethod and Description
public void
onError(REQUEST
The request that was made.
request
,
Throwable
The error that was received.
error
)

Implements com.oracle.bmc.responses.AsyncHandler.onError.

Called if the request could not be completed successfully.

public void
onSuccess(REQUEST
The request that was made.
request
,
RESPONSE
The response that was received.
response
)

Implements com.oracle.bmc.responses.AsyncHandler.onSuccess.

Called if the request was successfully completed.

public abstract void
retryCall()

If we need to retry the request (i.e. on a 401), this method contains the information on how to do that.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

authDetailsProviderback to summary
private final RefreshableOnNotAuthenticatedProvider<?> authDetailsProvider
currentAttemptback to summary
private int currentAttempt
innerHandlerback to summary
private final AsyncHandler<REQUEST, RESPONSE> innerHandler
LOGback to summary
private static final Logger LOG
NUM_TRIES_ALLOWEDback to summary
private static final int NUM_TRIES_ALLOWED

Constructor Detail

RefreshAuthTokenWrappingAsyncHandlerback to summary
public RefreshAuthTokenWrappingAsyncHandler(RefreshableOnNotAuthenticatedProvider<?> authDetailsProvider, AsyncHandler<REQUEST, RESPONSE> innerHandler)

Method Detail

onErrorback to summary
public void onError(REQUEST request, Throwable error)

Implements com.oracle.bmc.responses.AsyncHandler.onError.

Doc from com.oracle.bmc.responses.AsyncHandler.onError.

Called if the request could not be completed successfully.

Parameters
request:REQUEST

The request that was made.

error:Throwable

The error that was received.

Annotations
@Override
onSuccessback to summary
public void onSuccess(REQUEST request, RESPONSE response)

Implements com.oracle.bmc.responses.AsyncHandler.onSuccess.

Doc from com.oracle.bmc.responses.AsyncHandler.onSuccess.

Called if the request was successfully completed.

Parameters
request:REQUEST

The request that was made.

response:RESPONSE

The response that was received.

Annotations
@Override
retryCallback to summary
public abstract void retryCall()

If we need to retry the request (i.e. on a 401), this method contains the information on how to do that. This method will be leveraged by the onError callback of this handler.