The PKI CLI has been modified such that it initializes the
PKIClient (and retrieves the access banner) only if the CLI
needs to access the PKI server.

https://pagure.io/dogtagpki/issue/2612

Pushed to master under trivial rule.

--
Endi S. Dewata
>From 6bcb89b55db870766ddcf09002a5997b323bd196 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edew...@redhat.com>
Date: Sat, 18 Mar 2017 07:45:30 +0100
Subject: [PATCH] Fixed PKIClient initialization in PKI CLI.

The PKI CLI has been modified such that it initializes the
PKIClient (and retrieves the access banner) only if the CLI
needs to access the PKI server.

https://pagure.io/dogtagpki/issue/2612
---
 base/java-tools/src/com/netscape/cmstools/cli/CLI.java      |  2 +-
 base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java  | 11 +++++++++++
 base/java-tools/src/com/netscape/cmstools/cli/ProxyCLI.java |  2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/base/java-tools/src/com/netscape/cmstools/cli/CLI.java b/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
index 0a9106705f6d965b62b2600710ffb855b3a94485..65fad75e017ed57df871b45c7ce3009ca9f91857 100644
--- a/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/CLI.java
@@ -183,7 +183,7 @@ public class CLI {
         return null;
     }
 
-    public PKIClient getClient() {
+    public PKIClient getClient() throws Exception {
         return client;
     }
 
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 4c0a9182341f62b8718f4202b0825a7cdc2068d4..8f575dbf738af06885fb80bfaec6ca996a8db401 100644
--- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
@@ -522,6 +522,15 @@ public class MainCLI extends CLI {
         CryptoUtil.setSSLStreamVersionRange(SSLVersion.TLS_1_0, SSLVersion.TLS_1_2);
         CryptoUtil.setSSLDatagramVersionRange(SSLVersion.TLS_1_1, SSLVersion.TLS_1_2);
         CryptoUtil.setClientCiphers();
+    }
+
+    public PKIClient getClient() throws Exception {
+
+        if (client != null) return client;
+
+        if (verbose) {
+            System.out.println("Initializing PKIClient");
+        }
 
         client = new PKIClient(config, null);
         client.setVerbose(verbose);
@@ -558,6 +567,8 @@ public class MainCLI extends CLI {
                 }
             }
         }
+
+        return client;
     }
 
     public void execute(String[] args) throws Exception {
diff --git a/base/java-tools/src/com/netscape/cmstools/cli/ProxyCLI.java b/base/java-tools/src/com/netscape/cmstools/cli/ProxyCLI.java
index c5387cf0320c65459102f38f9f8b3d50ad060055..1cf6feaf2b044f2ec7473cdf0a1810761097ac1b 100644
--- a/base/java-tools/src/com/netscape/cmstools/cli/ProxyCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/ProxyCLI.java
@@ -87,7 +87,7 @@ public class ProxyCLI extends CLI {
         return module.removeModule(name);
     }
 
-    public PKIClient getClient() {
+    public PKIClient getClient() throws Exception {
         return module.getClient();
     }
 
-- 
2.9.3

_______________________________________________
Pki-devel mailing list
Pki-devel@redhat.com
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to