Package ome.security.policy
Interface Policy
-
- All Known Implementing Classes:
BasePolicy
,BinaryAccessPolicy
public interface Policy
Strategy to permit the flexible restriction of certain actions throughout OMERO. Code which intends to allow such checks should create a newPolicy
class with a uniquename
and add checks within that code. For example:public class MyPolicy implements Policy { public final static string NAME = "MyPolicy"; public String getName() { return NAME; } } public void someImportantMethod() { IObject objBeingAccessed = ...; policyService.checkRestriction(MyPolicy.NAME, objBeingAccessed); // Here an exception may be thrown }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
checkRestriction(ome.model.IObject obj)
LikeisRestricted(IObject)
but throws an appropriateSecurityViolation
subclass if the restriction is active.java.lang.String
getName()
Unique name for a class of restrictions that thisPolicy
will enforce.java.util.Set<java.lang.Class<ome.model.IObject>>
getTypes()
boolean
isRestricted(ome.model.IObject obj)
Checks whether or not this instance would throw aSecurityViolation
if the same instance were passed tocheckRestriction(IObject)
.
-
-
-
Method Detail
-
getName
java.lang.String getName()
Unique name for a class of restrictions that thisPolicy
will enforce. This string will be sent to clients viaPermissions.copyExtendedRestrictions()
in order to prevent exceptions, and server-code will pass the same name to the check method to potentially have an exception thrown.
-
getTypes
java.util.Set<java.lang.Class<ome.model.IObject>> getTypes()
EachPolicy
should tell thePolicyService
which types ofIObject
instances it cares about. Only those which are of interest to somePolicy
need be considered.
-
isRestricted
boolean isRestricted(ome.model.IObject obj)
Checks whether or not this instance would throw aSecurityViolation
if the same instance were passed tocheckRestriction(IObject)
. This is likely determined by first testing the type of theIObject
and then that the current user context has access to the given context.- Parameters:
obj
- a non-nullIObject
instance.- Returns:
- true if this
Policy
decides that a restriction should be placed on the passed context.
-
checkRestriction
void checkRestriction(ome.model.IObject obj) throws ome.conditions.SecurityViolation
LikeisRestricted(IObject)
but throws an appropriateSecurityViolation
subclass if the restriction is active.- Throws:
ome.conditions.SecurityViolation
-
-