Class GuardCachingSecurityDomain<T>

All Implemented Interfaces:
Direct Known Subclasses:

public abstract class GuardCachingSecurityDomain<T> extends Object implements SecurityDomain
Abstract SecurityDomain that caches Policy instances and shares them between different secured objects that use the same rules (per SecurityContext). The policy may contain hundreds of rules that need to checked to see if they apply to the current secured object. Therefore it makes sense to cache them if a lot of Guard objects are created for a SecurityDomain.
  • Field Details

    • context

      protected final Context context
  • Constructor Details

    • GuardCachingSecurityDomain

      protected GuardCachingSecurityDomain(Context context)
  • Method Details

    • getOrCreateFilteredPolicy

      public Policy getOrCreateFilteredPolicy(SecurityContext securityContext, List<?> objects, Callable<Policy> provider) throws Exception
      Description copied from interface: SecurityDomain
      Return a policy for the given objects. This can be used to cache and reuse policies for different objects. If no cached policy is available, the given Callable can be used to create a new one.
      Specified by:
      getOrCreateFilteredPolicy in interface SecurityDomain
    • createCacheKey

      protected abstract T createCacheKey(List<?> objects)
      Converts the list of secured objects into an object that is used to group policies. That means if two different lists return the same object, they will share the same policy.
    • buildCache

      protected abstract<T,Policy> buildCache()
    • clearGuardCache

      public void clearGuardCache(SecurityContext securityContext)
      Description copied from interface: SecurityDomain
      Clear all cached objects belonging to the given security context.
      Specified by:
      clearGuardCache in interface SecurityDomain