FELIX-1888: The karaf client hangs if the authentication fails

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@883422 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java b/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java
index 414bfd6..f010b2b 100644
--- a/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java
+++ b/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java
@@ -108,7 +108,9 @@
                     }
                 }
             } while (session == null);
-            session.authPassword(user, password);
+            if (!session.authPassword(user, password).await().isSuccess()) {
+                throw new Exception("Authentication failure");
+            }
             ClientChannel channel;
 			if (sb.length() > 0) {
  				channel = session.createChannel("exec");
@@ -124,7 +126,11 @@
             channel.open();
             channel.waitFor(ClientChannel.CLOSED, 0);
         } catch (Throwable t) {
-            t.printStackTrace();
+            if (level > 1) {
+                t.printStackTrace();
+            } else {
+                System.err.println(t.getMessage());
+            }
             System.exit(1);
         } finally {
             try {