From dabb719456d5993cc1e639d9dbb41f2a2651b37f Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Tue, 4 Nov 2008 22:46:21 +0000 Subject: [PATCH] SEC-1023: Add hasPermission() support to SecurityExpressionRoot http://jira.springframework.org/browse/SEC-1023. PermissionEvaluator interface for use by expressions when evaluating hasPermisson() expressions. --- .../expression/PermissionEvaluator.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 core/src/main/java/org/springframework/security/expression/PermissionEvaluator.java diff --git a/core/src/main/java/org/springframework/security/expression/PermissionEvaluator.java b/core/src/main/java/org/springframework/security/expression/PermissionEvaluator.java new file mode 100644 index 0000000000..1b4091fece --- /dev/null +++ b/core/src/main/java/org/springframework/security/expression/PermissionEvaluator.java @@ -0,0 +1,25 @@ +package org.springframework.security.expression; + +import org.springframework.security.Authentication; + +/** + * Strategy used in expression evaluation to determine whether a user has a permission or permissions + * for a given domain object. + * + * + * @author Luke Taylor + * @version $Id$ + * @since 2.5 + */ +public interface PermissionEvaluator { + /** + * + * @param authentication represents the user in question. Should not be null. + * @param targetDomainObject the domain object for which permissions should be checked. May be null + * in which case implementations should return false, as the null condition can be checked explicitly + * in the expression. + * @param permission a representation of the permission object as supplied by the expression system. Not null. + * @return true if the permission is granted, false otherwise + */ + boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission); +}