shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdem...@apache.org
Subject [6/6] shiro git commit: SHIRO-564 lower-case wildcard string before building subparts so that the subparts list is not created twice for case-insensitive strings.
Date Wed, 29 Jun 2016 22:06:15 GMT
SHIRO-564 lower-case wildcard string before building subparts so that the subparts list is
not created twice for case-insensitive strings.

Fixes #18


Project: http://git-wip-us.apache.org/repos/asf/shiro/repo
Commit: http://git-wip-us.apache.org/repos/asf/shiro/commit/6809366c
Tree: http://git-wip-us.apache.org/repos/asf/shiro/tree/6809366c
Diff: http://git-wip-us.apache.org/repos/asf/shiro/diff/6809366c

Branch: refs/heads/1.3.x
Commit: 6809366c83869d493e4109d822d0aa44a03d303b
Parents: fd161e0
Author: Matt Bishop <matthew.bishop@elasticpath.com>
Authored: Sun May 29 12:12:31 2016 -0700
Committer: Brian Demers <bdemers@stormpath.com>
Committed: Wed Jun 29 14:59:59 2016 -0700

----------------------------------------------------------------------
 .../shiro/authz/permission/WildcardPermission.java  | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/shiro/blob/6809366c/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java
b/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java
index cb9d14e..54032a3 100644
--- a/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java
+++ b/core/src/main/java/org/apache/shiro/authz/permission/WildcardPermission.java
@@ -154,14 +154,16 @@ public class WildcardPermission implements Permission, Serializable
{
             throw new IllegalArgumentException("Wildcard string cannot be null or empty.
Make sure permission strings are properly formatted.");
         }
 
+        if (!caseSensitive) {
+            wildcardString = wildcardString.toLowerCase();
+        }
+
         List<String> parts = CollectionUtils.asList(wildcardString.split(PART_DIVIDER_TOKEN));
 
         this.parts = new ArrayList<Set<String>>();
         for (String part : parts) {
             Set<String> subparts = CollectionUtils.asSet(part.split(SUBPART_DIVIDER_TOKEN));
-            if (!caseSensitive) {
-                subparts = lowercase(subparts);
-            }
+
             if (subparts.isEmpty()) {
                 throw new IllegalArgumentException("Wildcard string cannot contain parts
with only dividers. Make sure permission strings are properly formatted.");
             }
@@ -173,14 +175,6 @@ public class WildcardPermission implements Permission, Serializable {
         }
     }
 
-    private Set<String> lowercase(Set<String> subparts) {
-        Set<String> lowerCasedSubparts = new LinkedHashSet<String>(subparts.size());
-        for (String subpart : subparts) {
-            lowerCasedSubparts.add(subpart.toLowerCase());
-        }
-        return lowerCasedSubparts;
-    }
-
     /*--------------------------------------------
     |  A C C E S S O R S / M O D I F I E R S    |
     ============================================*/


Mime
View raw message