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-5243]add -p option for bin/client
Date Tue, 11 Jul 2017 03:15:19 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-4.1.x c13bb3226 -> 7d0cc1df8


[KARAF-5243]add -p option for bin/client

(cherry picked from commit e409ee5018b075be4fc77f94b6bf2bbdf460a25b)


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

Branch: refs/heads/karaf-4.1.x
Commit: 7d0cc1df89f6dadd9f7a4e20a99db47030a3bcfb
Parents: c13bb32
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Tue Jul 11 11:14:32 2017 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Tue Jul 11 11:15:08 2017 +0800

----------------------------------------------------------------------
 .../java/org/apache/karaf/client/ClientConfig.java  | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/7d0cc1df/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 cea1241..4d06fd0 100644
--- a/client/src/main/java/org/apache/karaf/client/ClientConfig.java
+++ b/client/src/main/java/org/apache/karaf/client/ClientConfig.java
@@ -45,6 +45,7 @@ public class ClientConfig {
     private String keyFile = null;
     private String command;
     private boolean interactiveMode = false;
+    private boolean inputPassword = false;
 
     public ClientConfig(String[] args) throws IOException {
         Properties shellCfg = loadProps(new File(System.getProperty("karaf.etc"), "org.apache.karaf.shell.cfg"),
null);
@@ -125,6 +126,16 @@ public class ClientConfig {
                     } else {
                         retryAttempts = Integer.parseInt(args[i]);
                     }
+                    
+                } else if (args[i].equals("-p")) {
+                    if (args.length <= ++i) {
+                        System.err.println("miss the password");
+                        System.exit(1);
+                    } else {
+                        password = args[i];
+                        interactiveMode = false;
+                        inputPassword = true;
+                    }
                 } else if (args[i].equals("-d")) {
                     if (args.length <= ++i) {
                         System.err.println("miss the delay in seconds");
@@ -185,9 +196,9 @@ public class ClientConfig {
                     user = users.iterator().next();
                 }
             }
-            if (interactiveMode) {
+            if (interactiveMode && !inputPassword) {
                 password = null;
-            } else {
+            } else if (!inputPassword) {
                 password = usersCfg.get(user);
                 if (password != null && password.contains(ROLE_DELIMITER)) {
                     password = password.substring(0, password.indexOf(ROLE_DELIMITER));
@@ -202,6 +213,7 @@ public class ClientConfig {
         System.out.println("  -a [port]     specify the port to connect to");
         System.out.println("  -h [host]     specify the host to connect to");
         System.out.println("  -u [user]     specify the user name");
+        System.out.println("  -p [password] specify the password (optional, if not provided,
the password is prompted)");
         System.out.println("  --help        shows this help message");
         System.out.println("  -v            raise verbosity");
         System.out.println("  -l            set client logging level. Set to 0 for ERROR
logging and up to 4 for TRACE");


Mime
View raw message