Class DefaultGuard

java.lang.Object
ch.tocco.nice2.security.spi.DefaultGuard
All Implemented Interfaces:
Guard

public abstract class DefaultGuard extends Object implements Guard
Standard Guard implementation which delegates the different ask/check/evaluatePermission methods to evaluatePermission(Permission). This implementation simply delegates to a ListGuard instance that contains exactly one secured object.
  • Constructor Details

  • Method Details

    • askPermission

      public final boolean askPermission(Permission permission)
      Description copied from interface: Guard
      Ask the guard for a specific permission. This method is usually used by the user interface, e.g. to disable buttons.
      Specified by:
      askPermission in interface Guard
      Parameters:
      permission - The permission to check.
      Returns:
      true, if the permission is granted, false, if it's denied.
    • askPermission

      public final boolean askPermission(String expression) throws InvalidPermissionException
      Description copied from interface: Guard
      Ask the guard for a specific permission. This method is usually used by the user interface, e.g. to disable buttons.
      Specified by:
      askPermission in interface Guard
      Parameters:
      expression - The permission to check as permission string.
      Returns:
      true, if the permission is granted, false, if it's denied.
      Throws:
      InvalidPermissionException - If the permission string cannot be parsed or mapped to a permission object.
    • checkPermission

      public final void checkPermission(Permission permission) throws UnauthorizedException
      Description copied from interface: Guard
      Ask the guard for a specific permission throwing an exception, if the permission is denied. This method is usually used by the protected object.
      Specified by:
      checkPermission in interface Guard
      Parameters:
      permission - The permission to check.
      Throws:
      UnauthorizedException - If the permission is denied.
    • checkPermission

      public final void checkPermission(String expression) throws UnauthorizedException, InvalidPermissionException
      Description copied from interface: Guard
      Ask the guard for a specific permission throwing an exception, if the permission is denied. This method is usually used by the protected object.
      Specified by:
      checkPermission in interface Guard
      Parameters:
      expression - The permission to check as permission string.
      Throws:
      UnauthorizedException - If the permission is denied.
      InvalidPermissionException - If the permission string cannot be parsed or mapped to a permission object.
    • evaluatePermission

      public final Guard.Decision evaluatePermission(Permission permission)
      Description copied from interface: Guard
      Evaluates a permission. This method returns an Guard.Decision providing some more information about *why* a permission is granted or denied.
      Specified by:
      evaluatePermission in interface Guard
      Parameters:
      permission - The permission to evaluate.
      Returns:
      An Guard.Decision.
    • readPermission

      protected Permission readPermission(String expression)
    • getSecurityDomainName

      protected abstract String getSecurityDomainName()
    • getPrincipal

      public Principal getPrincipal()
      Specified by:
      getPrincipal in interface Guard
    • getSecured

      public Object getSecured()
      Description copied from interface: Guard
      Get the object this guard is protecting
      Specified by:
      getSecured in interface Guard
      Returns:
      The object this guard is protecting.
    • getSecurityContext

      public SecurityContext getSecurityContext()
      Specified by:
      getSecurityContext in interface Guard