Skip to content

Commit 1173c30

Browse files
committed
Mark targetDomainObject as @Nullable in PermissionEvaluator
Closes: gh-18259 Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
1 parent 7503d80 commit 1173c30

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/src/main/java/org/springframework/security/access/PermissionEvaluator.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
import java.io.Serializable;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.aop.framework.AopInfrastructureBean;
2224
import org.springframework.security.core.Authentication;
2325

@@ -39,7 +41,7 @@ public interface PermissionEvaluator extends AopInfrastructureBean {
3941
* expression system. Not null.
4042
* @return true if the permission is granted, false otherwise
4143
*/
42-
boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission);
44+
boolean hasPermission(Authentication authentication, @Nullable Object targetDomainObject, Object permission);
4345

4446
/**
4547
* Alternative method for evaluating a permission where only the identifier of the

core/src/main/java/org/springframework/security/access/expression/DenyAllPermissionEvaluator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.apache.commons.logging.Log;
2222
import org.apache.commons.logging.LogFactory;
23+
import org.jspecify.annotations.Nullable;
2324

2425
import org.springframework.core.log.LogMessage;
2526
import org.springframework.security.access.PermissionEvaluator;
@@ -40,7 +41,7 @@ public class DenyAllPermissionEvaluator implements PermissionEvaluator {
4041
* @return false always
4142
*/
4243
@Override
43-
public boolean hasPermission(Authentication authentication, Object target, Object permission) {
44+
public boolean hasPermission(Authentication authentication, @Nullable Object target, Object permission) {
4445
this.logger.warn(LogMessage.format("Denying user %s permission '%s' on object %s", authentication.getName(),
4546
permission, target));
4647
return false;

0 commit comments

Comments
 (0)