public class DefaultPolicyService extends OnContextRefreshedEventListener implements PolicyService
PolicyService
which is configured with all Policy
instances
which are discovered in the Spring context and only focuses on a small
subset of IObject
types as specified by filterObject(IObject)
.Constructor and Description |
---|
DefaultPolicyService() |
Modifier and Type | Method and Description |
---|---|
void |
checkRestriction(String name,
IObject obj)
Give each configured
Policy instance the chance to throw a
SecurityViolation from its
Policy.checkRestriction(IObject) method. |
protected boolean |
filterObject(IObject obj)
Limit the objects to which
Policy instances are applied. |
void |
handleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent event)
Loads all
Policy instances from the context,
and uses them to initialize this PolicyService . |
boolean |
isRestricted(String name,
IObject obj)
|
Set<String> |
listActiveRestrictions(IObject obj)
Return all identifier strings as would be passed as the first argument to
PolicyService.isRestricted(String, IObject) or
PolicyService.checkRestriction(String, IObject) which considers
itself active for the given argument. |
Set<String> |
listAllRestrictions()
Return all configured identifier strings as would be passed as the first
argument to
PolicyService.isRestricted(String, IObject) or
PolicyService.checkRestriction(String, IObject) . |
onApplicationEvent, setApplicationContext
public void handleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent event)
Policy
instances from the context,
and uses them to initialize this PolicyService
.handleContextRefreshedEvent
in class OnContextRefreshedEventListener
public boolean isRestricted(String name, IObject obj)
PolicyService
Policy
instance with the given name argument
if it considers the restriction active for the given IObject
argument. If any are active, return true.isRestricted
in interface PolicyService
name
- non-null identifier of a class of Policy
instances.obj
- non-null "context" for this check.Policy
returns true from
Policy.isRestricted(IObject)
.public void checkRestriction(String name, IObject obj)
PolicyService
Policy
instance the chance to throw a
SecurityViolation
from its
Policy.checkRestriction(IObject)
method.checkRestriction
in interface PolicyService
name
- non-null identifier of a class of Policy
instances.obj
- non-null "context" for this check.public Set<String> listAllRestrictions()
PolicyService
PolicyService.isRestricted(String, IObject)
or
PolicyService.checkRestriction(String, IObject)
.listAllRestrictions
in interface PolicyService
public Set<String> listActiveRestrictions(IObject obj)
PolicyService
PolicyService.isRestricted(String, IObject)
or
PolicyService.checkRestriction(String, IObject)
which considers
itself active for the given argument.listActiveRestrictions
in interface PolicyService
obj
- non-null context passed to each Policy
instance.Permissions.copyExtendedRestrictions()
.protected boolean filterObject(IObject obj)
Policy
instances are applied. This
reduces the overhead of creating a HashSet
for every object in
a returned graph.obj
- e.g. the argument to listActiveRestrictions(IObject)
.
Version: 5.1.4-ice35-b55
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.