- All Implemented Interfaces:
public class DynamicAuthnFilter extends com.vmware.vapi.core.DecoratorApiProviderFilter that can be used to acquire on-demand security context for requests. This filter is to be used as decorator of the client
ApiProviderupon which the
Stubclasses are Instantiated.
The filter relies on externally provided
ExecutionContext.SecurityContexts. To allow for efficient operation a
CompletionStageis expected from the supplier.
Supplier will be invoked once on the first call to obtain security context and will be invoked subsequently when
Unauthenticatedexception is encountered from the remote service.
SecurityContextAcquisitionErrorwill 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.
Constructors Constructor Description
DynamicAuthnFilter(ApiProvider decoratedProvider, java.util.function.Supplier<java.util.concurrent.CompletionStage<ExecutionContext.SecurityContext>> supplier, long timeoutMs)Creates a new authentication filter that can be used to create stub that will have all their calls authenticated
All Methods Instance Methods Concrete Methods Modifier and Type Method Description
invoke(java.lang.String service, java.lang.String operation, DataValue input, ExecutionContext ctx, AsyncHandle<MethodResult> asyncHandle)
invokeNext(java.lang.String service, java.lang.String operation, DataValue input, ExecutionContext ctx, AsyncHandle<MethodResult> handle)
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
Unauthenticatederrors 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)Invokes the decorated provider and in case of
Unauthenticatederror retries the request with refreshed
ApiProvider.invoke(String, String, DataValue, ExecutionContext, AsyncHandle)for details on the parameters and operation.
- Specified by:
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