Interface PermissionEvaluator


public interface PermissionEvaluator

Decides hasPermission(...) in a method-security expression, as Spring Security's interface of the same name does. Declare one bean that implements it; without one, every hasPermission is denied, as with Spring's DenyAllPermissionEvaluator.

@Component
public class Permissions implements PermissionEvaluator {
    public boolean hasPermission(Authentication auth, Object target, Object permission) {
        return target instanceof Doc && ((Doc) target).getOwner().equals(auth.getName());
    }
    public boolean hasPermission(Authentication auth, Object id, String type,
                                 Object permission) {
        return false;
    }
}
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    hasPermission(Authentication authentication, Object targetDomainObject, Object permission)
    hasPermission(target, permission): may the caller act on this object?
    boolean
    hasPermission(Authentication authentication, Object targetId, String targetType, Object permission)
    hasPermission(id, 'Type', permission): may the caller act on the object of this type with this identifier, which the expression does not load?
  • Method Details

    • hasPermission

      boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission)
      hasPermission(target, permission): may the caller act on this object?
    • hasPermission

      boolean hasPermission(Authentication authentication, Object targetId, String targetType, Object permission)
      hasPermission(id, 'Type', permission): may the caller act on the object of this type with this identifier, which the expression does not load?