From 60f5dfd7eaa64aa931033c0e5266391ecbbc96fa Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Wed, 25 Sep 2013 07:31:13 +0000
Subject: [PATCH] Fix OPENDJ-18 - keystore import failes due to empty PIN Review CR-2353
---
opends/src/server/org/opends/server/tools/InstallDS.java | 59 ++++++++++++++++++++++++++++-------------------------------
1 files changed, 28 insertions(+), 31 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/InstallDS.java b/opends/src/server/org/opends/server/tools/InstallDS.java
index 4d8c424..fbafd78 100644
--- a/opends/src/server/org/opends/server/tools/InstallDS.java
+++ b/opends/src/server/org/opends/server/tools/InstallDS.java
@@ -69,6 +69,7 @@
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.CertificateManager;
import org.opends.server.util.SetupUtils;
+import org.opends.server.util.StaticUtils;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.IntegerArgument;
import org.opends.server.util.args.StringArgument;
@@ -1884,18 +1885,7 @@
errorWithPath = true;
}
}
- boolean pwdProvided = true;
- if (pwd == null)
- {
- pwdProvided = false;
- errorMessages.add(INFO_ERROR_NO_KEYSTORE_PASSWORD.get());
- }
- else if (pwd.length() == 0)
- {
- pwdProvided = false;
- errorMessages.add(INFO_ERROR_EMPTY_KEYSTORE_PASSWORD.get());
- }
- if (!errorWithPath && pwdProvided)
+ if (!errorWithPath)
{
try
{
@@ -1983,24 +1973,32 @@
}
catch (KeyStoreException ke)
{
- // Could not access to the key store: because the password is no good,
- // because the provided file is not a valid key store, etc.
- switch (type)
+ // issue OPENDJ-18, related to JDK bug
+ if (StaticUtils.stackTraceContainsCause(ke, ArithmeticException.class))
{
- case JKS:
- errorMessages.add(INFO_ERROR_ACCESSING_JKS_KEYSTORE.get());
- break;
- case JCEKS:
- errorMessages.add(INFO_ERROR_ACCESSING_JCEKS_KEYSTORE.get());
- break;
- case PKCS12:
- errorMessages.add(INFO_ERROR_ACCESSING_PKCS12_KEYSTORE.get());
- break;
- case PKCS11:
- errorMessages.add(INFO_ERROR_ACCESSING_PKCS11_KEYSTORE.get());
- break;
- default:
- throw new IllegalArgumentException("Invalid type: "+type);
+ errorMessages.add(INFO_ERROR_ACCESSING_KEYSTORE_JDK_BUG.get());
+ }
+ else
+ {
+ // Could not access to the key store: because the password is no good,
+ // because the provided file is not a valid key store, etc.
+ switch (type)
+ {
+ case JKS:
+ errorMessages.add(INFO_ERROR_ACCESSING_JKS_KEYSTORE.get());
+ break;
+ case JCEKS:
+ errorMessages.add(INFO_ERROR_ACCESSING_JCEKS_KEYSTORE.get());
+ break;
+ case PKCS12:
+ errorMessages.add(INFO_ERROR_ACCESSING_PKCS12_KEYSTORE.get());
+ break;
+ case PKCS11:
+ errorMessages.add(INFO_ERROR_ACCESSING_PKCS11_KEYSTORE.get());
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid type: " + type);
+ }
}
}
}
@@ -2236,8 +2234,7 @@
msg.getDescriptor().equals(INFO_ERROR_ACCESSING_JCEKS_KEYSTORE) ||
msg.getDescriptor().equals(INFO_ERROR_ACCESSING_PKCS12_KEYSTORE) ||
msg.getDescriptor().equals(INFO_ERROR_ACCESSING_PKCS11_KEYSTORE) ||
- msg.getDescriptor().equals(INFO_ERROR_NO_KEYSTORE_PASSWORD) ||
- msg.getDescriptor().equals(INFO_ERROR_EMPTY_KEYSTORE_PASSWORD))
+ msg.getDescriptor().equals(INFO_ERROR_ACCESSING_KEYSTORE_JDK_BUG))
{
found = true;
break;
--
Gitblit v1.10.0