Class RefreshAuthTokenWrapper<REQUEST extends BmcRequest<?>,RESPONSE>
- java.lang.Object
- 
- com.oracle.bmc.util.internal.RefreshAuthTokenWrapper<REQUEST,RESPONSE>
 
- 
- Type Parameters:
- REQUEST- The request type.
- RESPONSE- The response type.
 - All Implemented Interfaces:
- AsyncHandler<REQUEST,RESPONSE>,- Future<RESPONSE>
 
 public abstract class RefreshAuthTokenWrapper<REQUEST extends BmcRequest<?>,RESPONSE> extends Object implements AsyncHandler<REQUEST,RESPONSE>, Future<RESPONSE> Combined future and 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). It also wraps a delegate Future, and when the result of the future is requested, but the call fails with a 401, we perform the additional logic described above. 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. 
- 
- 
Constructor SummaryConstructors Constructor Description RefreshAuthTokenWrapper(RefreshableOnNotAuthenticatedProvider<?> authDetailsProvider, AsyncHandler<REQUEST,RESPONSE> innerHandler, Function<AsyncHandler<REQUEST,RESPONSE>,Future<RESPONSE>> futureSupplier)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidbeforeRetryAction()Abstract action to be taken before a retry.protected Future<RESPONSE>buildResponseFuture()Call the future supplier to get the response future.booleancancel(boolean mayInterruptIfRunning)RESPONSEget()RESPONSEget(long timeout, TimeUnit unit)booleanisCancelled()booleanisDone()voidonError(REQUEST request, Throwable error)Called if the request could not be completed successfully.voidonSuccess(REQUEST request, RESPONSE response)Called if the request was successfully completed.booleanretryCall()If we need to retry the request (i.e.
 
- 
- 
- 
Constructor Detail- 
RefreshAuthTokenWrapperpublic RefreshAuthTokenWrapper(RefreshableOnNotAuthenticatedProvider<?> authDetailsProvider, AsyncHandler<REQUEST,RESPONSE> innerHandler, Function<AsyncHandler<REQUEST,RESPONSE>,Future<RESPONSE>> futureSupplier) 
 
- 
 - 
Method Detail- 
onSuccesspublic void onSuccess(REQUEST request, RESPONSE response) Description copied from interface:AsyncHandlerCalled if the request was successfully completed.- Specified by:
- onSuccessin interface- AsyncHandler<REQUEST extends BmcRequest<?>,RESPONSE>
- Parameters:
- request- The request that was made.
- response- The response that was received.
 
 - 
onErrorpublic void onError(REQUEST request, Throwable error) Description copied from interface:AsyncHandlerCalled if the request could not be completed successfully.- Specified by:
- onErrorin interface- AsyncHandler<REQUEST extends BmcRequest<?>,RESPONSE>
- Parameters:
- request- The request that was made.
- error- The error that was received.
 
 - 
retryCallpublic boolean 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. - Returns:
- false if the retry was not allowed because of the number of attempts
 
 - 
beforeRetryActionprotected abstract void beforeRetryAction() Abstract action to be taken before a retry.
 - 
buildResponseFutureprotected Future<RESPONSE> buildResponseFuture() Call the future supplier to get the response future.- Returns:
- response future
 
 - 
cancelpublic boolean cancel(boolean mayInterruptIfRunning) - Specified by:
- cancelin interface- Future<REQUEST extends BmcRequest<?>>
 
 - 
isCancelledpublic boolean isCancelled() - Specified by:
- isCancelledin interface- Future<REQUEST extends BmcRequest<?>>
 
 - 
isDonepublic boolean isDone() - Specified by:
- isDonein interface- Future<REQUEST extends BmcRequest<?>>
 
 - 
getpublic RESPONSE get() throws InterruptedException, ExecutionException - Specified by:
- getin interface- Future<REQUEST extends BmcRequest<?>>
- Throws:
- InterruptedException
- ExecutionException
 
 - 
getpublic RESPONSE get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
- getin interface- Future<REQUEST extends BmcRequest<?>>
- Throws:
- InterruptedException
- ExecutionException
- TimeoutException
 
 
- 
 
-