From c959146d66becd1bc0fe233668ef353452085dc3 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Mon, 07 Apr 2014 12:09:23 +0000
Subject: [PATCH] Checkpoint for OPENDJ-1303 "opendj-cli" - Fixed isDN function. - LDAPManagementContextFactory.java :removed the unused alwaysSSL var. - LDAPConnectionConsoleInteraction.java : -- removed unused parameter canUseSSL. -- modified the cannotReadConnectionParameters => more clearer. (thanks to JN) N.B This LDAPConnectionConsoleInteraction class will disapear as soon as the SDK will provide the same 'prompt' capabilities. (and also because the code is absolutely unmaintainable and redundant.)
---
opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java | 45 +++++++++++++++++----------------------------
1 files changed, 17 insertions(+), 28 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java b/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
index e035984..70bcbc6 100644
--- a/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
+++ b/opendj3-server-dev/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -68,6 +68,9 @@
/**
* Supports interacting with a user through the command line to prompt for
* information necessary to create an LDAP connection.
+ *
+ * Actually the LDAPConnectionConsoleInteraction is used by UninstallCliHelper, StatusCli,
+ * LDAPManagementContextFactory and ReplicationCliMain.
*/
public class LDAPConnectionConsoleInteraction
{
@@ -324,37 +327,27 @@
*/
public void run() throws ArgumentException
{
- run(true, true);
+ run(true);
}
/**
* Interact with the user though the console to get information necessary to
* establish an LDAP connection.
*
- * @param canUseSSL
- * whether we can propose to connect using SSL or not.
* @param canUseStartTLS
* whether we can propose to connect using Start TLS or not.
* @throws ArgumentException
* if there is a problem with the arguments
*/
- public void run(boolean canUseSSL, boolean canUseStartTLS)
+ public void run(boolean canUseStartTLS)
throws ArgumentException
{
// Reset everything
commandBuilder.clearArguments();
copySecureArgsList.createGlobalArguments();
- boolean secureConnection =
- (canUseSSL || canUseStartTLS)
- && (secureArgsList.useSSLArg.isPresent()
- || secureArgsList.useStartTLSArg.isPresent()
- || secureArgsList.trustAllArg.isPresent()
- || secureArgsList.trustStorePathArg.isPresent()
- || secureArgsList.trustStorePasswordArg.isPresent()
- || secureArgsList.trustStorePasswordFileArg.isPresent()
- || secureArgsList.keyStorePathArg.isPresent()
- || secureArgsList.keyStorePasswordArg.isPresent() || secureArgsList.keyStorePasswordFileArg
- .isPresent());
+
+ boolean secureConnection = true;
+
// Get the LDAP host.
hostName = secureArgsList.hostNameArg.getValue();
final String tmpHostName = hostName;
@@ -403,7 +396,7 @@
}
catch (ClientException e)
{
- cannotReadConnectionParameters(e);
+ throw cannotReadConnectionParameters(e);
}
}
@@ -443,10 +436,6 @@
{
continue;
}
- if (!canUseSSL && p.equals(Protocols.SSL))
- {
- continue;
- }
if (!canUseStartTLS && p.equals(Protocols.START_TLS))
{
continue;
@@ -514,6 +503,7 @@
portNumber = secureArgsList.getPortFromConfig();
}
}
+
final int tmpPortNumber = portNumber;
if (app.isInteractive() && !secureArgsList.portArg.isPresent())
{
@@ -571,7 +561,7 @@
}
catch (ClientException e)
{
- cannotReadConnectionParameters(e);
+ throw cannotReadConnectionParameters(e);
}
}
@@ -683,7 +673,7 @@
}
catch (ClientException e)
{
- cannotReadConnectionParameters(e);
+ throw cannotReadConnectionParameters(e);
}
}
if (useAdminOrBindDn)
@@ -805,10 +795,9 @@
connectTimeout = secureArgsList.connectTimeoutArg.getIntValue();
}
- private void cannotReadConnectionParameters(ClientException e)
- throws ArgumentException
+ private ArgumentException cannotReadConnectionParameters(ClientException e)
{
- throw new ArgumentException(ERR_ERROR_CANNOT_READ_CONNECTION_PARAMETERS
+ return new ArgumentException(ERR_ERROR_CANNOT_READ_CONNECTION_PARAMETERS
.get(e.getMessage()), e.getCause());
}
@@ -982,7 +971,7 @@
}
catch (ClientException e)
{
- cannotReadConnectionParameters(e);
+ throw cannotReadConnectionParameters(e);
}
}
@@ -1159,7 +1148,7 @@
}
catch (ClientException e)
{
- cannotReadConnectionParameters(e);
+ throw cannotReadConnectionParameters(e);
}
}
@@ -1287,7 +1276,7 @@
}
catch (ClientException e)
{
- cannotReadConnectionParameters(e);
+ throw cannotReadConnectionParameters(e);
}
}
--
Gitblit v1.10.0