From ed803f46487547b3134c8fd58b12916372556878 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 08 Apr 2008 11:07:16 +0000
Subject: [PATCH] Fix for issue 3129 (stop-ds: -j/--bindPasswordFile option doesn't work) In fact the issue applies to most of the task based command-lines (like export-ldif or import-ldif).  THe fix consist basically on taking into account whether the user provided the password in a file or not.

---
 opendj-sdk/opends/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java b/opendj-sdk/opends/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java
index 970599d..e5789ac 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/args/LDAPConnectionArgumentParser.java
@@ -327,7 +327,7 @@
             args.hostNameArg.getValue(),
             args.portArg.getIntValue(),
             args.bindDnArg.getValue(),
-            args.bindPasswordArg.getValue(),
+            getPasswordValue(args.bindPasswordArg, args.bindPasswordFileArg),
             connectionOptions, out, err);
   }
 
@@ -407,6 +407,25 @@
     return args;
   }
 
+  /**
+   * Commodity method that retrieves the password value analyzing the contents
+   * of a string argument and of a file based argument.  It assumes that the
+   * arguments have already been parsed and validated.
+   * @param bindPwdArg the string argument.
+   * @param bindPwdFileArg the file based argument.
+   * @return the password value.
+   */
+  public static String getPasswordValue(StringArgument bindPwdArg,
+      FileBasedArgument bindPwdFileArg)
+  {
+    String pwd = bindPwdArg.getValue();
+    if ((pwd == null) && bindPwdFileArg.isPresent())
+    {
+      pwd = bindPwdFileArg.getValue();
+    }
+    return pwd;
+  }
+
   private void addLdapConnectionArguments(ArgumentGroup argGroup) {
     args = new SecureConnectionCliArgs();
     try {

--
Gitblit v1.10.0