Package org.forgerock.openig.tools
Class CachePolicyDecisionRequestHandler
- java.lang.Object
-
- org.forgerock.openig.tools.CachePolicyDecisionRequestHandler
-
- All Implemented Interfaces:
AutoCloseable
,RequestHandler
public class CachePolicyDecisionRequestHandler extends Object implements RequestHandler, AutoCloseable
ARequestHandler
that caches policies.
-
-
Constructor Summary
Constructors Constructor Description CachePolicyDecisionRequestHandler(com.github.benmanes.caffeine.cache.Caffeine<Object,Object> caffeine, Clock clock, Duration defaultTimeout, Duration maximumTimeout, NotificationService notificationService, DisconnectionStrategy disconnectionStrategy, RequestHandler requestHandler)
Builds aCachePolicyDecisionFilter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Promise<ActionResponse,ResourceException>
handleAction(Context context, ActionRequest actionRequest)
Handles performing an action on a resource, and optionally returns an associated result.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.forgerock.json.resource.RequestHandler
handleCreate, handleDelete, handlePatch, handleQuery, handleRead, handleUpdate
-
-
-
-
Constructor Detail
-
CachePolicyDecisionRequestHandler
public CachePolicyDecisionRequestHandler(com.github.benmanes.caffeine.cache.Caffeine<Object,Object> caffeine, Clock clock, Duration defaultTimeout, Duration maximumTimeout, NotificationService notificationService, DisconnectionStrategy disconnectionStrategy, RequestHandler requestHandler)
Builds aCachePolicyDecisionFilter
.- Parameters:
caffeine
- The caffeine cache to use. Notnull
.clock
- A clock providing access to the current instant, date and time using a time-zone, notnull
.defaultTimeout
- The default duration for which to cache AM policy decisions. If an AM policy decision provides a valid ttl value to specify the time until which the policy decision remains valid, IG uses that value or the maxTimeout.maximumTimeout
- The maximum duration for which to cache AM policy decisions. If the ttl value provided by the AM policy decision is after the current time plus the maxTimeout, IG uses the maxTimeout. Can benull
.notificationService
- The notification service used to connect on AM websocket notifications.disconnectionStrategy
- The strategy to apply in case of notifications' disconnection.requestHandler
- TheRequestHandler
to use to fetch the policy decisions.- Throws:
NullPointerException
- If caffeine or clock arenull
.
-
-
Method Detail
-
handleAction
public Promise<ActionResponse,ResourceException> handleAction(Context context, ActionRequest actionRequest)
Description copied from interface:RequestHandler
Handles performing an action on a resource, and optionally returns an associated result. The execution of an action is allowed to incur side effects.Actions are parametric; a set of named parameters is provided as input to the action. The action result is a JSON object structure composed of basic Java types; its overall structure is defined by a specific implementation.
On completion, the action result (or null) must be used to complete the returned
Promise
. On failure, the returnedPromise
must be completed with the exception.Action expects failure exceptions as follows:
ForbiddenException
if access to the resource is forbidden.NotSupportedException
if the requested functionality is not implemented/supportedBadRequestException
if the passed identifier, parameters or filter is invalidNotFoundException
if the specified resource could not be found.- Specified by:
handleAction
in interfaceRequestHandler
- Parameters:
context
- The request server context, such as associated principal.actionRequest
- The action request.- Returns:
- A
Promise
containing the result of the operation.
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-