Update the ldappasswordmodify tool to align the SSL-related arguments with the
other LDAP client tools.
OpenDS Issue Number: 1023
| | |
| | | |
| | | |
| | | /** |
| | | * 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. |
| | | */ |
| | |
| | | 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, |
| | |
| | | StringArgument ldapHost; |
| | | StringArgument newPW; |
| | | StringArgument sslKeyStore; |
| | | StringArgument sslKeyStorePIN; |
| | | StringArgument sslTrustStore; |
| | | StringArgument sslTrustStorePIN; |
| | | |
| | | |
| | | // Initialize the argument parser. |
| | |
| | | |
| | | |
| | | 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); |
| | | |
| | | |
| | |
| | | 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 |
| | |
| | | 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) |
| | |
| | | |
| | | args = new String[] |
| | | { |
| | | "-k" |
| | | }; |
| | | argLists.add(args); |
| | | reasonList.add("No value for '-k' argument"); |
| | | |
| | | args = new String[] |
| | | { |
| | | "-K" |
| | | }; |
| | | argLists.add(args); |
| | |
| | | |
| | | 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[] |
| | | { |
| | |
| | | "-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" |
| | |
| | | "-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" |