You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lp...@apache.org on 2023/09/03 18:49:53 UTC
[shiro] branch main updated: enh: make assertAuthorized() method more readable fixes #1057
This is an automated email from the ASF dual-hosted git repository.
lprimak pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shiro.git
The following commit(s) were added to refs/heads/main by this push:
new c92b82a33 enh: make assertAuthorized() method more readable fixes #1057
c92b82a33 is described below
commit c92b82a33f689c15ebacd850228dc2511fa1b230
Author: lprimak <le...@flowlogix.com>
AuthorDate: Sun Sep 3 13:48:45 2023 -0500
enh: make assertAuthorized() method more readable
fixes #1057
---
.../org/apache/shiro/authz/aop/PermissionAnnotationHandler.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/shiro/authz/aop/PermissionAnnotationHandler.java b/core/src/main/java/org/apache/shiro/authz/aop/PermissionAnnotationHandler.java
index 839b47333..a463123ad 100644
--- a/core/src/main/java/org/apache/shiro/authz/aop/PermissionAnnotationHandler.java
+++ b/core/src/main/java/org/apache/shiro/authz/aop/PermissionAnnotationHandler.java
@@ -81,7 +81,12 @@ public class PermissionAnnotationHandler extends AuthorizingAnnotationHandler {
if (Logical.OR.equals(rpAnnotation.logical())) {
// Avoid processing exceptions unnecessarily - "delay" throwing the exception by calling hasRole first
boolean hasAtLeastOnePermission = false;
- for (String permission : perms) if (getSubject().isPermitted(permission)) hasAtLeastOnePermission = true;
+ for (String permission : perms) {
+ if (getSubject().isPermitted(permission)) {
+ hasAtLeastOnePermission = true;
+ break;
+ }
+ }
// Cause the exception if none of the role match, note that the exception message will be a bit misleading
if (!hasAtLeastOnePermission) getSubject().checkPermission(perms[0]);