summaryrefslogtreecommitdiffstats
path: root/base/silent
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2012-06-15 09:58:40 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2012-06-18 15:13:29 -0500
commit4880d86856d183d4ba3fb0291519353ac238af5d (patch)
tree926db8f160fc48d6186d71091bc620e0b9893d26 /base/silent
parent10326ad4fe1b3db620f43feb3f47c4fd008f3f33 (diff)
downloadpki-4880d86856d183d4ba3fb0291519353ac238af5d.tar.gz
pki-4880d86856d183d4ba3fb0291519353ac238af5d.tar.xz
pki-4880d86856d183d4ba3fb0291519353ac238af5d.zip
Fixed null pointer exception in pkisilent on connection error.
Previously HTTPClient.sslConnect() would return a null if there is a connection issue. Some code in pkisilent did not check the return value properly so it would throw an exception. The sslConnect() has been modified to throw an exception instead. Ticket #180
Diffstat (limited to 'base/silent')
-rw-r--r--base/silent/src/com/netscape/pkisilent/ConfigureDRM.java35
-rw-r--r--base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java37
-rw-r--r--base/silent/src/com/netscape/pkisilent/ConfigureRA.java31
-rw-r--r--base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java33
-rw-r--r--base/silent/src/com/netscape/pkisilent/ConfigureTKS.java37
-rw-r--r--base/silent/src/com/netscape/pkisilent/ConfigureTPS.java33
-rw-r--r--base/silent/src/com/netscape/pkisilent/http/HTTPClient.java122
7 files changed, 175 insertions, 153 deletions
diff --git a/base/silent/src/com/netscape/pkisilent/ConfigureDRM.java b/base/silent/src/com/netscape/pkisilent/ConfigureDRM.java
index 6d2516399..ca3581869 100644
--- a/base/silent/src/com/netscape/pkisilent/ConfigureDRM.java
+++ b/base/silent/src/com/netscape/pkisilent/ConfigureDRM.java
@@ -24,7 +24,6 @@ import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
@@ -32,13 +31,13 @@ import org.mozilla.jss.asn1.SEQUENCE;
import org.mozilla.jss.pkcs12.AuthenticatedSafes;
import org.mozilla.jss.pkcs12.PFX;
+import com.netscape.cmsutil.util.Utils;
import com.netscape.pkisilent.argparser.ArgParser;
import com.netscape.pkisilent.argparser.StringHolder;
import com.netscape.pkisilent.common.ComCrypto;
import com.netscape.pkisilent.common.ParseXML;
import com.netscape.pkisilent.http.HTTPClient;
import com.netscape.pkisilent.http.HTTPResponse;
-import com.netscape.cmsutil.util.Utils;
public class ConfigureDRM {
@@ -194,7 +193,7 @@ public class ConfigureDRM {
}
- public boolean LoginPanel() {
+ public boolean LoginPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
@@ -227,7 +226,7 @@ public class ConfigureDRM {
return st;
}
- public boolean TokenChoicePanel() throws UnsupportedEncodingException {
+ public boolean TokenChoicePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -274,7 +273,7 @@ public class ConfigureDRM {
return true;
}
- public boolean DomainPanel() throws UnsupportedEncodingException {
+ public boolean DomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -299,7 +298,7 @@ public class ConfigureDRM {
}
- public boolean DisplayChainPanel() {
+ public boolean DisplayChainPanel() throws Exception {
String query_string = "p=4" + "&op=next" + "&xml=true";
hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string);
@@ -365,7 +364,7 @@ public class ConfigureDRM {
}
}
- public boolean SubsystemPanel() throws UnsupportedEncodingException {
+ public boolean SubsystemPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -414,7 +413,7 @@ public class ConfigureDRM {
}
}
- public boolean LdapConnectionPanel() throws UnsupportedEncodingException {
+ public boolean LdapConnectionPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -443,7 +442,7 @@ public class ConfigureDRM {
return true;
}
- public boolean KeyPanel() {
+ public boolean KeyPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -530,7 +529,7 @@ public class ConfigureDRM {
return true;
}
- public boolean CertSubjectPanel() throws UnsupportedEncodingException {
+ public boolean CertSubjectPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -600,7 +599,7 @@ public class ConfigureDRM {
return true;
}
- public boolean CertificatePanel() throws UnsupportedEncodingException {
+ public boolean CertificatePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -632,7 +631,7 @@ public class ConfigureDRM {
return true;
}
- public boolean BackupPanel() throws UnsupportedEncodingException {
+ public boolean BackupPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -652,7 +651,7 @@ public class ConfigureDRM {
return true;
}
- public boolean SavePKCS12Panel() {
+ public boolean SavePKCS12Panel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -711,7 +710,7 @@ public class ConfigureDRM {
return true;
}
- public boolean AdminCertReqPanel() throws UnsupportedEncodingException {
+ public boolean AdminCertReqPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -767,7 +766,7 @@ public class ConfigureDRM {
return true;
}
- public boolean AdminCertImportPanel() {
+ public boolean AdminCertImportPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
@@ -805,7 +804,7 @@ public class ConfigureDRM {
return true;
}
- public boolean UpdateDomainPanel() throws UnsupportedEncodingException {
+ public boolean UpdateDomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -824,7 +823,7 @@ public class ConfigureDRM {
return true;
}
- public boolean ConfigureDRMInstance() throws UnsupportedEncodingException {
+ public boolean ConfigureDRMInstance() throws Exception {
// 0. login to cert db
ComCrypto cCrypt = new ComCrypto(client_certdb_dir,
client_certdb_pwd,
@@ -985,7 +984,7 @@ public class ConfigureDRM {
}
}
- public static void main(String args[]) throws UnsupportedEncodingException {
+ public static void main(String args[]) throws Exception {
ConfigureDRM ca = new ConfigureDRM();
// set variables
diff --git a/base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java b/base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java
index d6caddbcb..0ca0a082a 100644
--- a/base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java
+++ b/base/silent/src/com/netscape/pkisilent/ConfigureOCSP.java
@@ -24,7 +24,6 @@ import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
@@ -32,13 +31,13 @@ import org.mozilla.jss.asn1.SEQUENCE;
import org.mozilla.jss.pkcs12.AuthenticatedSafes;
import org.mozilla.jss.pkcs12.PFX;
+import com.netscape.cmsutil.util.Utils;
import com.netscape.pkisilent.argparser.ArgParser;
import com.netscape.pkisilent.argparser.StringHolder;
import com.netscape.pkisilent.common.ComCrypto;
import com.netscape.pkisilent.common.ParseXML;
import com.netscape.pkisilent.http.HTTPClient;
import com.netscape.pkisilent.http.HTTPResponse;
-import com.netscape.cmsutil.util.Utils;
public class ConfigureOCSP {
public static final String DEFAULT_KEY_TYPE = "RSA";
@@ -170,7 +169,7 @@ public class ConfigureOCSP {
}
- public boolean LoginPanel() {
+ public boolean LoginPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
@@ -206,7 +205,7 @@ public class ConfigureOCSP {
return st;
}
- public boolean TokenChoicePanel() throws UnsupportedEncodingException {
+ public boolean TokenChoicePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -251,7 +250,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean DomainPanel() throws UnsupportedEncodingException {
+ public boolean DomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -276,7 +275,7 @@ public class ConfigureOCSP {
}
- public boolean DisplayChainPanel() {
+ public boolean DisplayChainPanel() throws Exception {
String query_string = null;
query_string = "p=4" + "&op=next" + "&xml=true";
@@ -290,7 +289,7 @@ public class ConfigureOCSP {
}
- public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException {
+ public boolean SecurityDomainLoginPanel() throws Exception {
HTTPResponse hr = null;
String ocsp_url = "https://" + cs_hostname + ":" + cs_port +
@@ -330,7 +329,7 @@ public class ConfigureOCSP {
}
- public boolean SubsystemPanel() throws UnsupportedEncodingException {
+ public boolean SubsystemPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -349,7 +348,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean LdapConnectionPanel() throws UnsupportedEncodingException {
+ public boolean LdapConnectionPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -375,7 +374,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean KeyPanel() {
+ public boolean KeyPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -437,7 +436,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean CertSubjectPanel() throws UnsupportedEncodingException {
+ public boolean CertSubjectPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -494,7 +493,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean CertificatePanel() throws UnsupportedEncodingException {
+ public boolean CertificatePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -526,7 +525,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean BackupPanel() throws UnsupportedEncodingException {
+ public boolean BackupPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -546,7 +545,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean SavePKCS12Panel() {
+ public boolean SavePKCS12Panel() throws Exception {
HTTPResponse hr = null;
String query_string = "";
@@ -594,7 +593,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean AdminCertReqPanel() throws UnsupportedEncodingException {
+ public boolean AdminCertReqPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -650,7 +649,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean AdminCertImportPanel() {
+ public boolean AdminCertImportPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
@@ -689,7 +688,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean UpdateDomainPanel() throws UnsupportedEncodingException {
+ public boolean UpdateDomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -708,7 +707,7 @@ public class ConfigureOCSP {
return true;
}
- public boolean ConfigureOCSPInstance() throws UnsupportedEncodingException {
+ public boolean ConfigureOCSPInstance() throws Exception {
// 0. login to cert db
ComCrypto cCrypt = new ComCrypto(client_certdb_dir,
client_certdb_pwd,
@@ -854,7 +853,7 @@ public class ConfigureOCSP {
}
}
- public static void main(String args[]) throws UnsupportedEncodingException {
+ public static void main(String args[]) throws Exception {
ConfigureOCSP ca = new ConfigureOCSP();
// set variables
diff --git a/base/silent/src/com/netscape/pkisilent/ConfigureRA.java b/base/silent/src/com/netscape/pkisilent/ConfigureRA.java
index 0188a126a..ed93a16f7 100644
--- a/base/silent/src/com/netscape/pkisilent/ConfigureRA.java
+++ b/base/silent/src/com/netscape/pkisilent/ConfigureRA.java
@@ -19,16 +19,15 @@ package com.netscape.pkisilent;
// --- END COPYRIGHT BLOCK ---
import java.io.ByteArrayInputStream;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import com.netscape.cmsutil.util.Utils;
import com.netscape.pkisilent.argparser.ArgParser;
import com.netscape.pkisilent.argparser.StringHolder;
import com.netscape.pkisilent.common.ComCrypto;
import com.netscape.pkisilent.common.ParseXML;
import com.netscape.pkisilent.http.HTTPClient;
import com.netscape.pkisilent.http.HTTPResponse;
-import com.netscape.cmsutil.util.Utils;
public class ConfigureRA {
@@ -121,7 +120,7 @@ public class ConfigureRA {
}
- public boolean LoginPanel() {
+ public boolean LoginPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
@@ -159,7 +158,7 @@ public class ConfigureRA {
return st;
}
- public boolean DomainPanel() throws UnsupportedEncodingException {
+ public boolean DomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -184,7 +183,7 @@ public class ConfigureRA {
}
- public boolean DisplayChainPanel() {
+ public boolean DisplayChainPanel() throws Exception {
String query_string = "p=2" + "&op=next" + "&xml=true";
hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string);
@@ -192,7 +191,7 @@ public class ConfigureRA {
}
- public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException {
+ public boolean SecurityDomainLoginPanel() throws Exception {
HTTPResponse hr = null;
String ra_url = "https://" + cs_hostname + ":" + cs_port +
@@ -236,7 +235,7 @@ public class ConfigureRA {
}
- public boolean SubsystemPanel() throws UnsupportedEncodingException {
+ public boolean SubsystemPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -272,7 +271,7 @@ public class ConfigureRA {
return true;
}
- public boolean DBPanel() {
+ public boolean DBPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -291,7 +290,7 @@ public class ConfigureRA {
return true;
}
- public boolean TokenChoicePanel() throws UnsupportedEncodingException {
+ public boolean TokenChoicePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -348,7 +347,7 @@ public class ConfigureRA {
return true;
}
- public boolean KeyPanel() {
+ public boolean KeyPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -376,7 +375,7 @@ public class ConfigureRA {
return true;
}
- public boolean CertSubjectPanel() throws UnsupportedEncodingException {
+ public boolean CertSubjectPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -404,7 +403,7 @@ public class ConfigureRA {
return true;
}
- public boolean CertificatePanel() {
+ public boolean CertificatePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -427,7 +426,7 @@ public class ConfigureRA {
return true;
}
- public boolean AdminCertReqPanel() throws UnsupportedEncodingException {
+ public boolean AdminCertReqPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -495,7 +494,7 @@ public class ConfigureRA {
return true;
}
- public boolean AdminCertImportPanel() throws UnsupportedEncodingException {
+ public boolean AdminCertImportPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
@@ -563,7 +562,7 @@ public class ConfigureRA {
return true;
}
- public boolean ConfigureRAInstance() throws UnsupportedEncodingException {
+ public boolean ConfigureRAInstance() throws Exception {
// 0. login to cert db
ComCrypto cCrypt = new ComCrypto(client_certdb_dir,
client_certdb_pwd,
@@ -677,7 +676,7 @@ public class ConfigureRA {
return true;
}
- public static void main(String args[]) throws UnsupportedEncodingException {
+ public static void main(String args[]) throws Exception {
ConfigureRA ca = new ConfigureRA();
// set variables
diff --git a/base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java b/base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java
index 32fe687a8..6147d256a 100644
--- a/base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java
+++ b/base/silent/src/com/netscape/pkisilent/ConfigureSubCA.java
@@ -19,7 +19,6 @@ package com.netscape.pkisilent;
// --- END COPYRIGHT BLOCK ---
import java.io.ByteArrayInputStream;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
@@ -174,7 +173,7 @@ public class ConfigureSubCA {
}
- public boolean LoginPanel() {
+ public boolean LoginPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
@@ -210,7 +209,7 @@ public class ConfigureSubCA {
return st;
}
- public boolean TokenChoicePanel() throws UnsupportedEncodingException {
+ public boolean TokenChoicePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -261,7 +260,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean DomainPanel() throws UnsupportedEncodingException {
+ public boolean DomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -294,7 +293,7 @@ public class ConfigureSubCA {
}
- public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException {
+ public boolean SecurityDomainLoginPanel() throws Exception {
String subca_url = "https://" + cs_hostname + ":" + cs_port +
"/ca/admin/console/config/wizard" +
"?p=5&subsystem=CA";
@@ -332,7 +331,7 @@ public class ConfigureSubCA {
}
- public boolean DisplayChainPanel() throws UnsupportedEncodingException {
+ public boolean DisplayChainPanel() throws Exception {
String query_string = "p=5" + "&op=next" + "&xml=true" +
"&choice=newsubsystem" +
"&subsystemName=" +
@@ -349,7 +348,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean HierarchyPanel() {
+ public boolean HierarchyPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -368,7 +367,7 @@ public class ConfigureSubCA {
}
- public boolean LdapConnectionPanel() throws UnsupportedEncodingException {
+ public boolean LdapConnectionPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -394,7 +393,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean KeyPanel() {
+ public boolean KeyPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -467,7 +466,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean CertSubjectPanel() throws UnsupportedEncodingException {
+ public boolean CertSubjectPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -553,7 +552,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean CertificatePanel() throws UnsupportedEncodingException {
+ public boolean CertificatePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -586,7 +585,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean BackupPanel() throws UnsupportedEncodingException {
+ public boolean BackupPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -627,7 +626,7 @@ public class ConfigureSubCA {
}
}
- public boolean AdminCertReqPanel() throws UnsupportedEncodingException {
+ public boolean AdminCertReqPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -685,7 +684,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean AdminCertImportPanel() {
+ public boolean AdminCertImportPanel() throws Exception {
boolean st = false;
String query_string = "serialNumber=" + admin_serial_number +
@@ -724,7 +723,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean UpdateDomainPanel() throws UnsupportedEncodingException {
+ public boolean UpdateDomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -755,7 +754,7 @@ public class ConfigureSubCA {
return true;
}
- public boolean ConfigureSubCAInstance() throws UnsupportedEncodingException {
+ public boolean ConfigureSubCAInstance() throws Exception {
// 0. login to cert db
ComCrypto cCrypt = new ComCrypto(client_certdb_dir,
client_certdb_pwd,
@@ -900,7 +899,7 @@ public class ConfigureSubCA {
}
}
- public static void main(String args[]) throws UnsupportedEncodingException {
+ public static void main(String args[]) throws Exception {
ConfigureSubCA ca = new ConfigureSubCA();
// set variables
diff --git a/base/silent/src/com/netscape/pkisilent/ConfigureTKS.java b/base/silent/src/com/netscape/pkisilent/ConfigureTKS.java
index 77f8ae0bc..aa8dccee8 100644
--- a/base/silent/src/com/netscape/pkisilent/ConfigureTKS.java
+++ b/base/silent/src/com/netscape/pkisilent/ConfigureTKS.java
@@ -24,7 +24,6 @@ import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
@@ -32,13 +31,13 @@ import org.mozilla.jss.asn1.SEQUENCE;
import org.mozilla.jss.pkcs12.AuthenticatedSafes;
import org.mozilla.jss.pkcs12.PFX;
+import com.netscape.cmsutil.util.Utils;
import com.netscape.pkisilent.argparser.ArgParser;
import com.netscape.pkisilent.argparser.StringHolder;
import com.netscape.pkisilent.common.ComCrypto;
import com.netscape.pkisilent.common.ParseXML;
import com.netscape.pkisilent.http.HTTPClient;
import com.netscape.pkisilent.http.HTTPResponse;
-import com.netscape.cmsutil.util.Utils;
public class ConfigureTKS {
@@ -155,7 +154,7 @@ public class ConfigureTKS {
}
}
- public boolean LoginPanel() {
+ public boolean LoginPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
@@ -191,7 +190,7 @@ public class ConfigureTKS {
return st;
}
- public boolean TokenChoicePanel() throws UnsupportedEncodingException {
+ public boolean TokenChoicePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -240,7 +239,7 @@ public class ConfigureTKS {
return true;
}
- public boolean DomainPanel() throws UnsupportedEncodingException {
+ public boolean DomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -265,7 +264,7 @@ public class ConfigureTKS {
}
- public boolean DisplayChainPanel() {
+ public boolean DisplayChainPanel() throws Exception {
String query_string = "p=4" + "&op=next" + "&xml=true";
hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string);
// parse xml
@@ -277,7 +276,7 @@ public class ConfigureTKS {
}
- public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException {
+ public boolean SecurityDomainLoginPanel() throws Exception {
String tks_url = "https://" + cs_hostname + ":" + cs_port +
"/tks/admin/console/config/wizard" +
"?p=5&subsystem=TKS";
@@ -320,7 +319,7 @@ public class ConfigureTKS {
}
- public boolean SubsystemPanel() throws UnsupportedEncodingException {
+ public boolean SubsystemPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -339,7 +338,7 @@ public class ConfigureTKS {
return true;
}
- public boolean LdapConnectionPanel() throws UnsupportedEncodingException {
+ public boolean LdapConnectionPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -365,7 +364,7 @@ public class ConfigureTKS {
return true;
}
- public boolean KeyPanel() {
+ public boolean KeyPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -419,7 +418,7 @@ public class ConfigureTKS {
return true;
}
- public boolean CertSubjectPanel() throws UnsupportedEncodingException {
+ public boolean CertSubjectPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -471,7 +470,7 @@ public class ConfigureTKS {
return true;
}
- public boolean CertificatePanel() throws UnsupportedEncodingException {
+ public boolean CertificatePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -499,7 +498,7 @@ public class ConfigureTKS {
return true;
}
- public boolean BackupPanel() throws UnsupportedEncodingException {
+ public boolean BackupPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -519,7 +518,7 @@ public class ConfigureTKS {
return true;
}
- public boolean SavePKCS12Panel() {
+ public boolean SavePKCS12Panel() throws Exception {
String query_string = "";
HTTPResponse hr = hc.sslConnect(cs_hostname, cs_port, pkcs12_uri, query_string);
@@ -565,7 +564,7 @@ public class ConfigureTKS {
return true;
}
- public boolean AdminCertReqPanel() throws UnsupportedEncodingException {
+ public boolean AdminCertReqPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -622,7 +621,7 @@ public class ConfigureTKS {
return true;
}
- public boolean AdminCertImportPanel() {
+ public boolean AdminCertImportPanel() throws Exception {
boolean st = false;
String query_string = "serialNumber=" + admin_serial_number +
@@ -660,7 +659,7 @@ public class ConfigureTKS {
return true;
}
- public boolean UpdateDomainPanel() throws UnsupportedEncodingException {
+ public boolean UpdateDomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -680,7 +679,7 @@ public class ConfigureTKS {
return true;
}
- public boolean ConfigureTKSInstance() throws UnsupportedEncodingException {
+ public boolean ConfigureTKSInstance() throws Exception {
// 0. login to cert db
ComCrypto cCrypt = new ComCrypto(client_certdb_dir,
client_certdb_pwd,
@@ -827,7 +826,7 @@ public class ConfigureTKS {
}
}
- public static void main(String args[]) throws UnsupportedEncodingException {
+ public static void main(String args[]) throws Exception {
ConfigureTKS ca = new ConfigureTKS();
// set variables
diff --git a/base/silent/src/com/netscape/pkisilent/ConfigureTPS.java b/base/silent/src/com/netscape/pkisilent/ConfigureTPS.java
index f3522d75d..f23b605fa 100644
--- a/base/silent/src/com/netscape/pkisilent/ConfigureTPS.java
+++ b/base/silent/src/com/netscape/pkisilent/ConfigureTPS.java
@@ -19,16 +19,15 @@ package com.netscape.pkisilent;
// --- END COPYRIGHT BLOCK ---
import java.io.ByteArrayInputStream;
-import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import com.netscape.cmsutil.util.Utils;
import com.netscape.pkisilent.argparser.ArgParser;
import com.netscape.pkisilent.argparser.StringHolder;
import com.netscape.pkisilent.common.ComCrypto;
import com.netscape.pkisilent.common.ParseXML;
import com.netscape.pkisilent.http.HTTPClient;
import com.netscape.pkisilent.http.HTTPResponse;
-import com.netscape.cmsutil.util.Utils;
public class ConfigureTPS {
// define global variables
@@ -156,7 +155,7 @@ public class ConfigureTPS {
}
- public boolean LoginPanel() {
+ public boolean LoginPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
@@ -194,7 +193,7 @@ public class ConfigureTPS {
return st;
}
- public boolean DomainPanel() throws UnsupportedEncodingException {
+ public boolean DomainPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -219,7 +218,7 @@ public class ConfigureTPS {
}
- public boolean DisplayChainPanel() {
+ public boolean DisplayChainPanel() throws Exception {
String query_string = "p=4" + "&op=next" + "&xml=true";
hc.sslConnect(cs_hostname, cs_port, wizard_uri, query_string);
@@ -227,7 +226,7 @@ public class ConfigureTPS {
}
- public boolean SecurityDomainLoginPanel() throws UnsupportedEncodingException {
+ public boolean SecurityDomainLoginPanel() throws Exception {
String tps_url = "https://" + cs_hostname + ":" + cs_port +
"/tps/admin/console/config/wizard" +
"?p=3&subsystem=TPS";
@@ -269,7 +268,7 @@ public class ConfigureTPS {
}
- public boolean SubsystemPanel() throws UnsupportedEncodingException {
+ public boolean SubsystemPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -336,7 +335,7 @@ public class ConfigureTPS {
return true;
}
- public boolean LdapAuthConnectionPanel() throws UnsupportedEncodingException {
+ public boolean LdapAuthConnectionPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -361,7 +360,7 @@ public class ConfigureTPS {
return true;
}
- public boolean LdapConnectionPanel() throws UnsupportedEncodingException {
+ public boolean LdapConnectionPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -393,7 +392,7 @@ public class ConfigureTPS {
return true;
}
- public boolean TokenChoicePanel() throws UnsupportedEncodingException {
+ public boolean TokenChoicePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -450,7 +449,7 @@ public class ConfigureTPS {
return true;
}
- public boolean KeyPanel() {
+ public boolean KeyPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -481,7 +480,7 @@ public class ConfigureTPS {
return true;
}
- public boolean CertSubjectPanel() throws UnsupportedEncodingException {
+ public boolean CertSubjectPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -515,7 +514,7 @@ public class ConfigureTPS {
return true;
}
- public boolean CertificatePanel() {
+ public boolean CertificatePanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -540,7 +539,7 @@ public class ConfigureTPS {
return true;
}
- public boolean AdminCertReqPanel() throws UnsupportedEncodingException {
+ public boolean AdminCertReqPanel() throws Exception {
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
ParseXML px = new ParseXML();
@@ -608,7 +607,7 @@ public class ConfigureTPS {
return true;
}
- public boolean AdminCertImportPanel() throws UnsupportedEncodingException {
+ public boolean AdminCertImportPanel() throws Exception {
boolean st = false;
HTTPResponse hr = null;
ByteArrayInputStream bais = null;
@@ -676,7 +675,7 @@ public class ConfigureTPS {
return true;
}
- public boolean ConfigureTPSInstance() throws UnsupportedEncodingException {
+ public boolean ConfigureTPSInstance() throws Exception {
// 0. login to cert db
ComCrypto cCrypt = new ComCrypto(client_certdb_dir,
client_certdb_pwd,
@@ -798,7 +797,7 @@ public class ConfigureTPS {
return true;
}
- public static void main(String args[]) throws UnsupportedEncodingException {
+ public static void main(String args[]) throws Exception {
ConfigureTPS ca = new ConfigureTPS();
// set variables
diff --git a/base/silent/src/com/netscape/pkisilent/http/HTTPClient.java b/base/silent/src/com/netscape/pkisilent/http/HTTPClient.java
index 80335c61f..01ee0f251 100644
--- a/base/silent/src/com/netscape/pkisilent/http/HTTPClient.java
+++ b/base/silent/src/com/netscape/pkisilent/http/HTTPClient.java
@@ -275,10 +275,13 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
// posts the given query data
// returns HTTPResponse
public HTTPResponse sslConnect(String hostname, String portnumber,
- String url, String query) {
+ String url, String query) throws Exception {
- boolean st = true;
- HTTPResponse hr = null;
+ Socket js = null;
+ SSLSocket socket = null;
+ OutputStream rawos = null;
+ BufferedOutputStream os = null;
+ PrintStream ps = null;
try {
@@ -294,8 +297,8 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
SSLClientCertificateSelectionCallback certSelectionCallback =
new TestClientCertificateSelectionCallback();
- Socket js = new Socket(InetAddress.getByName(hostname), port);
- SSLSocket socket = new SSLSocket(js, hostname, approvalCallback,
+ js = new Socket(InetAddress.getByName(hostname), port);
+ socket = new SSLSocket(js, hostname, approvalCallback,
certSelectionCallback);
setCipherPref(socket);
disableSSL2(socket);
@@ -309,9 +312,9 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
"/" + url +
"?" + query);
- OutputStream rawos = socket.getOutputStream();
- BufferedOutputStream os = new BufferedOutputStream(rawos);
- PrintStream ps = new PrintStream(os);
+ rawos = socket.getOutputStream();
+ os = new BufferedOutputStream(rawos);
+ ps = new PrintStream(os);
ps.println("POST " + url + " HTTP/1.0");
@@ -335,37 +338,43 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
ps.flush();
os.flush();
- try {
- hr = readResponse(socket.getInputStream());
- hr.parseContent();
+ HTTPResponse hr = readResponse(socket.getInputStream());
+ hr.parseContent();
- } catch (Exception e) {
- System.out.println("Exception");
- e.printStackTrace();
- st = false;
- }
-
- socket.close();
- os.close();
- rawos.close();
- ps.close();
-
- os = null;
- rawos = null;
- ps = null;
-
- }
+ return hr;
- catch (Exception e) {
+ } catch (Exception e) {
System.err.println("Exception: Unable to Send Request:" + e);
- e.printStackTrace();
- st = false;
- }
+ throw e;
- if (!st)
- return null;
- else
- return hr;
+ } finally {
+ if (ps != null)
+ ps.close();
+ if (os != null)
+ try {
+ os.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (rawos != null)
+ try {
+ rawos.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (socket != null)
+ try {
+ socket.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (js != null)
+ try {
+ js.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
// performs non ssl connect to given host/port
@@ -374,8 +383,11 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
public HTTPResponse nonsslConnect(String hostname, String portnumber,
String url, String query) throws Exception {
- HTTPResponse hr = null;
+ Socket socket = null;
+ OutputStream rawos = null;
+ BufferedOutputStream os = null;
PrintStream ps = null;
+
try {
System.out.println("#############################################");
@@ -385,7 +397,7 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
Integer x = new Integer(portnumber);
int port = x.intValue();
- Socket socket = new Socket(hostname, port);
+ socket = new Socket(hostname, port);
System.out.println("Posting Query = " +
"http://" + hostname +
@@ -393,8 +405,8 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
"/" + url +
"?" + query);
- OutputStream rawos = socket.getOutputStream();
- BufferedOutputStream os = new BufferedOutputStream(rawos);
+ rawos = socket.getOutputStream();
+ os = new BufferedOutputStream(rawos);
ps = new PrintStream(os);
System.out.println("Connected.");
@@ -421,21 +433,37 @@ public class HTTPClient implements SSLCertificateApprovalCallback {
ps.flush();
os.flush();
- hr = readResponse(socket.getInputStream());
- hr.parseContent();
+ HTTPResponse hr = readResponse(socket.getInputStream());
+ hr.parseContent();
+
+ return hr;
} catch (Exception e) {
System.err.println("Exception: Unable to Send Request:" + e);
- e.printStackTrace();
throw e;
+
} finally {
- if (ps != null) {
+ if (ps != null)
ps.close();
- ps = null;
- }
+ if (os != null)
+ try {
+ os.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (rawos != null)
+ try {
+ rawos.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (socket != null)
+ try {
+ socket.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
- return hr;
}
public HTTPResponse readResponse(InputStream inputStream)