summaryrefslogtreecommitdiffstats
path: root/base/java-tools/src
diff options
context:
space:
mode:
Diffstat (limited to 'base/java-tools/src')
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java3
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertRequestApproveCLI.java31
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java10
-rw-r--r--base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java3
-rw-r--r--base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java1
-rw-r--r--base/java-tools/src/com/netscape/cmstools/user/UserCLI.java3
6 files changed, 23 insertions, 28 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
index 6857b689e..034a12649 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertCLI.java
@@ -76,8 +76,7 @@ public class CertCLI extends CLI {
public void execute(String[] args) throws Exception {
- client = new CertClient(parent.config);
- client.setVerbose(verbose);
+ client = new CertClient(parent.connection);
if (args.length == 0) {
printHelp();
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestApproveCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestApproveCLI.java
index 98a3a2b4f..0c6db8a90 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestApproveCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestApproveCLI.java
@@ -1,16 +1,13 @@
package com.netscape.cmstools.cert;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
-import com.netscape.certsrv.base.PKIException;
import com.netscape.certsrv.cert.CertReviewResponse;
import com.netscape.cmstools.cli.CLI;
import com.netscape.cmstools.cli.MainCLI;
@@ -24,7 +21,7 @@ public class CertRequestApproveCLI extends CLI {
}
@Override
- public void execute(String[] args) {
+ public void execute(String[] args) throws Exception {
CommandLine cmd = null;
try {
@@ -42,23 +39,15 @@ public class CertRequestApproveCLI extends CLI {
printHelp();
System.exit(-1);
}
- CertReviewResponse reviewInfo = null;
- try {
- JAXBContext context = JAXBContext.newInstance(CertReviewResponse.class);
- Unmarshaller unmarshaller = context.createUnmarshaller();
- FileInputStream fis = new FileInputStream(cLineArgs[0].trim());
- reviewInfo = (CertReviewResponse) unmarshaller.unmarshal(fis);
- parent.client.approveRequest(reviewInfo.getRequestId(), reviewInfo);
- } catch (PKIException e) {
- System.err.println(e.getMessage());
- System.exit(-1);
- } catch (JAXBException e) {
- System.err.println("Error: " + e.getMessage());
- System.exit(-1);
- } catch (FileNotFoundException e) {
- System.err.println("Error: " + e.getMessage());
- System.exit(-1);
- }
+
+ FileInputStream fis = new FileInputStream(cLineArgs[0].trim());
+
+ JAXBContext context = JAXBContext.newInstance(CertReviewResponse.class);
+ Unmarshaller unmarshaller = context.createUnmarshaller();
+ CertReviewResponse reviewInfo = (CertReviewResponse) unmarshaller.unmarshal(fis);
+
+ parent.client.approveRequest(reviewInfo.getRequestId(), reviewInfo);
+
MainCLI.printMessage("Approved certificate request " + reviewInfo.getRequestId().toString());
}
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 bcc3bb27e..6f1c4909f 100644
--- a/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cli/MainCLI.java
@@ -31,6 +31,7 @@ import org.mozilla.jss.util.IncorrectPasswordException;
import org.mozilla.jss.util.Password;
import com.netscape.certsrv.client.ClientConfig;
+import com.netscape.certsrv.client.PKIConnection;
import com.netscape.cmstools.cert.CertCLI;
import com.netscape.cmstools.group.GroupCLI;
import com.netscape.cmstools.system.SecurityDomainCLI;
@@ -43,6 +44,8 @@ public class MainCLI extends CLI {
public ClientConfig config = new ClientConfig();
+ public PKIConnection connection;
+
public MainCLI() throws Exception {
super("pki", "PKI command-line interface");
@@ -161,6 +164,11 @@ public class MainCLI extends CLI {
config.setPassword(password);
}
+ public void connect() throws Exception {
+ connection = new PKIConnection(config);
+ connection.setVerbose(verbose);
+ }
+
public void execute(String[] args) throws Exception {
CLI module;
@@ -268,6 +276,8 @@ public class MainCLI extends CLI {
}
}
+ connect();
+
// execute module command
module.execute(moduleArgs);
diff --git a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
index ce28af243..b2c38d808 100644
--- a/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/group/GroupCLI.java
@@ -75,8 +75,7 @@ public class GroupCLI extends CLI {
public void execute(String[] args) throws Exception {
- client = new GroupClient(parent.config);
- client.setVerbose(verbose);
+ client = new GroupClient(parent.connection);
if (args.length == 0) {
printHelp();
diff --git a/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java b/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java
index 93c4c4b63..a6441e2fc 100644
--- a/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/system/SecurityDomainCLI.java
@@ -65,7 +65,6 @@ public class SecurityDomainCLI extends CLI {
public void execute(String[] args) throws Exception {
client = new SecurityDomainClient(parent.config);
- client.setVerbose(verbose);
if (args.length == 0) {
printHelp();
diff --git a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
index 301754a22..8c24d1746 100644
--- a/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/user/UserCLI.java
@@ -76,8 +76,7 @@ public class UserCLI extends CLI {
public void execute(String[] args) throws Exception {
- client = new UserClient(parent.config);
- client.setVerbose(verbose);
+ client = new UserClient(parent.connection);
if (args.length == 0) {
printHelp();