From 4300459bff057ba50093f735ee9289868e258215 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Mon, 8 Oct 2012 16:52:53 -0400 Subject: Added PKIConnection. The code in PKIClient has been refactored into PKIConnection such that a single connection object can be used by several REST clients. The PKIClient will remain the base class for all REST clients. Ticket #357 --- .../src/com/netscape/cmstools/cert/CertCLI.java | 3 +-- .../cmstools/cert/CertRequestApproveCLI.java | 31 +++++++--------------- 2 files changed, 11 insertions(+), 23 deletions(-) (limited to 'base/java-tools/src/com/netscape/cmstools/cert') 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()); } -- cgit