From c19c3b273fa2e1c9c82a5123612536882789fa51 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Thu, 20 Feb 2014 16:58:34 -0500
Subject: [PATCH] Reorganized REST service classes.

The REST service classes have been moved into org.dogtagpki.server
namespace. A new upgrade script has been added to update existing
instances.

Ticket #114
---
 base/ca/shared/webapps/ca/WEB-INF/web.xml          |  2 +-
 base/ca/src/CMakeLists.txt                         | 39 +++++++++++-
 .../dogtagpki/server/ca/rest/CAApplication.java}   | 31 ++++-----
 .../server/ca/rest}/CertRequestService.java        |  3 +-
 .../org/dogtagpki/server/ca/rest}/CertService.java |  5 +-
 .../server/ca/rest}/KRAConnectorService.java       |  3 +-
 .../dogtagpki/server/ca/rest}/ProfileService.java  |  4 +-
 base/kra/shared/webapps/kra/WEB-INF/web.xml        |  2 +-
 base/kra/src/CMakeLists.txt                        | 47 +++++++++++---
 .../netscape/kra/SecurityDataRecoveryService.java  |  2 +-
 .../src/com/netscape/kra/SecurityDataService.java  |  2 +-
 .../kra/src/com/netscape/kra/SymKeyGenService.java |  4 +-
 .../dogtagpki/server/kra/rest/KRAApplication.java} | 29 ++++-----
 .../server/kra/rest}/KeyRequestService.java        | 15 +----
 .../org/dogtagpki/server/kra/rest}/KeyService.java |  3 +-
 base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml      |  2 +-
 base/ocsp/src/CMakeLists.txt                       |  2 +
 .../server/ocsp/rest}/OCSPApplication.java         | 23 +++----
 base/server/cms/src/CMakeLists.txt                 | 19 +++---
 .../cms/servlet/csadmin/ConfigurationUtils.java    |  4 +-
 .../netscape/cms/servlet/key/KeyRequestDAO.java    | 17 ++++-
 .../dogtagpki/server/rest}/ACLInterceptor.java     |  2 +-
 .../dogtagpki/server/rest}/AccountService.java     |  2 +-
 .../org/dogtagpki/server/rest}/AuditService.java   |  2 +-
 .../server/rest}/AuthMethodInterceptor.java        |  2 +-
 .../dogtagpki/server/rest}/GroupService.java       |  3 +-
 .../server/rest}/SecurityDomainService.java        |  3 +-
 .../dogtagpki/server/rest}/SelfTestService.java    |  2 +-
 .../dogtagpki/server/rest}/SystemCertService.java  |  2 +-
 .../server/rest}/SystemConfigService.java          |  5 +-
 .../dogtagpki/server/rest}/UserService.java        |  3 +-
 .../src/com/netscape/cmscore/usrgrp/User.java      |  6 +-
 .../10.1.99/04-ReplaceRESTEasyApplicationClass     | 74 ++++++++++++++++++++++
 base/tks/shared/webapps/tks/WEB-INF/web.xml        |  2 +-
 base/tks/src/CMakeLists.txt                        | 61 ++++++++++++++----
 .../dogtagpki/server/tks/rest}/TKSApplication.java | 22 +++----
 .../server/tks/rest}/TPSConnectorService.java      |  2 +-
 base/tps-tomcat/shared/webapps/tps/WEB-INF/web.xml |  2 +-
 base/tps-tomcat/src/CMakeLists.txt                 | 44 ++++++++-----
 .../src/org/dogtagpki/server/tps/TPSSubsystem.java | 14 ++--
 .../{connection => config}/ConnectionDatabase.java |  5 +-
 .../{connection => config}/ConnectionRecord.java   |  2 +-
 .../tps/{profile => config}/ProfileDatabase.java   |  5 +-
 .../ProfileMappingDatabase.java                    |  5 +-
 .../{profile => config}/ProfileMappingRecord.java  |  2 +-
 .../tps/{profile => config}/ProfileRecord.java     |  2 +-
 .../tps/{logging => dbs}/ActivityDatabase.java     |  2 +-
 .../tps/{logging => dbs}/ActivityRecord.java       |  2 +-
 .../AuthenticatorDatabase.java                     |  2 +-
 .../AuthenticatorRecord.java                       |  2 +-
 .../server/tps/{cert => dbs}/TPSCertDatabase.java  |  2 +-
 .../server/tps/{cert => dbs}/TPSCertRecord.java    |  2 +-
 .../server/tps/{token => dbs}/TokenDatabase.java   |  2 +-
 .../server/tps/{token => dbs}/TokenRecord.java     |  2 +-
 .../tps/{logging => rest}/ActivityService.java     |  4 +-
 .../AuthenticatorService.java                      |  4 +-
 .../{connection => rest}/ConnectionService.java    |  4 +-
 .../{profile => rest}/ProfileMappingService.java   |  4 +-
 .../tps/{profile => rest}/ProfileService.java      |  4 +-
 .../server/tps/{ => rest}/TPSApplication.java      | 27 +++-----
 .../server/tps/{cert => rest}/TPSCertService.java  |  4 +-
 .../server/tps/{token => rest}/TokenService.java   |  4 +-
 62 files changed, 399 insertions(+), 204 deletions(-)
 rename base/ca/src/{com/netscape/ca/CertificateAuthorityApplication.java => org/dogtagpki/server/ca/rest/CAApplication.java} (71%)
 rename base/{server/cms/src/com/netscape/cms/servlet/request => ca/src/org/dogtagpki/server/ca/rest}/CertRequestService.java (99%)
 rename base/{server/cms/src/com/netscape/cms/servlet/cert => ca/src/org/dogtagpki/server/ca/rest}/CertService.java (99%)
 rename base/{server/cms/src/com/netscape/cms/servlet/admin => ca/src/org/dogtagpki/server/ca/rest}/KRAConnectorService.java (96%)
 rename base/{server/cms/src/com/netscape/cms/servlet/profile => ca/src/org/dogtagpki/server/ca/rest}/ProfileService.java (99%)
 rename base/kra/src/{com/netscape/kra/KeyRecoveryAuthorityApplication.java => org/dogtagpki/server/kra/rest/KRAApplication.java} (67%)
 rename base/{server/cms/src/com/netscape/cms/servlet/request => kra/src/org/dogtagpki/server/kra/rest}/KeyRequestService.java (95%)
 rename base/{server/cms/src/com/netscape/cms/servlet/key => kra/src/org/dogtagpki/server/kra/rest}/KeyService.java (99%)
 rename base/ocsp/src/{com/netscape/ocsp => org/dogtagpki/server/ocsp/rest}/OCSPApplication.java (74%)
 rename base/server/cms/src/{com/netscape/cms/authorization => org/dogtagpki/server/rest}/ACLInterceptor.java (99%)
 rename base/server/cms/src/{com/netscape/cms/servlet/account => org/dogtagpki/server/rest}/AccountService.java (98%)
 rename base/server/{cmscore/src/com/netscape/cmscore/logging => cms/src/org/dogtagpki/server/rest}/AuditService.java (99%)
 rename base/server/cms/src/{com/netscape/cms/authorization => org/dogtagpki/server/rest}/AuthMethodInterceptor.java (99%)
 rename base/server/cms/src/{com/netscape/cms/servlet/admin => org/dogtagpki/server/rest}/GroupService.java (99%)
 rename base/server/cms/src/{com/netscape/cms/servlet/csadmin => org/dogtagpki/server/rest}/SecurityDomainService.java (96%)
 rename base/server/{cmscore/src/com/netscape/cmscore/selftests => cms/src/org/dogtagpki/server/rest}/SelfTestService.java (99%)
 rename base/server/cms/src/{com/netscape/cms/servlet/admin => org/dogtagpki/server/rest}/SystemCertService.java (98%)
 rename base/server/cms/src/{com/netscape/cms/servlet/csadmin => org/dogtagpki/server/rest}/SystemConfigService.java (99%)
 rename base/server/cms/src/{com/netscape/cms/servlet/admin => org/dogtagpki/server/rest}/UserService.java (99%)
 create mode 100755 base/server/upgrade/10.1.99/04-ReplaceRESTEasyApplicationClass
 rename base/tks/src/{com/netscape/tks => org/dogtagpki/server/tks/rest}/TKSApplication.java (68%)
 rename base/{server/cms/src/com/netscape/cms/servlet/tks => tks/src/org/dogtagpki/server/tks/rest}/TPSConnectorService.java (99%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{connection => config}/ConnectionDatabase.java (97%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{connection => config}/ConnectionRecord.java (95%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{profile => config}/ProfileDatabase.java (97%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{profile => config}/ProfileMappingDatabase.java (97%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{profile => config}/ProfileMappingRecord.java (95%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{profile => config}/ProfileRecord.java (95%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{logging => dbs}/ActivityDatabase.java (97%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{logging => dbs}/ActivityRecord.java (99%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{authenticator => dbs}/AuthenticatorDatabase.java (99%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{authenticator => dbs}/AuthenticatorRecord.java (95%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{cert => dbs}/TPSCertDatabase.java (98%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{cert => dbs}/TPSCertRecord.java (99%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{token => dbs}/TokenDatabase.java (97%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{token => dbs}/TokenRecord.java (99%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{logging => rest}/ActivityService.java (97%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{authenticator => rest}/AuthenticatorService.java (98%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{connection => rest}/ConnectionService.java (98%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{profile => rest}/ProfileMappingService.java (98%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{profile => rest}/ProfileService.java (98%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{ => rest}/TPSApplication.java (73%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{cert => rest}/TPSCertService.java (97%)
 rename base/tps-tomcat/src/org/dogtagpki/server/tps/{token => rest}/TokenService.java (98%)

diff --git a/base/ca/shared/webapps/ca/WEB-INF/web.xml b/base/ca/shared/webapps/ca/WEB-INF/web.xml
index 6bf137ca7b50c91d492813583243177315a88afe..5f20ed1943754217fb81f26e1673bfd460e1fe1a 100644
--- a/base/ca/shared/webapps/ca/WEB-INF/web.xml
+++ b/base/ca/shared/webapps/ca/WEB-INF/web.xml
@@ -1860,7 +1860,7 @@
       <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
       <init-param>
          <param-name>javax.ws.rs.Application</param-name>
-         <param-value>com.netscape.ca.CertificateAuthorityApplication</param-value>
+         <param-value>org.dogtagpki.server.ca.rest.CAApplication</param-value>
       </init-param>
    </servlet>
    
diff --git a/base/ca/src/CMakeLists.txt b/base/ca/src/CMakeLists.txt
index 74533814acff2f156b7924543b80652cbb442707..5b805e1b3a5eddb46d17178ca2ac204c36ae5680 100644
--- a/base/ca/src/CMakeLists.txt
+++ b/base/ca/src/CMakeLists.txt
@@ -24,6 +24,13 @@ find_file(COMMONS_CODEC_JAR
         /usr/share/java
 )
 
+find_file(COMMONS_LANG_JAR
+    NAMES
+        commons-lang.jar
+    PATHS
+        /usr/share/java
+)
+
 find_file(JAXRS_API_JAR
     NAMES
         jaxrs-api.jar
@@ -31,6 +38,20 @@ find_file(JAXRS_API_JAR
         ${RESTEASY_LIB}
 )
 
+find_file(RESTEASY_JAXRS_JAR
+    NAMES
+        resteasy-jaxrs.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
+find_file(RESTEASY_ATOM_PROVIDER_JAR
+    NAMES
+        resteasy-atom-provider.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
 find_file(SERVLET_JAR
     NAMES
         servlet.jar
@@ -39,15 +60,26 @@ find_file(SERVLET_JAR
         /usr/share/java
 )
 
+find_file(TOMCAT_CATALINA_JAR
+    NAMES
+        catalina.jar
+    PATHS
+        /usr/share/java/tomcat
+)
+
 # build pki-ca
 javac(pki-ca-classes
     SOURCES
         com/netscape/ca/*.java
+        org/dogtagpki/server/ca/*.java
     CLASSPATH
-        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
+        ${COMMONS_CODEC_JAR} ${COMMONS_LANG_JAR}
+        ${JSS_JAR} ${SYMKEY_JAR}
+        ${LDAPJDK_JAR}
+        ${SERVLET_JAR} ${TOMCAT_CATALINA_JAR}
+        ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-        ${LDAPJDK_JAR} ${JAXRS_API_JAR}
-        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR} ${SERVLET_JAR}
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
     OUTPUT_DIR
         ${CMAKE_BINARY_DIR}/classes
     DEPENDS
@@ -70,6 +102,7 @@ jar(pki-ca-jar
         ${CMAKE_BINARY_DIR}/classes
     FILES
         com/netscape/ca/*.class
+        org/dogtagpki/server/ca/*.class
     DEPENDS
         pki-ca-classes
 )
diff --git a/base/ca/src/com/netscape/ca/CertificateAuthorityApplication.java b/base/ca/src/org/dogtagpki/server/ca/rest/CAApplication.java
similarity index 71%
rename from base/ca/src/com/netscape/ca/CertificateAuthorityApplication.java
rename to base/ca/src/org/dogtagpki/server/ca/rest/CAApplication.java
index b20a544f5c556859fa17e316853442c75fba490e..78f3da941d0b5f33737a9b4941a6d945e2fbe150 100644
--- a/base/ca/src/com/netscape/ca/CertificateAuthorityApplication.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/CAApplication.java
@@ -1,35 +1,32 @@
-package com.netscape.ca;
+package org.dogtagpki.server.ca.rest;
 
 import java.util.LinkedHashSet;
 import java.util.Set;
 
 import javax.ws.rs.core.Application;
 
+import org.dogtagpki.server.rest.ACLInterceptor;
+import org.dogtagpki.server.rest.AccountService;
+import org.dogtagpki.server.rest.AuditService;
+import org.dogtagpki.server.rest.AuthMethodInterceptor;
+import org.dogtagpki.server.rest.GroupService;
+import org.dogtagpki.server.rest.SecurityDomainService;
+import org.dogtagpki.server.rest.SelfTestService;
+import org.dogtagpki.server.rest.SystemCertService;
+import org.dogtagpki.server.rest.SystemConfigService;
+import org.dogtagpki.server.rest.UserService;
+
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.IConfigStore;
 import com.netscape.certsrv.base.PKIException;
-import com.netscape.cms.authorization.ACLInterceptor;
-import com.netscape.cms.authorization.AuthMethodInterceptor;
-import com.netscape.cms.servlet.account.AccountService;
-import com.netscape.cms.servlet.admin.GroupService;
-import com.netscape.cms.servlet.admin.KRAConnectorService;
-import com.netscape.cms.servlet.admin.SystemCertService;
-import com.netscape.cms.servlet.admin.UserService;
-import com.netscape.cms.servlet.cert.CertService;
-import com.netscape.cms.servlet.csadmin.SecurityDomainService;
-import com.netscape.cms.servlet.csadmin.SystemConfigService;
-import com.netscape.cms.servlet.profile.ProfileService;
-import com.netscape.cms.servlet.request.CertRequestService;
-import com.netscape.cmscore.logging.AuditService;
-import com.netscape.cmscore.selftests.SelfTestService;
 
-public class CertificateAuthorityApplication extends Application {
+public class CAApplication extends Application {
 
     private Set<Object> singletons = new LinkedHashSet<Object>();
     private Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
 
-    public CertificateAuthorityApplication() {
+    public CAApplication() {
 
         // account
         classes.add(AccountService.class);
diff --git a/base/server/cms/src/com/netscape/cms/servlet/request/CertRequestService.java b/base/ca/src/org/dogtagpki/server/ca/rest/CertRequestService.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/servlet/request/CertRequestService.java
rename to base/ca/src/org/dogtagpki/server/ca/rest/CertRequestService.java
index df50a007e0e2c716952e61e1759ac4895acfe23a..74f7b52f6372800ce4c3ce613116aad7020afced 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/request/CertRequestService.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/CertRequestService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.request;
+package org.dogtagpki.server.ca.rest;
 
 import java.net.URI;
 import java.util.ArrayList;
@@ -61,7 +61,6 @@ import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.request.RequestNotFoundException;
 import com.netscape.cms.servlet.base.PKIService;
 import com.netscape.cms.servlet.cert.CertRequestDAO;
-import com.netscape.cms.servlet.profile.ProfileService;
 import com.netscape.cmsutil.ldap.LDAPUtil;
 
 /**
diff --git a/base/server/cms/src/com/netscape/cms/servlet/cert/CertService.java b/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/servlet/cert/CertService.java
rename to base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
index e8e735e467a520a0f63eaff2d8712980db29bcf6..e8d0f2d88ef328c1aaa751061048366006384656 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/cert/CertService.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/CertService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.cert;
+package org.dogtagpki.server.ca.rest;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -77,6 +77,9 @@ import com.netscape.certsrv.logging.ILogger;
 import com.netscape.certsrv.request.IRequest;
 import com.netscape.cms.realm.PKIPrincipal;
 import com.netscape.cms.servlet.base.PKIService;
+import com.netscape.cms.servlet.cert.CertRequestDAO;
+import com.netscape.cms.servlet.cert.FilterBuilder;
+import com.netscape.cms.servlet.cert.RevocationProcessor;
 import com.netscape.cms.servlet.processors.CAProcessor;
 import com.netscape.cmsutil.ldap.LDAPUtil;
 import com.netscape.cmsutil.util.Utils;
diff --git a/base/server/cms/src/com/netscape/cms/servlet/admin/KRAConnectorService.java b/base/ca/src/org/dogtagpki/server/ca/rest/KRAConnectorService.java
similarity index 96%
rename from base/server/cms/src/com/netscape/cms/servlet/admin/KRAConnectorService.java
rename to base/ca/src/org/dogtagpki/server/ca/rest/KRAConnectorService.java
index 310e082061b8fb34c678a9d51dd2113453d2a479..b488e5381bbe4e5ad42a71b193ebeb065a8182c8 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/admin/KRAConnectorService.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/KRAConnectorService.java
@@ -15,7 +15,7 @@
 // (C) 2013 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
-package com.netscape.cms.servlet.admin;
+package org.dogtagpki.server.ca.rest;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.core.Context;
@@ -29,6 +29,7 @@ import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.PKIException;
 import com.netscape.certsrv.system.KRAConnectorInfo;
 import com.netscape.certsrv.system.KRAConnectorResource;
+import com.netscape.cms.servlet.admin.KRAConnectorProcessor;
 import com.netscape.cms.servlet.base.PKIService;
 
 /**
diff --git a/base/server/cms/src/com/netscape/cms/servlet/profile/ProfileService.java b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/servlet/profile/ProfileService.java
rename to base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
index eb9dc83dfd21499fd7047a6bf4af80e1ad6876d3..4c2b259b2d6e5195526ab89cc51cab92a7da0af9 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/profile/ProfileService.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
@@ -16,7 +16,7 @@
 //All rights reserved.
 //--- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.profile;
+package org.dogtagpki.server.ca.rest;
 
 import java.io.File;
 import java.io.IOException;
@@ -76,6 +76,8 @@ import com.netscape.certsrv.registry.IPluginInfo;
 import com.netscape.certsrv.registry.IPluginRegistry;
 import com.netscape.cms.realm.PKIPrincipal;
 import com.netscape.cms.servlet.base.PKIService;
+import com.netscape.cms.servlet.profile.PolicyConstraintFactory;
+import com.netscape.cms.servlet.profile.PolicyDefaultFactory;
 
 /**
  * @author alee
diff --git a/base/kra/shared/webapps/kra/WEB-INF/web.xml b/base/kra/shared/webapps/kra/WEB-INF/web.xml
index d27d88d7191a347783f749425dc92ceeb961ac31..0a5f92ae2804ea82c7c99c35b4599281ee8a7282 100644
--- a/base/kra/shared/webapps/kra/WEB-INF/web.xml
+++ b/base/kra/shared/webapps/kra/WEB-INF/web.xml
@@ -830,7 +830,7 @@
       <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
       <init-param>
          <param-name>javax.ws.rs.Application</param-name>
-         <param-value>com.netscape.kra.KeyRecoveryAuthorityApplication</param-value>
+         <param-value>org.dogtagpki.server.kra.rest.KRAApplication</param-value>
       </init-param>
    </servlet>
 
diff --git a/base/kra/src/CMakeLists.txt b/base/kra/src/CMakeLists.txt
index 99088ce069cfd0f5b70f33b79f8bfb6dbfec83bf..53de1a6a8d66c4aa994a45a522e0a9d3acd855a6 100644
--- a/base/kra/src/CMakeLists.txt
+++ b/base/kra/src/CMakeLists.txt
@@ -46,13 +46,6 @@ find_file(LDAPJDK_JAR
         /usr/share/java
 )
 
-find_file(JAXRS_API_JAR
-    NAMES
-        jaxrs-api.jar
-    PATHS
-        ${RESTEASY_LIB}
-)
-
 # '${JAVA_LIB_INSTALL_DIR}' jars
 find_file(JSS_JAR
     NAMES
@@ -68,6 +61,35 @@ find_file(COMMONS_CODEC_JAR
         /usr/share/java
 )
 
+find_file(JAXRS_API_JAR
+    NAMES
+        jaxrs-api.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
+find_file(RESTEASY_JAXRS_JAR
+    NAMES
+        resteasy-jaxrs.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
+find_file(RESTEASY_ATOM_PROVIDER_JAR
+    NAMES
+        resteasy-atom-provider.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
+find_file(SERVLET_JAR
+    NAMES
+        servlet.jar
+    PATHS
+        ${JAVA_LIB_INSTALL_DIR}
+        /usr/share/java
+)
+
 find_file(SYMKEY_JAR
     NAMES
         symkey.jar
@@ -80,11 +102,15 @@ find_file(SYMKEY_JAR
 javac(pki-kra-classes
     SOURCES
         com/netscape/kra/*.java
+        org/dogtagpki/server/kra/*.java
     CLASSPATH
-        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
+        ${COMMONS_CODEC_JAR}
+        ${JSS_JAR} ${SYMKEY_JAR}
+        ${LDAPJDK_JAR}
+        ${SERVLET_JAR}
+        ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-        ${LDAPJDK_JAR} ${JAXRS_API_JAR}
-        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
     OUTPUT_DIR
         ${CMAKE_BINARY_DIR}/classes
     DEPENDS
@@ -107,6 +133,7 @@ jar(pki-kra-jar
         ${CMAKE_BINARY_DIR}/classes
     FILES
         com/netscape/kra/*.class
+        org/dogtagpki/server/kra/*.class
     DEPENDS
         pki-kra-classes
 )
diff --git a/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java b/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java
index f3b7709e74c46423a0baff616a2e552477ae1c2d..269fa8df4aa39cc49ab2ec8fff50fd89d579b27a 100644
--- a/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java
+++ b/base/kra/src/com/netscape/kra/SecurityDataRecoveryService.java
@@ -30,6 +30,7 @@ import java.util.Random;
 
 import javax.crypto.spec.RC2ParameterSpec;
 
+import org.dogtagpki.server.kra.rest.KeyRequestService;
 import org.mozilla.jss.CryptoManager;
 import org.mozilla.jss.asn1.OCTET_STRING;
 import org.mozilla.jss.crypto.Cipher;
@@ -64,7 +65,6 @@ import com.netscape.certsrv.request.IService;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.security.IStorageKeyUnit;
 import com.netscape.certsrv.security.ITransportKeyUnit;
-import com.netscape.cms.servlet.request.KeyRequestService;
 import com.netscape.cmscore.dbs.KeyRecord;
 import com.netscape.cmsutil.util.Utils;
 
diff --git a/base/kra/src/com/netscape/kra/SecurityDataService.java b/base/kra/src/com/netscape/kra/SecurityDataService.java
index bbea11c32a0d53905cbdffd1377755c0d68c279e..e6ffc6d80c38b2cde1f70c58e0a655145f048d46 100644
--- a/base/kra/src/com/netscape/kra/SecurityDataService.java
+++ b/base/kra/src/com/netscape/kra/SecurityDataService.java
@@ -19,6 +19,7 @@ package com.netscape.kra;
 
 import java.math.BigInteger;
 
+import org.dogtagpki.server.kra.rest.KeyRequestService;
 import org.mozilla.jss.crypto.SymmetricKey;
 
 import com.netscape.certsrv.apps.CMS;
@@ -35,7 +36,6 @@ import com.netscape.certsrv.request.IService;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.security.IStorageKeyUnit;
 import com.netscape.certsrv.security.ITransportKeyUnit;
-import com.netscape.cms.servlet.request.KeyRequestService;
 import com.netscape.cmscore.dbs.KeyRecord;
 import com.netscape.cmsutil.util.Utils;
 
diff --git a/base/kra/src/com/netscape/kra/SymKeyGenService.java b/base/kra/src/com/netscape/kra/SymKeyGenService.java
index 32dc1ceb9f1c600b6c14533d190086475cfd345e..799d3570ba1e67a09e9e3a04db5bc04aeaf8af3d 100644
--- a/base/kra/src/com/netscape/kra/SymKeyGenService.java
+++ b/base/kra/src/com/netscape/kra/SymKeyGenService.java
@@ -44,7 +44,7 @@ import com.netscape.certsrv.request.IRequest;
 import com.netscape.certsrv.request.IService;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.security.IStorageKeyUnit;
-import com.netscape.cms.servlet.request.KeyRequestService;
+import com.netscape.cms.servlet.key.KeyRequestDAO;
 import com.netscape.cmscore.dbs.KeyRecord;
 
 /**
@@ -111,7 +111,7 @@ public class SymKeyGenService implements IService {
         }
 
         CryptoToken token = mStorageUnit.getToken();
-        KeyGenAlgorithm kgAlg = KeyRequestService.KEYGEN_ALGORITHMS.get(algorithm);
+        KeyGenAlgorithm kgAlg = KeyRequestDAO.KEYGEN_ALGORITHMS.get(algorithm);
         if (kgAlg == null) {
             throw new EBaseException("Invalid algorithm");
         }
diff --git a/base/kra/src/com/netscape/kra/KeyRecoveryAuthorityApplication.java b/base/kra/src/org/dogtagpki/server/kra/rest/KRAApplication.java
similarity index 67%
rename from base/kra/src/com/netscape/kra/KeyRecoveryAuthorityApplication.java
rename to base/kra/src/org/dogtagpki/server/kra/rest/KRAApplication.java
index 0b311427ffae32b1602c3e020d23698c518990f0..ea8a6c0389c36934d13b7bc40755b7a15c6d77f9 100644
--- a/base/kra/src/com/netscape/kra/KeyRecoveryAuthorityApplication.java
+++ b/base/kra/src/org/dogtagpki/server/kra/rest/KRAApplication.java
@@ -1,33 +1,32 @@
-package com.netscape.kra;
+package org.dogtagpki.server.kra.rest;
 
 import java.util.LinkedHashSet;
 import java.util.Set;
 
 import javax.ws.rs.core.Application;
 
+import org.dogtagpki.server.rest.ACLInterceptor;
+import org.dogtagpki.server.rest.AccountService;
+import org.dogtagpki.server.rest.AuditService;
+import org.dogtagpki.server.rest.AuthMethodInterceptor;
+import org.dogtagpki.server.rest.GroupService;
+import org.dogtagpki.server.rest.SecurityDomainService;
+import org.dogtagpki.server.rest.SelfTestService;
+import org.dogtagpki.server.rest.SystemCertService;
+import org.dogtagpki.server.rest.SystemConfigService;
+import org.dogtagpki.server.rest.UserService;
+
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.IConfigStore;
 import com.netscape.certsrv.base.PKIException;
-import com.netscape.cms.authorization.ACLInterceptor;
-import com.netscape.cms.authorization.AuthMethodInterceptor;
-import com.netscape.cms.servlet.account.AccountService;
-import com.netscape.cms.servlet.admin.GroupService;
-import com.netscape.cms.servlet.admin.SystemCertService;
-import com.netscape.cms.servlet.admin.UserService;
-import com.netscape.cms.servlet.csadmin.SecurityDomainService;
-import com.netscape.cms.servlet.csadmin.SystemConfigService;
-import com.netscape.cms.servlet.key.KeyService;
-import com.netscape.cms.servlet.request.KeyRequestService;
-import com.netscape.cmscore.logging.AuditService;
-import com.netscape.cmscore.selftests.SelfTestService;
 
-public class KeyRecoveryAuthorityApplication extends Application {
+public class KRAApplication extends Application {
 
     private Set<Object> singletons = new LinkedHashSet<Object>();
     private Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
 
-    public KeyRecoveryAuthorityApplication() {
+    public KRAApplication() {
 
         // account
         classes.add(AccountService.class);
diff --git a/base/server/cms/src/com/netscape/cms/servlet/request/KeyRequestService.java b/base/kra/src/org/dogtagpki/server/kra/rest/KeyRequestService.java
similarity index 95%
rename from base/server/cms/src/com/netscape/cms/servlet/request/KeyRequestService.java
rename to base/kra/src/org/dogtagpki/server/kra/rest/KeyRequestService.java
index b85978a34017aa28bf259e23fe6dc70272ed375a..162478de3a5cbc6a2fce0e980a710740779b1370 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/request/KeyRequestService.java
+++ b/base/kra/src/org/dogtagpki/server/kra/rest/KeyRequestService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.request;
+package org.dogtagpki.server.kra.rest;
 
 import java.lang.reflect.InvocationTargetException;
 import java.math.BigInteger;
@@ -36,7 +36,6 @@ import javax.ws.rs.core.UriInfo;
 
 import netscape.security.x509.X509CertImpl;
 
-import org.mozilla.jss.crypto.KeyGenAlgorithm;
 import org.mozilla.jss.crypto.SymmetricKey;
 
 import com.netscape.certsrv.apps.CMS;
@@ -103,18 +102,6 @@ public class KeyRequestService extends PKIService implements KeyRequestResource
     private IRequestQueue queue;
     private IKeyService service;
 
-    public static final Map<String, KeyGenAlgorithm> KEYGEN_ALGORITHMS;
-
-    static {
-        KEYGEN_ALGORITHMS = new HashMap<String, KeyGenAlgorithm>();
-        KEYGEN_ALGORITHMS.put(KeyRequestResource.DES_ALGORITHM, KeyGenAlgorithm.DES);
-        KEYGEN_ALGORITHMS.put(KeyRequestResource.DESEDE_ALGORITHM, KeyGenAlgorithm.DESede);
-        KEYGEN_ALGORITHMS.put(KeyRequestResource.DES3_ALGORITHM, KeyGenAlgorithm.DES3);
-        KEYGEN_ALGORITHMS.put(KeyRequestResource.RC2_ALGORITHM, KeyGenAlgorithm.RC2);
-        KEYGEN_ALGORITHMS.put(KeyRequestResource.RC4_ALGORITHM, KeyGenAlgorithm.RC4);
-        KEYGEN_ALGORITHMS.put(KeyRequestResource.AES_ALGORITHM, KeyGenAlgorithm.AES);
-    }
-
     public static final Map<String, SymmetricKey.Type> SYMKEY_TYPES;
     static {
         SYMKEY_TYPES = new HashMap<String, SymmetricKey.Type>();
diff --git a/base/server/cms/src/com/netscape/cms/servlet/key/KeyService.java b/base/kra/src/org/dogtagpki/server/kra/rest/KeyService.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/servlet/key/KeyService.java
rename to base/kra/src/org/dogtagpki/server/kra/rest/KeyService.java
index 31dd2c0aa0216e533710fd412a0abef7233bec72..14d364743c660bea2c81881f2bab84355e148b61 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/key/KeyService.java
+++ b/base/kra/src/org/dogtagpki/server/kra/rest/KeyService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.key;
+package org.dogtagpki.server.kra.rest;
 
 
 import java.math.BigInteger;
@@ -68,6 +68,7 @@ import com.netscape.certsrv.request.IRequestQueue;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.request.RequestStatus;
 import com.netscape.cms.servlet.base.PKIService;
+import com.netscape.cms.servlet.key.KeyRequestDAO;
 import com.netscape.cmsutil.ldap.LDAPUtil;
 import com.netscape.cmsutil.util.Utils;
 
diff --git a/base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml b/base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml
index 8002f749b8322b8c7770b059f09742215653ecd0..249f1eb1b1b02d23d605a65c0d6ef50ba088c2bc 100644
--- a/base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml
+++ b/base/ocsp/shared/webapps/ocsp/WEB-INF/web.xml
@@ -540,7 +540,7 @@
       <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
       <init-param>
          <param-name>javax.ws.rs.Application</param-name>
-         <param-value>com.netscape.ocsp.OCSPApplication</param-value>
+         <param-value>org.dogtagpki.server.ocsp.rest.OCSPApplication</param-value>
       </init-param>
    </servlet>
 
diff --git a/base/ocsp/src/CMakeLists.txt b/base/ocsp/src/CMakeLists.txt
index d3bdf0ed2d94309e993f99dbb334163e402a8b76..d4a2009a9b390d5401a338c0b86559d0d3adac51 100644
--- a/base/ocsp/src/CMakeLists.txt
+++ b/base/ocsp/src/CMakeLists.txt
@@ -80,6 +80,7 @@ find_file(SYMKEY_JAR
 javac(pki-ocsp-classes
     SOURCES
         com/netscape/ocsp/*.java
+        org/dogtagpki/server/ocsp/*.java
     CLASSPATH
         ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
@@ -107,6 +108,7 @@ jar(pki-ocsp-jar
         ${CMAKE_BINARY_DIR}/classes
     FILES
         com/netscape/ocsp/*.class
+        org/dogtagpki/server/ocsp/*.class
     DEPENDS
         pki-ocsp-classes
 )
diff --git a/base/ocsp/src/com/netscape/ocsp/OCSPApplication.java b/base/ocsp/src/org/dogtagpki/server/ocsp/rest/OCSPApplication.java
similarity index 74%
rename from base/ocsp/src/com/netscape/ocsp/OCSPApplication.java
rename to base/ocsp/src/org/dogtagpki/server/ocsp/rest/OCSPApplication.java
index 21b81f47ffc105a8f627f1416ef2853f5fd41b33..1be534978ff967e5be9d5d7c067b649c247e8b91 100644
--- a/base/ocsp/src/com/netscape/ocsp/OCSPApplication.java
+++ b/base/ocsp/src/org/dogtagpki/server/ocsp/rest/OCSPApplication.java
@@ -1,24 +1,25 @@
-package com.netscape.ocsp;
+package org.dogtagpki.server.ocsp.rest;
 
 import java.util.LinkedHashSet;
 import java.util.Set;
 
 import javax.ws.rs.core.Application;
 
+import org.dogtagpki.server.rest.ACLInterceptor;
+import org.dogtagpki.server.rest.AccountService;
+import org.dogtagpki.server.rest.AuditService;
+import org.dogtagpki.server.rest.AuthMethodInterceptor;
+import org.dogtagpki.server.rest.GroupService;
+import org.dogtagpki.server.rest.SecurityDomainService;
+import org.dogtagpki.server.rest.SelfTestService;
+import org.dogtagpki.server.rest.SystemCertService;
+import org.dogtagpki.server.rest.SystemConfigService;
+import org.dogtagpki.server.rest.UserService;
+
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.IConfigStore;
 import com.netscape.certsrv.base.PKIException;
-import com.netscape.cms.authorization.ACLInterceptor;
-import com.netscape.cms.authorization.AuthMethodInterceptor;
-import com.netscape.cms.servlet.account.AccountService;
-import com.netscape.cms.servlet.admin.GroupService;
-import com.netscape.cms.servlet.admin.SystemCertService;
-import com.netscape.cms.servlet.admin.UserService;
-import com.netscape.cms.servlet.csadmin.SecurityDomainService;
-import com.netscape.cms.servlet.csadmin.SystemConfigService;
-import com.netscape.cmscore.logging.AuditService;
-import com.netscape.cmscore.selftests.SelfTestService;
 
 public class OCSPApplication extends Application {
 
diff --git a/base/server/cms/src/CMakeLists.txt b/base/server/cms/src/CMakeLists.txt
index 16fa1fe8abf517b78aebbbf67c3fc3d2d78f6a4e..d414d2859ba2512d1184b973a54e5807ff0c92fe 100644
--- a/base/server/cms/src/CMakeLists.txt
+++ b/base/server/cms/src/CMakeLists.txt
@@ -30,9 +30,9 @@ find_file(COMMONS_HTTPCLIENT_JAR
         /usr/share/java
 )
 
-find_file(APACHE_COMMONS_LANG_JAR
+find_file(COMMONS_LANG_JAR
     NAMES
-        apache-commons-lang.jar
+        commons-lang.jar
     PATHS
         /usr/share/java
 )
@@ -122,14 +122,16 @@ find_file(HTTPCORE_JAR
 javac(pki-cms-classes
     SOURCES
         com/netscape/cms/*.java
+        org/dogtagpki/server/*.java
     CLASSPATH
-        ${PKI_NSUTIL_JAR} ${PKI_CMSUTIL_JAR} ${PKI_CERTSRV_JAR} ${PKI_TOMCAT_JAR}
-        ${LDAPJDK_JAR} ${SERVLET_JAR} ${VELOCITY_JAR} ${XALAN_JAR} ${XERCES_JAR}
-        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${COMMONS_HTTPCLIENT_JAR}
-        ${APACHE_COMMONS_LANG_JAR}
-        ${TOMCAT_CATALINA_JAR} ${TOMCAT_UTIL_JAR} ${SYMKEY_JAR}
-        ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
+        ${COMMONS_CODEC_JAR} ${COMMONS_LANG_JAR} ${COMMONS_HTTPCLIENT_JAR}
         ${HTTPCLIENT_JAR} ${HTTPCORE_JAR}
+        ${XALAN_JAR} ${XERCES_JAR}
+        ${JSS_JAR} ${SYMKEY_JAR}
+        ${LDAPJDK_JAR}
+        ${SERVLET_JAR} ${TOMCAT_CATALINA_JAR} ${TOMCAT_UTIL_JAR} ${VELOCITY_JAR}
+        ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
+        ${PKI_NSUTIL_JAR} ${PKI_CMSUTIL_JAR} ${PKI_CERTSRV_JAR} ${PKI_TOMCAT_JAR}
     OUTPUT_DIR
         ${CMAKE_BINARY_DIR}/classes
     DEPENDS
@@ -152,6 +154,7 @@ jar(pki-cms-jar
         ${CMAKE_BINARY_DIR}/classes
     FILES
         com/netscape/cms/*.class
+        org/dogtagpki/server/*.class
     EXCLUDE
         com/netscape/cms/tomcat/*.class
     DEPENDS
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
index 840b9f613454bd16e4e7f9dca1a89277011879e9..3553854c01680d2d36c6570d08903a57deffbc9a 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/csadmin/ConfigurationUtils.java
@@ -158,11 +158,11 @@ import com.netscape.certsrv.system.InstallToken;
 import com.netscape.certsrv.system.SecurityDomainClient;
 import com.netscape.certsrv.system.TPSConnectorClient;
 import com.netscape.certsrv.system.TPSConnectorData;
+import com.netscape.certsrv.user.UserResource;
 import com.netscape.certsrv.usrgrp.EUsrGrpException;
 import com.netscape.certsrv.usrgrp.IGroup;
 import com.netscape.certsrv.usrgrp.IUGSubsystem;
 import com.netscape.certsrv.usrgrp.IUser;
-import com.netscape.cms.servlet.admin.UserService;
 import com.netscape.cmsutil.crypto.CryptoUtil;
 import com.netscape.cmsutil.http.HttpClient;
 import com.netscape.cmsutil.http.HttpRequest;
@@ -3760,7 +3760,7 @@ public class ConfigurationUtils {
         IUser user = system.getUser(adminID);
 
         List<String> profiles = new ArrayList<String>();
-        profiles.add(UserService.ALL_PROFILES);
+        profiles.add(UserResource.ALL_PROFILES);
 
         user.setTpsProfiles(profiles);
         system.modifyUser(user);
diff --git a/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java b/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
index b19f92b642f45edff8e59f0343d6467fa2e368bb..e8e061fa34d3d55e10f11bcf70e12ad04edcc755 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/key/KeyRequestDAO.java
@@ -19,8 +19,10 @@ package com.netscape.cms.servlet.key;
 
 import java.util.Collection;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Map;
 
 import javax.ws.rs.Path;
 import javax.ws.rs.core.UriBuilder;
@@ -52,7 +54,6 @@ import com.netscape.certsrv.request.IRequest;
 import com.netscape.certsrv.request.RequestId;
 import com.netscape.certsrv.request.RequestStatus;
 import com.netscape.cms.servlet.request.CMSRequestDAO;
-import com.netscape.cms.servlet.request.KeyRequestService;
 
 /**
  * @author alee
@@ -60,6 +61,18 @@ import com.netscape.cms.servlet.request.KeyRequestService;
  */
 public class KeyRequestDAO extends CMSRequestDAO {
 
+    public static final Map<String, KeyGenAlgorithm> KEYGEN_ALGORITHMS;
+
+    static {
+        KEYGEN_ALGORITHMS = new HashMap<String, KeyGenAlgorithm>();
+        KEYGEN_ALGORITHMS.put(KeyRequestResource.DES_ALGORITHM, KeyGenAlgorithm.DES);
+        KEYGEN_ALGORITHMS.put(KeyRequestResource.DESEDE_ALGORITHM, KeyGenAlgorithm.DESede);
+        KEYGEN_ALGORITHMS.put(KeyRequestResource.DES3_ALGORITHM, KeyGenAlgorithm.DES3);
+        KEYGEN_ALGORITHMS.put(KeyRequestResource.RC2_ALGORITHM, KeyGenAlgorithm.RC2);
+        KEYGEN_ALGORITHMS.put(KeyRequestResource.RC4_ALGORITHM, KeyGenAlgorithm.RC4);
+        KEYGEN_ALGORITHMS.put(KeyRequestResource.AES_ALGORITHM, KeyGenAlgorithm.AES);
+    }
+
     private static String REQUEST_ARCHIVE_OPTIONS = IEnrollProfile.REQUEST_ARCHIVE_OPTIONS;
     public static final String ATTR_SERIALNO = "serialNumber";
 
@@ -242,7 +255,7 @@ public class KeyRequestDAO extends CMSRequestDAO {
             keySize = new Integer(128);
         }
 
-        KeyGenAlgorithm alg = KeyRequestService.KEYGEN_ALGORITHMS.get(algName);
+        KeyGenAlgorithm alg = KEYGEN_ALGORITHMS.get(algName);
         if (alg == null) {
             throw new BadRequestException("Invalid Algorithm");
         }
diff --git a/base/server/cms/src/com/netscape/cms/authorization/ACLInterceptor.java b/base/server/cms/src/org/dogtagpki/server/rest/ACLInterceptor.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/authorization/ACLInterceptor.java
rename to base/server/cms/src/org/dogtagpki/server/rest/ACLInterceptor.java
index c4b890e12750681bfd90878153a1d3984e834e86..7ea5d74aa797b28d78a5e6ebaec6d96d6cd066ea 100644
--- a/base/server/cms/src/com/netscape/cms/authorization/ACLInterceptor.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/ACLInterceptor.java
@@ -15,7 +15,7 @@
 //(C) 2012 Red Hat, Inc.
 //All rights reserved.
 //--- END COPYRIGHT BLOCK ---
-package com.netscape.cms.authorization;
+package org.dogtagpki.server.rest;
 
 import java.io.File;
 import java.io.FileReader;
diff --git a/base/server/cms/src/com/netscape/cms/servlet/account/AccountService.java b/base/server/cms/src/org/dogtagpki/server/rest/AccountService.java
similarity index 98%
rename from base/server/cms/src/com/netscape/cms/servlet/account/AccountService.java
rename to base/server/cms/src/org/dogtagpki/server/rest/AccountService.java
index 1a07a3a2383dc59a381d3564a4f447fce594aa5e..a016bda69ce5de03d69b5c6b21913e879a99c400 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/account/AccountService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/AccountService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.account;
+package org.dogtagpki.server.rest;
 
 import java.security.Principal;
 
diff --git a/base/server/cmscore/src/com/netscape/cmscore/logging/AuditService.java b/base/server/cms/src/org/dogtagpki/server/rest/AuditService.java
similarity index 99%
rename from base/server/cmscore/src/com/netscape/cmscore/logging/AuditService.java
rename to base/server/cms/src/org/dogtagpki/server/rest/AuditService.java
index 284d8a6397aa0a42fb259e7fc86a86f9e4ce04bb..26fd0c0d73c99682c32a3aa18f04a34d1a0e9c59 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/logging/AuditService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/AuditService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cmscore.logging;
+package org.dogtagpki.server.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
diff --git a/base/server/cms/src/com/netscape/cms/authorization/AuthMethodInterceptor.java b/base/server/cms/src/org/dogtagpki/server/rest/AuthMethodInterceptor.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/authorization/AuthMethodInterceptor.java
rename to base/server/cms/src/org/dogtagpki/server/rest/AuthMethodInterceptor.java
index 6d26840b67800b3458ec12f127f3118fba9be439..ac0b2518cdc42528b7c0e94153f2b02777c26785 100644
--- a/base/server/cms/src/com/netscape/cms/authorization/AuthMethodInterceptor.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/AuthMethodInterceptor.java
@@ -15,7 +15,7 @@
 //(C) 2013 Red Hat, Inc.
 //All rights reserved.
 //--- END COPYRIGHT BLOCK ---
-package com.netscape.cms.authorization;
+package org.dogtagpki.server.rest;
 
 import java.io.File;
 import java.io.FileReader;
diff --git a/base/server/cms/src/com/netscape/cms/servlet/admin/GroupService.java b/base/server/cms/src/org/dogtagpki/server/rest/GroupService.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/servlet/admin/GroupService.java
rename to base/server/cms/src/org/dogtagpki/server/rest/GroupService.java
index 3af4bae436470a6869526a1c7b745983f91a4af3..2c3c0011aca6b8e6b69c859ccd35dfc4a215a807 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/admin/GroupService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/GroupService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.admin;
+package org.dogtagpki.server.rest;
 
 import java.net.URI;
 import java.net.URLEncoder;
@@ -49,6 +49,7 @@ import com.netscape.certsrv.logging.IAuditor;
 import com.netscape.certsrv.logging.ILogger;
 import com.netscape.certsrv.usrgrp.IGroup;
 import com.netscape.certsrv.usrgrp.IUGSubsystem;
+import com.netscape.cms.servlet.admin.GroupMemberProcessor;
 import com.netscape.cms.servlet.base.PKIService;
 import com.netscape.cmsutil.ldap.LDAPUtil;
 
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainService.java b/base/server/cms/src/org/dogtagpki/server/rest/SecurityDomainService.java
similarity index 96%
rename from base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainService.java
rename to base/server/cms/src/org/dogtagpki/server/rest/SecurityDomainService.java
index 399c28a35f29e833f44fd8e399137aff70948816..27a0fde11bb27d37f95c4c845e177febefeb120c 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/SecurityDomainService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/SecurityDomainService.java
@@ -15,7 +15,7 @@
 // (C) 2012 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
-package com.netscape.cms.servlet.csadmin;
+package org.dogtagpki.server.rest;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.core.Context;
@@ -29,6 +29,7 @@ import com.netscape.certsrv.system.DomainInfo;
 import com.netscape.certsrv.system.InstallToken;
 import com.netscape.certsrv.system.SecurityDomainResource;
 import com.netscape.cms.servlet.base.PKIService;
+import com.netscape.cms.servlet.csadmin.SecurityDomainProcessor;
 
 /**
  * @author alee
diff --git a/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestService.java b/base/server/cms/src/org/dogtagpki/server/rest/SelfTestService.java
similarity index 99%
rename from base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestService.java
rename to base/server/cms/src/org/dogtagpki/server/rest/SelfTestService.java
index bc632fee112bb697dae47e9e9de5da049e978b8b..652875fe80f9949137a6e1a47cbd6d52ea113d4a 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/SelfTestService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cmscore.selftests;
+package org.dogtagpki.server.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
diff --git a/base/server/cms/src/com/netscape/cms/servlet/admin/SystemCertService.java b/base/server/cms/src/org/dogtagpki/server/rest/SystemCertService.java
similarity index 98%
rename from base/server/cms/src/com/netscape/cms/servlet/admin/SystemCertService.java
rename to base/server/cms/src/org/dogtagpki/server/rest/SystemCertService.java
index 50df221f92fea1bef1e1f4cb74d14b98375f9daf..c4f26f829afa29587caafa57aab7b7d6d19bbc48 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/admin/SystemCertService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/SystemCertService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.admin;
+package org.dogtagpki.server.rest;
 
 import java.security.cert.CertificateEncodingException;
 
diff --git a/base/server/cms/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java
rename to base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
index 3b3ad225fd93fd4c32b2c9409606aa9fa3d138fe..50b17a61110f122452438954969e1944c4016558 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/SystemConfigService.java
@@ -15,7 +15,7 @@
 // (C) 2012 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
-package com.netscape.cms.servlet.csadmin;
+package org.dogtagpki.server.rest;
 
 import java.math.BigInteger;
 import java.net.MalformedURLException;
@@ -62,6 +62,9 @@ import com.netscape.certsrv.system.SystemConfigResource;
 import com.netscape.certsrv.usrgrp.IUGSubsystem;
 import com.netscape.certsrv.usrgrp.IUser;
 import com.netscape.cms.servlet.base.PKIService;
+import com.netscape.cms.servlet.csadmin.Cert;
+import com.netscape.cms.servlet.csadmin.ConfigurationUtils;
+import com.netscape.cms.servlet.csadmin.SystemCertDataFactory;
 import com.netscape.cmsutil.crypto.CryptoUtil;
 import com.netscape.cmsutil.util.Utils;
 
diff --git a/base/server/cms/src/com/netscape/cms/servlet/admin/UserService.java b/base/server/cms/src/org/dogtagpki/server/rest/UserService.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/servlet/admin/UserService.java
rename to base/server/cms/src/org/dogtagpki/server/rest/UserService.java
index 70124b4f4fa21176b9741f2f6b5ac5381dd86a1a..ac1f0617fc24f2d995865d034aad269d2fbb3bd4 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/admin/UserService.java
+++ b/base/server/cms/src/org/dogtagpki/server/rest/UserService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package com.netscape.cms.servlet.admin;
+package org.dogtagpki.server.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -74,6 +74,7 @@ import com.netscape.certsrv.usrgrp.EUsrGrpException;
 import com.netscape.certsrv.usrgrp.IGroup;
 import com.netscape.certsrv.usrgrp.IUGSubsystem;
 import com.netscape.certsrv.usrgrp.IUser;
+import com.netscape.cms.servlet.admin.GroupMemberProcessor;
 import com.netscape.cms.servlet.base.PKIService;
 import com.netscape.cmsutil.ldap.LDAPUtil;
 import com.netscape.cmsutil.util.Cert;
diff --git a/base/server/cmscore/src/com/netscape/cmscore/usrgrp/User.java b/base/server/cmscore/src/com/netscape/cmscore/usrgrp/User.java
index ef09a1ab56e07c57ae5445abc32539326acb3938..dd59335bd7612d4bfe682ac21f17e2d3a2c104eb 100644
--- a/base/server/cmscore/src/com/netscape/cmscore/usrgrp/User.java
+++ b/base/server/cmscore/src/com/netscape/cmscore/usrgrp/User.java
@@ -25,9 +25,9 @@ import java.util.Vector;
 
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.user.UserResource;
 import com.netscape.certsrv.usrgrp.IUser;
 import com.netscape.certsrv.usrgrp.IUsrGrp;
-import com.netscape.cms.servlet.admin.UserService;
 
 /**
  * A class represents a user.
@@ -77,7 +77,7 @@ public class User implements IUser {
     public void setTpsProfiles(List<String> tpsProfiles) {
         boolean setAll = false;
         for (String profile: tpsProfiles) {
-            if (profile.equals(UserService.ALL_PROFILES)) {
+            if (profile.equals(UserResource.ALL_PROFILES)) {
                 setAll = true;
                 break;
             }
@@ -86,7 +86,7 @@ public class User implements IUser {
             this.tpsProfiles = tpsProfiles;
         } else {
             List<String> list = new ArrayList<String>();
-            list.add(UserService.ALL_PROFILES);
+            list.add(UserResource.ALL_PROFILES);
             this.tpsProfiles = list;
         }
     }
diff --git a/base/server/upgrade/10.1.99/04-ReplaceRESTEasyApplicationClass b/base/server/upgrade/10.1.99/04-ReplaceRESTEasyApplicationClass
new file mode 100755
index 0000000000000000000000000000000000000000..bd10b09fe2a304a4118ef1c091549d6d280b8dd1
--- /dev/null
+++ b/base/server/upgrade/10.1.99/04-ReplaceRESTEasyApplicationClass
@@ -0,0 +1,74 @@
+#!/usr/bin/python
+# Authors:
+#     Endi S. Dewata <edewata@redhat.com>
+#
+# 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.
+#
+# Copyright (C) 2014 Red Hat, Inc.
+# All rights reserved.
+#
+
+import os
+import sys
+from lxml import etree as ET
+
+import pki
+import pki.server.upgrade
+
+class ReplaceRESTEasyApplicationClass(pki.server.upgrade.PKIServerUpgradeScriptlet):
+
+    def __init__(self):
+
+        self.message = 'Replace RESTEasy application class'
+        self.class_names = {
+            'ca': 'org.dogtagpki.server.ca.rest.CAApplication',
+            'kra': 'org.dogtagpki.server.kra.rest.KRAApplication',
+            'ocsp': 'org.dogtagpki.server.ocsp.rest.OCSPApplication',
+            'tks': 'org.dogtagpki.server.tks.rest.TKSApplication',
+            'tps': 'org.dogtagpki.server.tps.rest.TPSApplication'
+        }
+
+    def upgrade_subsystem(self, instance, subsystem):
+
+        if subsystem.name not in self.class_names:
+            return
+
+        web_xml = os.path.join(
+            instance.base_dir,
+            'webapps', subsystem.name,
+            'WEB-INF', 'web.xml')
+
+        self.backup(web_xml)
+
+        doc = ET.parse(web_xml)
+        root = doc.getroot()
+
+        servlet = root.find('servlet[servlet-name="Resteasy"]')
+
+        if servlet is None:
+            raise Exception('Resteasy servlet not found in ' + web_xml)
+
+        param = servlet.find('init-param[param-name="javax.ws.rs.Application"]')
+
+        if param is None:
+            raise Exception('Resteasy application parameter not found in ' + web_xml)
+
+        value = param.find('param-value')
+
+        if value is None:
+            raise Exception('Resteasy application value not found in ' + web_xml)
+
+        value.text = self.class_names[subsystem.name]
+
+        doc.write(web_xml)
diff --git a/base/tks/shared/webapps/tks/WEB-INF/web.xml b/base/tks/shared/webapps/tks/WEB-INF/web.xml
index 65273621764dd8a656a365f76107e08793f78911..e4650475d45fa77b7b74ebf0473ded52408e0457 100644
--- a/base/tks/shared/webapps/tks/WEB-INF/web.xml
+++ b/base/tks/shared/webapps/tks/WEB-INF/web.xml
@@ -295,7 +295,7 @@
       <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
       <init-param>
          <param-name>javax.ws.rs.Application</param-name>
-         <param-value>com.netscape.tks.TKSApplication</param-value>
+         <param-value>org.dogtagpki.server.tks.rest.TKSApplication</param-value>
       </init-param>
    </servlet>
 
diff --git a/base/tks/src/CMakeLists.txt b/base/tks/src/CMakeLists.txt
index 9d0d3a70a5a0752939588f22ae1aced72e737493..d1ebbb13d60a3205c3547ebf209c93a40f29612b 100644
--- a/base/tks/src/CMakeLists.txt
+++ b/base/tks/src/CMakeLists.txt
@@ -46,14 +46,6 @@ find_file(LDAPJDK_JAR
         /usr/share/java
 )
 
-find_file(JAXRS_API_JAR
-    NAMES
-        jaxrs-api.jar
-    PATHS
-        ${RESTEASY_LIB}
-)
-
-
 # '${JAVA_LIB_INSTALL_DIR}' jars
 find_file(JSS_JAR
     NAMES
@@ -69,6 +61,34 @@ find_file(COMMONS_CODEC_JAR
         /usr/share/java
 )
 
+find_file(COMMONS_LANG_JAR
+    NAMES
+        commons-lang.jar
+    PATHS
+        /usr/share/java
+)
+
+find_file(JAXRS_API_JAR
+    NAMES
+        jaxrs-api.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
+find_file(RESTEASY_JAXRS_JAR
+    NAMES
+        resteasy-jaxrs.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
+find_file(RESTEASY_ATOM_PROVIDER_JAR
+    NAMES
+        resteasy-atom-provider.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
 find_file(SYMKEY_JAR
     NAMES
         symkey.jar
@@ -76,16 +96,34 @@ find_file(SYMKEY_JAR
         ${JAVA_LIB_INSTALL_DIR}
 )
 
+find_file(SERVLET_JAR
+    NAMES
+        servlet.jar
+    PATHS
+        ${JAVA_LIB_INSTALL_DIR}
+        /usr/share/java
+)
+
+find_file(TOMCAT_CATALINA_JAR
+    NAMES
+        catalina.jar
+    PATHS
+        /usr/share/java/tomcat
+)
 
 # build pki-tks
 javac(pki-tks-classes
     SOURCES
         com/netscape/tks/*.java
+        org/dogtagpki/server/tks/*.java
     CLASSPATH
-        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
+        ${COMMONS_CODEC_JAR} ${COMMONS_LANG_JAR}
+        ${LDAPJDK_JAR}
+        ${JSS_JAR} ${SYMKEY_JAR}
+        ${SERVLET_JAR} ${TOMCAT_CATALINA_JAR}
+        ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-        ${LDAPJDK_JAR} ${JAXRS_API_JAR}
-        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
     OUTPUT_DIR
         ${CMAKE_BINARY_DIR}/classes
     DEPENDS
@@ -108,6 +146,7 @@ jar(pki-tks-jar
         ${CMAKE_BINARY_DIR}/classes
     FILES
         com/netscape/tks/*.class
+        org/dogtagpki/server/tks/*.class
     DEPENDS
         pki-tks-classes
 )
diff --git a/base/tks/src/com/netscape/tks/TKSApplication.java b/base/tks/src/org/dogtagpki/server/tks/rest/TKSApplication.java
similarity index 68%
rename from base/tks/src/com/netscape/tks/TKSApplication.java
rename to base/tks/src/org/dogtagpki/server/tks/rest/TKSApplication.java
index f4a8730d940345299459694d1326e906b5e0632b..976b9bd9faef6d441670a87bb321a8236241c649 100644
--- a/base/tks/src/com/netscape/tks/TKSApplication.java
+++ b/base/tks/src/org/dogtagpki/server/tks/rest/TKSApplication.java
@@ -1,21 +1,21 @@
-package com.netscape.tks;
+package org.dogtagpki.server.tks.rest;
 
 import java.util.LinkedHashSet;
 import java.util.Set;
 
 import javax.ws.rs.core.Application;
 
+import org.dogtagpki.server.rest.ACLInterceptor;
+import org.dogtagpki.server.rest.AccountService;
+import org.dogtagpki.server.rest.AuditService;
+import org.dogtagpki.server.rest.AuthMethodInterceptor;
+import org.dogtagpki.server.rest.GroupService;
+import org.dogtagpki.server.rest.SelfTestService;
+import org.dogtagpki.server.rest.SystemCertService;
+import org.dogtagpki.server.rest.SystemConfigService;
+import org.dogtagpki.server.rest.UserService;
+
 import com.netscape.certsrv.base.PKIException;
-import com.netscape.cms.authorization.ACLInterceptor;
-import com.netscape.cms.authorization.AuthMethodInterceptor;
-import com.netscape.cms.servlet.account.AccountService;
-import com.netscape.cms.servlet.admin.GroupService;
-import com.netscape.cms.servlet.admin.SystemCertService;
-import com.netscape.cms.servlet.admin.UserService;
-import com.netscape.cms.servlet.csadmin.SystemConfigService;
-import com.netscape.cms.servlet.tks.TPSConnectorService;
-import com.netscape.cmscore.logging.AuditService;
-import com.netscape.cmscore.selftests.SelfTestService;
 
 public class TKSApplication extends Application {
 
diff --git a/base/server/cms/src/com/netscape/cms/servlet/tks/TPSConnectorService.java b/base/tks/src/org/dogtagpki/server/tks/rest/TPSConnectorService.java
similarity index 99%
rename from base/server/cms/src/com/netscape/cms/servlet/tks/TPSConnectorService.java
rename to base/tks/src/org/dogtagpki/server/tks/rest/TPSConnectorService.java
index c11f1239f552ef6cee999186d10bfb79ecb7d494..36512690aef03882c6414cdeae0337663a916b92 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/tks/TPSConnectorService.java
+++ b/base/tks/src/org/dogtagpki/server/tks/rest/TPSConnectorService.java
@@ -1,4 +1,4 @@
-package com.netscape.cms.servlet.tks;
+package org.dogtagpki.server.tks.rest;
 
 import java.io.IOException;
 import java.net.URI;
diff --git a/base/tps-tomcat/shared/webapps/tps/WEB-INF/web.xml b/base/tps-tomcat/shared/webapps/tps/WEB-INF/web.xml
index 6f83271cce10e7a7935b291fcc189cec5bdffefe..0fe3df4dc3cc41f3bdae7ea752d057d56e13595d 100644
--- a/base/tps-tomcat/shared/webapps/tps/WEB-INF/web.xml
+++ b/base/tps-tomcat/shared/webapps/tps/WEB-INF/web.xml
@@ -119,7 +119,7 @@
         <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
         <init-param>
             <param-name>javax.ws.rs.Application</param-name>
-            <param-value>org.dogtagpki.server.tps.TPSApplication</param-value>
+            <param-value>org.dogtagpki.server.tps.rest.TPSApplication</param-value>
         </init-param>
     </servlet>
 
diff --git a/base/tps-tomcat/src/CMakeLists.txt b/base/tps-tomcat/src/CMakeLists.txt
index 837587f63dc72d97b616a5e559fcbc350750fa73..0070a3c3442d3a74a6e4a285e8e88e31ddae841e 100644
--- a/base/tps-tomcat/src/CMakeLists.txt
+++ b/base/tps-tomcat/src/CMakeLists.txt
@@ -1,12 +1,5 @@
 project(pki-tps_java NONE)
 
-find_file(APACHE_COMMONS_LANG_JAR
-    NAMES
-        apache-commons-lang.jar
-    PATHS
-        /usr/share/java
-)
-
 find_file(LDAPJDK_JAR
     NAMES
         ldapjdk.jar
@@ -14,13 +7,6 @@ find_file(LDAPJDK_JAR
         /usr/share/java
 )
 
-find_file(JAXRS_API_JAR
-    NAMES
-        jaxrs-api.jar
-    PATHS
-        ${RESTEASY_LIB}
-)
-
 find_file(JSS_JAR
     NAMES
         jss4.jar
@@ -35,6 +21,13 @@ find_file(COMMONS_CODEC_JAR
         /usr/share/java
 )
 
+find_file(COMMONS_LANG_JAR
+    NAMES
+        commons-lang.jar
+    PATHS
+        /usr/share/java
+)
+
 find_file(JAXRS_API_JAR
     NAMES
         jaxrs-api.jar
@@ -84,6 +77,20 @@ find_file(PKI_NSUTIL_JAR
         /usr/share/java/pki
 )
 
+find_file(JAXRS_API_JAR
+    NAMES
+        jaxrs-api.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
+find_file(RESTEASY_JAXRS_JAR
+    NAMES
+        resteasy-jaxrs.jar
+    PATHS
+        ${RESTEASY_LIB}
+)
+
 find_file(RESTEASY_ATOM_PROVIDER_JAR
     NAMES
         resteasy-atom-provider.jar
@@ -112,10 +119,13 @@ javac(pki-tps-classes
     SOURCES
         org/dogtagpki/server/tps/*.java
     CLASSPATH
-        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
+        ${COMMONS_CODEC_JAR} ${COMMONS_LANG_JAR}
+        ${LDAPJDK_JAR}
+        ${JSS_JAR} ${SYMKEY_JAR}
+        ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
+        ${SERVLET_JAR} ${TOMCAT_CATALINA_JAR}
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
-        ${APACHE_COMMONS_LANG_JAR} ${LDAPJDK_JAR} ${JAXRS_API_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
-        ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR} ${SERVLET_JAR} ${TOMCAT_CATALINA_JAR}
+        ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
     OUTPUT_DIR
         ${CMAKE_BINARY_DIR}/classes
     DEPENDS
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
index e17d37d10ec478f22817359b4eab58a46ab0ceed..eb279d819c6cd0d700fa47fa4f757c6870f86549 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSSubsystem.java
@@ -17,14 +17,14 @@
 // --- END COPYRIGHT BLOCK ---
 package org.dogtagpki.server.tps;
 
-import org.dogtagpki.server.tps.authenticator.AuthenticatorDatabase;
-import org.dogtagpki.server.tps.cert.TPSCertDatabase;
 import org.dogtagpki.server.tps.config.ConfigDatabase;
-import org.dogtagpki.server.tps.connection.ConnectionDatabase;
-import org.dogtagpki.server.tps.logging.ActivityDatabase;
-import org.dogtagpki.server.tps.profile.ProfileDatabase;
-import org.dogtagpki.server.tps.profile.ProfileMappingDatabase;
-import org.dogtagpki.server.tps.token.TokenDatabase;
+import org.dogtagpki.server.tps.config.ConnectionDatabase;
+import org.dogtagpki.server.tps.config.ProfileDatabase;
+import org.dogtagpki.server.tps.config.ProfileMappingDatabase;
+import org.dogtagpki.server.tps.dbs.ActivityDatabase;
+import org.dogtagpki.server.tps.dbs.AuthenticatorDatabase;
+import org.dogtagpki.server.tps.dbs.TPSCertDatabase;
+import org.dogtagpki.server.tps.dbs.TokenDatabase;
 import org.mozilla.jss.CryptoManager;
 import org.mozilla.jss.CryptoManager.NotInitializedException;
 import org.mozilla.jss.crypto.ObjectNotFoundException;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java
similarity index 97%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionDatabase.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java
index 1aadc7a072ab0d1094d19b14eb2e90cf9951c8d9..35eb382ea90f918b740b02de10f0360578d113d1 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionDatabase.java
@@ -16,15 +16,12 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.connection;
+package org.dogtagpki.server.tps.config;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
 
-import org.dogtagpki.server.tps.config.ConfigDatabase;
-import org.dogtagpki.server.tps.config.ConfigRecord;
-
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.IConfigStore;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java
similarity index 95%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionRecord.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java
index 71aac3139307b75e1085d30e25adc2dcde2e00ab..3a2f78037bb44b33aa0f9c83e9a648d2e2c94a9b 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionRecord.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ConnectionRecord.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.connection;
+package org.dogtagpki.server.tps.config;
 
 import com.netscape.cmscore.dbs.CSCfgRecord;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileDatabase.java
similarity index 97%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileDatabase.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileDatabase.java
index 794661281a335fddf0a51abd12fcb1cb20c9cd5b..6054bf38da2661881c82abe593b3af611fdf6ad2 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileDatabase.java
@@ -16,15 +16,12 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.config;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
 
-import org.dogtagpki.server.tps.config.ConfigDatabase;
-import org.dogtagpki.server.tps.config.ConfigRecord;
-
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.cmscore.dbs.CSCfgDatabase;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingDatabase.java
similarity index 97%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingDatabase.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingDatabase.java
index febb71857c3c4293ebc43640eb4acdd030e61125..dca0beb02f8ad4ecfaad02596bdab6560ef7dde0 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingDatabase.java
@@ -16,15 +16,12 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.config;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Map;
 
-import org.dogtagpki.server.tps.config.ConfigDatabase;
-import org.dogtagpki.server.tps.config.ConfigRecord;
-
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.cmscore.dbs.CSCfgDatabase;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingRecord.java
similarity index 95%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingRecord.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingRecord.java
index e44acd24a11b8079cf7920dafc6bb5779c1a866d..92793ce5e4be5f805cdef45850ef6e8a9c7250c8 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingRecord.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileMappingRecord.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.config;
 
 import com.netscape.cmscore.dbs.CSCfgRecord;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileRecord.java
similarity index 95%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileRecord.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileRecord.java
index 20c254d03dec51c65a74fd920c3c35c4f97f8859..a84b7f5ba2a4e1026e5f7e112e716ef0cf3bd9c4 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileRecord.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/config/ProfileRecord.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.config;
 
 import com.netscape.cmscore.dbs.CSCfgRecord;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/ActivityDatabase.java
similarity index 97%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityDatabase.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/ActivityDatabase.java
index aecfcad2a6ff1f9cdb230f7b0c77ce6459d2d2ec..d48d31489b2554b4c8c71e8f84520766b9aa2d9e 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/ActivityDatabase.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.logging;
+package org.dogtagpki.server.tps.dbs;
 
 import java.util.Date;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/ActivityRecord.java
similarity index 99%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityRecord.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/ActivityRecord.java
index 4794ecb8bc579e601f35ce97e77af2a3ec0ed686..815d5ee08134c9c123c5e2df6f1dacabd65861c4 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityRecord.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/ActivityRecord.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.logging;
+package org.dogtagpki.server.tps.dbs;
 
 import java.util.Date;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/AuthenticatorDatabase.java
similarity index 99%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorDatabase.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/AuthenticatorDatabase.java
index a4f735b73bd5afc20c1275c9c8d094dfcc1b47eb..f6425bc8defec3ac6b6d18c529a89f6cec37071e 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/AuthenticatorDatabase.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.authenticator;
+package org.dogtagpki.server.tps.dbs;
 
 import java.util.ArrayList;
 import java.util.Collection;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/AuthenticatorRecord.java
similarity index 95%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorRecord.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/AuthenticatorRecord.java
index a07c05aaa068a885fc58e4daeaa272d7ca6e3e94..7586dbb0562bc7c63737e12d77b6e44e98026aa4 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorRecord.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/AuthenticatorRecord.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.authenticator;
+package org.dogtagpki.server.tps.dbs;
 
 import com.netscape.cmscore.dbs.CSCfgRecord;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TPSCertDatabase.java
similarity index 98%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertDatabase.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TPSCertDatabase.java
index d07a11f6d417ec910467e4981047c0ab9ce7f352..9922c4d50d094a7005f0957ded866fc5b163b31d 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TPSCertDatabase.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.cert;
+package org.dogtagpki.server.tps.dbs;
 
 import java.util.Date;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TPSCertRecord.java
similarity index 99%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertRecord.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TPSCertRecord.java
index 6a55e60d67e8d4a205c7b720098ed664dda4eb04..9589139539d48a90ee2bfafa6c8814e3560f6870 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertRecord.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TPSCertRecord.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.cert;
+package org.dogtagpki.server.tps.dbs;
 
 import java.util.Date;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenDatabase.java
similarity index 97%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenDatabase.java
index d16e4fc2522b13d141ef76920cc0009b30b442a7..517d3151e8a5983ed060645372024c318afcc418 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenDatabase.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenDatabase.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.token;
+package org.dogtagpki.server.tps.dbs;
 
 import java.util.Date;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenRecord.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenRecord.java
similarity index 99%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenRecord.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenRecord.java
index bf0d1b1205e09defb7684fa29b5f03fc8957026d..bab61ac199e619fb55b00eee952f83868b739812 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenRecord.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/dbs/TokenRecord.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.token;
+package org.dogtagpki.server.tps.dbs;
 
 import java.util.Date;
 
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ActivityService.java
similarity index 97%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityService.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ActivityService.java
index 0bed20311c05ab29fe969df55abf2982a4259c25..1c331f150619559ec7c4555f84c5a838c0799b92 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ActivityService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.logging;
+package org.dogtagpki.server.tps.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -31,6 +31,8 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
+import org.dogtagpki.server.tps.dbs.ActivityDatabase;
+import org.dogtagpki.server.tps.dbs.ActivityRecord;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.apps.CMS;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/AuthenticatorService.java
similarity index 98%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorService.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/rest/AuthenticatorService.java
index 282ee4c0e44bde505e1d513ba68afd74242ba2bf..21d15cc1084c31df1b314b0835193fbc0e65bb2f 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/AuthenticatorService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.authenticator;
+package org.dogtagpki.server.tps.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -32,6 +32,8 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
+import org.dogtagpki.server.tps.dbs.AuthenticatorDatabase;
+import org.dogtagpki.server.tps.dbs.AuthenticatorRecord;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.apps.CMS;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ConnectionService.java
similarity index 98%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ConnectionService.java
index a78420eda2fea22b095ca44c1ff52082d4d76d73..2cd6f2bfd84359dbc16158590924d1219f9a81db 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ConnectionService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.connection;
+package org.dogtagpki.server.tps.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -32,6 +32,8 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
+import org.dogtagpki.server.tps.config.ConnectionDatabase;
+import org.dogtagpki.server.tps.config.ConnectionRecord;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.apps.CMS;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ProfileMappingService.java
similarity index 98%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingService.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ProfileMappingService.java
index bcb169578958e96525cf7f8f386e929e644d9af4..8336bff7f7c0ed07fdf60aaeb71b6c58b246f3fb 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileMappingService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ProfileMappingService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -32,6 +32,8 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
+import org.dogtagpki.server.tps.config.ProfileMappingDatabase;
+import org.dogtagpki.server.tps.config.ProfileMappingRecord;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.apps.CMS;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ProfileService.java
similarity index 98%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileService.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ProfileService.java
index edc7df1cdeb282c257aad036492ba18a536527f2..866a1dc7f8942fa4f745eec25f8b314baafef3e0 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/profile/ProfileService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/ProfileService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.profile;
+package org.dogtagpki.server.tps.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -32,6 +32,8 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
+import org.dogtagpki.server.tps.config.ProfileDatabase;
+import org.dogtagpki.server.tps.config.ProfileRecord;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.apps.CMS;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSApplication.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TPSApplication.java
similarity index 73%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/TPSApplication.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TPSApplication.java
index 2571e26048c85f362ebc160e9808ac29b5d3e938..0dfd2b7c097e85bfaa336449c6433afe3f8b024f 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/TPSApplication.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TPSApplication.java
@@ -15,32 +15,25 @@
 // (C) 2013 Red Hat, Inc.
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
-package org.dogtagpki.server.tps;
+package org.dogtagpki.server.tps.rest;
 
 import java.util.LinkedHashSet;
 import java.util.Set;
 
 import javax.ws.rs.core.Application;
 
-import org.dogtagpki.server.tps.authenticator.AuthenticatorService;
-import org.dogtagpki.server.tps.cert.TPSCertService;
+import org.dogtagpki.server.rest.ACLInterceptor;
+import org.dogtagpki.server.rest.AccountService;
+import org.dogtagpki.server.rest.AuditService;
+import org.dogtagpki.server.rest.AuthMethodInterceptor;
+import org.dogtagpki.server.rest.GroupService;
+import org.dogtagpki.server.rest.SelfTestService;
+import org.dogtagpki.server.rest.SystemCertService;
+import org.dogtagpki.server.rest.SystemConfigService;
+import org.dogtagpki.server.rest.UserService;
 import org.dogtagpki.server.tps.config.ConfigService;
-import org.dogtagpki.server.tps.connection.ConnectionService;
-import org.dogtagpki.server.tps.logging.ActivityService;
-import org.dogtagpki.server.tps.profile.ProfileMappingService;
-import org.dogtagpki.server.tps.profile.ProfileService;
-import org.dogtagpki.server.tps.token.TokenService;
 
 import com.netscape.certsrv.base.PKIException;
-import com.netscape.cms.authorization.ACLInterceptor;
-import com.netscape.cms.authorization.AuthMethodInterceptor;
-import com.netscape.cms.servlet.account.AccountService;
-import com.netscape.cms.servlet.admin.GroupService;
-import com.netscape.cms.servlet.admin.SystemCertService;
-import com.netscape.cms.servlet.admin.UserService;
-import com.netscape.cms.servlet.csadmin.SystemConfigService;
-import com.netscape.cmscore.logging.AuditService;
-import com.netscape.cmscore.selftests.SelfTestService;
 
 /**
  * @author Endi S. Dewata <edewata@redhat.com>
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TPSCertService.java
similarity index 97%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertService.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TPSCertService.java
index 0397f5cc193750ee7effdf513ddd175044653a59..45e5db6b83c684dcad0ae070fdda4f3f70a73c7c 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TPSCertService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.cert;
+package org.dogtagpki.server.tps.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -31,6 +31,8 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
+import org.dogtagpki.server.tps.dbs.TPSCertDatabase;
+import org.dogtagpki.server.tps.dbs.TPSCertRecord;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.apps.CMS;
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TokenService.java
similarity index 98%
rename from base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java
rename to base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TokenService.java
index 548c797b7ba15938fd3281a26a236a71ff8f2548..3f30e973b3eabd1130b2d738cd04d99d4e68f6de 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/rest/TokenService.java
@@ -16,7 +16,7 @@
 // All rights reserved.
 // --- END COPYRIGHT BLOCK ---
 
-package org.dogtagpki.server.tps.token;
+package org.dogtagpki.server.tps.rest;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
@@ -31,6 +31,8 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
+import org.dogtagpki.server.tps.dbs.TokenDatabase;
+import org.dogtagpki.server.tps.dbs.TokenRecord;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
 import com.netscape.certsrv.apps.CMS;
-- 
1.8.4.2

