From adc012b618096504d36bcfb1718455b03511ad96 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 02 May 2008 13:10:04 +0000
Subject: [PATCH] Fix for issue 3224 (uninstall raises execption if specified keystore does not exist)
---
opendj-sdk/opends/src/messages/messages/tools.properties | 6 +++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java | 4 ++
opendj-sdk/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java | 48 +++++++++++++++++++++++
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java | 26 ++++++++-----
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java | 1
5 files changed, 74 insertions(+), 11 deletions(-)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 46c8b5e..66a9241 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -254,9 +254,12 @@
{
LOG.log(Level.WARNING,
"Error retrieving a valid LDAP URL in conf file: "+ce, ce);
- println();
- println(ERR_COULD_NOT_FIND_VALID_LDAPURL.get());
- println();
+ if (!parser.isInteractive())
+ {
+ Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
+ throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
+ ce);
+ }
}
userData.setReferencedHostName(referencedHostName);
@@ -748,9 +751,10 @@
* remote servers. <CODE>false</CODE> otherwise.
* @throws UserDataException if there is a problem with the information
* provided by the user.
+ * @throws ApplicationException if there is an error processing data.
*/
private boolean askForAuthenticationIfNeeded(UninstallUserData userData)
- throws UserDataException
+ throws UserDataException, ApplicationException
{
boolean accepted = true;
String uid = userData.getAdminUID();
@@ -883,11 +887,12 @@
}
catch (ConfigException ce)
{
+ // This is unexpected
LOG.log(Level.WARNING,
"Error retrieving a valid LDAP URL in conf file: "+ce, ce);
- println();
- println(ERR_COULD_NOT_FIND_VALID_LDAPURL.get());
- println();
+ Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
+ throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg,
+ ce);
}
finally
{
@@ -1133,11 +1138,12 @@
}
catch (ConfigException ce)
{
+ // This is unexpected, when calling this code this should already been
+ // checked.
LOG.log(Level.WARNING,
"Error retrieving a valid LDAP URL in conf file: "+ce, ce);
- println();
- println(ERR_COULD_NOT_FIND_VALID_LDAPURL.get());
- userData.setLocalServerUrl("ldap://localhost:389");
+ Message msg = ERR_COULD_NOT_FIND_VALID_LDAPURL.get();
+ throw new ApplicationException(ReturnCode.APPLICATION_ERROR, msg, ce);
}
catch (NamingException ne)
{
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
index 9a3637d..2a75e01 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
@@ -410,6 +410,7 @@
}
}
}
+ super.validateGlobalOptions(buf);
if (buf.length() > 0)
{
returnValue = CONFLICTING_ARGS.getReturnCode();
diff --git a/opendj-sdk/opends/src/messages/messages/tools.properties b/opendj-sdk/opends/src/messages/messages/tools.properties
index 9d768d3..cec583f 100644
--- a/opendj-sdk/opends/src/messages/messages/tools.properties
+++ b/opendj-sdk/opends/src/messages/messages/tools.properties
@@ -2348,3 +2348,9 @@
INFO_TASK_TOOL_TASK_SUCESSFULL_1608=%s task %s has been successfully completed
INFO_TASK_TOOL_TASK_NOT_SUCESSFULL_1609=%s task %s has not complete \
successfully
+SEVERE_ERR_CANNOT_READ_TRUSTSTORE_1610=Cannot access trust store '%s'. Verify \
+ that the provided trust store exists and that you have read access rights to it
+SEVERE_ERR_CANNOT_READ_KEYSTORE_1611=Cannot access key store '%s'. Verify \
+ that the provided key store exists and that you have read access rights to it
+
+
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java
index 1a38adc..3363e4c 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java
@@ -62,6 +62,8 @@
logger.addHandler(fileHandler);
logger = Logger.getLogger("org.opends.admin.ads");
logger.addHandler(fileHandler);
+ logger = Logger.getLogger("org.opends.server.admin.client.cli");
+ logger.addHandler(fileHandler);
disableConsoleLogging();
logger = Logger.getLogger("org.opends.quicksetup");
logger.log(Level.INFO, getInitialLogRecord());
@@ -95,6 +97,8 @@
logger.setUseParentHandlers(false);
logger = Logger.getLogger("org.opends.server.tools");
logger.setUseParentHandlers(false);
+ logger = Logger.getLogger("org.opends.server.admin.client.cli");
+ logger.setUseParentHandlers(false);
}
/**
diff --git a/opendj-sdk/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java b/opendj-sdk/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
index 7409670..d365221 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
@@ -38,6 +38,7 @@
import static org.opends.server.util.ServerConstants.MAX_LINE_WIDTH;
import static org.opends.server.util.StaticUtils.wrapText;
+import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -625,6 +626,30 @@
errors.add(message);
}
+ if (trustStorePathArg.isPresent())
+ {
+ // Check that the path exists and is readable
+ String value = trustStorePathArg.getValue();
+ if (!canRead(trustStorePathArg.getValue()))
+ {
+ Message message = ERR_CANNOT_READ_TRUSTSTORE.get(
+ value);
+ errors.add(message);
+ }
+ }
+
+ if (keyStorePathArg.isPresent())
+ {
+ // Check that the path exists and is readable
+ String value = keyStorePathArg.getValue();
+ if (!canRead(trustStorePathArg.getValue()))
+ {
+ Message message = ERR_CANNOT_READ_KEYSTORE.get(
+ value);
+ errors.add(message);
+ }
+ }
+
// Couldn't have at the same time startTLSArg and
// useSSLArg
if (useStartTLSArg.isPresent()
@@ -634,7 +659,6 @@
.getLongIdentifier(), useSSLArg.getLongIdentifier());
errors.add(message);
}
-
if (errors.size() > 0)
{
for (Message error : errors)
@@ -876,4 +900,26 @@
return null;
}
}
+
+ /**
+ * Returns <CODE>true</CODE> if we can read on the provided path and
+ * <CODE>false</CODE> otherwise.
+ * @param path the path.
+ * @return <CODE>true</CODE> if we can read on the provided path and
+ * <CODE>false</CODE> otherwise.
+ */
+ private boolean canRead(String path)
+ {
+ boolean canRead;
+ File file = new File(path);
+ if (file.exists())
+ {
+ canRead = file.canRead();
+ }
+ else
+ {
+ canRead = false;
+ }
+ return canRead;
+ }
}
--
Gitblit v1.10.0