summaryrefslogtreecommitdiffstats
path: root/pki
diff options
context:
space:
mode:
authorJack Magne <jmagne@redhat.com>2012-01-13 16:57:06 -0800
committerJack Magne <jmagne@redhat.com>2012-01-13 16:57:06 -0800
commit0491736b2570447391835bc2e5282d809f0de4f1 (patch)
tree63bba7b989327317831c452c495b5b8e667c2e20 /pki
parente7ffc2b51be1e0826f93889896e3601b5f1d3f57 (diff)
downloadpki-0491736b2570447391835bc2e5282d809f0de4f1.tar.gz
pki-0491736b2570447391835bc2e5282d809f0de4f1.tar.xz
pki-0491736b2570447391835bc2e5282d809f0de4f1.zip
Big numbers fix for CA and DRM.
This patch resolves multiple issues related to use of big numbers on CA and DRM It also provides a fix for incomplete recovery requests causing null pointer exception. Bugs: 756133, 758505. Complete formatting changes for QueryRec.java.
Diffstat (limited to 'pki')
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java16
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java5
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java4
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java4
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/cert/GetCertFromRequest.java3
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/ConfirmRecoverBySerial.java12
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerial.java10
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerialForRecovery.java10
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/KeyRecordParser.java5
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/key/RecoverBySerial.java8
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/CheckRequest.java3
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/ProcessCertReq.java23
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/ProcessReq.java18
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/QueryReq.java70
-rw-r--r--pki/base/common/src/com/netscape/cms/servlet/request/ReqParser.java5
15 files changed, 98 insertions, 98 deletions
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java b/pki/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java
index 4c11d477d..97a70fac3 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/cert/DoRevoke.java
@@ -24,6 +24,7 @@ import java.util.Date;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Vector;
+import java.math.BigInteger;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -1161,31 +1162,28 @@ public class DoRevoke extends CMSServlet {
// find out if the value is hex or decimal
- int value = -1;
+ BigInteger value = BigInteger.ONE.negate();
//try int
try {
- value = Integer.parseInt(serialNumber, 10);
+ value = new BigInteger(serialNumber, 10);
} catch (NumberFormatException e) {
}
//try hex
- if (value == -1) {
+ if (value.compareTo(BigInteger.ONE.negate()) == 0) {
try {
- value = Integer.parseInt(serialNumber, 16);
-
+ value = new BigInteger(serialNumber, 16);
} catch (NumberFormatException e) {
}
}
// give up if it isn't hex or dec
- if (value == -1) {
+ if (value.compareTo(BigInteger.ONE.negate()) == 0) {
throw new NumberFormatException();
}
// convert it to hexadecimal
- serialNumber = "0x"
- + Integer.toHexString(
- value);
+ serialNumber = "0x" + value.toString(16);
} else {
serialNumber = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java b/pki/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java
index f17e576d6..075f3218b 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/cert/DoRevokeTPS.java
@@ -23,6 +23,7 @@ import java.util.Date;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Vector;
+import java.math.BigInteger;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -917,9 +918,7 @@ public class DoRevokeTPS extends CMSServlet {
serialNumber = eeSerialNumber.trim();
// convert it to hexadecimal
- serialNumber = "0x"
- + Integer.toHexString(
- Integer.valueOf(serialNumber).intValue());
+ serialNumber = "0x" + (new BigInteger(serialNumber)).toString(16);
} else {
serialNumber = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java b/pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java
index 656d36f85..edf04b1ba 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevoke.java
@@ -662,9 +662,7 @@ public class DoUnrevoke extends CMSServlet {
serialNumber = eeSerialNumber.trim();
// convert it to hexadecimal
- serialNumber = "0x"
- + Integer.toHexString(
- Integer.valueOf(serialNumber).intValue());
+ serialNumber = "0x" + (new BigInteger(serialNumber)).toString(16);
} else {
serialNumber = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java b/pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java
index 3af743a95..edc406137 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/cert/DoUnrevokeTPS.java
@@ -615,9 +615,7 @@ public class DoUnrevokeTPS extends CMSServlet {
serialNumber = eeSerialNumber.trim();
// convert it to hexadecimal
- serialNumber = "0x"
- + Integer.toHexString(
- Integer.valueOf(serialNumber).intValue());
+ serialNumber = "0x" + (new BigInteger(serialNumber)).toString(16);
} else {
serialNumber = ILogger.SIGNED_AUDIT_EMPTY_VALUE;
}
diff --git a/pki/base/common/src/com/netscape/cms/servlet/cert/GetCertFromRequest.java b/pki/base/common/src/com/netscape/cms/servlet/cert/GetCertFromRequest.java
index 67481e7df..71b0004cd 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/cert/GetCertFromRequest.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/cert/GetCertFromRequest.java
@@ -19,6 +19,7 @@ package com.netscape.cms.servlet.cert;
import java.io.IOException;
import java.util.Locale;
+import java.math.BigInteger;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -169,7 +170,7 @@ public class GetCertFromRequest extends CMSServlet {
}
// check if request Id is valid.
try {
- Integer.parseInt(requestId);
+ new BigInteger(requestId);
} catch (NumberFormatException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSGW_INVALID_REQ_ID_FORMAT", requestId));
throw new EBaseException(
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/ConfirmRecoverBySerial.java b/pki/base/common/src/com/netscape/cms/servlet/key/ConfirmRecoverBySerial.java
index d7c3ffaef..15e73179e 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/key/ConfirmRecoverBySerial.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/ConfirmRecoverBySerial.java
@@ -130,12 +130,11 @@ public class ConfirmRecoverBySerial extends CMSServlet {
IArgBlock fixed = CMS.createArgBlock();
CMSTemplateParams argSet = new CMSTemplateParams(header, fixed);
- int seqNum = -1;
+ BigInteger seqNum = BigInteger.ZERO;
try {
if (req.getParameter(IN_SERIALNO) != null) {
- seqNum = Integer.parseInt(
- req.getParameter(IN_SERIALNO));
+ seqNum = new BigInteger(req.getParameter(IN_SERIALNO));
}
// make sure this page, which contains password
@@ -167,11 +166,11 @@ public class ConfirmRecoverBySerial extends CMSServlet {
* Requests for a list of agent passwords.
*/
private void process(CMSTemplateParams argSet,
- IArgBlock header, int seq,
+ IArgBlock header, BigInteger seq,
HttpServletRequest req, HttpServletResponse resp,
Locale locale) {
try {
- header.addIntegerValue(OUT_SERIALNO, seq);
+ header.addBigIntegerValue(OUT_SERIALNO, seq, 10);
header.addIntegerValue(OUT_M,
mRecoveryService.getNoOfRequiredAgents());
header.addStringValue(OUT_OP,
@@ -179,8 +178,7 @@ public class ConfirmRecoverBySerial extends CMSServlet {
header.addStringValue(OUT_SERVICE_URL,
req.getRequestURI());
- IKeyRecord rec = (IKeyRecord) mKeyDB.readKeyRecord(new BigInteger(
- Integer.toString(seq)));
+ IKeyRecord rec = (IKeyRecord) mKeyDB.readKeyRecord(seq);
KeyRecordParser.fillRecordIntoArg(rec, header);
} catch (EBaseException e) {
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerial.java b/pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerial.java
index a3490d893..8876d9350 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerial.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerial.java
@@ -147,12 +147,11 @@ public class DisplayBySerial extends CMSServlet {
IArgBlock header = CMS.createArgBlock();
IArgBlock fixed = CMS.createArgBlock();
CMSTemplateParams argSet = new CMSTemplateParams(header, fixed);
- int seqNum = -1;
+ BigInteger seqNum = BigInteger.ZERO;
try {
if (req.getParameter(IN_SERIALNO) != null) {
- seqNum = Integer.parseInt(
- req.getParameter(IN_SERIALNO));
+ seqNum = new BigInteger(req.getParameter(IN_SERIALNO));
}
process(argSet, header, seqNum, req, resp, locale[0]);
} catch (NumberFormatException e) {
@@ -177,7 +176,7 @@ public class DisplayBySerial extends CMSServlet {
* Display information about a particular key.
*/
private void process(CMSTemplateParams argSet,
- IArgBlock header, int seq,
+ IArgBlock header, BigInteger seq,
HttpServletRequest req, HttpServletResponse resp,
Locale locale) {
try {
@@ -185,8 +184,7 @@ public class DisplayBySerial extends CMSServlet {
req.getParameter(OUT_OP));
header.addStringValue(OUT_SERVICE_URL,
req.getRequestURI());
- IKeyRecord rec = (IKeyRecord) mKeyDB.readKeyRecord(new
- BigInteger(Integer.toString(seq)));
+ IKeyRecord rec = (IKeyRecord) mKeyDB.readKeyRecord(seq);
KeyRecordParser.fillRecordIntoArg(rec, header);
} catch (EBaseException e) {
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerialForRecovery.java b/pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerialForRecovery.java
index 1ef0ba40b..29cc2b3b3 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerialForRecovery.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/DisplayBySerialForRecovery.java
@@ -150,12 +150,11 @@ public class DisplayBySerialForRecovery extends CMSServlet {
IArgBlock fixed = CMS.createArgBlock();
CMSTemplateParams argSet = new CMSTemplateParams(header, fixed);
- int seqNum = -1;
+ BigInteger seqNum = BigInteger.ZERO;
try {
if (req.getParameter(IN_SERIALNO) != null) {
- seqNum = Integer.parseInt(
- req.getParameter(IN_SERIALNO));
+ seqNum = new BigInteger(req.getParameter(IN_SERIALNO));
}
process(argSet, header,
req.getParameter("publicKeyData"),
@@ -185,7 +184,7 @@ public class DisplayBySerialForRecovery extends CMSServlet {
* Display information about a particular key.
*/
private synchronized void process(CMSTemplateParams argSet,
- IArgBlock header, String publicKeyData, int seq,
+ IArgBlock header, String publicKeyData, BigInteger seq,
HttpServletRequest req, HttpServletResponse resp,
Locale locale) {
try {
@@ -201,8 +200,7 @@ public class DisplayBySerialForRecovery extends CMSServlet {
header.addStringValue("publicKeyData",
publicKeyData);
}
- IKeyRecord rec = (IKeyRecord) mKeyDB.readKeyRecord(new
- BigInteger(Integer.toString(seq)));
+ IKeyRecord rec = (IKeyRecord) mKeyDB.readKeyRecord(seq);
KeyRecordParser.fillRecordIntoArg(rec, header);
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/KeyRecordParser.java b/pki/base/common/src/com/netscape/cms/servlet/key/KeyRecordParser.java
index 1171236b8..d6bc57fcf 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/key/KeyRecordParser.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/KeyRecordParser.java
@@ -17,6 +17,7 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.servlet.key;
+import java.math.BigInteger;
import java.util.Date;
import com.netscape.certsrv.apps.CMS;
@@ -54,8 +55,8 @@ public class KeyRecordParser {
rec.getState().toString());
rarg.addStringValue(OUT_OWNER_NAME,
rec.getOwnerName());
- rarg.addIntegerValue(OUT_SERIALNO,
- rec.getSerialNumber().intValue());
+ rarg.addBigIntegerValue(OUT_SERIALNO,
+ rec.getSerialNumber(), 10);
rarg.addStringValue(OUT_KEY_ALGORITHM,
rec.getAlgorithm());
// Possible Enhancement: sun's BASE64Encode is not
diff --git a/pki/base/common/src/com/netscape/cms/servlet/key/RecoverBySerial.java b/pki/base/common/src/com/netscape/cms/servlet/key/RecoverBySerial.java
index 8abafa155..6bb013b1c 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/key/RecoverBySerial.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/key/RecoverBySerial.java
@@ -271,7 +271,7 @@ public class RecoverBySerial extends CMSServlet {
}
X509CertImpl x509cert = null;
- if (cert == null) {
+ if (cert == null || cert.trim().length() == 0) {
header.addStringValue(OUT_ERROR, "certificate not found");
return;
} else {
@@ -335,7 +335,7 @@ public class RecoverBySerial extends CMSServlet {
}
X509CertImpl x509cert = null;
- if (cert == null) {
+ if (cert == null || cert.trim().length() == 0) {
// perform recovery
header.addStringValue(OUT_ERROR, "certificate not found");
return null;
@@ -407,8 +407,8 @@ public class RecoverBySerial extends CMSServlet {
header.addStringValue(OUT_OP,
req.getParameter(OUT_OP));
- header.addIntegerValue(OUT_SERIALNO,
- Integer.parseInt(seq));
+ header.addBigIntegerValue(OUT_SERIALNO,
+ new BigInteger(seq), 10);
header.addStringValue(OUT_SERVICE_URL,
req.getRequestURI());
byte pkcs12[] = mService.doKeyRecovery(
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/CheckRequest.java b/pki/base/common/src/com/netscape/cms/servlet/request/CheckRequest.java
index b53413dcf..b0a70ffc1 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/request/CheckRequest.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/CheckRequest.java
@@ -27,6 +27,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.Locale;
import java.util.StringTokenizer;
+import java.math.BigInteger;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -279,7 +280,7 @@ public class CheckRequest extends CMSServlet {
throw new ECMSGWException(CMS.getUserMessage("CMS_GW_NO_REQUEST_ID_PROVIDED"));
}
try {
- Integer.parseInt(requestId);
+ new BigInteger(requestId);
} catch (NumberFormatException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("BASE_INVALID_NUMBER_FORMAT_1", requestId));
throw new EBaseException(
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/ProcessCertReq.java b/pki/base/common/src/com/netscape/cms/servlet/request/ProcessCertReq.java
index 6e782f5ab..cbed8ae6b 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/request/ProcessCertReq.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/ProcessCertReq.java
@@ -18,6 +18,7 @@
package com.netscape.cms.servlet.request;
import java.io.IOException;
+import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
@@ -263,7 +264,7 @@ public class ProcessCertReq extends CMSServlet {
String signatureAlgorithm = null;
long notValidBefore = 0;
long notValidAfter = 0;
- int seqNum = -1;
+ BigInteger seqNum = BigInteger.ONE.negate();
EBaseException error = null;
HttpServletRequest req = cmsReq.getHttpReq();
@@ -289,7 +290,7 @@ public class ProcessCertReq extends CMSServlet {
if (req.getParameter(SEQNUM) != null) {
CMS.debug(
"ProcessCertReq: parameter seqNum " + req.getParameter(SEQNUM));
- seqNum = Integer.parseInt(req.getParameter(SEQNUM));
+ seqNum = new BigInteger(req.getParameter(SEQNUM));
}
String notValidBeforeStr = req.getParameter("notValidBefore");
@@ -311,20 +312,19 @@ public class ProcessCertReq extends CMSServlet {
IRequest r = null;
- if (seqNum > -1) {
- r = mQueue.findRequest(new RequestId(
- Integer.toString(seqNum)));
+ if (seqNum.compareTo(BigInteger.ONE.negate()) > 0) {
+ r = mQueue.findRequest(new RequestId(seqNum.toString()));
}
- if (seqNum > -1 && r != null) {
+ if (seqNum.compareTo(BigInteger.ONE.negate()) > 0 && r != null) {
processX509(cmsReq, argSet, header, seqNum, req, resp,
toDo, signatureAlgorithm, subject,
notValidBefore, notValidAfter, locale[0], startTime);
} else {
- log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSGW_INVALID_REQUEST_ID_1", String.valueOf(seqNum)));
+ log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSGW_INVALID_REQUEST_ID_1", seqNum.toString()));
error = new ECMSGWException(
CMS.getUserMessage("CMS_GW_INVALID_REQUEST_ID",
- String.valueOf(seqNum)));
+ seqNum.toString()));
}
} catch (EBaseException e) {
error = e;
@@ -399,7 +399,7 @@ public class ProcessCertReq extends CMSServlet {
*/
private void processX509(CMSRequest cmsReq,
CMSTemplateParams argSet, IArgBlock header,
- int seqNum, HttpServletRequest req,
+ BigInteger seqNum, HttpServletRequest req,
HttpServletResponse resp,
String toDo, String signatureAlgorithm,
String subject,
@@ -423,8 +423,7 @@ public class ProcessCertReq extends CMSServlet {
}
try {
- IRequest r = mQueue.findRequest(new RequestId(
- Integer.toString(seqNum)));
+ IRequest r = mQueue.findRequest(new RequestId(seqNum.toString()));
if (r != null) {
// overwrite "auditRequesterID" if and only if "id" != null
@@ -1264,7 +1263,7 @@ public class ProcessCertReq extends CMSServlet {
if (CMS.getSubsystem("ra") != null)
header.addStringValue("localra", "yes");
- header.addIntegerValue("seqNum", seqNum);
+ header.addBigIntegerValue("seqNum", seqNum, 10);
mParser.fillRequestIntoArg(locale, r, argSet, header);
String rid = r.getExtDataInString(IRequest.REMOTE_REQID);
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/ProcessReq.java b/pki/base/common/src/com/netscape/cms/servlet/request/ProcessReq.java
index 78f047d2c..93457a281 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/request/ProcessReq.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/ProcessReq.java
@@ -19,6 +19,7 @@ package com.netscape.cms.servlet.request;
import java.io.IOException;
import java.util.Locale;
+import java.math.BigInteger;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -130,7 +131,7 @@ public class ProcessReq extends CMSServlet {
* @param cmsReq the object holding the request and response information
*/
public void process(CMSRequest cmsReq) throws EBaseException {
- int seqNum = -1;
+ BigInteger seqNum = BigInteger.ONE.negate();
HttpServletRequest req = cmsReq.getHttpReq();
HttpServletResponse resp = cmsReq.getHttpResp();
@@ -158,11 +159,11 @@ public class ProcessReq extends CMSServlet {
try {
if (req.getParameter(SEQNUM) != null) {
- seqNum = Integer.parseInt(req.getParameter(SEQNUM));
+ seqNum = new BigInteger(req.getParameter(SEQNUM));
}
doAssign = req.getParameter(DO_ASSIGN);
- if (seqNum > -1) {
+ if (seqNum.compareTo(BigInteger.ONE.negate()) > 0) {
// start authorization
AuthzToken authzToken = null;
@@ -237,15 +238,14 @@ public class ProcessReq extends CMSServlet {
* returns whether there was an error or not.
*/
private void process(CMSTemplateParams argSet, IArgBlock header,
- int seqNum, HttpServletRequest req,
+ BigInteger seqNum, HttpServletRequest req,
HttpServletResponse resp,
String doAssign, Locale locale)
throws EBaseException {
- header.addIntegerValue("seqNum", seqNum);
+ header.addBigIntegerValue("seqNum", seqNum, 10);
- IRequest r =
- mQueue.findRequest(new RequestId(Integer.toString(seqNum)));
+ IRequest r = mQueue.findRequest(new RequestId(seqNum.toString()));
if (r != null) {
if (doAssign != null) {
@@ -324,10 +324,10 @@ public class ProcessReq extends CMSServlet {
mParser.fillRequestIntoArg(locale, r, argSet, header);
} else {
- log(ILogger.LL_FAILURE, "Invalid sequence number " + seqNum);
+ log(ILogger.LL_FAILURE, "Invalid sequence number " + seqNum.toString());
throw new ECMSGWException(
CMS.getUserMessage("CMS_GW_INVALID_REQUEST_ID",
- String.valueOf(seqNum)));
+ seqNum.toString()));
}
return;
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/QueryReq.java b/pki/base/common/src/com/netscape/cms/servlet/request/QueryReq.java
index 3cb270466..8ec82d0a4 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/request/QueryReq.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/QueryReq.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Vector;
+import java.math.BigInteger;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -291,7 +292,8 @@ public class QueryReq extends CMSServlet {
direction = req.getParameter("direction").trim();
}
- int top = 0, bottom = 0;
+ BigInteger top = BigInteger.ZERO;
+ BigInteger bottom = BigInteger.ZERO;
try {
String top_s = req.getParameter(OUT_FIRST_ENTRY_ON_PAGE);
@@ -303,14 +305,14 @@ public class QueryReq extends CMSServlet {
bottom_s = "0";
if (top_s.trim().startsWith("0x")) {
- top = Integer.parseInt(top_s.trim().substring(2), 16);
+ top = new BigInteger(top_s.trim().substring(2), 16);
} else {
- top = Integer.parseInt(top_s.trim());
+ top = new BigInteger(top_s.trim());
}
if (bottom_s.trim().startsWith("0x")) {
- bottom = Integer.parseInt(bottom_s.trim().substring(2), 16);
+ bottom = new BigInteger(bottom_s.trim().substring(2), 16);
} else {
- bottom = Integer.parseInt(bottom_s.trim());
+ bottom = new BigInteger(bottom_s.trim());
}
} catch (NumberFormatException e) {
@@ -362,18 +364,19 @@ public class QueryReq extends CMSServlet {
*/
private CMSTemplateParams doSearch(Locale l, String filter,
- int count, String direction, int top, int bottom) {
+ int count, String direction, BigInteger top, BigInteger bottom) {
CMSTemplateParams ctp = null;
if (direction.equals("previous")) {
- ctp = doSearch(l, filter, -count, top - 1);
+ ctp = doSearch(l, filter, -count, top);
} else if (direction.equals("next")) {
- ctp = doSearch(l, filter, count, bottom + 1);
+ bottom = bottom.add(BigInteger.ONE);
+ ctp = doSearch(l, filter, count, bottom);
} else if (direction.equals("begin")) {
- ctp = doSearch(l, filter, count, 0);
+ ctp = doSearch(l, filter, count, BigInteger.ZERO);
} else if (direction.equals("first")) {
ctp = doSearch(l, filter, count, bottom);
} else { // if 'direction is 'end', default here
- ctp = doSearch(l, filter, -count, -1);
+ ctp = doSearch(l, filter, -count, BigInteger.ONE.negate());
}
return ctp;
}
@@ -391,7 +394,7 @@ public class QueryReq extends CMSServlet {
Locale locale,
String filter,
int count,
- int marker) {
+ BigInteger marker) {
IArgBlock header = CMS.createArgBlock();
IArgBlock context = CMS.createArgBlock();
@@ -406,32 +409,41 @@ public class QueryReq extends CMSServlet {
header.addStringValue(OUT_REQUESTING_USER, "admin");
boolean jumptoend = false;
- if (marker == -1) {
- marker = 0; // I think this is inconsequential
+ if (marker.toString().equals("-1")) {
+ marker = BigInteger.ZERO; // I think this is inconsequential
jumptoend = true; // override to '99' during search
}
- RequestId id = new RequestId(Integer.toString(marker));
+ RequestId id = new RequestId(marker.toString());
IRequestVirtualList list = mQueue.getPagedRequestsByFilter(
id,
jumptoend,
filter,
- count + 1,
+ ((count < 0) ? count - 1 : count + 1),
"requestId");
- int totalCount = list.getSize() - list.getCurrentIndex();
+ int maxCount = 0;
+ if (count < 0 && jumptoend) {
+ maxCount = -count;
+ } else if (count < 0) {
+ maxCount = -count + 1;
+ } else {
+ maxCount = count;
+ }
+ int totalCount = (jumptoend) ? maxCount :
+ (list.getSize() - list.getCurrentIndex());
header.addIntegerValue(OUT_TOTALCOUNT, totalCount);
header.addIntegerValue(OUT_CURRENTCOUNT, list.getSize());
int numEntries = list.getSize() - list.getCurrentIndex();
- Vector v = fetchRecords(list, Math.abs(count));
+ Vector v = fetchRecords(list, maxCount);
v = normalizeOrder(v);
trim(v, id);
int currentCount = 0;
- int curNum = 0;
- int firstNum = -1;
+ BigInteger curNum = BigInteger.ZERO;
+ BigInteger firstNum = BigInteger.ONE.negate();
Enumeration requests = v.elements();
while (requests.hasMoreElements()) {
@@ -447,10 +459,9 @@ public class QueryReq extends CMSServlet {
continue;
}
- curNum = Integer.parseInt(
- request.getRequestId().toString());
+ curNum = new BigInteger(request.getRequestId().toString());
- if (firstNum == -1) {
+ if (firstNum.equals(BigInteger.ONE.negate())) {
firstNum = curNum;
}
@@ -466,15 +477,14 @@ public class QueryReq extends CMSServlet {
header.addIntegerValue(OUT_CURRENTCOUNT, currentCount);
header.addStringValue("time", Long.toString(endTime - startTime));
- header.addIntegerValue(OUT_FIRST_ENTRY_ON_PAGE, firstNum);
- header.addIntegerValue(OUT_LAST_ENTRY_ON_PAGE, curNum);
+ header.addBigIntegerValue(OUT_FIRST_ENTRY_ON_PAGE, firstNum, 10);
+ header.addBigIntegerValue(OUT_LAST_ENTRY_ON_PAGE, curNum, 10);
} catch (EBaseException e) {
header.addStringValue(OUT_ERROR, e.toString(locale));
} catch (Exception e) {
}
return argset;
-
}
/**
@@ -485,10 +495,10 @@ public class QueryReq extends CMSServlet {
*/
private void trim(Vector v, RequestId marker) {
int i = v.size() - 1;
- if (((IRequest) v.elementAt(i)).getRequestId().equals(marker)) {
+ if (((IRequest) v.elementAt(i)).getRequestId().toString().equals(
+ marker.toString())) {
v.remove(i);
}
-
}
/**
@@ -525,12 +535,12 @@ public class QueryReq extends CMSServlet {
*/
private Vector normalizeOrder(Vector list) {
- int firstrequestnum = Integer.parseInt(((IRequest) list.elementAt(0))
+ BigInteger firstrequestnum = new BigInteger(((IRequest) list.elementAt(0))
.getRequestId().toString());
- int lastrequestnum = Integer.parseInt(((IRequest) list.elementAt(list
+ BigInteger lastrequestnum = new BigInteger(((IRequest) list.elementAt(list
.size() - 1)).getRequestId().toString());
boolean reverse = false;
- if (firstrequestnum > lastrequestnum) {
+ if (firstrequestnum.compareTo(lastrequestnum) > 0) {
reverse = true; // if the order is backwards, place items at the beginning
}
Vector v = new Vector();
diff --git a/pki/base/common/src/com/netscape/cms/servlet/request/ReqParser.java b/pki/base/common/src/com/netscape/cms/servlet/request/ReqParser.java
index 00f95ec2d..230ddb433 100644
--- a/pki/base/common/src/com/netscape/cms/servlet/request/ReqParser.java
+++ b/pki/base/common/src/com/netscape/cms/servlet/request/ReqParser.java
@@ -18,6 +18,7 @@
package com.netscape.cms.servlet.request;
import java.util.Locale;
+import java.math.BigInteger;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.IArgBlock;
@@ -51,8 +52,8 @@ public class ReqParser implements IReqParser {
public void fillRequestIntoArg(Locale l, IRequest req, CMSTemplateParams argSet, IArgBlock arg)
throws EBaseException {
arg.addStringValue(TYPE, req.getRequestType());
- arg.addLongValue("seqNum",
- Long.parseLong(req.getRequestId().toString()));
+ arg.addBigIntegerValue("seqNum",
+ new BigInteger(req.getRequestId().toString()), 10);
arg.addStringValue(STATUS,
req.getRequestStatus().toString());
arg.addLongValue(CREATE_ON,