From a79011f624c210800f747f0d3bf549970b769b66 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Fri, 11 May 2007 16:50:12 +0000
Subject: [PATCH] Fix for issue #1604: status command does not allow password from stdin.

---
 opends/src/statuspanel/org/opends/statuspanel/StatusCli.java                 |   19 ++++++++++++++++++-
 opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties |    3 ++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java b/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
index 9d01935..a34d80f 100644
--- a/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
+++ b/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
@@ -50,6 +50,9 @@
 import org.opends.statuspanel.ui.ListenersTableModel;
 
 import static org.opends.server.tools.ToolConstants.*;
+import org.opends.server.util.PasswordReader;
+import static org.opends.server.messages.ToolMessages.*;
+import static org.opends.server.messages.MessageHandler.*;
 
 /**
  * The class used to provide some CLI interface to display status.
@@ -167,7 +170,7 @@
         }
         else
         {
-          if (args[i+1].indexOf("-") == 0)
+          if (args[i+1].indexOf("-") == 0 && args[i+1].length() > 1)
           {
             errors.add(getMsg("cli-status-root-user-pwd-not-provided", true));
           }
@@ -213,6 +216,20 @@
     }
     else
     {
+      if(directoryManagerPwd != null && directoryManagerPwd.equals("-"))
+      {
+        // read the password from stdin.
+        try
+        {
+          System.out.print(getMsg("cli-status-ldapauth-password-prompt",
+                                  new String[] {directoryManagerDn}, false));
+          char[] pwChars = PasswordReader.readPassword();
+          directoryManagerPwd = new String(pwChars);
+        } catch(Exception ex)
+        {
+          errors.add(ex.getMessage());
+        }
+      }
       if (directoryManagerPwdFile != null)
       {
         directoryManagerPwd = readPwdFromFile(directoryManagerPwdFile);
diff --git a/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties b/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
index 1011830..9a01405 100644
--- a/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
+++ b/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
@@ -170,7 +170,8 @@
 time.
 cli-status-error-reading-pwd-file=Could not read the password from \
 file {0}.  Check that the file path is correct, that you have access rights to \
-it and that it contains a password. 
+it and that it contains a password.
+cli-status-ldapauth-password-prompt=Password for user {0}:  
 status-cli-usage=This utility may be used to display basic server \
 information\n\n\
 Usage:  {0} {options}\n        where {options} include:\n\

--
Gitblit v1.10.0