From 4d22a2caaeb77a78e2e962efa60e30772b1227be Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Sat, 27 Apr 2013 02:13:33 -0400 Subject: Added separate CLI option for client database password. Previously the -w option is used to specify the password for either the username/password authentication or client database password to do client certificate authentication. Since the passwords now may be used at the same time, a new -c option has been added for the client database password. --- .../src/com/netscape/certsrv/client/ClientConfig.java | 16 ++++++++++++++++ .../src/com/netscape/cmstools/cli/MainCLI.java | 12 ++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'base') diff --git a/base/common/src/com/netscape/certsrv/client/ClientConfig.java b/base/common/src/com/netscape/certsrv/client/ClientConfig.java index 885b60a26..6be7abae2 100644 --- a/base/common/src/com/netscape/certsrv/client/ClientConfig.java +++ b/base/common/src/com/netscape/certsrv/client/ClientConfig.java @@ -52,6 +52,7 @@ public class ClientConfig { String certDatabase; String certNickname; + String certPassword; String username; String password; @@ -86,6 +87,15 @@ public class ClientConfig { this.certNickname = certNickname; } + @XmlElement(name="CertPassword") + public String getCertPassword() { + return certPassword; + } + + public void setCertPassword(String certPassword) { + this.certPassword = certPassword; + } + @XmlElement(name="Username") public String getUsername() { return username; @@ -110,6 +120,7 @@ public class ClientConfig { int result = 1; result = prime * result + ((certDatabase == null) ? 0 : certDatabase.hashCode()); result = prime * result + ((certNickname == null) ? 0 : certNickname.hashCode()); + result = prime * result + ((certPassword == null) ? 0 : certPassword.hashCode()); result = prime * result + ((password == null) ? 0 : password.hashCode()); result = prime * result + ((serverURI == null) ? 0 : serverURI.hashCode()); result = prime * result + ((username == null) ? 0 : username.hashCode()); @@ -135,6 +146,11 @@ public class ClientConfig { return false; } else if (!certNickname.equals(other.certNickname)) return false; + if (certPassword == null) { + if (other.certPassword != null) + return false; + } else if (!certPassword.equals(other.certPassword)) + return false; if (password == null) { if (other.password != null) return false; diff --git a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java index 9b011f0d8..3c0c3d6bc 100644 --- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java @@ -140,6 +140,10 @@ public class MainCLI extends CLI { option.setArgName("nickname"); options.addOption(option); + option = new Option("c", true, "Certificate password"); + option.setArgName("password"); + options.addOption(option); + option = new Option("u", true, "Username"); option.setArgName("username"); options.addOption(option); @@ -184,6 +188,7 @@ public class MainCLI extends CLI { String certDatabase = cmd.getOptionValue("d"); String certNickname = cmd.getOptionValue("n"); + String certPassword = cmd.getOptionValue("c"); String username = cmd.getOptionValue("u"); String password = cmd.getOptionValue("w"); @@ -194,6 +199,9 @@ public class MainCLI extends CLI { if (certNickname != null) config.setCertNickname(certNickname); + if (certPassword != null) + config.setCertPassword(certPassword); + if (username != null) config.setUsername(username); @@ -342,11 +350,11 @@ public class MainCLI extends CLI { if (verbose) System.out.println("Certificate database: "+certDatabase.getAbsolutePath()); CryptoManager.initialize(certDatabase.getAbsolutePath()); - if (config.getPassword() != null) { + if (config.getCertPassword() != null) { try { CryptoManager manager = CryptoManager.getInstance(); CryptoToken token = manager.getInternalKeyStorageToken(); - Password password = new Password(config.getPassword().toCharArray()); + Password password = new Password(config.getCertPassword().toCharArray()); token.login(password); } catch (IncorrectPasswordException e) { -- cgit