summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src/com
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2017-03-24 03:49:46 +0100
committerEndi S. Dewata <edewata@redhat.com>2017-03-28 01:09:11 +0200
commitf44965d97cb8d501797ad574ba4aee42d41634c7 (patch)
treeb3a568c0fcb846594b8bbf4940739a8299994df2 /base/java-tools/src/com
parentca04971010a92f84db8b0f18df0761192ea26023 (diff)
downloadpki-f44965d97cb8d501797ad574ba4aee42d41634c7.tar.gz
pki-f44965d97cb8d501797ad574ba4aee42d41634c7.tar.xz
pki-f44965d97cb8d501797ad574ba4aee42d41634c7.zip
Refactored AuthenticatorCLI.
The AuthenticatorCLI and its submodules have been modified to use lazy initialization to get the PKIClient object.
Diffstat (limited to 'base/java-tools/src/com')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorCLI.java9
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorModifyCLI.java6
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorRemoveCLI.java4
-rw-r--r--base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorShowCLI.java4
6 files changed, 22 insertions, 9 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java
index 5ae04afa5..163b89c76 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorAddCLI.java
@@ -27,6 +27,7 @@ import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
+import com.netscape.certsrv.tps.authenticator.AuthenticatorClient;
import com.netscape.certsrv.tps.authenticator.AuthenticatorData;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -87,7 +88,8 @@ public class AuthenticatorAddCLI extends CLI {
authenticatorData = AuthenticatorData.valueOf(sw.toString());
}
- authenticatorData = authenticatorCLI.authenticatorClient.addAuthenticator(authenticatorData);
+ AuthenticatorClient authenticatorClient = authenticatorCLI.getAuthenticatorClient();
+ authenticatorData = authenticatorClient.addAuthenticator(authenticatorData);
MainCLI.printMessage("Added authenticator \"" + authenticatorData.getID() + "\"");
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorCLI.java
index 8f802f57b..e35f41430 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorCLI.java
@@ -23,6 +23,7 @@ import java.util.Map;
import org.jboss.resteasy.plugins.providers.atom.Link;
+import com.netscape.certsrv.client.PKIClient;
import com.netscape.certsrv.tps.authenticator.AuthenticatorClient;
import com.netscape.certsrv.tps.authenticator.AuthenticatorData;
import com.netscape.cmstools.cli.CLI;
@@ -44,12 +45,14 @@ public class AuthenticatorCLI extends CLI {
addModule(new AuthenticatorShowCLI(this));
}
- public void execute(String[] args) throws Exception {
+ public AuthenticatorClient getAuthenticatorClient() throws Exception {
- client = parent.getClient();
+ if (authenticatorClient != null) return authenticatorClient;
+
+ PKIClient client = getClient();
authenticatorClient = (AuthenticatorClient)parent.getClient("authenticator");
- super.execute(args);
+ return authenticatorClient;
}
public static void printAuthenticatorData(AuthenticatorData authenticatorData, boolean showProperties) throws IOException {
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java
index 778f370f0..ec46476af 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorFindCLI.java
@@ -24,6 +24,7 @@ import java.util.Collection;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
+import com.netscape.certsrv.tps.authenticator.AuthenticatorClient;
import com.netscape.certsrv.tps.authenticator.AuthenticatorCollection;
import com.netscape.certsrv.tps.authenticator.AuthenticatorData;
import com.netscape.cmstools.cli.CLI;
@@ -75,7 +76,8 @@ public class AuthenticatorFindCLI extends CLI {
s = cmd.getOptionValue("size");
Integer size = s == null ? null : Integer.valueOf(s);
- AuthenticatorCollection result = authenticatorCLI.authenticatorClient.findAuthenticators(filter, start, size);
+ AuthenticatorClient authenticatorClient = authenticatorCLI.getAuthenticatorClient();
+ AuthenticatorCollection result = authenticatorClient.findAuthenticators(filter, start, size);
MainCLI.printMessage(result.getTotal() + " entries matched");
if (result.getTotal() == 0) return;
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorModifyCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorModifyCLI.java
index db5849b31..4e6baeb9b 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorModifyCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorModifyCLI.java
@@ -27,6 +27,7 @@ import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
+import com.netscape.certsrv.tps.authenticator.AuthenticatorClient;
import com.netscape.certsrv.tps.authenticator.AuthenticatorData;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -78,6 +79,7 @@ public class AuthenticatorModifyCLI extends CLI {
String action = cmd.getOptionValue("action", "update");
String input = cmd.getOptionValue("input");
+ AuthenticatorClient authenticatorClient = authenticatorCLI.getAuthenticatorClient();
AuthenticatorData authenticatorData;
if (action.equals("update")) {
@@ -98,10 +100,10 @@ public class AuthenticatorModifyCLI extends CLI {
authenticatorData = AuthenticatorData.valueOf(sw.toString());
}
- authenticatorData = authenticatorCLI.authenticatorClient.updateAuthenticator(authenticatorID, authenticatorData);
+ authenticatorData = authenticatorClient.updateAuthenticator(authenticatorID, authenticatorData);
} else { // other actions
- authenticatorData = authenticatorCLI.authenticatorClient.changeAuthenticatorStatus(authenticatorID, action);
+ authenticatorData = authenticatorClient.changeAuthenticatorStatus(authenticatorID, action);
}
MainCLI.printMessage("Modified authenticator \"" + authenticatorID + "\"");
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorRemoveCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorRemoveCLI.java
index 1e40873db..e3327b532 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorRemoveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorRemoveCLI.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
+import com.netscape.certsrv.tps.authenticator.AuthenticatorClient;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -58,7 +59,8 @@ public class AuthenticatorRemoveCLI extends CLI {
String authenticatorID = args[0];
- authenticatorCLI.authenticatorClient.removeAuthenticator(authenticatorID);
+ AuthenticatorClient authenticatorClient = authenticatorCLI.getAuthenticatorClient();
+ authenticatorClient.removeAuthenticator(authenticatorID);
MainCLI.printMessage("Deleted authenticator \"" + authenticatorID + "\"");
}
diff --git a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorShowCLI.java b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorShowCLI.java
index 6df9129c0..f764bde1d 100644
--- a/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorShowCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/tps/authenticator/AuthenticatorShowCLI.java
@@ -25,6 +25,7 @@ import java.util.Arrays;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
+import com.netscape.certsrv.tps.authenticator.AuthenticatorClient;
import com.netscape.certsrv.tps.authenticator.AuthenticatorData;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -71,7 +72,8 @@ public class AuthenticatorShowCLI extends CLI {
String authenticatorID = args[0];
String output = cmd.getOptionValue("output");
- AuthenticatorData authenticatorData = authenticatorCLI.authenticatorClient.getAuthenticator(authenticatorID);
+ AuthenticatorClient authenticatorClient = authenticatorCLI.getAuthenticatorClient();
+ AuthenticatorData authenticatorData = authenticatorClient.getAuthenticator(authenticatorID);
if (output == null) {
MainCLI.printMessage("Authenticator \"" + authenticatorID + "\"");