Package ome.security.policy
Class DefaultPolicyService
- java.lang.Object
-
- ome.tools.spring.OnContextRefreshedEventListener
-
- ome.security.policy.DefaultPolicyService
-
- All Implemented Interfaces:
java.util.EventListener,PolicyService,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
public class DefaultPolicyService extends OnContextRefreshedEventListener implements PolicyService
PolicyServicewhich is configured with allPolicyinstances which are discovered in the Spring context and only focuses on a small subset ofIObjecttypes as specified byfilterObject(IObject).
-
-
Constructor Summary
Constructors Constructor Description DefaultPolicyService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckRestriction(java.lang.String name, ome.model.IObject obj)Give each configuredPolicyinstance the chance to throw aSecurityViolationfrom itsPolicy.checkRestriction(IObject)method.protected booleanfilterObject(ome.model.IObject obj)Limit the objects to whichPolicyinstances are applied.voidhandleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent event)Loads allPolicyinstances from the context, and uses them to initialize thisPolicyService.booleanisRestricted(java.lang.String name, ome.model.IObject obj)Ask each configuredPolicyinstance with the given name argument if it considers the restriction active for the givenIObjectargument.java.util.Set<java.lang.String>listActiveRestrictions(ome.model.IObject obj)Return all identifier strings as would be passed as the first argument toPolicyService.isRestricted(String, IObject)orPolicyService.checkRestriction(String, IObject)which considers itself active for the given argument.java.util.Set<java.lang.String>listAllRestrictions()Return all configured identifier strings as would be passed as the first argument toPolicyService.isRestricted(String, IObject)orPolicyService.checkRestriction(String, IObject).-
Methods inherited from class ome.tools.spring.OnContextRefreshedEventListener
onApplicationEvent, setApplicationContext
-
-
-
-
Method Detail
-
handleContextRefreshedEvent
public void handleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent event)
Loads allPolicyinstances from the context, and uses them to initialize thisPolicyService.- Specified by:
handleContextRefreshedEventin classOnContextRefreshedEventListener
-
isRestricted
public boolean isRestricted(java.lang.String name, ome.model.IObject obj)Description copied from interface:PolicyServiceAsk each configuredPolicyinstance with the given name argument if it considers the restriction active for the givenIObjectargument. If any are active, return true.- Specified by:
isRestrictedin interfacePolicyService- Parameters:
name- non-null identifier of a class ofPolicyinstances.obj- non-null "context" for this check.- Returns:
- true if any
Policyreturns true fromPolicy.isRestricted(IObject).
-
checkRestriction
public void checkRestriction(java.lang.String name, ome.model.IObject obj)Description copied from interface:PolicyServiceGive each configuredPolicyinstance the chance to throw aSecurityViolationfrom itsPolicy.checkRestriction(IObject)method.- Specified by:
checkRestrictionin interfacePolicyService- Parameters:
name- non-null identifier of a class ofPolicyinstances.obj- non-null "context" for this check.
-
listAllRestrictions
public java.util.Set<java.lang.String> listAllRestrictions()
Description copied from interface:PolicyServiceReturn all configured identifier strings as would be passed as the first argument toPolicyService.isRestricted(String, IObject)orPolicyService.checkRestriction(String, IObject).- Specified by:
listAllRestrictionsin interfacePolicyService
-
listActiveRestrictions
public java.util.Set<java.lang.String> listActiveRestrictions(ome.model.IObject obj)
Description copied from interface:PolicyServiceReturn all identifier strings as would be passed as the first argument toPolicyService.isRestricted(String, IObject)orPolicyService.checkRestriction(String, IObject)which considers itself active for the given argument.- Specified by:
listActiveRestrictionsin interfacePolicyService- Parameters:
obj- non-null context passed to eachPolicyinstance.- Returns:
- a possibly empty string set of identifiers which should be
returned to clients via
Permissions.copyExtendedRestrictions().
-
filterObject
protected boolean filterObject(ome.model.IObject obj)
Limit the objects to whichPolicyinstances are applied. This reduces the overhead of creating aHashSetfor every object in a returned graph.- Parameters:
obj- e.g. the argument tolistActiveRestrictions(IObject).- Returns:
- true if the given object should not be restricted.
-
-