From 25de8d265e039d0e26b2930585b2267a428eb31e Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 20 Nov 2006 06:02:30 +0000
Subject: [PATCH] Update the ldappasswordmodify tool to align the SSL-related arguments with the other LDAP client tools.
---
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java | 40 +++++++++----
opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java | 31 +++++++++-
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java | 81 ++++++++++++++++++++++----
3 files changed, 121 insertions(+), 31 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java b/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
index b76f13f..2843689 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
@@ -7448,6 +7448,24 @@
/**
+ * The message ID for the message that will be used as the description for the
+ * sslKeyStorePIN argument. It does not take any arguments.
+ */
+ public static final int MSGID_LDAPPWMOD_DESCRIPTION_KEYSTORE_PIN =
+ CATEGORY_MASK_TOOLS | SEVERITY_MASK_INFORMATIONAL | 783;
+
+
+
+ /**
+ * The message ID for the message that will be used as the description for the
+ * sslKeyStorePIN argument. It does not take any arguments.
+ */
+ public static final int MSGID_LDAPPWMOD_DESCRIPTION_TRUSTSTORE_PIN =
+ CATEGORY_MASK_TOOLS | SEVERITY_MASK_INFORMATIONAL | 784;
+
+
+
+ /**
* Associates a set of generic messages with the message IDs defined in this
* class.
*/
@@ -9465,15 +9483,20 @@
registerMessage(MSGID_LDAPPWMOD_DESCRIPTION_KEYSTORE,
"The path to the keystore to use when establishing " +
"SSL/TLS communication with the server.");
+ registerMessage(MSGID_LDAPPWMOD_DESCRIPTION_KEYSTORE_PIN,
+ "The PIN needed to access the contents of the keystore.");
registerMessage(MSGID_LDAPPWMOD_DESCRIPTION_KEYSTORE_PINFILE,
- "Specifies the path to a file containing the PIN needed " +
+ "The path to a file containing the PIN needed " +
"to access the contents of the keystore.");
registerMessage(MSGID_LDAPPWMOD_DESCRIPTION_TRUSTSTORE,
- "The path to the truststore to use when establishing " +
+ "The path to the trust store to use when establishing " +
"SSL/TLS communication with the server.");
+ registerMessage(MSGID_LDAPPWMOD_DESCRIPTION_TRUSTSTORE_PIN,
+ "The PIN needed to access the contents of the trust " +
+ "store.");
registerMessage(MSGID_LDAPPWMOD_DESCRIPTION_TRUSTSTORE_PINFILE,
- "Specifies the path to a file containing the PIN needed " +
- "to access the contents of the truststore.");
+ "The path to a file containing the PIN needed to access" +
+ "the contents of the trust store.");
registerMessage(MSGID_LDAPPWMOD_DESCRIPTION_USAGE,
"Show this usage information.");
registerMessage(MSGID_LDAPPWMOD_CANNOT_INITIALIZE_ARGS,
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
index 7572c20..87d6c11 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
@@ -179,7 +179,9 @@
StringArgument ldapHost;
StringArgument newPW;
StringArgument sslKeyStore;
+ StringArgument sslKeyStorePIN;
StringArgument sslTrustStore;
+ StringArgument sslTrustStorePIN;
// Initialize the argument parser.
@@ -269,36 +271,51 @@
sslBlindTrust =
- new BooleanArgument("blindtrust", 'X', "trustAllCertificates",
+ new BooleanArgument("blindtrust", 'X', "trustAll",
MSGID_LDAPPWMOD_DESCRIPTION_BLIND_TRUST);
argParser.addArgument(sslBlindTrust);
sslKeyStore =
- new StringArgument("sslkeystore", 'k', "sslKeyStore", false, false,
- true, "{file}", null, null,
+ new StringArgument("keystorepath", 'K', "keyStorePath", false, false,
+ true, "{keyStorePath}", null, null,
MSGID_LDAPPWMOD_DESCRIPTION_KEYSTORE);
argParser.addArgument(sslKeyStore);
+ sslKeyStorePIN =
+ new StringArgument("keystorepassword", 'W', "keyStorePassword",
+ false, false, true, "{password}", null, null,
+ MSGID_LDAPPWMOD_DESCRIPTION_KEYSTORE_PIN);
+ argParser.addArgument(sslKeyStorePIN);
+
+
sslKeyStorePINFile =
- new FileBasedArgument("sslkeystorepin", 'K', "sslKeyStorePINFile",
- false, false, "{file}", null, null,
+ new FileBasedArgument("keystorepasswordilfe", null,
+ "keyStorePasswordFile", false, false, "{path}",
+ null, null,
MSGID_LDAPPWMOD_DESCRIPTION_KEYSTORE_PINFILE);
argParser.addArgument(sslKeyStorePINFile);
sslTrustStore =
- new StringArgument("ssltruststore", 't', "sslTrustStore", false,
- false, true, "{file}", null, null,
+ new StringArgument("truststorepath", 'P', "trustStorePath", false,
+ false, true, "{trustStorePath}", null, null,
MSGID_LDAPPWMOD_DESCRIPTION_TRUSTSTORE);
argParser.addArgument(sslTrustStore);
+ sslTrustStorePIN =
+ new StringArgument("truststorepassword", null, "trustStorePassword",
+ false, false, true, "{password}", null, null,
+ MSGID_LDAPPWMOD_DESCRIPTION_TRUSTSTORE_PIN);
+ argParser.addArgument(sslTrustStorePIN);
+
+
sslTrustStorePINFile =
- new FileBasedArgument("ssltruststorepin", 'T',
- "sslTrustStorePINFile", false, false, "{file}", null, null,
- MSGID_LDAPPWMOD_DESCRIPTION_TRUSTSTORE_PINFILE);
+ new FileBasedArgument("truststorepasswordfile", null,
+ "trustStorePasswordFile", false, false, "{path}", null,
+ null, MSGID_LDAPPWMOD_DESCRIPTION_TRUSTSTORE_PINFILE);
argParser.addArgument(sslTrustStorePINFile);
@@ -378,6 +395,24 @@
return 1;
}
+ if (sslKeyStorePIN.isPresent() && sslKeyStorePINFile.isPresent())
+ {
+ int msgID = MSGID_TOOL_CONFLICTING_ARGS;
+ String message = getMessage(msgID, sslKeyStorePIN.getLongIdentifier(),
+ sslKeyStorePINFile.getLongIdentifier());
+ err.println(wrapText(message, MAX_LINE_WIDTH));
+ return 1;
+ }
+
+ if (sslTrustStorePIN.isPresent() && sslTrustStorePINFile.isPresent())
+ {
+ int msgID = MSGID_TOOL_CONFLICTING_ARGS;
+ String message = getMessage(msgID, sslTrustStorePIN.getLongIdentifier(),
+ sslTrustStorePINFile.getLongIdentifier());
+ err.println(wrapText(message, MAX_LINE_WIDTH));
+ return 1;
+ }
+
// If a bind DN was provided, make sure that a password was given. If a
// password was given, make sure a bind DN was provided. If neither were
@@ -459,14 +494,32 @@
connectionOptions.setVersionNumber(3);
if(connectionOptions.useSSL() || connectionOptions.useStartTLS())
{
+ String keyPIN = null;
+ if (sslKeyStorePIN.isPresent())
+ {
+ keyPIN = sslKeyStorePIN.getValue();
+ }
+ else if (sslKeyStorePINFile.isPresent())
+ {
+ keyPIN = sslKeyStorePINFile.getValue();
+ }
+
+ String trustPIN = null;
+ if (sslTrustStorePIN.isPresent())
+ {
+ trustPIN = sslTrustStorePIN.getValue();
+ }
+ else if (sslTrustStorePINFile.isPresent())
+ {
+ trustPIN = sslTrustStorePINFile.getValue();
+ }
+
try
{
SSLConnectionFactory sslConnectionFactory = new SSLConnectionFactory();
sslConnectionFactory.init(sslBlindTrust.isPresent(),
- sslKeyStore.getValue(),
- sslKeyStorePINFile.getValue(),
- sslTrustStore.getValue(),
- sslTrustStorePINFile.getValue());
+ sslKeyStore.getValue(), keyPIN,
+ sslTrustStore.getValue(), trustPIN);
connectionOptions.setSSLConnectionFactory(sslConnectionFactory);
}
catch (Exception e)
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java
index 226b902..fd592c3 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPPasswordModifyTestCase.java
@@ -181,13 +181,6 @@
args = new String[]
{
- "-k"
- };
- argLists.add(args);
- reasonList.add("No value for '-k' argument");
-
- args = new String[]
- {
"-K"
};
argLists.add(args);
@@ -195,17 +188,38 @@
args = new String[]
{
- "-t"
+ "-W"
};
argLists.add(args);
- reasonList.add("No value for '-t' argument");
+ reasonList.add("No value for '-W' argument");
args = new String[]
{
- "-T"
+ "--keyStorePasswordFile"
};
argLists.add(args);
- reasonList.add("No value for '-T' argument");
+ reasonList.add("No value for '--keyStorePasswordFile' argument");
+
+ args = new String[]
+ {
+ "-P"
+ };
+ argLists.add(args);
+ reasonList.add("No value for '-P' argument");
+
+ args = new String[]
+ {
+ "--trustStorePassword"
+ };
+ argLists.add(args);
+ reasonList.add("No value for '--trustStorePassword' argument");
+
+ args = new String[]
+ {
+ "--trustStorePasswordFile"
+ };
+ argLists.add(args);
+ reasonList.add("No value for '--trustStorePasswordFile' argument");
args = new String[]
{
@@ -909,7 +923,7 @@
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapsPort()),
"-Z",
- "-t", trustStorePath,
+ "-P", trustStorePath,
"-a", "dn:uid=test.user,o=test",
"-c", "password",
"-n", "newPassword"
@@ -1006,7 +1020,7 @@
"-h", "127.0.0.1",
"-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
"-q",
- "-t", trustStorePath,
+ "-P", trustStorePath,
"-a", "dn:uid=test.user,o=test",
"-c", "password",
"-n", "newPassword"
--
Gitblit v1.10.0