From 8229af74c356984f8b50ec0403ffa6de3e35d6e3 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Wed, 23 May 2012 14:14:38 -0500
Subject: [PATCH] Added cert revocation REST service.

The cert revocation REST service is based on DoRevoke and DoUnrevoke
servlets. It provides an interface to manage certificate revocation.

Ticket #161
---
 .../netscape/cms/servlet/test/CARestClient.java    |    2 +-
 .../src/com/netscape/cms/servlet/test/CATest.java  |   12 +-
 base/common/src/CMakeLists.txt                     |    3 +
 .../netscape/certsrv/dbs/certdb/CertIdAdapter.java |    7 +-
 .../netscape/certsrv/dbs/keydb/KeyIdAdapter.java   |    7 +-
 .../netscape/certsrv/request/RequestIdAdapter.java |    7 +-
 .../com/netscape/certsrv/user/UserCertData.java    |   15 +-
 .../KeyIdAdapter.java => util/DateAdapter.java}    |   19 +-
 .../netscape/cms/client/user/UserAddCertCLI.java   |    2 +-
 .../src/com/netscape/cms/client/user/UserCLI.java  |   26 +-
 .../netscape/cms/client/user/UserFindCertCLI.java  |    2 +-
 .../netscape/cms/client/user/UserShowCertCLI.java  |    8 +-
 .../cms/servlet/admin/UserCertResourceService.java |    5 +-
 .../cms/servlet/base/CMSResourceService.java       |    4 +-
 .../netscape/cms/servlet/cert/CertResource.java    |   17 +-
 .../cms/servlet/cert/CertResourceService.java      |  637 +++++++++++++++++++-
 .../cms/servlet/cert/CertsResourceService.java     |   15 +-
 .../netscape/cms/servlet/cert/model/CertDAO.java   |  134 ++---
 .../cms/servlet/cert/model/CertDataInfo.java       |  152 ++++-
 .../cms/servlet/cert/model/CertRevokeRequest.java  |  228 +++++++
 .../servlet/cert/model/CertUnrevokeRequest.java    |  124 ++++
 .../cms/servlet/cert/model/CertificateData.java    |  252 ++++++--
 .../netscape/cms/servlet/test/DRMRestClient.java   |    2 +-
 .../src/com/netscape/cmsutil/ldap/LDAPUtil.java    |    4 +-
 24 files changed, 1472 insertions(+), 212 deletions(-)
 copy base/common/src/com/netscape/certsrv/{dbs/keydb/KeyIdAdapter.java => util/DateAdapter.java} (64%)
 create mode 100644 base/common/src/com/netscape/cms/servlet/cert/model/CertRevokeRequest.java
 create mode 100644 base/common/src/com/netscape/cms/servlet/cert/model/CertUnrevokeRequest.java

diff --git a/base/ca/functional/src/com/netscape/cms/servlet/test/CARestClient.java b/base/ca/functional/src/com/netscape/cms/servlet/test/CARestClient.java
index 775c3d9b69b2bdbbf53c35ed9785705dfcad39a6..076d60d58c420b5429b51d53ed6d749420b93e07 100644
--- a/base/ca/functional/src/com/netscape/cms/servlet/test/CARestClient.java
+++ b/base/ca/functional/src/com/netscape/cms/servlet/test/CARestClient.java
@@ -100,7 +100,7 @@ public class CARestClient extends CMSRestClient {
             return null;
         }
 
-        return certClient.retrieveCert(id);
+        return certClient.getCert(id);
 
     }
 
diff --git a/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java b/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java
index c3d55527ca030dc14049a5f1bed683690d20cd58..00559dd3f324401f2d1a37d1574021b835aae25d 100644
--- a/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java
+++ b/base/ca/functional/src/com/netscape/cms/servlet/test/CATest.java
@@ -404,8 +404,8 @@ public class CATest {
             log("No CertInfo: ");
             return;
         }
-        log("CertId: " + info.getCertId().toString());
-        log("CertUrl: " + info.getCertURL());
+        log("CertId: " + info.getID().toString());
+        log("CertUrl: " + info.getLink().getHref());
 
     }
 
@@ -419,12 +419,12 @@ public class CATest {
         log("CertificateInfo: " + "\n");
         log("-----------------");
 
-        log("CertSerialNo:  \n" + info.getSerialNo() + "\n");
-        log("CertSubject:  \n" + info.getSubjectName() + "\n");
-        log("CertIssuer: \n" + info.getIssuerName() + "\n");
+        log("CertSerialNo:  \n" + info.getSerialNumber() + "\n");
+        log("CertSubject:  \n" + info.getSubjectDN() + "\n");
+        log("CertIssuer: \n" + info.getIssuerDN() + "\n");
         log("NotBefore:  \n" + info.getNotBefore() + "\n");
         log("NotAfter: \n" + info.getNotAfter() + "\n");
-        log("CertBase64: \n" + info.getB64() + "\n");
+        log("CertBase64: \n" + info.getEncoded() + "\n");
         log("CertPKCS7Chain: \n" + info.getPkcs7CertChain() + "\n");
         log("CertPrettyPrint: \n" + info.getPrettyPrint());
 
diff --git a/base/common/src/CMakeLists.txt b/base/common/src/CMakeLists.txt
index 7b73a8536c1c282e3491122f148cea456cbc4603..0a6fb8ad3866e2fb3c3e94dc7b14aa63ea819ce9 100644
--- a/base/common/src/CMakeLists.txt
+++ b/base/common/src/CMakeLists.txt
@@ -191,6 +191,7 @@ set(pki-certsrv_java_SRCS
     com/netscape/certsrv/publish/ERulePluginNotFound.java
     com/netscape/certsrv/publish/MapperProxy.java
     com/netscape/certsrv/publish/ILdapCrlMapper.java
+    com/netscape/certsrv/util/DateAdapter.java
     com/netscape/certsrv/util/IStatsSubsystem.java
     com/netscape/certsrv/util/HttpInput.java
     com/netscape/certsrv/util/StatsEvent.java
@@ -618,7 +619,9 @@ set(pki-cms_java_SRCS
     com/netscape/cms/servlet/cert/model/CertDAO.java
     com/netscape/cms/servlet/cert/model/CertDataInfo.java
     com/netscape/cms/servlet/cert/model/CertDataInfos.java
+    com/netscape/cms/servlet/cert/model/CertRevokeRequest.java
     com/netscape/cms/servlet/cert/model/CertSearchData.java
+    com/netscape/cms/servlet/cert/model/CertUnrevokeRequest.java
     com/netscape/cms/servlet/admin/OCSPAdminServlet.java
     com/netscape/cms/servlet/admin/CMSAdminServlet.java
     com/netscape/cms/servlet/admin/JobsAdminServlet.java
diff --git a/base/common/src/com/netscape/certsrv/dbs/certdb/CertIdAdapter.java b/base/common/src/com/netscape/certsrv/dbs/certdb/CertIdAdapter.java
index cfafff0642a64dfce5a488940bfd0931916bc98a..f6e46cad5079df8c61d59b5d53046f001c5a962c 100644
--- a/base/common/src/com/netscape/certsrv/dbs/certdb/CertIdAdapter.java
+++ b/base/common/src/com/netscape/certsrv/dbs/certdb/CertIdAdapter.java
@@ -19,19 +19,20 @@ package com.netscape.certsrv.dbs.certdb;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 
+import org.apache.commons.lang.StringUtils;
+
 /**
  * The CertIdAdapter class provides custom marshaling for CertId.
  *
  * @author Endi S. Dewata
- * @version $Revision$ $Date$
  */
 public class CertIdAdapter extends XmlAdapter<String, CertId> {
 
     public CertId unmarshal(String value) throws Exception {
-        return new CertId(value);
+        return StringUtils.isEmpty(value) ? null : new CertId(value);
     }
 
     public String marshal(CertId value) throws Exception {
-        return value.toString();
+        return value == null ? null : value.toHexString();
     }
 }
diff --git a/base/common/src/com/netscape/certsrv/dbs/keydb/KeyIdAdapter.java b/base/common/src/com/netscape/certsrv/dbs/keydb/KeyIdAdapter.java
index 3232999fdc3f92693e80170b61a7d1d6d891787c..0f0c43c8238c66decdf74853b6fa41a09d589ee9 100644
--- a/base/common/src/com/netscape/certsrv/dbs/keydb/KeyIdAdapter.java
+++ b/base/common/src/com/netscape/certsrv/dbs/keydb/KeyIdAdapter.java
@@ -19,19 +19,20 @@ package com.netscape.certsrv.dbs.keydb;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 
+import org.apache.commons.lang.StringUtils;
+
 /**
  * The KeyIdAdapter class provides custom marshaling for KeyId.
  *
  * @author Endi S. Dewata
- * @version $Revision$ $Date$
  */
 public class KeyIdAdapter extends XmlAdapter<String, KeyId> {
 
     public KeyId unmarshal(String value) throws Exception {
-        return new KeyId(value);
+        return StringUtils.isEmpty(value) ? null : new KeyId(value);
     }
 
     public String marshal(KeyId value) throws Exception {
-        return value.toString();
+        return value == null ? null : value.toString();
     }
 }
diff --git a/base/common/src/com/netscape/certsrv/request/RequestIdAdapter.java b/base/common/src/com/netscape/certsrv/request/RequestIdAdapter.java
index 1780bc3377b55a9c2be61a5d7337b3f45dac8028..a6051fa8d3e98006d56c7bc3025e40b5330238ab 100644
--- a/base/common/src/com/netscape/certsrv/request/RequestIdAdapter.java
+++ b/base/common/src/com/netscape/certsrv/request/RequestIdAdapter.java
@@ -19,19 +19,20 @@ package com.netscape.certsrv.request;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 
+import org.apache.commons.lang.StringUtils;
+
 /**
  * The RequestIdAdapter class provides custom marshaling for RequestId.
  *
  * @author Endi S. Dewata
- * @version $Revision$ $Date$
  */
 public class RequestIdAdapter extends XmlAdapter<String, RequestId> {
 
     public RequestId unmarshal(String value) throws Exception {
-        return new RequestId(value);
+        return StringUtils.isEmpty(value) ? null : new RequestId(value);
     }
 
     public String marshal(RequestId value) throws Exception {
-        return value.toString();
+        return value == null ? null : value.toString();
     }
 }
\ No newline at end of file
diff --git a/base/common/src/com/netscape/certsrv/user/UserCertData.java b/base/common/src/com/netscape/certsrv/user/UserCertData.java
index d77e1dc8b152633be8e8c201a9f1bb677a045cd0..708d0343045867698ebf6d065cf1677564b85dd6 100644
--- a/base/common/src/com/netscape/certsrv/user/UserCertData.java
+++ b/base/common/src/com/netscape/certsrv/user/UserCertData.java
@@ -21,7 +21,6 @@ package com.netscape.certsrv.user;
 import java.io.PrintWriter;
 import java.io.StringReader;
 import java.io.StringWriter;
-import java.math.BigInteger;
 import java.util.StringTokenizer;
 
 import javax.ws.rs.FormParam;
@@ -31,10 +30,13 @@ import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.common.Constants;
+import com.netscape.certsrv.dbs.certdb.CertId;
+import com.netscape.certsrv.dbs.certdb.CertIdAdapter;
 
 /**
  * @author Endi S. Dewata
@@ -56,7 +58,7 @@ public class UserCertData {
     }
 
     Integer version;
-    BigInteger serialNumber;
+    CertId serialNumber;
     String issuerDN;
     String subjectDN;
     String prettyPrint;
@@ -76,7 +78,7 @@ public class UserCertData {
     public void setID(String id) {
         StringTokenizer st = new StringTokenizer(id, ";");
         version = Integer.valueOf(st.nextToken());
-        serialNumber = new BigInteger(st.nextToken());
+        serialNumber = new CertId(st.nextToken());
         issuerDN = st.nextToken();
         subjectDN = st.nextToken();
     }
@@ -91,11 +93,12 @@ public class UserCertData {
     }
 
     @XmlElement(name="SerialNumber")
-    public BigInteger getSerialNumber() {
+    @XmlJavaTypeAdapter(CertIdAdapter.class)
+    public CertId getSerialNumber() {
         return serialNumber;
     }
 
-    public void setSerialNumber(BigInteger serialNumber) {
+    public void setSerialNumber(CertId serialNumber) {
         this.serialNumber = serialNumber;
     }
 
@@ -240,7 +243,7 @@ public class UserCertData {
 
         UserCertData before = new UserCertData();
         before.setVersion(1);
-        before.setSerialNumber(new BigInteger("12512514865863765114"));
+        before.setSerialNumber(new CertId("12512514865863765114"));
         before.setIssuerDN("CN=Test User,UID=testuser,O=EXAMPLE-COM");
         before.setSubjectDN("CN=Test User,UID=testuser,O=EXAMPLE-COM");
         before.setEncoded(sw.toString());
diff --git a/base/common/src/com/netscape/certsrv/dbs/keydb/KeyIdAdapter.java b/base/common/src/com/netscape/certsrv/util/DateAdapter.java
similarity index 64%
copy from base/common/src/com/netscape/certsrv/dbs/keydb/KeyIdAdapter.java
copy to base/common/src/com/netscape/certsrv/util/DateAdapter.java
index 3232999fdc3f92693e80170b61a7d1d6d891787c..f461f8dc69afc1965f37a158f7ad463891abbba9 100644
--- a/base/common/src/com/netscape/certsrv/dbs/keydb/KeyIdAdapter.java
+++ b/base/common/src/com/netscape/certsrv/util/DateAdapter.java
@@ -15,23 +15,26 @@
 // (C) 2007 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
-package com.netscape.certsrv.dbs.keydb;
+package com.netscape.certsrv.util;
+
+import java.util.Date;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
 
+import org.apache.commons.lang.StringUtils;
+
 /**
- * The KeyIdAdapter class provides custom marshaling for KeyId.
+ * The DateAdapter class provides custom marshaling for Date.
  *
  * @author Endi S. Dewata
- * @version $Revision$ $Date$
  */
-public class KeyIdAdapter extends XmlAdapter<String, KeyId> {
+public class DateAdapter extends XmlAdapter<String, Date> {
 
-    public KeyId unmarshal(String value) throws Exception {
-        return new KeyId(value);
+    public Date unmarshal(String value) throws Exception {
+        return StringUtils.isEmpty(value) ? null : new Date(Long.parseLong(value));
     }
 
-    public String marshal(KeyId value) throws Exception {
-        return value.toString();
+    public String marshal(Date value) throws Exception {
+        return value == null ? null : Long.toString(value.getTime());
     }
 }
diff --git a/base/common/src/com/netscape/cms/client/user/UserAddCertCLI.java b/base/common/src/com/netscape/cms/client/user/UserAddCertCLI.java
index 2370865ad9694b6791b90b67c056414dd32cc1d2..61ca60137c18d8e69e2af5d8afb3a4cd1682855d 100644
--- a/base/common/src/com/netscape/cms/client/user/UserAddCertCLI.java
+++ b/base/common/src/com/netscape/cms/client/user/UserAddCertCLI.java
@@ -92,6 +92,6 @@ public class UserAddCertCLI extends CLI {
 
         MainCLI.printMessage("Added certificate \"" + userCertData.getID() + "\"");
 
-        UserCLI.printCert(userCertData);
+        UserCLI.printCert(userCertData, false, false);
     }
 }
diff --git a/base/common/src/com/netscape/cms/client/user/UserCLI.java b/base/common/src/com/netscape/cms/client/user/UserCLI.java
index a7bc752e14278a9b4d588968c76dc6737822de25..e9c9acd677a6052c90f87417db8c8d6c492852be 100644
--- a/base/common/src/com/netscape/cms/client/user/UserCLI.java
+++ b/base/common/src/com/netscape/cms/client/user/UserCLI.java
@@ -125,28 +125,32 @@ public class UserCLI extends CLI {
         }
     }
 
-    public static void printCert(UserCertData userCertData) throws Exception {
+    public static void printCert(
+            UserCertData userCertData,
+            boolean showPrettyPrint,
+            boolean showEncoded) {
+
         System.out.println("  Cert ID: " + userCertData.getID());
-        System.out.println("  Serial Number: " + userCertData.getSerialNumber());
         System.out.println("  Version: " + userCertData.getVersion());
-        System.out.println("  Issuer DN: " + userCertData.getIssuerDN());
-        System.out.println("  Subject DN: " + userCertData.getSubjectDN());
+        System.out.println("  Serial Number: " + userCertData.getSerialNumber().toHexString());
+        System.out.println("  Issuer: " + userCertData.getIssuerDN());
+        System.out.println("  Subject: " + userCertData.getSubjectDN());
+
+        Link link = userCertData.getLink();
+        if (verbose && link != null) {
+            System.out.println("  Link: " + link.getHref());
+        }
 
         String prettyPrint = userCertData.getPrettyPrint();
-        if (prettyPrint != null) {
+        if (showPrettyPrint && prettyPrint != null) {
             System.out.println();
             System.out.println(prettyPrint);
         }
 
         String encoded = userCertData.getEncoded();
-        if (encoded != null) {
+        if (showEncoded && encoded != null) {
             System.out.println();
             System.out.println(encoded);
         }
-
-        Link link = userCertData.getLink();
-        if (verbose && link != null) {
-            System.out.println("  Link: " + link.getHref());
-        }
     }
 }
diff --git a/base/common/src/com/netscape/cms/client/user/UserFindCertCLI.java b/base/common/src/com/netscape/cms/client/user/UserFindCertCLI.java
index 41fe3984a3c9cec5c7c08cee89db6426aae3c5b2..c06d21faf9ddd2105927f6397fa9373902986643 100644
--- a/base/common/src/com/netscape/cms/client/user/UserFindCertCLI.java
+++ b/base/common/src/com/netscape/cms/client/user/UserFindCertCLI.java
@@ -96,7 +96,7 @@ public class UserFindCertCLI extends CLI {
                 System.out.println();
             }
 
-            UserCLI.printCert(userCertData);
+            UserCLI.printCert(userCertData, false, false);
         }
 
         MainCLI.printMessage("Number of entries returned " + entries.size());
diff --git a/base/common/src/com/netscape/cms/client/user/UserShowCertCLI.java b/base/common/src/com/netscape/cms/client/user/UserShowCertCLI.java
index 7e58fb1b00638aaa3383ac18451cac634caefe7e..71e14b4fcfb0a419d4f2b4a4db58448c5808c241 100644
--- a/base/common/src/com/netscape/cms/client/user/UserShowCertCLI.java
+++ b/base/common/src/com/netscape/cms/client/user/UserShowCertCLI.java
@@ -50,6 +50,9 @@ public class UserShowCertCLI extends CLI {
         option.setArgName("file");
         options.addOption(option);
 
+        options.addOption(null, "pretty", false, "Pretty print");
+        options.addOption(null, "encoded", false, "Base-64 encoded");
+
         CommandLine cmd = null;
 
         try {
@@ -61,6 +64,9 @@ public class UserShowCertCLI extends CLI {
             System.exit(1);
         }
 
+        boolean showPrettyPrint = cmd.hasOption("pretty");
+        boolean showEncoded = cmd.hasOption("encoded");
+
         String[] cmdArgs = cmd.getArgs();
 
         if (cmdArgs.length != 2) {
@@ -82,6 +88,6 @@ public class UserShowCertCLI extends CLI {
             out.close();
         }
 
-        UserCLI.printCert(userCertData);
+        UserCLI.printCert(userCertData, showPrettyPrint, showEncoded);
     }
 }
diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserCertResourceService.java b/base/common/src/com/netscape/cms/servlet/admin/UserCertResourceService.java
index ebeb5b134a462d14996c1b2fbb20ef94cdf89310..e0e2ddfde3921f35eff6df065b2e0e518c35f821 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/UserCertResourceService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/UserCertResourceService.java
@@ -42,6 +42,7 @@ import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.ICertPrettyPrint;
 import com.netscape.certsrv.common.OpDef;
 import com.netscape.certsrv.common.ScopeDef;
+import com.netscape.certsrv.dbs.certdb.CertId;
 import com.netscape.certsrv.logging.IAuditor;
 import com.netscape.certsrv.logging.ILogger;
 import com.netscape.certsrv.user.UserCertCollection;
@@ -68,7 +69,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC
         UserCertData userCertData = new UserCertData();
 
         userCertData.setVersion(cert.getVersion());
-        userCertData.setSerialNumber(cert.getSerialNumber());
+        userCertData.setSerialNumber(new CertId(cert.getSerialNumber()));
         userCertData.setIssuerDN(cert.getIssuerDN().toString());
         userCertData.setSubjectDN(cert.getSubjectDN().toString());
 
@@ -358,7 +359,7 @@ public class UserCertResourceService extends CMSResourceService implements UserC
                 // read the data back
 
                 userCertData.setVersion(cert.getVersion());
-                userCertData.setSerialNumber(cert.getSerialNumber());
+                userCertData.setSerialNumber(new CertId(cert.getSerialNumber()));
                 userCertData.setIssuerDN(cert.getIssuerDN().toString());
                 userCertData.setSubjectDN(cert.getSubjectDN().toString());
                 String certID = userCertData.getID();
diff --git a/base/common/src/com/netscape/cms/servlet/base/CMSResourceService.java b/base/common/src/com/netscape/cms/servlet/base/CMSResourceService.java
index 85ccbf9f7100e2e8768129b470721491ddf53713..2d95d1904839551234a306a88e26af90d32f05bf 100644
--- a/base/common/src/com/netscape/cms/servlet/base/CMSResourceService.java
+++ b/base/common/src/com/netscape/cms/servlet/base/CMSResourceService.java
@@ -90,7 +90,7 @@ public class CMSResourceService {
             throws CertificateEncodingException {
         CertificateData data = new CertificateData();
         String b64 = HEADER + CMS.BtoA(cert.getEncoded()) + TRAILER;
-        data.setB64(b64);
+        data.setEncoded(b64);
         return data;
     }
 
@@ -116,7 +116,7 @@ public class CMSResourceService {
                 null,
                 source,
                 level,
-                getClass().getSimpleName()+": " + message);
+                getClass().getSimpleName() + ": " + message);
     }
 
     public void audit(String message, String scope, String type, String id, Map<String, String> params, String status) {
diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertResource.java b/base/common/src/com/netscape/cms/servlet/cert/CertResource.java
index 9df06d8e8e50c4bd99487d2c26c2df36c99a608a..8aa90c2cba8fe1f72629184a214ff1fd260fe0d1 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/CertResource.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/CertResource.java
@@ -1,12 +1,16 @@
 package com.netscape.cms.servlet.cert;
 
+import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
+import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
 import com.netscape.certsrv.dbs.certdb.CertId;
+import com.netscape.cms.servlet.cert.model.CertRevokeRequest;
+import com.netscape.cms.servlet.cert.model.CertUnrevokeRequest;
 import com.netscape.cms.servlet.cert.model.CertificateData;
 
 @Path("/cert")
@@ -15,6 +19,17 @@ public interface CertResource {
     @GET
     @Path("{id}")
     @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML })
-    public CertificateData retrieveCert(@PathParam("id") CertId id);
+    public CertificateData getCert(@PathParam("id") CertId id);
 
+    @POST
+    @Path("{id}/revoke")
+    @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public CertificateData revokeCert(@PathParam("id") CertId id, CertRevokeRequest request);
+
+    @POST
+    @Path("{id}/unrevoke")
+    @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
+    public CertificateData unrevokeCert(@PathParam("id") CertId id, CertUnrevokeRequest request);
 }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertResourceService.java b/base/common/src/com/netscape/cms/servlet/cert/CertResourceService.java
index c05d61b1cb0e9641b38f8e1b94fdf2f412bbcdbd..c82676af3e63433547ac6a11dff2fb672f51d105 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/CertResourceService.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/CertResourceService.java
@@ -18,16 +18,42 @@
 
 package com.netscape.cms.servlet.cert;
 
-
+import java.io.IOException;
+import java.math.BigInteger;
 import java.security.cert.CertificateEncodingException;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Vector;
 
+import netscape.security.x509.CRLExtensions;
+import netscape.security.x509.CRLReasonExtension;
+import netscape.security.x509.InvalidityDateExtension;
+import netscape.security.x509.RevocationReason;
+import netscape.security.x509.RevokedCertImpl;
+import netscape.security.x509.X509CertImpl;
+
+import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.ca.ICRLIssuingPoint;
+import com.netscape.certsrv.ca.ICertificateAuthority;
 import com.netscape.certsrv.dbs.EDBRecordNotFoundException;
 import com.netscape.certsrv.dbs.certdb.CertId;
+import com.netscape.certsrv.dbs.certdb.ICertRecord;
+import com.netscape.certsrv.dbs.certdb.ICertificateRepository;
+import com.netscape.certsrv.logging.AuditFormat;
+import com.netscape.certsrv.logging.ILogger;
+import com.netscape.certsrv.publish.IPublisherProcessor;
+import com.netscape.certsrv.request.IRequest;
+import com.netscape.certsrv.request.IRequestQueue;
+import com.netscape.certsrv.request.RequestId;
+import com.netscape.certsrv.request.RequestStatus;
 import com.netscape.cms.servlet.base.BadRequestException;
 import com.netscape.cms.servlet.base.CMSException;
 import com.netscape.cms.servlet.base.CMSResourceService;
 import com.netscape.cms.servlet.cert.model.CertDAO;
+import com.netscape.cms.servlet.cert.model.CertRevokeRequest;
+import com.netscape.cms.servlet.cert.model.CertUnrevokeRequest;
 import com.netscape.cms.servlet.cert.model.CertificateData;
 import com.netscape.cms.servlet.request.model.CertRetrievalRequestData;
 
@@ -35,7 +61,45 @@ import com.netscape.cms.servlet.request.model.CertRetrievalRequestData;
  * @author alee
  *
  */
-public class CertResourceService extends CMSResourceService implements CertResource{
+public class CertResourceService extends CMSResourceService implements CertResource {
+
+    public final static String REVOKE = "revoke";
+    public final static String ON_HOLD = "on-hold";
+    public final static String OFF_HOLD = "off-hold";
+
+    public final static String LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST =
+            "LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_5";
+    public final static String LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED =
+            "LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED_7";
+
+    ICertificateAuthority authority;
+    ICertificateRepository repo;
+    IRequestQueue requestQueue;
+    IPublisherProcessor publisherProcessor;
+
+    int timeLimits = 30; /* in seconds */
+
+    String initiative;
+    CertId serialNumber;
+    String subjectDN;
+    RequestId requestID;
+    String requestType;
+    RevocationReason revocationReason;
+    RequestStatus requestStatus;
+
+    public CertResourceService() {
+        authority = (ICertificateAuthority) CMS.getSubsystem("ca");
+        repo = authority.getCertificateRepository();
+        requestQueue = authority.getRequestQueue();
+        publisherProcessor = authority.getPublisherProcessor();
+    }
+
+    public CertDAO createDAO() {
+        CertDAO dao = new CertDAO();
+        dao.setLocale(getLocale());
+        dao.setUriInfo(uriInfo);
+        return dao;
+    }
 
     private void validateRequest(CertId id) {
 
@@ -46,27 +110,586 @@ public class CertResourceService extends CMSResourceService implements CertResou
     }
 
     @Override
-    public CertificateData retrieveCert(CertId id) {
+    public CertificateData getCert(CertId id) {
 
         validateRequest(id);
 
         CertRetrievalRequestData data = new CertRetrievalRequestData();
         data.setCertId(id);
-        CertDAO dao = new CertDAO();
+        CertDAO dao = createDAO();
 
         CertificateData certData = null;
 
         try {
             certData = dao.getCert(data);
-        }  catch(EDBRecordNotFoundException e) {
+        } catch (EDBRecordNotFoundException e) {
             throw new CertNotFoundException(id);
-        }  catch (EBaseException e) {
+        } catch (EBaseException e) {
             throw new CMSException("Problem returning certificate: " + id);
-        }  catch(CertificateEncodingException e) {
+        } catch (CertificateEncodingException e) {
             throw new CMSException("Problem encoding certificate searched for: " + id);
         }
 
         return certData;
 
     }
+
+    /**
+     * Process cert status change request
+     * <P>
+     *
+     * (Certificate Request - either an "agent" cert status change request, or an "EE" cert status change request)
+     * <P>
+     *
+     * (Certificate Request Processed - either an "agent" cert status change request, or an "EE" cert status change
+     * request)
+     * <P>
+     *
+     * <ul>
+     * <li>signed.audit LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST used when a cert status change request (e. g. -
+     * "revocation") is made (before approval process)
+     * <li>signed.audit LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED used when a certificate status is
+     * changed (revoked, expired, on-hold, off-hold)
+     * </ul>
+     */
+    @Override
+    public CertificateData revokeCert(CertId id, CertRevokeRequest request) {
+
+        long startTime = CMS.getCurrentDate().getTime();
+
+        IRequest revReq;
+        X509CertImpl cert;
+
+        try {
+            // TODO: set initiative based on auth info
+            initiative = AuditFormat.FROMAGENT;
+
+            // TODO: get user cert's serial number from auth info
+            // String userSerialNumber = null;
+
+            // TODO: get user cert's subject DN from auth info
+            // String userSubjectDN = null;
+
+            serialNumber = id;
+            requestID = request.getRequestID();
+            revocationReason = RevocationReason.fromInt(request.getReason());
+            requestType = revocationReason == RevocationReason.CERTIFICATE_HOLD ? ON_HOLD : REVOKE;
+
+            CMS.debug("revokeCert: serialNumber: " + serialNumber.toHexString());
+
+            // Construct a CRL extension for this request.
+            CRLExtensions entryExtn = new CRLExtensions();
+
+            // Construct a CRL reason code extension.
+            CRLReasonExtension crlReasonExtn = new CRLReasonExtension(revocationReason);
+            entryExtn.set(crlReasonExtn.getName(), crlReasonExtn);
+
+            // Construct a CRL invalidity date extension.
+            Date invalidityDate = request.getInvalidityDate();
+            if (invalidityDate != null) {
+                InvalidityDateExtension invalidityDateExtn = new InvalidityDateExtension(invalidityDate);
+                entryExtn.set(invalidityDateExtn.getName(), invalidityDateExtn);
+            }
+
+            ICertRecord record = repo.readCertificateRecord(serialNumber.toBigInteger());
+            cert = record.getCertificate();
+
+            if (cert == null) {
+                log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSGW_REV_CERTS_ZERO"));
+                throw new EBaseException(CMS.getLogMessage("CMSGW_REVOCATION_ERROR_CERT_NOT_FOUND"));
+            }
+
+            // we do not want to revoke the CA certificate accidentally
+            if (cert != null && isSystemCertificate(cert)) {
+                CMS.debug("revokeCert: skipped revocation request for system certificate " + cert.getSerialNumber());
+                throw new EBaseException(CMS.getLogMessage("CMSGW_UNAUTHORIZED"));
+            }
+
+            // TODO: verify user cert is not revoked
+            /*
+            if (userSerialNumber != null
+                    && userSerialNumber.equals(cert.getSerialNumber().toString())
+                    && record.getStatus().equals(ICertRecord.STATUS_REVOKED)) {
+
+                log(ILogger.LL_FAILURE,
+                        CMS.getLogMessage("CA_CERTIFICATE_ALREADY_REVOKED_1",
+                                cert.getSerialNumber().toString(16)));
+
+                throw new EBaseException(CMS.getLogMessage("CMSGW_UNAUTHORIZED"));
+            }
+            */
+
+            // verify target cert is not revoked
+            if (record.getStatus().equals(ICertRecord.STATUS_REVOKED)) {
+
+                throw new EBaseException(CMS.getLogMessage("CA_CERTIFICATE_ALREADY_REVOKED_1",
+                        cert.getSerialNumber().toString(16)));
+            }
+
+            // TODO: verify user cert's subject DN matches the target cert's subject DN
+            /*
+            if (eeSubjectDN != null && !eeSubjectDN.equals(cert.getSubjectDN().toString())) {
+
+                log(ILogger.LL_FAILURE,
+                        "Certificate 0x" + cert.getSerialNumber().toString(16) + " belongs to different subject.");
+
+                throw new EBaseException(CMS.getLogMessage("BASE_PERMISSION_DENIED"));
+            }
+            */
+
+            subjectDN = cert.getSubjectDN().toString();
+
+            revReq = requestQueue.newRequest(IRequest.REVOCATION_REQUEST);
+
+            revReq.setExtData(IRequest.CERT_INFO, new RevokedCertImpl[] {
+                    new RevokedCertImpl(cert.getSerialNumber(), CMS.getCurrentDate(), entryExtn)
+            });
+
+            revReq.setExtData(IRequest.REQ_TYPE, IRequest.REVOCATION_REQUEST);
+
+            if (AuditFormat.FROMUSER.equals(initiative)) {
+                revReq.setExtData(IRequest.REQUESTOR_TYPE, IRequest.REQUESTOR_EE);
+            } else {
+                revReq.setExtData(IRequest.REQUESTOR_TYPE, IRequest.REQUESTOR_AGENT);
+            }
+
+            revReq.setExtData(IRequest.OLD_CERTS, new X509CertImpl[] { cert });
+
+            String comments = request.getComments();
+            if (comments != null)
+                revReq.setExtData(IRequest.REQUESTOR_COMMENTS, comments);
+
+            revReq.setExtData(IRequest.REVOKED_REASON, revocationReason.toInt());
+
+            // store a message in the signed audit log file
+            auditChangeRequest(ILogger.SUCCESS);
+
+        } catch (EBaseException e) {
+            log(ILogger.LL_FAILURE, "error " + e);
+
+            // store a "CERT_STATUS_CHANGE_REQUEST" failure
+            // message in the signed audit log file
+            auditChangeRequest(ILogger.FAILURE);
+
+            throw new CMSException(e.getMessage());
+
+        } catch (IOException e) {
+            log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSGW_ERROR_MARKING_CERT_REVOKED_1", e.toString()));
+
+            // store a "CERT_STATUS_CHANGE_REQUEST" failure
+            // message in the signed audit log file
+            auditChangeRequest(ILogger.FAILURE);
+
+            throw new CMSException(CMS.getLogMessage("CMSGW_ERROR_MARKING_CERT_REVOKED"));
+        }
+
+        // change audit processing from "REQUEST" to "REQUEST_PROCESSED"
+        // to distinguish which type of signed audit log message to save
+        // as a failure outcome in case an exception occurs
+
+        try {
+            requestQueue.processRequest(revReq);
+
+            // retrieve the request status
+            requestStatus = revReq.getRequestStatus();
+            CMS.debug("revokeCert: status: " + requestStatus);
+
+            String type = revReq.getRequestType();
+
+            // The SVC_PENDING check has been added for the Cloned CA request
+            // that is meant for the Master CA. From Clone's point of view
+            // the request is complete
+            if (requestStatus == RequestStatus.COMPLETE
+                    || requestStatus == RequestStatus.SVC_PENDING
+                    && type.equals(IRequest.CLA_CERT4CRL_REQUEST)) {
+
+                // audit log the error
+                Integer result = revReq.getExtDataInInteger(IRequest.RESULT);
+
+                if (result.equals(IRequest.RES_ERROR)) {
+                    String[] svcErrors = revReq.getExtDataInStringArray(IRequest.SVCERRORS);
+
+                    if (svcErrors != null && svcErrors.length > 0) {
+                        logRevoke(RequestStatus.COMPLETE + " with error: " + svcErrors[0], revocationReason.toString());
+                        throw new EBaseException(svcErrors[0]);
+                    }
+                }
+
+                Integer updateCRLResult = revReq.getExtDataInInteger(IRequest.CRL_UPDATE_STATUS);
+                if (updateCRLResult != null && !updateCRLResult.equals(IRequest.RES_SUCCESS)) {
+                    String crlError = revReq.getExtDataInString(IRequest.CRL_UPDATE_ERROR);
+                    CMS.debug("revokeCert: " + IRequest.CRL_UPDATE_ERROR + ": " + crlError);
+                }
+
+                // let known crl publishing status too.
+                Integer publishCRLResult = revReq.getExtDataInInteger(IRequest.CRL_PUBLISH_STATUS);
+                if (publishCRLResult != null && !publishCRLResult.equals(IRequest.RES_SUCCESS)) {
+                    String publError = revReq.getExtDataInString(IRequest.CRL_PUBLISH_ERROR);
+                    CMS.debug("revokeCert: " + IRequest.CRL_PUBLISH_ERROR + ": " + publError);
+                }
+
+                // let known update and publish status of all crls.
+                Enumeration<ICRLIssuingPoint> otherCRLs = authority.getCRLIssuingPoints();
+                while (otherCRLs.hasMoreElements()) {
+                    ICRLIssuingPoint crl = otherCRLs.nextElement();
+
+                    String crlId = crl.getId();
+                    if (crlId.equals(ICertificateAuthority.PROP_MASTER_CRL))
+                        continue;
+
+                    String updateStatusStr = crl.getCrlUpdateStatusStr();
+                    Integer updateResult = revReq.getExtDataInInteger(updateStatusStr);
+                    if (updateResult != null && !updateResult.equals(IRequest.RES_SUCCESS)) {
+                        String updateErrorStr = crl.getCrlUpdateErrorStr();
+                        String error = revReq.getExtDataInString(updateErrorStr);
+                        CMS.debug("revokeCert: " + updateErrorStr + ": " + error);
+                    }
+
+                    String publishStatusStr = crl.getCrlPublishStatusStr();
+                    Integer publishResult = revReq.getExtDataInInteger(publishStatusStr);
+                    if (publishResult != null && !publishResult.equals(IRequest.RES_SUCCESS)) {
+                        String publishErrorStr = crl.getCrlPublishErrorStr();
+                        String error = revReq.getExtDataInString(publishErrorStr);
+                        CMS.debug("revokeCert: " + publishErrorStr + ": " + error);
+                    }
+                }
+
+                if (publisherProcessor != null && publisherProcessor.ldapEnabled()) {
+                    Integer[] ldapPublishStatus = revReq.getExtDataInIntegerArray("ldapPublishStatus");
+                    if (ldapPublishStatus != null && ldapPublishStatus[0] != IRequest.RES_SUCCESS) {
+                        CMS.debug("revokeCert: dir not updated");
+                    }
+                }
+
+                long endTime = CMS.getCurrentDate().getTime();
+
+                // audit log the success.
+                logRevoke(RequestStatus.COMPLETE.toString(), revocationReason + " time: " + (endTime - startTime));
+
+            } else {
+
+                Vector<String> errors = revReq.getExtDataInStringVector(IRequest.ERRORS);
+                if (errors != null) {
+                    StringBuilder errInfo = new StringBuilder();
+                    for (int i = 0; i < errors.size(); i++) {
+                        errInfo.append(errors.elementAt(i));
+                        errInfo.append("\n");
+                    }
+                    CMS.debug("revokeCert: " + IRequest.ERRORS + ": " + errInfo);
+                }
+
+                // audit log the pending, revoked and rest
+                logRevoke(requestStatus.toString(), revocationReason.toString());
+            }
+
+            // store a message in the signed audit log file
+            // if and only if "requestStatus" is
+            // "complete", "revoked", or "canceled"
+            if (requestStatus == RequestStatus.COMPLETE
+                    || requestStatus == RequestStatus.REJECTED
+                    || requestStatus == RequestStatus.CANCELED) {
+
+                auditChangeRequestProcessed(ILogger.SUCCESS);
+            }
+
+        } catch (EBaseException e) {
+            log(ILogger.LL_FAILURE, "error " + e);
+
+            // store a "CERT_STATUS_CHANGE_REQUEST_PROCESSED" failure
+            // message in the signed audit log file
+            // if and only if "requestStatus" is
+            // "complete", "revoked", or "canceled"
+            if (requestStatus == RequestStatus.COMPLETE
+                    || requestStatus == RequestStatus.REJECTED
+                    || requestStatus == RequestStatus.CANCELED) {
+
+                auditChangeRequestProcessed(ILogger.FAILURE);
+            }
+
+            throw new CMSException(e.getMessage());
+        }
+
+        return getCert(id);
+    }
+
+    /**
+     * A system certificate such as the CA signing certificate
+     * should not be allowed to delete.
+     * The main purpose is to avoid revoking the self signed
+     * CA certificate accidentally.
+     */
+    public boolean isSystemCertificate(X509Certificate cert) {
+
+        X509Certificate caCert = authority.getCACert();
+        if (caCert == null)
+            return false;
+
+        /* only check this if we are self-signed */
+        if (!caCert.getSubjectDN().equals(caCert.getIssuerDN()))
+            return false;
+
+        return caCert.getSerialNumber().equals(cert.getSerialNumber());
+    }
+
+    /**
+     * Process X509 cert status change request
+     * <P>
+     *
+     * (Certificate Request - an "agent" cert status change request to take a certificate off-hold)
+     * <P>
+     *
+     * (Certificate Request Processed - an "agent" cert status change request to take a certificate off-hold)
+     * <P>
+     *
+     * <ul>
+     * <li>signed.audit LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST used when a cert status change request (e. g. -
+     * "revocation") is made (before approval process)
+     * <li>signed.audit LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED used when a certificate status is
+     * changed (taken off-hold)
+     * </ul>
+     */
+    @Override
+    public CertificateData unrevokeCert(CertId id, CertUnrevokeRequest request) {
+
+        X509Certificate cert;
+        IRequest unrevReq;
+
+        try {
+            // TODO: set initiative based on auth info
+            initiative = AuditFormat.FROMAGENT;
+
+            serialNumber = id;
+            requestID = request.getRequestID();
+            revocationReason = RevocationReason.CERTIFICATE_HOLD;
+            requestType = OFF_HOLD;
+
+            // certs are for old cloning and they should be removed as soon as possible
+            try {
+                cert = repo.getX509Certificate(serialNumber.toBigInteger());
+
+            } catch (EBaseException e) {
+                log(ILogger.LL_FAILURE,
+                        CMS.getLogMessage("CMSGW_NO_CERT_REC", serialNumber.toBigInteger().toString(16), e.toString()));
+
+                throw new EBaseException(CMS.getLogMessage("CMSGW_REVOCATION_ERROR_CERT_NOT_FOUND"));
+            }
+
+            subjectDN = cert.getSubjectDN().toString();
+
+            unrevReq = requestQueue.newRequest(IRequest.UNREVOCATION_REQUEST);
+
+            unrevReq.setExtData(IRequest.REQ_TYPE, IRequest.UNREVOCATION_REQUEST);
+            unrevReq.setExtData(IRequest.OLD_SERIALS, new BigInteger[] { cert.getSerialNumber() });
+            unrevReq.setExtData(IRequest.REQUESTOR_TYPE, IRequest.REQUESTOR_AGENT);
+
+            // store a message in the signed audit log file
+            auditChangeRequest(ILogger.SUCCESS);
+
+        } catch (EBaseException e) {
+
+            // store a "CERT_STATUS_CHANGE_REQUEST" failure
+            // message in the signed audit log file
+            auditChangeRequest(ILogger.FAILURE);
+
+            throw new CMSException(e.getMessage());
+        }
+
+        // change audit processing from "REQUEST" to "REQUEST_PROCESSED"
+        // to distinguish which type of signed audit log message to save
+        // as a failure outcome in case an exception occurs
+
+        try {
+            requestQueue.processRequest(unrevReq);
+
+            // retrieve the request status
+            requestStatus = unrevReq.getRequestStatus();
+
+            String type = unrevReq.getRequestType();
+
+            if (requestStatus == RequestStatus.COMPLETE
+                    || requestStatus == RequestStatus.SVC_PENDING
+                    && type.equals(IRequest.CLA_UNCERT4CRL_REQUEST)) {
+
+                Integer result = unrevReq.getExtDataInInteger(IRequest.RESULT);
+
+                if (result != null && result.equals(IRequest.RES_SUCCESS)) {
+                    logUnrevoke(RequestStatus.COMPLETE.toString());
+
+                } else {
+                    String error = unrevReq.getExtDataInString(IRequest.ERROR);
+                    logUnrevoke(RequestStatus.COMPLETE + " with error: " + error);
+
+                    /****************************************************/
+                    /* IMPORTANT:  In the event that the following      */
+                    /*             "throw" statement is uncommented,    */
+                    /*             uncomment the following signed       */
+                    /*             audit log message, also!!!           */
+                    /****************************************************/
+                    /*
+                    // store a message in the signed audit log file
+                    // if and only if "requestStatus" is
+                    // "complete", "revoked", or "canceled"
+                    if (requestStatus == RequestStatus.COMPLETE
+                            || requestStatus == RequestStatus.REJECTED
+                            || requestStatus == RequestStatus.CANCELED) {
+
+                        auditChangeRequestProcessed(ILogger.FAILURE);
+                    }
+
+                    throw new EBaseException(error);
+                    */
+                }
+
+                Integer updateCRLResult = unrevReq.getExtDataInInteger(IRequest.CRL_UPDATE_STATUS);
+                if (updateCRLResult != null && !updateCRLResult.equals(IRequest.RES_SUCCESS)) {
+                    String crlError = unrevReq.getExtDataInString(IRequest.CRL_UPDATE_ERROR);
+                    CMS.debug("unrevokeCert: " + IRequest.CRL_UPDATE_ERROR + ": " + crlError);
+
+                    // let known crl publishing status too.
+                    Integer publishCRLResult = unrevReq.getExtDataInInteger(IRequest.CRL_PUBLISH_STATUS);
+                    if (publishCRLResult != null && !publishCRLResult.equals(IRequest.RES_SUCCESS)) {
+                        String publError = unrevReq.getExtDataInString(IRequest.CRL_PUBLISH_ERROR);
+                        CMS.debug("unrevokeCert: " + IRequest.CRL_PUBLISH_ERROR + ": " + publError);
+                    }
+                }
+
+                // let known update and publish status of all crls.
+                Enumeration<ICRLIssuingPoint> otherCRLs = authority.getCRLIssuingPoints();
+                while (otherCRLs.hasMoreElements()) {
+                    ICRLIssuingPoint crl = otherCRLs.nextElement();
+
+                    String crlId = crl.getId();
+                    if (crlId.equals(ICertificateAuthority.PROP_MASTER_CRL))
+                        continue;
+
+                    String updateStatusStr = crl.getCrlUpdateStatusStr();
+                    Integer updateResult = unrevReq.getExtDataInInteger(updateStatusStr);
+                    if (updateResult != null && updateResult.equals(IRequest.RES_SUCCESS)) {
+                        String updateErrorStr = crl.getCrlUpdateErrorStr();
+                        String error = unrevReq.getExtDataInString(updateErrorStr);
+                        CMS.debug("unrevokeCert: " + updateStatusStr + ": " + error);
+                    }
+
+                    String publishStatusStr = crl.getCrlPublishStatusStr();
+                    Integer publishResult = unrevReq.getExtDataInInteger(publishStatusStr);
+                    if (publishResult != null && !publishResult.equals(IRequest.RES_SUCCESS)) {
+                        String publishErrorStr = crl.getCrlPublishErrorStr();
+                        String error = unrevReq.getExtDataInString(publishErrorStr);
+                        CMS.debug("unrevokeCert: " + publishErrorStr + ": " + error);
+                    }
+                }
+
+                if (publisherProcessor != null && publisherProcessor.ldapEnabled()) {
+                    Integer[] ldapPublishStatus = unrevReq.getExtDataInIntegerArray("ldapPublishStatus");
+                    if (ldapPublishStatus != null && ldapPublishStatus[0] != IRequest.RES_SUCCESS) {
+                        CMS.debug("unrevokeCert: dir not updated");
+                    }
+                }
+
+            } else {
+                logUnrevoke(requestStatus.toString());
+            }
+
+            // store a message in the signed audit log file
+            // if and only if "requestStatus" is
+            // "complete", "revoked", or "canceled"
+            if (requestStatus == RequestStatus.COMPLETE
+                    || requestStatus == RequestStatus.REJECTED
+                    || requestStatus == RequestStatus.CANCELED) {
+
+                auditChangeRequestProcessed(ILogger.SUCCESS);
+            }
+
+        } catch (EBaseException e) {
+            // store a "CERT_STATUS_CHANGE_REQUEST_PROCESSED" failure
+            // message in the signed audit log file
+            // if and only if "requestStatus" is
+            // "complete", "revoked", or "canceled"
+            if (requestStatus == RequestStatus.COMPLETE
+                    || requestStatus == RequestStatus.REJECTED
+                    || requestStatus == RequestStatus.CANCELED) {
+
+                auditChangeRequestProcessed(ILogger.FAILURE);
+            }
+        }
+
+        return getCert(id);
+    }
+
+    public void log(int level, String message) {
+        log(ILogger.S_CA, level, message);
+    }
+
+    public void logRevoke(String status, String message) {
+
+        if (logger == null)
+            return;
+
+        logger.log(
+                ILogger.EV_AUDIT,
+                ILogger.S_OTHER,
+                AuditFormat.LEVEL,
+                AuditFormat.DOREVOKEFORMAT,
+                new Object[] {
+                        requestID == null ? ILogger.UNIDENTIFIED : requestID.toString(),
+                        initiative,
+                        status,
+                        subjectDN,
+                        serialNumber.toHexString(),
+                        message
+                });
+    }
+
+    public void logUnrevoke(String status) {
+
+        if (logger == null)
+            return;
+
+        logger.log(
+                ILogger.EV_AUDIT,
+                ILogger.S_OTHER,
+                AuditFormat.LEVEL,
+                AuditFormat.DOUNREVOKEFORMAT,
+                new Object[] {
+                        requestID == null ? ILogger.UNIDENTIFIED : requestID.toString(),
+                        initiative,
+                        status,
+                        subjectDN,
+                        serialNumber.toHexString()
+                });
+    }
+
+    public void auditChangeRequest(String status) {
+
+        if (auditor == null)
+            return;
+
+        String auditMessage = CMS.getLogMessage(
+                LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST,
+                auditor.getSubjectID(),
+                status,
+                requestID == null ? ILogger.UNIDENTIFIED : requestID.toString(),
+                serialNumber.toHexString(),
+                requestType);
+
+        auditor.log(auditMessage);
+    }
+
+    public void auditChangeRequestProcessed(String status) {
+
+        if (auditor == null)
+            return;
+
+        String auditMessage = CMS.getLogMessage(
+                LOGGING_SIGNED_AUDIT_CERT_STATUS_CHANGE_REQUEST_PROCESSED,
+                auditor.getSubjectID(),
+                status,
+                requestID == null ? ILogger.UNIDENTIFIED : requestID.toString(),
+                serialNumber.toHexString(),
+                requestType,
+                String.valueOf(revocationReason.toInt()),
+                requestStatus == null ? ILogger.SIGNED_AUDIT_EMPTY_VALUE : requestStatus.toString());
+
+        auditor.log(auditMessage);
+    }
 }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertsResourceService.java b/base/common/src/com/netscape/cms/servlet/cert/CertsResourceService.java
index ed503dad4939ccb778a6bf8617bdba9a56c08ced..60daee11ffc79abc4baa02393cbb104fca2bf40c 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/CertsResourceService.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/CertsResourceService.java
@@ -38,6 +38,13 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
  */
 public class CertsResourceService extends CMSResourceService implements CertsResource {
 
+    public CertDAO createDAO() {
+        CertDAO dao = new CertDAO();
+        dao.setLocale(getLocale());
+        dao.setUriInfo(uriInfo);
+        return dao;
+    }
+
     private String createSearchFilter(String status) {
         String filter = "";
 
@@ -70,10 +77,10 @@ public class CertsResourceService extends CMSResourceService implements CertsRes
         String filter = createSearchFilter(status);
         CMS.debug("listKeys: filter is " + filter);
 
-        CertDAO dao = new CertDAO();
+        CertDAO dao = createDAO();
         CertDataInfos infos;
         try {
-            infos = dao.listCerts(filter, maxResults, maxTime, uriInfo);
+            infos = dao.listCerts(filter, maxResults, maxTime);
         } catch (EBaseException e) {
             e.printStackTrace();
             throw new CMSException("Error listing certs in CertsResourceService.listCerts!");
@@ -88,11 +95,11 @@ public class CertsResourceService extends CMSResourceService implements CertsRes
             throw new WebApplicationException(Response.Status.BAD_REQUEST);
         }
         String filter = createSearchFilter(data);
-        CertDAO dao = new CertDAO();
+        CertDAO dao = createDAO();
         CertDataInfos infos;
 
         try {
-            infos = dao.listCerts(filter, maxResults, maxTime, uriInfo);
+            infos = dao.listCerts(filter, maxResults, maxTime);
         } catch (EBaseException e) {
             e.printStackTrace();
             throw new CMSException("Error listing certs in CertsResourceService.listCerts!");
diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertDAO.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertDAO.java
index e71055580377899e611a46b5dcae393f0b225f38..1177b66f675ad2e0e493206585e535e9f677e98d 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/model/CertDAO.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/model/CertDAO.java
@@ -18,7 +18,7 @@
 package com.netscape.cms.servlet.cert.model;
 
 import java.io.ByteArrayOutputStream;
-import java.math.BigInteger;
+import java.net.URI;
 import java.security.Principal;
 import java.security.cert.CertificateEncodingException;
 import java.security.cert.X509Certificate;
@@ -26,9 +26,8 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.Locale;
 
-import javax.ws.rs.Path;
-import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 
 import netscape.security.pkcs.ContentInfo;
@@ -37,8 +36,11 @@ import netscape.security.pkcs.SignerInfo;
 import netscape.security.x509.AlgorithmId;
 import netscape.security.x509.X509CertImpl;
 
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.base.ICertPrettyPrint;
 import com.netscape.certsrv.ca.ICertificateAuthority;
 import com.netscape.certsrv.dbs.certdb.CertId;
 import com.netscape.certsrv.dbs.certdb.ICertRecord;
@@ -53,6 +55,9 @@ import com.netscape.cmsutil.util.Utils;
  */
 public class CertDAO {
 
+    Locale locale;
+    UriInfo uriInfo;
+
     private ICertificateRepository repo;
     private ICertificateAuthority ca;
 
@@ -61,6 +66,22 @@ public class CertDAO {
         repo = ca.getCertificateRepository();
     }
 
+    public Locale getLocale() {
+        return locale;
+    }
+
+    public void setLocale(Locale locale) {
+        this.locale = locale;
+    }
+
+    public UriInfo getUriInfo() {
+        return uriInfo;
+    }
+
+    public void setUriInfo(UriInfo uriInfo) {
+        this.uriInfo = uriInfo;
+    }
+
     /**
      * Returns list of certs meeting specified search filter.
      * Currently, vlv searches are not used for certs.
@@ -72,7 +93,7 @@ public class CertDAO {
      * @return
      * @throws EBaseException
      */
-    public CertDataInfos listCerts(String filter, int maxResults, int maxTime, UriInfo uriInfo)
+    public CertDataInfos listCerts(String filter, int maxResults, int maxTime)
             throws EBaseException {
         List<CertDataInfo> list = new ArrayList<CertDataInfo>();
         Enumeration<ICertRecord> e = null;
@@ -85,7 +106,7 @@ public class CertDAO {
         while (e.hasMoreElements()) {
             ICertRecord rec = e.nextElement();
             if (rec != null) {
-                list.add(createCertDataInfo(rec, uriInfo));
+                list.add(createCertDataInfo(rec));
             }
         }
 
@@ -97,96 +118,61 @@ public class CertDAO {
 
     public CertificateData getCert(CertRetrievalRequestData data) throws EBaseException, CertificateEncodingException {
 
-        CertificateData certData = null;
         CertId certId = data.getCertId();
 
         //find the cert in question
+        ICertRecord record = repo.readCertificateRecord(certId.toBigInteger());
+        X509CertImpl cert = record.getCertificate();
 
-        ICertRecord rec = null;
-        BigInteger seq = certId.toBigInteger();
+        CertificateData certData = new CertificateData();
 
-        rec = repo.readCertificateRecord(seq);
-        X509CertImpl x509cert = null;
+        certData.setSerialNumber(certId);
 
-        if (rec != null) {
-            x509cert = rec.getCertificate();
-        }
+        Principal issuerDN = cert.getIssuerDN();
+        if (issuerDN != null) certData.setIssuerDN(issuerDN.toString());
 
-        if (x509cert != null) {
-            certData = new CertificateData();
+        Principal subjectDN = cert.getSubjectDN();
+        if (subjectDN != null) certData.setSubjectDN(subjectDN.toString());
 
-            byte[] ba = null;
-            String encoded64 = null;
+        String base64 = CMS.getEncodedCert(cert);
+        certData.setEncoded(base64);
 
-            ba = x509cert.getEncoded();
+        ICertPrettyPrint print = CMS.getCertPrettyPrint(cert);
+        certData.setPrettyPrint(print.toString(locale));
 
-            encoded64 = Utils.base64encode(ba);
+        String p7Str = getCertChainData(cert);
+        certData.setPkcs7CertChain(p7Str);
 
-            String prettyPrint = x509cert.toString();
+        Date notBefore = cert.getNotBefore();
+        if (notBefore != null) certData.setNotBefore(notBefore.toString());
 
-            certData.setB64(encoded64);
-            certData.setPrettyPrint(prettyPrint);
+        Date notAfter = cert.getNotAfter();
+        if (notAfter != null) certData.setNotAfter(notAfter.toString());
 
-            String subjectNameStr = null;
-            Principal subjectName = x509cert.getSubjectDN();
+        certData.setStatus(record.getStatus());
 
-            if (subjectName != null) {
-                subjectNameStr = subjectName.toString();
-            }
-
-            certData.setSubjectName(subjectNameStr);
-
-            //Try to get the chain
-
-            String p7Str = getCertChainData(x509cert);
-
-            certData.setPkcs7CertChain(p7Str);
-
-            certData.setSerialNo(certId);
-
-            Date notBefore = x509cert.getNotBefore();
-            Date notAfter = x509cert.getNotAfter();
-
-            String notBeforeStr = null;
-            String notAfterStr = null;
-
-            if (notBefore != null) {
-                notBeforeStr = notBefore.toString();
-            }
-
-            if (notAfter != null) {
-                notAfterStr = notAfter.toString();
-            }
-
-            certData.setNotBefore(notBeforeStr);
-            certData.setNotAfter(notAfterStr);
-
-            String issuerNameStr = null;
-
-            Principal issuerName = x509cert.getIssuerDN();
-
-            if (issuerName != null) {
-                issuerNameStr = issuerName.toString();
-            }
-
-            certData.setIssuerName(issuerNameStr);
-
-        }
+        URI uri = uriInfo.getBaseUriBuilder().path(CertResource.class).path("{id}").build(certId.toHexString());
+        certData.setLink(new Link("self", uri));
 
         return certData;
     }
 
-    private CertDataInfo createCertDataInfo(ICertRecord rec, UriInfo uriInfo) throws EBaseException {
-        CertDataInfo ret = new CertDataInfo();
+    private CertDataInfo createCertDataInfo(ICertRecord record) throws EBaseException {
 
-        Path certPath = CertResource.class.getAnnotation(Path.class);
-        BigInteger serial = rec.getSerialNumber();
+        CertDataInfo info = new CertDataInfo();
 
-        UriBuilder certBuilder = uriInfo.getBaseUriBuilder();
-        certBuilder.path(certPath.value() + "/" + serial);
-        ret.setCertURL(certBuilder.build().toString());
+        CertId id = new CertId(record.getSerialNumber());
+        info.setID(id);
 
-        return ret;
+        X509Certificate cert = record.getCertificate();
+        info.setSubjectDN(cert.getSubjectDN().toString());
+
+        info.setStatus(record.getStatus());
+
+        URI uri = uriInfo.getBaseUriBuilder().path(CertResource.class).path("{id}").build(id.toHexString());
+        info.setLink(new Link("self", uri));
+
+        return info;
     }
 
     private String getCertChainData(X509CertImpl x509cert) {
diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java
index 0f8d35e05180a02f39cf3a8d4c21d7010c71c0ca..4c6a9b19e5f9e2c19fce269096ae858b8cb5a752 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/model/CertDataInfo.java
@@ -20,48 +20,154 @@
  */
 package com.netscape.cms.servlet.cert.model;
 
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.dbs.certdb.CertId;
+import com.netscape.certsrv.dbs.certdb.CertIdAdapter;
 
 /**
  * @author alee
  *
  */
 @XmlRootElement(name = "CertDataInfo")
-@XmlAccessorType(XmlAccessType.FIELD)
 public class CertDataInfo {
 
-    @XmlElement
-    protected String certURL;
+    public static Marshaller marshaller;
+    public static Unmarshaller unmarshaller;
 
-    public CertDataInfo() {
-        // required for JAXB (defaults)
+    static {
+        try {
+            JAXBContext context = JAXBContext.newInstance(CertDataInfo.class);
+            marshaller = context.createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+            unmarshaller = context.createUnmarshaller();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
-    /**
-     * @return the CertURL
-     */
-    public String getCertURL() {
-        return certURL;
+    CertId id;
+    String subjectDN;
+    String status;
+
+    Link link;
+
+    @XmlAttribute(name="id")
+    @XmlJavaTypeAdapter(CertIdAdapter.class)
+    public CertId getID() {
+        return id;
+    }
+
+    public void setID(CertId id) {
+        this.id = id;
+    }
+
+    @XmlElement(name="SubjectDN")
+    public String getSubjectDN() {
+        return subjectDN;
+    }
+
+    public void setSubjectDN(String subjectDN) {
+        this.subjectDN = subjectDN;
+    }
+
+    @XmlElement(name="Status")
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    @XmlElement(name="Link")
+    public Link getLink() {
+        return link;
+    }
+
+    public void setLink(Link link) {
+        this.link = link;
     }
 
-    /**
-     * @param CertURL the certURL to set
-     */
-    public void setCertURL(String certURL) {
-        this.certURL = certURL;
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        result = prime * result + ((status == null) ? 0 : status.hashCode());
+        result = prime * result + ((subjectDN == null) ? 0 : subjectDN.hashCode());
+        return result;
     }
 
-    /**
-     * @return the Cert ID in the CertURL
-     */
-    public CertId getCertId() {
-        String id = certURL.substring(certURL.lastIndexOf("/") + 1);
-        return new CertId(id);
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        CertDataInfo other = (CertDataInfo) obj;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        if (status == null) {
+            if (other.status != null)
+                return false;
+        } else if (!status.equals(other.status))
+            return false;
+        if (subjectDN == null) {
+            if (other.subjectDN != null)
+                return false;
+        } else if (!subjectDN.equals(other.subjectDN))
+            return false;
+        return true;
     }
 
+    public String toString() {
+        try {
+            StringWriter sw = new StringWriter();
+            marshaller.marshal(this, sw);
+            return sw.toString();
+
+        } catch (Exception e) {
+            return super.toString();
+        }
+    }
+
+    public static CertDataInfo valueOf(String string) throws Exception {
+        try {
+            return (CertDataInfo)unmarshaller.unmarshal(new StringReader(string));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        CertDataInfo before = new CertDataInfo();
+        before.setID(new CertId("12512514865863765114"));
+        before.setSubjectDN("CN=Test User,UID=testuser,O=EXAMPLE-COM");
+        before.setStatus("VALID");
+
+        String string = before.toString();
+        System.out.println(string);
+
+        CertDataInfo after = CertDataInfo.valueOf(string);
+
+        System.out.println(before.equals(after));
+    }
 }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertRevokeRequest.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertRevokeRequest.java
new file mode 100644
index 0000000000000000000000000000000000000000..8bdfe2efe68d4547036c1918d107b25bb5b80185
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/cert/model/CertRevokeRequest.java
@@ -0,0 +1,228 @@
+// --- 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
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2012 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.cms.servlet.cert.model;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Date;
+
+import javax.ws.rs.FormParam;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import com.netscape.certsrv.request.IRequest;
+import com.netscape.certsrv.request.RequestId;
+import com.netscape.certsrv.request.RequestIdAdapter;
+import com.netscape.certsrv.util.DateAdapter;
+
+/**
+ * @author Endi S. Dewata
+ */
+@XmlRootElement(name="CertRevokeRequest")
+public class CertRevokeRequest {
+
+    public static Marshaller marshaller;
+    public static Unmarshaller unmarshaller;
+
+    static {
+        try {
+            JAXBContext context = JAXBContext.newInstance(CertRevokeRequest.class);
+            marshaller = context.createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+            unmarshaller = context.createUnmarshaller();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    RequestId requestID;
+    int reason;
+    int totalRecordCount;
+    int verifiedRecordCount;
+    Date invalidityDate;
+    String comments;
+    String encoded;
+
+
+    @XmlElement(name="requestID")
+    @FormParam("requestId")
+    @XmlJavaTypeAdapter(RequestIdAdapter.class)
+    public RequestId getRequestID() {
+        return requestID;
+    }
+
+    public void setRequestID(RequestId requestID) {
+        this.requestID = requestID;
+    }
+
+    @XmlElement(name="Reason")
+    @FormParam("revocationReason")
+    public int getReason() {
+        return reason;
+    }
+
+    public void setReason(int reason) {
+        this.reason = reason;
+    }
+
+    @XmlElement(name="TotalRecordCount")
+    @FormParam("totalRecordCount")
+    public int getTotalRecordCount() {
+        return totalRecordCount;
+    }
+
+    public void setTotalRecordCount(int totalRecordCount) {
+        this.totalRecordCount = totalRecordCount;
+    }
+
+    @XmlElement(name="VerifiedRecordCount")
+    @FormParam("verifiedRecordCount")
+    public int getVerifiedRecordCount() {
+        return verifiedRecordCount;
+    }
+
+    public void setVerifiedRecordCount(int verifiedRecordCount) {
+        this.verifiedRecordCount = verifiedRecordCount;
+    }
+
+    @XmlElement(name="InvalidityDate")
+    @FormParam("invalidityDate")
+    @XmlJavaTypeAdapter(DateAdapter.class)
+    public Date getInvalidityDate() {
+        return invalidityDate;
+    }
+
+    public void setInvalidityDate(Date invalidityDate) {
+        this.invalidityDate = invalidityDate;
+    }
+
+    @XmlElement(name="Comments")
+    @FormParam(IRequest.REQUESTOR_COMMENTS)
+    public String getComments() {
+        return comments;
+    }
+
+    public void setComments(String comments) {
+        this.comments = comments;
+    }
+
+    @XmlElement(name="Encoded")
+    @FormParam("b64eCertificate")
+    public String getEncoded() {
+        return encoded;
+    }
+
+    public void setEncoded(String encoded) {
+        this.encoded = encoded;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((comments == null) ? 0 : comments.hashCode());
+        result = prime * result + ((encoded == null) ? 0 : encoded.hashCode());
+        result = prime * result + ((invalidityDate == null) ? 0 : invalidityDate.hashCode());
+        result = prime * result + reason;
+        result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
+        result = prime * result + totalRecordCount;
+        result = prime * result + verifiedRecordCount;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        CertRevokeRequest other = (CertRevokeRequest) obj;
+        if (comments == null) {
+            if (other.comments != null)
+                return false;
+        } else if (!comments.equals(other.comments))
+            return false;
+        if (encoded == null) {
+            if (other.encoded != null)
+                return false;
+        } else if (!encoded.equals(other.encoded))
+            return false;
+        if (invalidityDate == null) {
+            if (other.invalidityDate != null)
+                return false;
+        } else if (!invalidityDate.equals(other.invalidityDate))
+            return false;
+        if (reason != other.reason)
+            return false;
+        if (requestID == null) {
+            if (other.requestID != null)
+                return false;
+        } else if (!requestID.equals(other.requestID))
+            return false;
+        if (totalRecordCount != other.totalRecordCount)
+            return false;
+        if (verifiedRecordCount != other.verifiedRecordCount)
+            return false;
+        return true;
+    }
+
+    public String toString() {
+        try {
+            StringWriter sw = new StringWriter();
+            marshaller.marshal(this, sw);
+            return sw.toString();
+
+        } catch (Exception e) {
+            return super.toString();
+        }
+    }
+
+    public static CertRevokeRequest valueOf(String string) throws Exception {
+        try {
+            return (CertRevokeRequest)unmarshaller.unmarshal(new StringReader(string));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        CertRevokeRequest before = new CertRevokeRequest();
+        before.setRequestID(new RequestId("42323234"));
+        before.setReason(1);
+        before.setTotalRecordCount(2);
+        before.setVerifiedRecordCount(3);
+        before.setInvalidityDate(new Date());
+        before.setComments("test");
+        before.setEncoded("test");
+
+        String string = before.toString();
+        System.out.println(string);
+
+        CertRevokeRequest after = CertRevokeRequest.valueOf(string);
+
+        System.out.println(before.equals(after));
+    }
+}
diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertUnrevokeRequest.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertUnrevokeRequest.java
new file mode 100644
index 0000000000000000000000000000000000000000..98d24d36367cc2c511e870d5f1baba8d3885b53b
--- /dev/null
+++ b/base/common/src/com/netscape/cms/servlet/cert/model/CertUnrevokeRequest.java
@@ -0,0 +1,124 @@
+// --- 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
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2012 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+
+package com.netscape.cms.servlet.cert.model;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.ws.rs.FormParam;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import com.netscape.certsrv.request.RequestId;
+import com.netscape.certsrv.request.RequestIdAdapter;
+
+/**
+ * @author Endi S. Dewata
+ */
+@XmlRootElement(name="CertUnrevokeRequest")
+public class CertUnrevokeRequest {
+
+    public static Marshaller marshaller;
+    public static Unmarshaller unmarshaller;
+
+    static {
+        try {
+            JAXBContext context = JAXBContext.newInstance(CertUnrevokeRequest.class);
+            marshaller = context.createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+            unmarshaller = context.createUnmarshaller();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    RequestId requestID;
+
+    @XmlElement(name="requestID")
+    @FormParam("requestId")
+    @XmlJavaTypeAdapter(RequestIdAdapter.class)
+    public RequestId getRequestID() {
+        return requestID;
+    }
+
+    public void setRequestID(RequestId requestID) {
+        this.requestID = requestID;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((requestID == null) ? 0 : requestID.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        CertUnrevokeRequest other = (CertUnrevokeRequest) obj;
+        if (requestID == null) {
+            if (other.requestID != null)
+                return false;
+        } else if (!requestID.equals(other.requestID))
+            return false;
+        return true;
+    }
+
+    public String toString() {
+        try {
+            StringWriter sw = new StringWriter();
+            marshaller.marshal(this, sw);
+            return sw.toString();
+
+        } catch (Exception e) {
+            return super.toString();
+        }
+    }
+
+    public static CertUnrevokeRequest valueOf(String string) throws Exception {
+        try {
+            return (CertUnrevokeRequest)unmarshaller.unmarshal(new StringReader(string));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        CertUnrevokeRequest before = new CertUnrevokeRequest();
+        before.setRequestID(new RequestId("42323234"));
+
+        String string = before.toString();
+        System.out.println(string);
+
+        CertUnrevokeRequest after = CertUnrevokeRequest.valueOf(string);
+
+        System.out.println(before.equals(after));
+    }
+}
diff --git a/base/common/src/com/netscape/cms/servlet/cert/model/CertificateData.java b/base/common/src/com/netscape/cms/servlet/cert/model/CertificateData.java
index cb6ed937dc95700ca6cd8ecf4f7159ee12aca122..bfdb894cb199c238b00a45cd26a84f8d5b448bc3 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/model/CertificateData.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/model/CertificateData.java
@@ -17,12 +17,20 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.cms.servlet.cert.model;
 
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
+import org.jboss.resteasy.plugins.providers.atom.Link;
+
 import com.netscape.certsrv.dbs.certdb.CertId;
 import com.netscape.certsrv.dbs.certdb.CertIdAdapter;
 
@@ -31,51 +39,62 @@ import com.netscape.certsrv.dbs.certdb.CertIdAdapter;
  *
  */
 @XmlRootElement(name = "CertificateData")
-@XmlAccessorType(XmlAccessType.FIELD)
 public class CertificateData {
-    @XmlElement
-    private String b64;
 
-    @XmlElement
-    private String prettyPrint;
+    public static Marshaller marshaller;
+    public static Unmarshaller unmarshaller;
 
-    @XmlElement
-    private String subjectName;
+    static {
+        try {
+            marshaller = JAXBContext.newInstance(CertificateData.class).createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+            unmarshaller = JAXBContext.newInstance(CertificateData.class).createUnmarshaller();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
 
-    @XmlElement
-    private String pkcs7CertChain;
+    CertId serialNumber;
+    String issuerDN;
+    String subjectDN;
+    String prettyPrint;
+    String encoded;
+    String pkcs7CertChain;
+    String notBefore;
+    String notAfter;
+    String status;
 
-    @XmlElement
+    Link link;
+
+    @XmlAttribute(name="id")
     @XmlJavaTypeAdapter(CertIdAdapter.class)
-    private CertId serialNo;
-
-    @XmlElement
-    private String notBefore;
+    public CertId getSerialNumber() {
+        return serialNumber;
+    }
 
-    @XmlElement
-    private String notAfter;
+    public void setSerialNumber(CertId serialNumber) {
+        this.serialNumber = serialNumber;
+    }
 
-    @XmlElement
-    private String issuerName;
+    @XmlElement(name="IssuerDN")
+    public String getIssuerDN() {
+        return issuerDN;
+    }
 
-    public CertificateData() {
-        // required for jaxb
+    public void setIssuerDN(String issuerDN) {
+        this.issuerDN = issuerDN;
     }
 
-    /**
-     * @return the b64
-     */
-    public String getB64() {
-        return b64;
+    @XmlElement(name="SubjectDN")
+    public String getSubjectDN() {
+        return subjectDN;
     }
 
-    /**
-     * @param b64 the b64 to set
-     */
-    public void setB64(String b64) {
-        this.b64 = b64;
+    public void setSubjectDN(String subjectDN) {
+        this.subjectDN = subjectDN;
     }
 
+    @XmlElement(name="PrettyPrint")
     public String getPrettyPrint() {
         return prettyPrint;
     }
@@ -84,6 +103,16 @@ public class CertificateData {
         this.prettyPrint = prettyPrint;
     }
 
+    @XmlElement(name="Encoded")
+    public String getEncoded() {
+        return encoded;
+    }
+
+    public void setEncoded(String encoded) {
+        this.encoded = encoded;
+    }
+
+    @XmlElement(name="PKCS7CertChain")
     public void setPkcs7CertChain(String chain) {
         this.pkcs7CertChain = chain;
     }
@@ -92,22 +121,7 @@ public class CertificateData {
         return pkcs7CertChain;
     }
 
-    public String getSubjectName() {
-        return subjectName;
-    }
-
-    public void setSubjectName(String subjectName) {
-        this.subjectName = subjectName;
-    }
-
-    public CertId getSerialNo() {
-        return serialNo;
-    }
-
-    public void setSerialNo(CertId serialNo) {
-        this.serialNo = serialNo;
-    }
-
+    @XmlElement(name="NotBefore")
     public String getNotBefore() {
         return notBefore;
     }
@@ -116,6 +130,7 @@ public class CertificateData {
         this.notBefore = notBefore;
     }
 
+    @XmlElement(name="NotAfter")
     public String getNotAfter() {
         return notAfter;
     }
@@ -124,12 +139,145 @@ public class CertificateData {
         this.notAfter = notAfter;
     }
 
-    public String getIssuerName() {
-        return issuerName;
+    @XmlElement(name="Status")
+    public String getStatus() {
+        return status;
     }
 
-    public void setIssuerName(String issuerName) {
-        this.issuerName = issuerName;
+    public void setStatus(String status) {
+        this.status = status;
     }
 
+    @XmlElement(name="Link")
+    public Link getLink() {
+        return link;
+    }
+
+    public void setLink(Link link) {
+        this.link = link;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((encoded == null) ? 0 : encoded.hashCode());
+        result = prime * result + ((issuerDN == null) ? 0 : issuerDN.hashCode());
+        result = prime * result + ((notAfter == null) ? 0 : notAfter.hashCode());
+        result = prime * result + ((notBefore == null) ? 0 : notBefore.hashCode());
+        result = prime * result + ((pkcs7CertChain == null) ? 0 : pkcs7CertChain.hashCode());
+        result = prime * result + ((prettyPrint == null) ? 0 : prettyPrint.hashCode());
+        result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode());
+        result = prime * result + ((status == null) ? 0 : status.hashCode());
+        result = prime * result + ((subjectDN == null) ? 0 : subjectDN.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        CertificateData other = (CertificateData) obj;
+        if (encoded == null) {
+            if (other.encoded != null)
+                return false;
+        } else if (!encoded.equals(other.encoded))
+            return false;
+        if (issuerDN == null) {
+            if (other.issuerDN != null)
+                return false;
+        } else if (!issuerDN.equals(other.issuerDN))
+            return false;
+        if (notAfter == null) {
+            if (other.notAfter != null)
+                return false;
+        } else if (!notAfter.equals(other.notAfter))
+            return false;
+        if (notBefore == null) {
+            if (other.notBefore != null)
+                return false;
+        } else if (!notBefore.equals(other.notBefore))
+            return false;
+        if (pkcs7CertChain == null) {
+            if (other.pkcs7CertChain != null)
+                return false;
+        } else if (!pkcs7CertChain.equals(other.pkcs7CertChain))
+            return false;
+        if (prettyPrint == null) {
+            if (other.prettyPrint != null)
+                return false;
+        } else if (!prettyPrint.equals(other.prettyPrint))
+            return false;
+        if (serialNumber == null) {
+            if (other.serialNumber != null)
+                return false;
+        } else if (!serialNumber.equals(other.serialNumber))
+            return false;
+        if (status == null) {
+            if (other.status != null)
+                return false;
+        } else if (!status.equals(other.status))
+            return false;
+        if (subjectDN == null) {
+            if (other.subjectDN != null)
+                return false;
+        } else if (!subjectDN.equals(other.subjectDN))
+            return false;
+        return true;
+    }
+
+    public String toString() {
+        try {
+            StringWriter sw = new StringWriter();
+            marshaller.marshal(this, sw);
+            return sw.toString();
+
+        } catch (Exception e) {
+            return super.toString();
+        }
+    }
+
+    public static CertificateData valueOf(String string) throws Exception {
+        try {
+            return (CertificateData)unmarshaller.unmarshal(new StringReader(string));
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        StringWriter sw = new StringWriter();
+        PrintWriter out = new PrintWriter(sw, true);
+
+        out.println("-----BEGIN CERTIFICATE-----");
+        out.println("MIIB/zCCAWgCCQCtpWH58pqsejANBgkqhkiG9w0BAQUFADBEMRQwEgYDVQQKDAtF");
+        out.println("WEFNUExFLUNPTTEYMBYGCgmSJomT8ixkAQEMCHRlc3R1c2VyMRIwEAYDVQQDDAlU");
+        out.println("ZXN0IFVzZXIwHhcNMTIwNTE0MTcxNzI3WhcNMTMwNTE0MTcxNzI3WjBEMRQwEgYD");
+        out.println("VQQKDAtFWEFNUExFLUNPTTEYMBYGCgmSJomT8ixkAQEMCHRlc3R1c2VyMRIwEAYD");
+        out.println("VQQDDAlUZXN0IFVzZXIwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKmmiPJp");
+        out.println("Agh/gPUAZjfgJ3a8QiHvpMzZ/hZy1FVP3+2sNhCkMv+D/I8Y7AsrbJGxxvD7bTDm");
+        out.println("zQYtYx2ryGyOgY7KBRxEj/IrNVHIkJMYq5G/aIU4FAzpc6ntNSwUQBYUAamfK8U6");
+        out.println("Wo4Cp6rLePXIDE6sfGn3VX6IeSJ8U2V+vwtzAgMBAAEwDQYJKoZIhvcNAQEFBQAD");
+        out.println("gYEAY9bjcD/7Z+oX6gsJtX6Rd79E7X5IBdOdArYzHNE4vjdaQrZw6oCxrY8ffpKC");
+        out.println("0T0q5PX9I7er+hx/sQjGPMrJDEN+vFBSNrZE7sTeLRgkyiqGvChSyuG05GtGzXO4");
+        out.println("bFBr+Gwk2VF2wJvOhTXU2hN8sfkkd9clzIXuL8WCDhWk1bY=");
+        out.println("-----END CERTIFICATE-----");
+
+        CertificateData before = new CertificateData();
+        before.setSerialNumber(new CertId("12512514865863765114"));
+        before.setIssuerDN("CN=Test User,UID=testuser,O=EXAMPLE-COM");
+        before.setSubjectDN("CN=Test User,UID=testuser,O=EXAMPLE-COM");
+        before.setEncoded(sw.toString());
+
+        String string = before.toString();
+        System.out.println(string);
+
+        CertificateData after = CertificateData.valueOf(string);
+        System.out.println(before.equals(after));
+    }
 }
diff --git a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMRestClient.java b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMRestClient.java
index 772612bf494683e70448c2cbdcea4392082404cf..cd25d7b78338a803a16bbc0d8e64a8e0fcc1c8ce 100644
--- a/base/kra/functional/src/com/netscape/cms/servlet/test/DRMRestClient.java
+++ b/base/kra/functional/src/com/netscape/cms/servlet/test/DRMRestClient.java
@@ -49,7 +49,7 @@ public class DRMRestClient  extends CMSRestClient {
         ClientResponse<CertificateData> response = (ClientResponse<CertificateData>) systemCertClient
                 .getTransportCert();
         CertificateData certData = response.getEntity();
-        String transportCert = certData.getB64();
+        String transportCert = certData.getEncoded();
         return transportCert;
     }
 
diff --git a/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java b/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java
index 4409ddeaf3107a61008727b428293ce84374a975..de8569e4de33fed2819a7d915cfeb2bdc77a09d9 100644
--- a/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java
+++ b/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java
@@ -45,9 +45,9 @@ public class LDAPUtil {
      * @param string string to escape
      * @return escaped string
      */
-    public static String escapeFilter(String string) {
+    public static String escapeFilter(Object object) {
         StringBuilder sb = new StringBuilder();
-        for (char c : string.toCharArray()) {
+        for (char c : object.toString().toCharArray()) {
             if (SPECIAL_CHARS.indexOf(c) >= 0) {
                 sb.append('\\');
                 if (c < 0x10)
-- 
1.7.7.6

