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:55:08 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x fd62cbca6 -> 50690aafd


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

(cherry picked from commit 33439779e146dc016f2cb7cbd8184802b8b85c19)


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

Branch: refs/heads/karaf-3.0.x
Commit: 50690aafda90e69d38a1377ef54dff5edb8e2940
Parents: fd62cbc
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:53:11 2015 +0800

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


http://git-wip-us.apache.org/repos/asf/karaf/blob/50690aaf/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