Interface DecisionCache

  • All Superinterfaces:
    AutoCloseable, Closeable

    public interface DecisionCache
    extends Closeable
    Authorization (XACML) decision result cache. Implements Closeable because a cache may use resources external to the JVM such as a disk or connection to a remote server for persistence, replication, clustering, etc. Therefore, these resources must be released by calling Closeable.close() when it is no longer needed.

    Implementations of this interface are expected to be thread-safe, and allow access by multiple concurrent threads.

    Note: This is quite similar to Guava Cache interface but specialized for specific type of key and value.

    • Method Detail

      • isEvaluationContextRequired

        boolean isEvaluationContextRequired()
        Tells the PDP to always pass a valid/non-null EvaluationContext argument - representing the PDP's evaluation context - to other methods of this API with EvaluationContext arg. Else the PDP may pass a null value to save time and memory.
        Returns:
        true iff a non-null EvaluationContext argument - referring to the PDP's evaluation context - is required for all methods of this API with EvaluationContext arg of this DecisionCache.
      • get

        DecisionResult get​(DecisionRequest request,
                           EvaluationContext evalCtx)
        Get the decision result from the cache for the given decision request.
        Parameters:
        request - individual decision request
        evalCtx - evaluation context that can be used to save context about any partial/preliminary evaluation done by this decision cache when there is no cached result for {code request} yet. In this case, the PDP will call back put(DecisionRequest, DecisionResult, EvaluationContext) with this same evalCtx after the PDP has computed the new result. Therefore, this allows the decision cache to reuse some context during an evaluation, and also to do some evaluation itself. This argument may be null if not required, i.e. isEvaluationContextRequired() returns false.
        Returns:
        the corresponding decision result from cache; null if there is no such result in cache.
      • getAll

        <DECISION_REQ_T extends DecisionRequestMap<DECISION_REQ_T,​DecisionResult> getAll​(List<DECISION_REQ_T> requests)
        Gets the decision result(s) from the cache for the given decision request(s). The ability to get multiple cached results at once allows the Cache implementation to optimize the retrieval by requesting all in the same request, e.g. if the cache is in a remote storage/server.
        Parameters:
        requests - individual decision request(s)
        Returns:
        a map where each entry key is a request from requests, and the value is the corresponding decision result from cache. If there is no such result in cache, the key must not be present in the map. In other words, each request in requests must be a key in the Map returned, except if there is no corresponding result in cache. Therefore, there must not be any null key/value in the map.
      • putAll

        <DECISION_REQ_T extends DecisionRequest> void putAll​(Map<DECISION_REQ_T,​DecisionResult> resultsByRequest)
        Puts decision requests and corresponding results in cache. The ability to put multiple cache entries at once allows the Cache implementation to optimize the creation/update by doing them all in the same request, e.g. if the cache is in a remote storage/server.
        Parameters:
        resultsByRequest - (request, result) pairs as key-value pairs to be cached