diff options
| author | Endi Sukma Dewata <edewata@redhat.com> | 2013-04-27 01:08:51 -0400 |
|---|---|---|
| committer | Ade Lee <alee@redhat.com> | 2013-04-28 01:07:28 -0400 |
| commit | e7a9add502681e13fde159e6f3a026af249e92f9 (patch) | |
| tree | 23f5f8989a628c5fd86d64a2a0ac9c0597a42d09 /base/java-tools | |
| parent | 4d22a2caaeb77a78e2e962efa60e30772b1227be (diff) | |
| download | pki-e7a9add502681e13fde159e6f3a026af249e92f9.tar.gz pki-e7a9add502681e13fde159e6f3a026af249e92f9.tar.xz pki-e7a9add502681e13fde159e6f3a026af249e92f9.zip | |
Reverting to old CLI behavior on client database initialization.
Recently the CLI was changed to initialize the default client database
automatically which will create it if it did not exist before. This was
causing a problem since the database was not created with a password.
To create the database properly a separate command is needed. For now
the CLI is reverted to the old behavior where it initializes the database
only if it requires for SSL connection and/or client authentication.
Diffstat (limited to 'base/java-tools')
| -rw-r--r-- | base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java | 50 |
1 files changed, 7 insertions, 43 deletions
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 3c0c3d6bc..50095b173 100644 --- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java +++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java @@ -29,11 +29,7 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.lang.StringUtils; -import org.mozilla.jss.CryptoManager; -import org.mozilla.jss.crypto.CryptoToken; import org.mozilla.jss.ssl.SSLCertificateApprovalCallback; -import org.mozilla.jss.util.IncorrectPasswordException; -import org.mozilla.jss.util.Password; import com.netscape.certsrv.account.AccountClient; import com.netscape.certsrv.client.ClientConfig; @@ -232,7 +228,7 @@ public class MainCLI extends CLI { } } - public void connect() throws Exception { + public void init() throws Exception { client = new PKIClient(config); client.setVerbose(verbose); @@ -248,6 +244,11 @@ public class MainCLI extends CLI { } accountClient = new AccountClient(client); + + // initialize certificate database if specified + if (config.getCertDatabase() != null) { + client.initCertDatabase(); + } } public void execute(String[] args) throws Exception { @@ -334,47 +335,10 @@ public class MainCLI extends CLI { if (verbose) System.out.println("Server URI: "+config.getServerURI()); - // initialize certificate database - if (config.getCertDatabase() == null) { - this.certDatabase = new File( - System.getProperty("user.home") + File.separator + - ".dogtag" + File.separator + "nssdb"); - - } else { - this.certDatabase = new File(config.getCertDatabase()); - } - - certDatabase.mkdirs(); - - try { - if (verbose) System.out.println("Certificate database: "+certDatabase.getAbsolutePath()); - CryptoManager.initialize(certDatabase.getAbsolutePath()); - - if (config.getCertPassword() != null) { - try { - CryptoManager manager = CryptoManager.getInstance(); - CryptoToken token = manager.getInternalKeyStorageToken(); - Password password = new Password(config.getCertPassword().toCharArray()); - token.login(password); - - } catch (IncorrectPasswordException e) { - throw new Error("Incorrect certificate database password.", e); - } - } - - } catch (Throwable t) { - if (verbose) { - t.printStackTrace(System.err); - } else { - System.err.println(t.getClass().getSimpleName()+": "+t.getMessage()); - } - System.exit(1); - } - // execute command boolean loggedIn = false; try { - connect(); + init(); // login if username or nickname is specified if (config.getUsername() != null || config.getCertNickname() != null) { |
