Interface SecurityManager
- All Known Implementing Classes:
DefaultSecurityManager
public interface SecurityManager
The SecurityManager applies security rules to
PersistentDomainObjects
or classes and grants or denies permissions.
A disabled security manager grants everything.
- Author:
- harald
-
Method Summary
Modifier and TypeMethodDescriptionevaluate(DomainContext context, Permission permission, int objectClassId, long objectId) Checks a permission for a PDO or a PDO class.evaluate(DomainContext context, Permission permission, Class<?> clazz) Checks a permission for a non-PDO class.voidInvalidate the manager.
The next request will re-initialize it.booleanDetermines whether this manager accepts by default.booleanDetermines whether this manager is enabled.voidremoveObsoleteRules(Session session) Removes obsolete rules.voidsetAcceptByDefault(boolean acceptByDefault) Sets the default behavior if no rule fires.
If true, theSecurityResultis "accepted", otherwise "denied".voidsetEnabled(boolean enabled) Enables or disables this security manager.
A disabled security manager grants everything.
-
Method Details
-
evaluate
SecurityResult evaluate(DomainContext context, Permission permission, int objectClassId, long objectId) Checks a permission for a PDO or a PDO class.- Parameters:
context- the domain contextpermission- the requested permissionobjectClassId- the object class idobjectId- the identifiable id, 0 for all PDOs of that class- Returns:
- the SecurityResult
- Throws:
SecurityException- if the arguments are invalid or the grantee cannot be determined
-
evaluate
Checks a permission for a non-PDO class.- Parameters:
context- the domain contextpermission- the requested permissionclazz- the class- Returns:
- the SecurityResult
- Throws:
SecurityException- if the arguments are invalid or the grantee cannot be determined
-
invalidate
void invalidate()Invalidate the manager.
The next request will re-initialize it. -
removeObsoleteRules
Removes obsolete rules.Since the model has no relation to the security implementation, security rules may become obsolete if PDOs are deleted. This method will remove such obsolete rules, i.e., rules whose secured PDO or grantee no longer exists.
Failures are logged and the transaction is rolled back, but no exception is thrown.- Parameters:
session- the session
-
isEnabled
boolean isEnabled()Determines whether this manager is enabled.- Returns:
- true if enabled.
-
setEnabled
void setEnabled(boolean enabled) Enables or disables this security manager.
A disabled security manager grants everything.- Parameters:
enabled- true to enable the security manager- See Also:
-
isAcceptByDefault
boolean isAcceptByDefault()Determines whether this manager accepts by default.- Returns:
- true to accept if no matching rule is found
-
setAcceptByDefault
void setAcceptByDefault(boolean acceptByDefault) Sets the default behavior if no rule fires.
If true, theSecurityResultis "accepted", otherwise "denied". The default is true.- Parameters:
acceptByDefault- true ifSecurityResult.isAccepted()returns true if no rules found.
-