Class GuardCachingSecurityDomain<T>
java.lang.Object
ch.tocco.nice2.persist.security.impl.provider.GuardCachingSecurityDomain<T>
- All Implemented Interfaces:
SecurityDomain
- Direct Known Subclasses:
AbstractEntitySecurityDomain
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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clearGuardCache
(SecurityContext securityContext) Clear all cached objects belonging to the given security context.protected abstract T
createCacheKey
(List<?> objects) Converts the list of secured objects into an object that is used to group policies.getOrCreateFilteredPolicy
(SecurityContext securityContext, List<?> objects, Callable<Policy> provider) Return a policy for the given objects.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.security.spi.SecurityDomain
aggregateSupportedObjects, evaluateCondition, getSelectorFactory
-
Field Details
-
context
-
-
Constructor Details
-
GuardCachingSecurityDomain
-
-
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 givenCallable
can be used to create a new one.- Specified by:
getOrCreateFilteredPolicy
in interfaceSecurityDomain
- Throws:
Exception
-
createCacheKey
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
-
clearGuardCache
Description copied from interface:SecurityDomain
Clear all cached objects belonging to the given security context.- Specified by:
clearGuardCache
in interfaceSecurityDomain
-