From 9d26dfb9884fbac1c94d776e25f381bb08a57ac2 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 14 Nov 2007 14:09:26 +0000
Subject: [PATCH] Fix some issues in the interactive mode of dsreplication enable and dsreplication disable when the user provides values in the command-line.
---
opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java | 88 +++++++++++++++++++++++-----
opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java | 45 +++++++++++---
2 files changed, 105 insertions(+), 28 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java b/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
index 7603fcb..6ec6fc1 100644
--- a/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
+++ b/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
@@ -31,7 +31,6 @@
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
import static org.opends.messages.ToolMessages.*;
-import static org.opends.messages.UtilityMessages.*;
import static org.opends.quicksetup.util.Utils.getFirstValue;
import static org.opends.quicksetup.util.Utils.getThrowableMsg;
@@ -568,8 +567,22 @@
String bindDn1 = argParser.getBindDn1();
String pwd1 = argParser.getBindPassword1();
- initializeGlobalArguments(host1, port1, useSSL1,
- useStartTLS1, adminUid, bindDn1, (pwd1 != null) ? pwd1 : adminPwd);
+ String pwd = null;
+ if (pwd1 != null)
+ {
+ pwd = pwd1;
+ }
+ else if (bindDn1 != null)
+ {
+ pwd = null;
+ }
+ else
+ {
+ pwd = adminPwd;
+ }
+
+ initializeGlobalArguments(host1, port1, useSSL1, useStartTLS1, adminUid,
+ bindDn1, pwd);
InitialLdapContext ctx1 = null;
while ((ctx1 == null) && !cancelled)
@@ -583,10 +596,16 @@
useStartTLS1 = ci.useStartTLS();
host1 = ci.getHostName();
port1 = ci.getPortNumber();
- adminUid = ci.getAdministratorUID();
- if (adminUid != null)
+ if (ci.getProvidedAdminUID() != null)
{
- adminPwd = ci.getBindPassword();
+ adminUid = ci.getProvidedAdminUID();
+ if (ci.getProvidedBindDN() == null)
+ {
+ // If the explicitit bind DN is not null, the password corresponds
+ // to that bind DN. We are in the case where the user provides
+ // bind DN on first server and admin UID globally.
+ adminPwd = ci.getBindPassword();
+ }
}
bindDn1 = ci.getBindDN();
pwd1 = ci.getBindPassword();
@@ -718,7 +737,6 @@
useStartTLS2 = argParser.useStartTLS2();
bindDn2 = argParser.getBindDn2();
pwd2 = argParser.getBindPassword2();
- String pwd;
if (pwd2 != null)
{
pwd = pwd2;
@@ -748,7 +766,11 @@
useStartTLS2 = ci.useStartTLS();
host2 = ci.getHostName();
port2 = ci.getPortNumber();
- adminUid = ci.getAdministratorUID();
+ if (ci.getProvidedAdminUID() != null)
+ {
+ adminUid = ci.getProvidedAdminUID();
+ adminPwd = ci.getBindPassword();
+ }
bindDn2 = ci.getBindDN();
pwd2 = ci.getBindPassword();
@@ -1020,8 +1042,8 @@
useStartTLS = ci.useStartTLS();
host = ci.getHostName();
port = ci.getPortNumber();
- bindDn = ci.getBindDN();
- adminUid = ci.getAdministratorUID();
+ bindDn = ci.getProvidedBindDN();
+ adminUid = ci.getProvidedAdminUID();
adminPwd = ci.getBindPassword();
ctx = createInitialLdapContextInteracting(ci);
@@ -5963,6 +5985,8 @@
argParser.getSecureArgsList().hostNameArg.addValue(hostName);
argParser.getSecureArgsList().hostNameArg.setPresent(true);
}
+ // resetConnectionArguments does not clear the values for the port
+ argParser.getSecureArgsList().portArg.clearValues();
if (port != -1)
{
argParser.getSecureArgsList().portArg.addValue(String.valueOf(port));
@@ -5970,7 +5994,6 @@
}
else
{
- argParser.getSecureArgsList().portArg.clearValues();
// This is done to be able to call IntegerArgument.getIntValue()
argParser.getSecureArgsList().portArg.addValue(
argParser.getSecureArgsList().portArg.getDefaultValue());
diff --git a/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java b/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
index f2d9914..37fef16 100644
--- a/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
+++ b/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -73,7 +73,9 @@
private String hostName;
private int portNumber;
private String bindDN;
+ private String providedBindDN;
private String adminUID;
+ private String providedAdminUID;
private String bindPassword;
private KeyManager keyManager;
private ApplicationTrustManager trustManager;
@@ -530,9 +532,25 @@
bindDN = secureArgsList.bindDnArg.getValue();
adminUID = secureArgsList.adminUidArg.getValue();
final boolean useAdmin = secureArgsList.useAdminUID();
- boolean argIsPresent = useAdmin ?
- secureArgsList.adminUidArg.isPresent() :
- secureArgsList.bindDnArg.isPresent();
+ if (useAdmin && secureArgsList.adminUidArg.isPresent())
+ {
+ providedAdminUID = adminUID;
+ }
+ else
+ {
+ providedAdminUID = null;
+ }
+ if ((!useAdmin || useAdminOrBindDn) &&
+ secureArgsList.bindDnArg.isPresent())
+ {
+ providedBindDN = bindDN;
+ }
+ else
+ {
+ providedBindDN = null;
+ }
+ boolean argIsPresent = (providedAdminUID != null) ||
+ (providedBindDN != null);
final String tmpBindDN = bindDN;
final String tmpAdminUID = adminUID;
if (keyManager == null)
@@ -579,12 +597,16 @@
if (Utils.isDn(v))
{
bindDN = v;
+ providedBindDN = v;
adminUID = null;
+ providedAdminUID = null;
}
else
{
bindDN = null;
+ providedBindDN = null;
adminUID = v;
+ providedAdminUID = v;
}
}
else if (useAdmin)
@@ -592,11 +614,13 @@
adminUID = app.readValidatedInput(
INFO_LDAP_CONN_PROMPT_ADMINISTRATOR_UID.get(adminUID),
callback);
+ providedAdminUID = adminUID;
}
else
{
bindDN = app.readValidatedInput(INFO_LDAP_CONN_PROMPT_BIND_DN
.get(bindDN), callback);
+ providedBindDN = bindDN;
}
}
catch (CLIException e)
@@ -647,24 +671,21 @@
{
app.println();
Message prompt;
- if (useAdminOrBindDn)
+ if (providedAdminUID != null)
{
- if (adminUID != null)
- {
- prompt = INFO_LDAPAUTH_PASSWORD_PROMPT.get(adminUID);
- }
- else
- {
- prompt = INFO_LDAPAUTH_PASSWORD_PROMPT.get(bindDN);
- }
+ prompt = INFO_LDAPAUTH_PASSWORD_PROMPT.get(providedAdminUID);
}
- else if (useAdmin)
+ else if (providedBindDN != null)
{
- prompt = INFO_LDAPAUTH_PASSWORD_PROMPT.get(adminUID);
+ prompt = INFO_LDAPAUTH_PASSWORD_PROMPT.get(providedBindDN);
+ }
+ else if (bindDN != null)
+ {
+ prompt = INFO_LDAPAUTH_PASSWORD_PROMPT.get(bindDN);
}
else
{
- prompt = INFO_LDAPAUTH_PASSWORD_PROMPT.get(bindDN);
+ prompt = INFO_LDAPAUTH_PASSWORD_PROMPT.get(adminUID);
}
bindPassword = app.readPassword(prompt);
}
@@ -1143,13 +1164,25 @@
String dn;
if (useAdminOrBindDn)
{
- if (this.adminUID != null)
+ if (providedBindDN != null)
+ {
+ dn = providedBindDN;
+ }
+ else if (providedAdminUID != null)
+ {
+ dn = ADSContext.getAdministratorDN(providedAdminUID);
+ }
+ else if (this.bindDN != null)
+ {
+ dn = this.bindDN;
+ }
+ else if (this.adminUID != null)
{
dn = ADSContext.getAdministratorDN(this.adminUID);
}
else
{
- dn = this.bindDN;
+ dn = null;
}
}
else if (secureArgsList.useAdminUID())
@@ -1711,4 +1744,25 @@
trustManagerInitialized = true;
}
+ /**
+ * Returns the explicitly provided Admin UID from the user (interactively
+ * or through the argument).
+ * @return the explicitly provided Admin UID from the user (interactively
+ * or through the argument).
+ */
+ public String getProvidedAdminUID()
+ {
+ return providedAdminUID;
+ }
+
+ /**
+ * Returns the explicitly provided bind DN from the user (interactively
+ * or through the argument).
+ * @return the explicitly provided bind DN from the user (interactively
+ * or through the argument).
+ */
+ public String getProvidedBindDN()
+ {
+ return providedBindDN;
+ }
}
--
Gitblit v1.10.0