summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-04-22 01:37:37 +0200
committerEndi S. Dewata <edewata@redhat.com>2016-04-26 00:28:48 +0200
commitd3f94840c9ae3c5ed437d382b5795fe773962887 (patch)
treea4e86d93305ff2ebd0817dcbc65ea9cbe33cb45c
parent5ef131f1f3711490576a8f512d822ded43a1f417 (diff)
downloadpki-d3f94840c9ae3c5ed437d382b5795fe773962887.zip
pki-d3f94840c9ae3c5ed437d382b5795fe773962887.tar.gz
pki-d3f94840c9ae3c5ed437d382b5795fe773962887.tar.xz
Added TPSCertRecord.getSerialNumberInBigInteger().
The code that parses the token certificate serial number has been refactored into a new method in TPSCertRecord.
-rw-r--r--base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java27
-rw-r--r--base/tps/src/org/dogtagpki/server/tps/dbs/TPSCertRecord.java13
2 files changed, 22 insertions, 18 deletions
diff --git a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
index 4142bab..dcb3bc1 100644
--- a/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
+++ b/base/tps/src/org/dogtagpki/server/tps/TPSTokendb.java
@@ -509,24 +509,15 @@ public class TPSTokendb {
}
}
- CARemoteRequestHandler caRH = null;
- caRH = new CARemoteRequestHandler(connID);
- String hexSerial = cert.getSerialNumber();
- if (hexSerial.length() >= 3 && hexSerial.startsWith("0x")) {
- String serial = hexSerial.substring(2); // skip over the '0x'
- BigInteger bInt = new BigInteger(serial, 16);
- String serialStr = bInt.toString();
- CMS.debug(method + ": found cert hex serial: " + serial +
- " dec serial:" + serialStr);
- CARevokeCertResponse response =
- caRH.revokeCertificate(isRevoke, serialStr, cert.getCertificate(),
- revokeReason);
- CMS.debug(method + ": response status =" + response.getStatus());
- } else {
- logMsg = "mulformed hex serial number :" + hexSerial;
- CMS.debug(method + ": " + logMsg);
- throw new Exception(logMsg);
- }
+ CARemoteRequestHandler caRH = new CARemoteRequestHandler(connID);
+ BigInteger bInt = cert.getSerialNumberInBigInteger();
+ String serialStr = bInt.toString();
+ CMS.debug(method + ": found cert hex serial: " + cert.getSerialNumber() +
+ " dec serial: " + serialStr);
+ CARevokeCertResponse response =
+ caRH.revokeCertificate(isRevoke, serialStr, cert.getCertificate(),
+ revokeReason);
+ CMS.debug(method + ": response status: " + response.getStatus());
// update certificate status
if (isRevoke) {
diff --git a/base/tps/src/org/dogtagpki/server/tps/dbs/TPSCertRecord.java b/base/tps/src/org/dogtagpki/server/tps/dbs/TPSCertRecord.java
index 288f25f..0f846c6 100644
--- a/base/tps/src/org/dogtagpki/server/tps/dbs/TPSCertRecord.java
+++ b/base/tps/src/org/dogtagpki/server/tps/dbs/TPSCertRecord.java
@@ -18,6 +18,7 @@
package org.dogtagpki.server.tps.dbs;
+import java.math.BigInteger;
import java.util.Date;
import com.netscape.cmscore.dbs.DBAttribute;
@@ -68,6 +69,18 @@ public class TPSCertRecord extends DBRecord {
this.serialNumber = serialNumber;
}
+ public BigInteger getSerialNumberInBigInteger() {
+
+ if (serialNumber == null) return null;
+
+ if (serialNumber.length() < 3 || !serialNumber.startsWith("0x")) {
+ throw new NumberFormatException("Malformed hex serial number: " + serialNumber);
+ }
+
+ String value = serialNumber.substring(2); // skip over the '0x'
+ return new BigInteger(value, 16);
+ }
+
@DBAttribute("tokenSubject")
public String getSubject() {
return subject;