Repository: karaf
Updated Branches:
  refs/heads/master 8cbddaf74 -> 4e339910e


[KARAF-3859]bin/client script should go in interactive way to prompt the 
password when the -u option is used

(cherry picked from commit 3c308312f166b69772ae9a3da28891b1e7547043)


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

Branch: refs/heads/master
Commit: 4e339910e0514bd64bfd68adcddb1a3e74fa0ed9
Parents: 8cbddaf
Author: Freeman Fang <[email protected]>
Authored: Wed Aug 17 14:30:14 2016 +0800
Committer: Freeman Fang <[email protected]>
Committed: Wed Aug 17 14:45:12 2016 +0800

----------------------------------------------------------------------
 .../java/org/apache/karaf/client/ClientConfig.java     | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/4e339910/client/src/main/java/org/apache/karaf/client/ClientConfig.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/karaf/client/ClientConfig.java 
b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
index 995ee01..72bd0d4 100644
--- a/client/src/main/java/org/apache/karaf/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
@@ -46,6 +46,7 @@ public class ClientConfig {
     private String file = null;
     private String keyFile = null;
     private String command;
+    private boolean interactiveMode = false;
 
     public ClientConfig(String[] args) throws IOException {
         Properties shellCfg = loadProps(new 
File(System.getProperty("karaf.etc"), "org.apache.karaf.shell.cfg"));
@@ -98,6 +99,8 @@ public class ClientConfig {
                         System.exit(1);
                     } else {
                         user = args[i];
+                        interactiveMode = true;
+                        password = null;//get chance to input the password 
with interactive way
                     }
                 } else if (args[i].equals("-v")) {
                     level++;
@@ -180,9 +183,13 @@ public class ClientConfig {
                     user = (String) users.iterator().next();
                 }
             }
-            password = (String) usersCfg.getProperty(user);
-            if (password != null && password.contains(ROLE_DELIMITER)) {
-                password = password.substring(0, 
password.indexOf(ROLE_DELIMITER));
+            if (interactiveMode) {
+                password = null;
+            } else {
+                password = (String) usersCfg.getProperty(user);
+                if (password != null && password.contains(ROLE_DELIMITER)) {
+                    password = password.substring(0, 
password.indexOf(ROLE_DELIMITER));
+                }
             }
         }
 

Reply via email to