karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject karaf git commit: [KARAF-3886]should escape specify characters in ROLE names
Date Mon, 27 Jul 2015 08:50:11 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-2.x 8b7e50254 -> 33439779e


[KARAF-3886]should escape specify characters in ROLE names


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

Branch: refs/heads/karaf-2.x
Commit: 33439779e146dc016f2cb7cbd8184802b8b85c19
Parents: 8b7e502
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Mon Jul 27 16:45:47 2015 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Mon Jul 27 16:45:47 2015 +0800

----------------------------------------------------------------------
 .../security/impl/SecuredCommandProcessorImpl.java      | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/33439779/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandProcessorImpl.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandProcessorImpl.java
b/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandProcessorImpl.java
index b046c2f..5c46bad 100644
--- a/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandProcessorImpl.java
+++ b/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandProcessorImpl.java
@@ -75,7 +75,7 @@ public class SecuredCommandProcessorImpl extends CommandProcessorImpl {
                 sb.append('(');
                 sb.append("org.apache.karaf.service.guard.roles");
                 sb.append('=');
-                sb.append(rp.getName());
+                sb.append(escapeforFilterString(rp.getName()));
                 sb.append(')');
             }
             sb.append("(!(org.apache.karaf.service.guard.roles=*))"); // Or no roles specified
at all
@@ -226,4 +226,14 @@ public class SecuredCommandProcessorImpl extends CommandProcessorImpl
{
         };
     }
 
+    private String escapeforFilterString(String original) {
+        //the filter string follow the LDAP rule
+        //where we need escape the special char
+        String ret = original;
+        ret = ret.replace("\\", "\\\\");
+        ret = ret.replace("*", "\\*");
+        ret = ret.replace("(", "\\(");
+        ret = ret.replace(")", "\\)");
+        return ret;
+    }
 }


Mime
View raw message