From 1a4f0d584bc5c40e316368190c16afb361438fbb 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)
---
opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java b/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
index 7409670..d365221 100644
--- a/opends/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
+++ b/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