knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lmc...@apache.org
Subject [1/2] git commit: KNOX-279 - optimized the matching of wildcard addresses
Date Fri, 07 Mar 2014 21:45:03 GMT
Repository: knox
Updated Branches:
  refs/heads/master a2905911d -> bfe4ce7e7


KNOX-279 - optimized the matching of wildcard addresses


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/1ca4faa9
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/1ca4faa9
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/1ca4faa9

Branch: refs/heads/master
Commit: 1ca4faa9bbad10b41b75ada4f10ec3c8d2022516
Parents: a290591
Author: Larry McCay <lmccay@hortonworks.com>
Authored: Fri Feb 21 22:28:05 2014 -0500
Committer: Larry McCay <lmccay@hortonworks.com>
Committed: Fri Mar 7 16:38:28 2014 -0500

----------------------------------------------------------------------
 .../org/apache/hadoop/gateway/util/IpAddressValidator.java     | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/1ca4faa9/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/IpAddressValidator.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/IpAddressValidator.java
b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/IpAddressValidator.java
index fd6f9ef..6382975 100644
--- a/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/IpAddressValidator.java
+++ b/gateway-util-common/src/main/java/org/apache/hadoop/gateway/util/IpAddressValidator.java
@@ -65,7 +65,7 @@ public class IpAddressValidator {
       // check whether there are any wildcarded ip's - example: 192.* or 192.168.* or 192.168.1.*
       for (String addr : ipaddr) {
         if (addr.contains("*")) {
-          wildCardIPs.add(addr);
+          wildCardIPs.add(addr.substring(0, addr.lastIndexOf('*')));
         }
       }
     }
@@ -89,7 +89,7 @@ public class IpAddressValidator {
         // check for wildcards if there are wildcardIP acls configured
         if (wildCardIPs.size() > 0) {
           for (String ip : wildCardIPs) {
-            if (addr.startsWith(ip.substring(0, ip.lastIndexOf('*')))) {
+            if (addr.startsWith(ip)) {
               valid = true;
               break;
             }
@@ -113,4 +113,4 @@ public class IpAddressValidator {
   public ArrayList<String> getIPAddresses() {
     return ipaddr;
   }
-}
\ No newline at end of file
+}


Mime
View raw message