Mark targetDomainObject as @Nullable in PermissionEvaluator
Closes: gh-18259 Signed-off-by: Andrey Litvitski <andrey1010102008@gmail.com>
This commit is contained in:
committed by
Rob Winch
parent
d31ca7a758
commit
6d4726bfb7
@@ -23,6 +23,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.core.log.LogMessage;
|
import org.springframework.core.log.LogMessage;
|
||||||
import org.springframework.security.access.PermissionEvaluator;
|
import org.springframework.security.access.PermissionEvaluator;
|
||||||
@@ -73,7 +74,7 @@ public class AclPermissionEvaluator implements PermissionEvaluator {
|
|||||||
* be overridden using a null check in the expression itself).
|
* be overridden using a null check in the expression itself).
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(Authentication authentication, Object domainObject, Object permission) {
|
public boolean hasPermission(Authentication authentication, @Nullable Object domainObject, Object permission) {
|
||||||
if (domainObject == null) {
|
if (domainObject == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package org.springframework.security.access;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.aop.framework.AopInfrastructureBean;
|
import org.springframework.aop.framework.AopInfrastructureBean;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
|
||||||
@@ -39,7 +41,7 @@ public interface PermissionEvaluator extends AopInfrastructureBean {
|
|||||||
* expression system. Not null.
|
* expression system. Not null.
|
||||||
* @return true if the permission is granted, false otherwise
|
* @return true if the permission is granted, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission);
|
boolean hasPermission(Authentication authentication, @Nullable Object targetDomainObject, Object permission);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alternative method for evaluating a permission where only the identifier of the
|
* Alternative method for evaluating a permission where only the identifier of the
|
||||||
|
|||||||
+2
-1
@@ -20,6 +20,7 @@ import java.io.Serializable;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import org.springframework.core.log.LogMessage;
|
import org.springframework.core.log.LogMessage;
|
||||||
import org.springframework.security.access.PermissionEvaluator;
|
import org.springframework.security.access.PermissionEvaluator;
|
||||||
@@ -40,7 +41,7 @@ public class DenyAllPermissionEvaluator implements PermissionEvaluator {
|
|||||||
* @return false always
|
* @return false always
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(Authentication authentication, Object target, Object permission) {
|
public boolean hasPermission(Authentication authentication, @Nullable Object target, Object permission) {
|
||||||
this.logger.warn(LogMessage.format("Denying user %s permission '%s' on object %s", authentication.getName(),
|
this.logger.warn(LogMessage.format("Denying user %s permission '%s' on object %s", authentication.getName(),
|
||||||
permission, target));
|
permission, target));
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user