From 390948050c34e7ed6668059ccdb4af27b4204fd9 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Fri, 14 Sep 2007 09:09:16 +0000
Subject: [PATCH] Fix for issue #2256 (limit the number of prompt in status CLI) status cli will now exit after 3 connection failure.
---
opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java | 21 +++++++++++++++++++--
opends/src/messages/messages/admin_tool.properties | 1 +
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java b/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
index b5e810a..3450f60 100644
--- a/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
+++ b/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
@@ -85,6 +85,9 @@
/** Suffix for log files. */
static public final String LOG_FILE_SUFFIX = ".log";
+ /** Maximum number of connection attempts. */
+ private final int MAX_CONNECTION_RETRY =3;
+
/**
* The enumeration containing the different return codes that the command-line
* can have.
@@ -112,7 +115,11 @@
/**
* User cancelled (for instance not accepting the certificate proposed).
*/
- USER_CANCELLED(3);
+ USER_CANCELLED(3),
+ /**
+ * Too many connection failure.
+ */
+ ERROR_TOO_MANY_CONNECTION_FAILURE(4);
private int returnCode;
private ErrorReturnCode(int returnCode)
@@ -350,8 +357,10 @@
}
InitialLdapContext ctx = null;
- while (!connected && !cancelled)
+ int remainingRetry = MAX_CONNECTION_RETRY;
+ while (!connected && !cancelled && (remainingRetry > 0))
{
+ remainingRetry--;
if (prompted)
{
printLineBreak();
@@ -446,6 +455,14 @@
{
return ErrorReturnCode.USER_CANCELLED.getReturnCode();
}
+ else
+ if (remainingRetry <= 0)
+ {
+ printErrorMessage(
+ ERR_STATUS_CLI_TOO_MANY_CONNECTION_ATTEMPT.get());
+ return ErrorReturnCode.ERROR_TOO_MANY_CONNECTION_FAILURE
+ .getReturnCode();
+ }
}
else
{
diff --git a/opends/src/messages/messages/admin_tool.properties b/opends/src/messages/messages/admin_tool.properties
index a94afe6..8c58364 100644
--- a/opends/src/messages/messages/admin_tool.properties
+++ b/opends/src/messages/messages/admin_tool.properties
@@ -533,6 +533,7 @@
MILD_ERR_STATUS_CLI_ERROR_CONNECTING_PROMPT_AGAIN=Could not connect to the \
Directory Server with the provided credentials.%nError details: %s%nProvide \
again the required information to connect to the server:
+SEVERE_ERR_STATUS_CLI_TOO_MANY_CONNECTION_ATTEMPT=Too many authentication failures - Exit
INFO_REPLICATION_ENABLE_HOSTNAME1_PROMPT=Host name of the first server
INFO_REPLICATION_ENABLE_PORT1_PROMPT=LDAP port of the first server
INFO_REPLICATION_ENABLE_REPLICATIONPORT1_PROMPT=Replication port for the first \
--
Gitblit v1.10.0