diff options
Diffstat (limited to 'pki/base/silent/src/com/netscape/pkisilent/common/checkRequest.java')
-rw-r--r-- | pki/base/silent/src/com/netscape/pkisilent/common/checkRequest.java | 78 |
1 files changed, 35 insertions, 43 deletions
diff --git a/pki/base/silent/src/com/netscape/pkisilent/common/checkRequest.java b/pki/base/silent/src/com/netscape/pkisilent/common/checkRequest.java index c67689e42..3b06d3d23 100644 --- a/pki/base/silent/src/com/netscape/pkisilent/common/checkRequest.java +++ b/pki/base/silent/src/com/netscape/pkisilent/common/checkRequest.java @@ -1,4 +1,5 @@ package com.netscape.pkisilent.common; + // --- BEGIN COPYRIGHT BLOCK --- // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -17,7 +18,6 @@ package com.netscape.pkisilent.common; // All rights reserved. // --- END COPYRIGHT BLOCK --- - import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileOutputStream; @@ -29,15 +29,12 @@ import java.util.GregorianCalendar; import org.mozilla.jss.ssl.SSLSocket; - - /** * CMS Test framework . - * Submits a checkRequestStatus request to the server. parses the response from server and can import cert to the specified client database. - *<P> + * Submits a checkRequestStatus request to the server. parses the response from server and can import cert to the specified client database. + * <P> */ - public class checkRequest extends TestClient { private int i; @@ -62,27 +59,26 @@ public class checkRequest extends TestClient { /** * Constructor . Takes the parameter for Properties file name * <p> - * @param propfilename name of the parameter file + * + * @param propfilename name of the parameter file */ - public checkRequest(String pfile) { propfileName = pfile; } /** - * Constructor . Takes the parameter for hostname and EESSLportnumber + * Constructor . Takes the parameter for hostname and EESSLportnumber * <p> */ public checkRequest(String h, String p) { host = h; ports = p; - } - ; + }; /** - * Constructor . Takes the parameter for hostname , EESSLportnumber , Requestnumber and ImportCert ( true/false) + * Constructor . Takes the parameter for hostname , EESSLportnumber , Requestnumber and ImportCert ( true/false) * <p> */ @@ -94,11 +90,10 @@ public class checkRequest extends TestClient { } /** - * Constructor . Takes the parameter for hostname , EESSLportnumber , certdbdir, certdbpassword, Requestnumber ,certnickname and ImportCert ( true/false) + * Constructor . Takes the parameter for hostname , EESSLportnumber , certdbdir, certdbpassword, Requestnumber ,certnickname and ImportCert ( true/false) * <p> */ - public checkRequest(String hs, String pt, String certdir, String certtokenpwd, String seqnum, String nickname, String impc) { host = hs; ports = pt; @@ -154,11 +149,10 @@ public class checkRequest extends TestClient { } /** - * returns the hex serial number of the certificate + * returns the hex serial number of the certificate **/ - - public String getSerialNumberHex() { + public String getSerialNumberHex() { return serialNumber; } @@ -166,7 +160,7 @@ public class checkRequest extends TestClient { * returns the serial number as interger **/ - public int getSerialNumber() { + public int getSerialNumber() { if (serialNumber != null) { Integer y = new Integer(Integer.parseInt(serialNumber, 16)); @@ -189,9 +183,9 @@ public class checkRequest extends TestClient { cCrypt.setTokenPWD(tokenpwd); cCrypt.setDebug(debug); - if (!cCrypt.loginDB()) { - System.out.println("Error : Login certdb failed "); - System.err.println("FAIL : Login certdb failed "); + if (!cCrypt.loginDB()) { + System.out.println("Error : Login certdb failed "); + System.err.println("FAIL : Login certdb failed "); return false; } @@ -235,8 +229,6 @@ public class checkRequest extends TestClient { return false; } - - // Private functions private void setElapsedTime(long dif) { @@ -271,12 +263,12 @@ public class checkRequest extends TestClient { tmp = cCrypt.normalizeForLDAP(getCert()); if (debug) { System.out.println(tmp); - } + } fos.write(("usercertificate:: ").getBytes()); fos.write(tmp.getBytes()); fos.close(); } else { - String tmp = cCrypt.normalize(getCert()); + String tmp = cCrypt.normalize(getCert()); if (debug) { System.out.println(tmp); @@ -285,21 +277,21 @@ public class checkRequest extends TestClient { fos.close(); } - + } catch (Exception e) { System.out.println( "exception in writeCert2File: " + e.getMessage()); return false; } - } + } return true; } private boolean importCert(String certpack) { - if (importcert.equals("false")) { + if (importcert.equals("false")) { return true; } @@ -380,8 +372,8 @@ public class checkRequest extends TestClient { boolean st = true; String retriveStr[] = { - "record.base64Cert=", "record.certPrettyPrint=", - "header.certChainBase64 = ", "header.certPrettyPrint = "}; + "record.base64Cert=", "record.certPrettyPrint=", + "header.certChainBase64 = ", "header.certPrettyPrint = " }; String baseCertStr, certPrettyprintStr; if (AUTH.equals("ra")) { @@ -391,19 +383,19 @@ public class checkRequest extends TestClient { baseCertStr = retriveStr[2]; certPrettyprintStr = retriveStr[3]; } - + if (line.indexOf(baseCertStr) != -1) { // if status is complete retrieve cert baseCert = line.substring(baseCertStr.length() + 1, line.indexOf(";", 10) - 1); if (importcert.equals("true")) { - if (importCert(baseCert)) { + if (importCert(baseCert)) { st = true; } } else { st = true; - } + } } if (line.indexOf(certPrettyprintStr) != -1) { @@ -475,9 +467,9 @@ public class checkRequest extends TestClient { while ((line = stdin.readLine()) != null) { switch (type) { - case 1: + case 1: RetrieveRequestDetail(line); - st = true; + st = true; break; case 2: @@ -488,7 +480,7 @@ public class checkRequest extends TestClient { System.out.println("invalid format"); } - + } stdin.close(); socket.close(); @@ -517,9 +509,9 @@ public class checkRequest extends TestClient { if (debug) { System.out.println(serialNumber); } - + return st; - + } private void buildquery() { @@ -527,7 +519,7 @@ public class checkRequest extends TestClient { StringBuffer queryStrBuf = new StringBuffer(); if (type == 1) { - ACTION_STRING = "/checkRequest"; + ACTION_STRING = "/checkRequest"; queryStrBuf.append("requestId="); queryStrBuf.append(requestId); queryStrBuf.append("&importCert=true"); @@ -592,23 +584,23 @@ public class checkRequest extends TestClient { } // Enroll using a pkscks10 request - return(checkRequestStatus()); + return (checkRequestStatus()); } public static void main(String args[]) { // Exit Status - (0) for error/Fail // - requestId Pass boolean st; - + if (args.length < 1) { System.out.println("Usage : propertiesfile"); System.exit(0); - } + } checkRequest t = new checkRequest(args[0]); st = t.readProperties(); - if (st) { + if (st) { System.exit(t.getSerialNumber()); } else { |