From 2302060670eb0dc1712249c1eccc54683e63bb8c Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 13 Nov 2007 01:46:38 +0000
Subject: [PATCH] Remove some unused methods. Fix a bug in the uninstall and dsreplication. When the user connected to the servers using LDAP, a null trust manager was used to load the topology (so all certificates were accepted). The code has been fixed to prompt the user to accept non trusted certificates.
---
opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java | 79 ++++++++++++++++++++++++++-------------
1 files changed, 53 insertions(+), 26 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index cc7600d..69504f1 100644
--- a/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -92,6 +92,8 @@
private UninstallerArgumentParser parser;
+ private boolean forceNonInteractive;
+
private LDAPConnectionConsoleInteraction ci = null;
/**
@@ -370,7 +372,7 @@
((i == 7) && (outsideLogs.size() == 0));
if (!ignore)
{
- answers[i] = confirm(msgs[i], true);
+ answers[i] = askConfirmation(msgs[i], true, LOG);
}
else
{
@@ -619,7 +621,7 @@
*/
private boolean confirmToStopServer()
{
- return confirm(INFO_CLI_UNINSTALL_CONFIRM_STOP.get(), true);
+ return askConfirmation(INFO_CLI_UNINSTALL_CONFIRM_STOP.get(), true, LOG);
}
/**
@@ -629,7 +631,8 @@
*/
private boolean confirmDeleteFiles()
{
- return confirm(INFO_CLI_UNINSTALL_CONFIRM_DELETE_FILES.get(), true);
+ return askConfirmation(INFO_CLI_UNINSTALL_CONFIRM_DELETE_FILES.get(), true,
+ LOG);
}
/**
@@ -639,7 +642,8 @@
*/
private boolean confirmToUpdateRemote()
{
- return confirm(INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE.get(), true);
+ return askConfirmation(INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE.get(), true,
+ LOG);
}
/**
@@ -649,8 +653,8 @@
*/
private boolean confirmToUpdateRemoteAndStart()
{
- return confirm(
- INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE_AND_START.get(), true);
+ return askConfirmation(
+ INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE_AND_START.get(), true, LOG);
}
/**
@@ -660,22 +664,8 @@
*/
private boolean promptToProvideAuthenticationAgain()
{
- return confirm(INFO_UNINSTALL_CONFIRM_PROVIDE_AUTHENTICATION_AGAIN.get(),
- true);
- }
-
- private boolean confirm(Message msg, boolean defaultValue)
- {
- boolean v = defaultValue;
- try
- {
- v = confirmAction(msg, defaultValue);
- }
- catch (CLIException ce)
- {
- LOG.log(Level.WARNING, "Error reading input: "+ce, ce);
- }
- return v;
+ return askConfirmation(
+ INFO_UNINSTALL_CONFIRM_PROVIDE_AUTHENTICATION_AGAIN.get(), true, LOG);
}
/**
@@ -1024,6 +1014,15 @@
pwd, userData.getTrustManager());
ADSContext adsContext = new ADSContext(ctx);
+ if (interactive && (userData.getTrustManager() == null))
+ {
+ // This is required when the user did connect to the server using SSL
+ // or Start TLS in interactive mode. In this case
+ // LDAPConnectionInteraction.run does not initialize the keystore and
+ // the trust manager is null.
+ forceTrustManagerInitialization();
+ updateTrustManager(userData, ci);
+ }
TopologyCache cache = new TopologyCache(adsContext,
userData.getTrustManager());
cache.reloadTopology();
@@ -1103,7 +1102,8 @@
}
else
{
- accepted = confirm(ERR_UNINSTALL_NOT_UPDATE_REMOTE_PROMPT.get(), false);
+ accepted = askConfirmation(ERR_UNINSTALL_NOT_UPDATE_REMOTE_PROMPT.get(),
+ false, LOG);
}
}
userData.setUpdateRemoteReplication(accepted);
@@ -1199,10 +1199,10 @@
if (!stopProcessing && (exceptionMsgs.size() > 0))
{
println();
- returnValue = confirm(
+ returnValue = askConfirmation(
ERR_UNINSTALL_READING_REGISTERED_SERVERS_CONFIRM_UPDATE_REMOTE.get(
Utils.getMessageFromCollection(exceptionMsgs,
- Constants.LINE_SEPARATOR).toString()), true);
+ Constants.LINE_SEPARATOR).toString()), true, LOG);
}
else if (reloadTopologyCache)
{
@@ -1243,7 +1243,14 @@
* {@inheritDoc}
*/
public boolean isInteractive() {
- return parser.isInteractive();
+ if (forceNonInteractive)
+ {
+ return false;
+ }
+ else
+ {
+ return parser.isInteractive();
+ }
}
@@ -1308,4 +1315,24 @@
}
userData.setTrustManager(trust);
}
+
+
+
+ /**
+ * Forces the initialization of the trust manager in the
+ * LDAPConnectionInteraction object.
+ */
+ private void forceTrustManagerInitialization()
+ {
+ forceNonInteractive = true;
+ try
+ {
+ ci.initializeTrustManagerIfRequired();
+ }
+ catch (ArgumentException ae)
+ {
+ LOG.log(Level.WARNING, "Error initializing trust store: "+ae, ae);
+ }
+ forceNonInteractive = false;
+ }
}
--
Gitblit v1.10.0