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 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 context
      permission - the requested permission
      objectClassId - the object class id
      objectId - 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

      SecurityResult evaluate(DomainContext context, Permission permission, Class<?> clazz)
      Checks a permission for a non-PDO class.
      Parameters:
      context - the domain context
      permission - the requested permission
      clazz - 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

      void removeObsoleteRules(Session session)
      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, the SecurityResult is "accepted", otherwise "denied". The default is true.
      Parameters:
      acceptByDefault - true if SecurityResult.isAccepted() returns true if no rules found.