public class DynamicAuthnFilter extends com.vmware.vapi.core.DecoratorApiProvider
ApiProviderupon which the
Stubclasses are Instantiated.
The filter relies on externally provided
ExecutionContext.SecurityContexts. To allow for
efficient operation a
CompletionStage is expected from the supplier.
Supplier will be invoked once on the first call to obtain security context
and will be invoked subsequently when
Unauthenticated exception is
encountered from the remote service.
SecurityContextAcquisitionError will be returned when the filter
cannot obtain authentication token with the provided
Calls waiting on a failing future before the timeout for refreshing failed future lapse will fail with no retry. If multiple retries are to be made to acquire credential this is to be implemented in the future logic.
|Constructor and Description|
Creates a new authentication filter that can be used to create stub that will have all their calls authenticated
|Modifier and Type||Method and Description|
public DynamicAuthnFilter(ApiProvider decoratedProvider, java.util.function.Supplier<java.util.concurrent.CompletionStage<ExecutionContext.SecurityContext>> supplier, long timeoutMs)
ApiProviderthat invokes the real API. Typically obtained from a connection.
supplier- whenever new security context is needed this will be called to obtain a new
CompletionStagethat will deliver the context. It is expected that this operation is relatively fast. While the completion stage may take time to acquire the actual
Supplier will be called on the first request and after
Unauthenticated errors are reported from the API.
timeoutMs- is the interval after acquisition of token fails until refresh is attempted. Positive number is required.
public void invoke(java.lang.String service, java.lang.String operation, DataValue input, ExecutionContext ctx, AsyncHandle<MethodResult> asyncHandle)
Unauthenticatederror retries the request with refreshed
ApiProvider.invoke(String, String, DataValue, ExecutionContext, AsyncHandle)for details on the parameters and operation.
service- identifier of the target service
operation- identifier of the target operation
input- operation input parameters
ctx- execution context for the invocation
asyncHandle- handle used to asynchronously "return" the result or error of the invocation