From 99fe23a6ad64503108e1097ef7eedb77c589a441 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Wed, 01 Apr 2009 22:51:33 +0000
Subject: [PATCH] Move the password prompting out of the LDAPAuthenticationHandler class so a connection to the server isn't tied up while waiting for the user to enter a password. Issue 3828.
---
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java | 4 +
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java | 4 +
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPAuthenticationHandler.java | 60 ++----------------------------
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java | 4 +
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java | 6 ++-
5 files changed, 17 insertions(+), 61 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPAuthenticationHandler.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPAuthenticationHandler.java
index a9c64c8..cac5606 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPAuthenticationHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPAuthenticationHandler.java
@@ -282,29 +282,10 @@
List<Control> responseControls)
throws ClientException, LDAPException
{
- // See if we need to prompt the user for the password.
+ //Password is empty, set it to ByteString.empty.
if (bindPassword == null)
{
- if (bindDN == null)
- {
bindPassword = ByteString.empty();
- }
- else
- {
- System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(
- bindDN.toString()));
- System.out.flush();
- char[] pwChars = PasswordReader.readPassword();
- if (pwChars == null)
- {
- bindPassword = ByteString.empty();
- }
- else
- {
- bindPassword = ByteString.wrap(getBytes(pwChars));
- Arrays.fill(pwChars, '\u0000');
- }
- }
}
@@ -876,21 +857,10 @@
}
- // See if the password was null. If so, then interactively prompt it from
- // the user.
+ // Set password to ByteString.empty if the password is null.
if (bindPassword == null)
{
- System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(authID));
- char[] pwChars = PasswordReader.readPassword();
- if (pwChars == null)
- {
bindPassword = ByteString.empty();
- }
- else
- {
- bindPassword = ByteString.wrap(getBytes(pwChars));
- Arrays.fill(pwChars, '\u0000');
- }
}
@@ -1474,21 +1444,10 @@
}
- // See if the password was null. If so, then interactively prompt it from
- // the user.
+ // Set password to ByteString.empty if the password is null.
if (bindPassword == null)
{
- System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(authID));
- char[] pwChars = PasswordReader.readPassword();
- if (pwChars == null)
- {
bindPassword = ByteString.empty();
- }
- else
- {
- bindPassword = ByteString.wrap(getBytes(pwChars));
- Arrays.fill(pwChars, '\u0000');
- }
}
@@ -3058,21 +3017,10 @@
}
- // See if the password was null. If so, then interactively prompt it from
- // the user.
+ // Set password to ByteString.empty if the password is null.
if (bindPassword == null)
{
- System.out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(authID));
- char[] pwChars = PasswordReader.readPassword();
- if (pwChars == null)
- {
bindPassword = ByteString.empty();
- }
- else
- {
- bindPassword = ByteString.wrap(getBytes(pwChars));
- Arrays.fill(pwChars, '\u0000');
- }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
index 77e8b52..a133b14 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
@@ -758,7 +758,9 @@
String bindDNValue = bindDN.getValue();
String fileNameValue = filename.getValue();
String bindPasswordValue = bindPassword.getValue();
- if(bindPasswordValue != null && bindPasswordValue.equals("-"))
+ if(bindPasswordValue != null && bindPasswordValue.equals("-") ||
+ (!bindPasswordFile.isPresent() &&
+ (bindDNValue != null && bindPasswordValue == null)))
{
// read the password from the stdin.
try
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java
index ea0ae3e..2fe8f9f 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -644,7 +644,9 @@
String bindDNValue = bindDN.getValue();
String fileNameValue = filename.getValue();
String bindPasswordValue = bindPassword.getValue();
- if(bindPasswordValue != null && bindPasswordValue.equals("-"))
+ if(bindPasswordValue != null && bindPasswordValue.equals("-") ||
+ (!bindPasswordFile.isPresent() &&
+ (bindDNValue != null && bindPasswordValue == null)))
{
// read the password from the stdin.
try
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java
index d29e073..2760dd6 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java
@@ -972,7 +972,9 @@
String bindDNValue = bindDN.getValue();
String fileNameValue = filename.getValue();
String bindPasswordValue = bindPassword.getValue();
- if(bindPasswordValue != null && bindPasswordValue.equals("-"))
+ if(bindPasswordValue != null && bindPasswordValue.equals("-") ||
+ (!bindPasswordFile.isPresent() &&
+ (bindDNValue != null && bindPasswordValue == null)))
{
// read the password from the stdin.
try
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java
index 28b7e16..a123fed 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -1185,7 +1185,9 @@
String bindDNValue = bindDN.getValue();
String fileNameValue = filename.getValue();
String bindPasswordValue = bindPassword.getValue();
- if(bindPasswordValue != null && bindPasswordValue.equals("-"))
+ if(bindPasswordValue != null && bindPasswordValue.equals("-") ||
+ (!bindPasswordFile.isPresent() &&
+ (bindDNValue != null && bindPasswordValue == null)))
{
// read the password from the stdin.
try
--
Gitblit v1.10.0