/**
  * 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. If the string is a dash, or no password is available, it will prompt for it on the
  * command line.
  *
  * @param bindPassword the string argument for the password.
  * @param bindPasswordFile the file based argument for the password.
  * @param bindDNValue the string value for the bindDN.
  * @param out stream to write message.
  * @param err stream to write error message.
  * @return the password value.
  * @throws ClientException if the password cannot be read
  */
 public static String getPasswordValue(
     StringArgument bindPassword,
     FileBasedArgument bindPasswordFile,
     String bindDNValue,
     PrintStream out,
     PrintStream err)
     throws ClientException {
   String bindPasswordValue = bindPassword.getValue();
   if ("-".equals(bindPasswordValue)
       || (!bindPasswordFile.isPresent() && bindDNValue != null && bindPasswordValue == null)) {
     // read the password from the stdin.
     out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(bindDNValue));
     char[] pwChars = ConsoleApplication.readPassword();
     // As per rfc 4513(section-5.1.2) a client should avoid sending
     // an empty password to the server.
     while (pwChars.length == 0) {
       printWrappedText(err, INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get());
       out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(bindDNValue));
       pwChars = ConsoleApplication.readPassword();
     }
     return new String(pwChars);
   } else if (bindPasswordValue == null) {
     // Read from file if it exists.
     return bindPasswordFile.getValue();
   }
   return bindPasswordValue;
 }