>From 0056da09d4b149511a78e4ee349bf9a341811955 Mon Sep 17 00:00:00 2001
From: Ade Lee <alee@redhat.com>
Date: Tue, 17 Sep 2013 12:29:06 -0400
Subject: [PATCH 156/156] Workaround for resteasy context problem

Resteasy 3.0.1 is not populating the @Context parameters if they are
defined in a super class.  This is a workaround until that problem is fixed.
---
 .../cms/servlet/account/AccountService.java        | 21 +++++++++++++++++++++
 .../cms/servlet/admin/GroupMemberService.java      | 21 +++++++++++++++++++++
 .../netscape/cms/servlet/admin/GroupService.java   | 21 +++++++++++++++++++++
 .../cms/servlet/admin/KRAConnectorService.java     | 21 +++++++++++++++++++++
 .../cms/servlet/admin/SystemCertService.java       | 22 ++++++++++++++++++++++
 .../cms/servlet/admin/UserCertService.java         | 21 +++++++++++++++++++++
 .../cms/servlet/admin/UserMembershipService.java   | 21 +++++++++++++++++++++
 .../netscape/cms/servlet/admin/UserService.java    | 21 +++++++++++++++++++++
 .../com/netscape/cms/servlet/base/PKIService.java  | 12 +++++++-----
 .../com/netscape/cms/servlet/cert/CertService.java | 19 +++++++++++++++++++
 .../cms/servlet/csadmin/SecurityDomainService.java | 22 ++++++++++++++++++++++
 .../cms/servlet/csadmin/SystemConfigService.java   | 18 ++++++++++++++++++
 .../com/netscape/cms/servlet/key/KeyService.java   | 18 ++++++++++++++++++
 .../cms/servlet/profile/ProfileService.java        | 20 ++++++++++++++++++++
 .../cms/servlet/request/CertRequestService.java    | 21 +++++++++++++++++++++
 .../cms/servlet/request/KeyRequestService.java     | 21 +++++++++++++++++++++
 .../tps/authenticator/AuthenticatorService.java    | 18 ++++++++++++++++++
 .../dogtagpki/server/tps/cert/TPSCertService.java  | 19 +++++++++++++++++++
 .../server/tps/connection/ConnectionService.java   | 18 ++++++++++++++++++
 .../server/tps/logging/ActivityService.java        | 19 +++++++++++++++++++
 .../dogtagpki/server/tps/token/TokenService.java   | 18 ++++++++++++++++++
 21 files changed, 407 insertions(+), 5 deletions(-)

diff --git a/base/common/src/com/netscape/cms/servlet/account/AccountService.java b/base/common/src/com/netscape/cms/servlet/account/AccountService.java
index eb43233534cd39ffdbc14a89359884f2428562ae..87f3212f53c899ab1dbc25633ae100d37456b228 100644
--- a/base/common/src/com/netscape/cms/servlet/account/AccountService.java
+++ b/base/common/src/com/netscape/cms/servlet/account/AccountService.java
@@ -20,7 +20,12 @@ package com.netscape.cms.servlet.account;
 
 import java.security.Principal;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
 
 import com.netscape.certsrv.account.AccountResource;
 import com.netscape.cms.servlet.base.PKIService;
@@ -30,6 +35,22 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class AccountService extends PKIService implements AccountResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
+    public AccountService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     @Override
     public void login() {
         HttpSession session = servletRequest.getSession();
diff --git a/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java b/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java
index 989b89db04955529eacb86244c9c4747e6a1ef16..1d5dffec609bffd0e52b36072b60fd5ff15564fc 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/GroupMemberService.java
@@ -18,7 +18,12 @@
 
 package com.netscape.cms.servlet.admin;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import com.netscape.certsrv.base.PKIException;
 import com.netscape.certsrv.group.GroupMemberCollection;
@@ -31,6 +36,22 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class GroupMemberService extends PKIService implements GroupMemberResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
+    public GroupMemberService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     @Override
     public GroupMemberCollection findGroupMembers(String groupID, Integer start, Integer size) {
         try {
diff --git a/base/common/src/com/netscape/cms/servlet/admin/GroupService.java b/base/common/src/com/netscape/cms/servlet/admin/GroupService.java
index 012e00c33798ac43480f63ec2054f2b276b95a80..021d087d0ec55cf65a139227ff4b9add56d9046a 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/GroupService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/GroupService.java
@@ -23,8 +23,13 @@ import java.net.URLEncoder;
 import java.util.Enumeration;
 import java.util.Map;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.commons.lang.StringUtils;
 import org.jboss.resteasy.plugins.providers.atom.Link;
@@ -51,10 +56,26 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
  */
 public class GroupService extends PKIService implements GroupResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public final static int DEFAULT_SIZE = 20;
 
     public IUGSubsystem userGroupManager = (IUGSubsystem) CMS.getSubsystem(CMS.SUBSYSTEM_UG);
 
+    public GroupService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     public GroupData createGroupData(IGroup group) throws Exception {
 
         GroupData groupData = new GroupData();
diff --git a/base/common/src/com/netscape/cms/servlet/admin/KRAConnectorService.java b/base/common/src/com/netscape/cms/servlet/admin/KRAConnectorService.java
index b1d0b07c25228e6d285194c419ad860160d40e6f..75b1e15c6f4e197dadad6da910234fdada1fa670 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/KRAConnectorService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/KRAConnectorService.java
@@ -17,7 +17,12 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.cms.servlet.admin;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
 
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.PKIException;
@@ -30,6 +35,22 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class KRAConnectorService extends PKIService implements KRAConnectorResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
+    public KRAConnectorService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     @Override
     public void addConnector(KRAConnectorInfo info) {
         try {
diff --git a/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java b/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java
index 2e1277b30f2625f061f13c328d1088e6afd7dce9..0ecb26a8256458fa9217fdfa930567906f3373fc 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/SystemCertService.java
@@ -20,7 +20,12 @@ package com.netscape.cms.servlet.admin;
 
 import java.security.cert.CertificateEncodingException;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.PKIException;
@@ -39,6 +44,23 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class SystemCertService extends PKIService implements SystemCertResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
+    public SystemCertService() {
+        CMS.debug("TokenService.<init>()");
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     /**
      * Used to retrieve the transport certificate
      */
diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java b/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java
index efefcca8c52c442ebfade918454eec19e412667c..9ba055f1a56391aa1529f236f0bc06bebf0ef352 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/UserCertService.java
@@ -27,8 +27,13 @@ import java.security.cert.CertificateNotYetValidException;
 import java.security.cert.X509Certificate;
 import java.util.Map;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import netscape.ldap.LDAPException;
 import netscape.security.pkcs.PKCS7;
@@ -63,10 +68,26 @@ import com.netscape.cmsutil.util.Utils;
  */
 public class UserCertService extends PKIService implements UserCertResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public final static int DEFAULT_SIZE = 20;
 
     public IUGSubsystem userGroupManager = (IUGSubsystem) CMS.getSubsystem(CMS.SUBSYSTEM_UG);
 
+    public UserCertService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     public UserCertData createUserCertData(String userID, X509Certificate cert) throws Exception {
 
         UserCertData userCertData = new UserCertData();
diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserMembershipService.java b/base/common/src/com/netscape/cms/servlet/admin/UserMembershipService.java
index c87368a974131259e2320071a9501cba936ec698..94cd3bc6309c9e6da20930f3b3a0afda3336a53a 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/UserMembershipService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/UserMembershipService.java
@@ -23,8 +23,13 @@ import java.net.URI;
 import java.net.URLEncoder;
 import java.util.Enumeration;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
@@ -47,10 +52,26 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class UserMembershipService extends PKIService implements UserMembershipResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public final static int DEFAULT_SIZE = 20;
 
     public IUGSubsystem userGroupManager = (IUGSubsystem) CMS.getSubsystem(CMS.SUBSYSTEM_UG);
 
+    public UserMembershipService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     public UserMembershipData createUserMembershipData(String userID, String groupID) throws UnsupportedEncodingException {
 
         UserMembershipData userMembershipData = new UserMembershipData();
diff --git a/base/common/src/com/netscape/cms/servlet/admin/UserService.java b/base/common/src/com/netscape/cms/servlet/admin/UserService.java
index a098980cd48ecc24ac824ace8b09f4d08f17b243..064874c1e7a9d179f5fbcc2a98125fe4e02fa420 100644
--- a/base/common/src/com/netscape/cms/servlet/admin/UserService.java
+++ b/base/common/src/com/netscape/cms/servlet/admin/UserService.java
@@ -25,8 +25,13 @@ import java.util.Enumeration;
 import java.util.List;
 import java.util.Map;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import netscape.ldap.LDAPException;
 
@@ -62,6 +67,22 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
  */
 public class UserService extends PKIService implements UserResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
+    public UserService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     public final static int DEFAULT_SIZE = 20;
 
     public final static String BACK_SLASH = "\\";
diff --git a/base/common/src/com/netscape/cms/servlet/base/PKIService.java b/base/common/src/com/netscape/cms/servlet/base/PKIService.java
index 4034a75a312df2b70587ef5f396fa606afa580f3..ed691bfe4c42f8c7c6dd69398addba8111ae7493 100644
--- a/base/common/src/com/netscape/cms/servlet/base/PKIService.java
+++ b/base/common/src/com/netscape/cms/servlet/base/PKIService.java
@@ -27,7 +27,6 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.Request;
@@ -54,21 +53,24 @@ public class PKIService {
     // caching parameters
     public static final int DEFAULT_LONG_CACHE_LIFETIME = 1000;
 
-    @Context
     protected UriInfo uriInfo;
 
-    @Context
     protected HttpHeaders headers;
 
-    @Context
     protected Request request;
 
-    @Context
     protected HttpServletRequest servletRequest;
 
     public ILogger logger = CMS.getLogger();
     public IAuditor auditor = CMS.getAuditor();
 
+    public void setContextParams(UriInfo uriInfo, HttpHeaders headers, Request request, HttpServletRequest servletRequest) {
+        this.uriInfo = uriInfo;
+        this.headers = headers;
+        this.request = request;
+        this.servletRequest = servletRequest;
+    }
+
     public Response createOKResponse(Object object) {
         return Response.ok(object).build();
     }
diff --git a/base/common/src/com/netscape/cms/servlet/cert/CertService.java b/base/common/src/com/netscape/cms/servlet/cert/CertService.java
index 7d07af8abed007fe9f689f846114cb9472037b6d..615e1f5c3baff956ee5f9a79907c1ae2618bd3aa 100644
--- a/base/common/src/com/netscape/cms/servlet/cert/CertService.java
+++ b/base/common/src/com/netscape/cms/servlet/cert/CertService.java
@@ -34,6 +34,12 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+
 import netscape.security.pkcs.ContentInfo;
 import netscape.security.pkcs.PKCS7;
 import netscape.security.pkcs.SignerInfo;
@@ -81,6 +87,18 @@ import com.netscape.cmsutil.util.Utils;
  */
 public class CertService extends PKIService implements CertResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     ICertificateAuthority authority;
     ICertificateRepository repo;
     Random random;
@@ -93,6 +111,7 @@ public class CertService extends PKIService implements CertResource {
             random = new Random();
         }
         repo = authority.getCertificateRepository();
+        super.setContextParams(uriInfo, headers, request, servletRequest);
     }
 
     private void validateRequest(CertId id) {
diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainService.java b/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainService.java
index feec685dd43f6f326ea3985244b91ff154c603d1..42badede052dd4b2dc860bd636ea183a17467a7b 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainService.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/SecurityDomainService.java
@@ -17,6 +17,12 @@
 // --- END COPYRIGHT BLOCK ---
 package com.netscape.cms.servlet.csadmin;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+
 import com.netscape.certsrv.base.EBaseException;
 import com.netscape.certsrv.base.PKIException;
 import com.netscape.certsrv.system.DomainInfo;
@@ -29,6 +35,22 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class SecurityDomainService extends PKIService implements SecurityDomainResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
+    public SecurityDomainService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     @Override
     public InstallToken getInstallToken(String hostname, String subsystem) {
         try {
diff --git a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java
index f450fe73175fc1cfb9a18a7e056d7e174573d169..f558822cba64e9dd00b4b1d963df68c45667c1c4 100644
--- a/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java
+++ b/base/common/src/com/netscape/cms/servlet/csadmin/SystemConfigService.java
@@ -30,7 +30,12 @@ import java.util.Random;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
 
 import netscape.security.x509.X509CertImpl;
 
@@ -65,6 +70,18 @@ import com.netscape.cmsutil.util.Utils;
  *
  */
 public class SystemConfigService extends PKIService implements SystemConfigResource {
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     IConfigStore cs;
     String csType;
     String csState;
@@ -84,6 +101,7 @@ public class SystemConfigService extends PKIService implements SystemConfigResou
             isMasterCA = true;
         }
         instanceRoot = cs.getString("instanceRoot");
+        super.setContextParams(uriInfo, headers, request, servletRequest);
     }
 
     /* (non-Javadoc)
diff --git a/base/common/src/com/netscape/cms/servlet/key/KeyService.java b/base/common/src/com/netscape/cms/servlet/key/KeyService.java
index 4b8a907589ec4deec29e7bd212f459f2681e51de..5eae6423d8ac393d38fb493fca06975bfbf31aee 100644
--- a/base/common/src/com/netscape/cms/servlet/key/KeyService.java
+++ b/base/common/src/com/netscape/cms/servlet/key/KeyService.java
@@ -23,9 +23,14 @@ import java.math.BigInteger;
 import java.util.Enumeration;
 import java.util.Hashtable;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
 
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.BadRequestException;
@@ -56,6 +61,18 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
  */
 public class KeyService extends PKIService implements KeyResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public static final int DEFAULT_MAXRESULTS = 100;
     public static final int DEFAULT_MAXTIME = 10;
 
@@ -67,6 +84,7 @@ public class KeyService extends PKIService implements KeyResource {
         kra = ( IKeyRecoveryAuthority ) CMS.getSubsystem( "kra" );
         repo = kra.getKeyRepository();
         queue = kra.getRequestQueue();
+        super.setContextParams(uriInfo, headers, request, servletRequest);
     }
 
     /**
diff --git a/base/common/src/com/netscape/cms/servlet/profile/ProfileService.java b/base/common/src/com/netscape/cms/servlet/profile/ProfileService.java
index b1dd233e79b0f75292240aa4a79aa31a6f27010f..85d326b88a0796b9472f85ee136557150c4df59c 100644
--- a/base/common/src/com/netscape/cms/servlet/profile/ProfileService.java
+++ b/base/common/src/com/netscape/cms/servlet/profile/ProfileService.java
@@ -30,7 +30,11 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Vector;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 
@@ -78,6 +82,18 @@ import com.netscape.cmscore.realm.PKIPrincipal;
  */
 public class ProfileService extends PKIService implements ProfileResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     private IProfileSubsystem ps = (IProfileSubsystem) CMS.getSubsystem(IProfileSubsystem.ID);
     private IPluginRegistry registry = (IPluginRegistry) CMS.getSubsystem(CMS.SUBSYSTEM_REGISTRY);
     private IConfigStore cs = CMS.getConfigStore().getSubStore("profile");
@@ -87,6 +103,10 @@ public class ProfileService extends PKIService implements ProfileResource {
     private final static String LOGGING_SIGNED_AUDIT_CONFIG_CERT_PROFILE =
             "LOGGING_SIGNED_AUDIT_CONFIG_CERT_PROFILE_3";
 
+    public ProfileService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     public ProfileDataInfos listProfiles() {
         List<ProfileDataInfo> list = new ArrayList<ProfileDataInfo>();
         ProfileDataInfos infos = new ProfileDataInfos();
diff --git a/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java b/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java
index 2e61f26f692b4e86651b3d9d6363ded2d29aedab..f8a0698c1f19a46eff29e2983720b67c5644da0e 100644
--- a/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java
+++ b/base/common/src/com/netscape/cms/servlet/request/CertRequestService.java
@@ -22,8 +22,13 @@ import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.PathParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
 
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.authentication.EAuthException;
@@ -61,11 +66,27 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
  */
 public class CertRequestService extends PKIService implements CertRequestResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public static final int DEFAULT_START = 0;
     public static final int DEFAULT_PAGESIZE = 20;
     public static final int DEFAULT_MAXRESULTS = 100;
     public static final int DEFAULT_MAXTIME = 10;
 
+    public CertRequestService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     /**
      * Used to retrieve key request info for a specific request
      */
diff --git a/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java b/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java
index 433206298741fc798232ced1f8187dc9f749f03c..47ef8acc8caf29a1e486055a18eeba3e3ef03a11 100644
--- a/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java
+++ b/base/common/src/com/netscape/cms/servlet/request/KeyRequestService.java
@@ -18,7 +18,12 @@
 
 package com.netscape.cms.servlet.request;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
 
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.base.BadRequestException;
@@ -41,11 +46,27 @@ import com.netscape.cmsutil.ldap.LDAPUtil;
  */
 public class KeyRequestService extends PKIService implements KeyRequestResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public static final int DEFAULT_START = 0;
     public static final int DEFAULT_PAGESIZE = 20;
     public static final int DEFAULT_MAXRESULTS = 100;
     public static final int DEFAULT_MAXTIME = 10;
 
+    public KeyRequestService() {
+        super.setContextParams(uriInfo, headers, request, servletRequest);
+    }
+
     /**
      * Used to retrieve key request info for a specific request
      */
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorService.java
index dfe042b6641db160f72df72d4be70398034ddc41..5f543bbd1f20dcb7b7ff660c777bc1c2324b4b6a 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/authenticator/AuthenticatorService.java
@@ -23,8 +23,13 @@ import java.net.URI;
 import java.net.URLEncoder;
 import java.util.Iterator;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
 import org.jboss.resteasy.plugins.providers.atom.Link;
@@ -43,10 +48,23 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class AuthenticatorService extends PKIService implements AuthenticatorResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public final static int DEFAULT_SIZE = 20;
 
     public AuthenticatorService() {
         CMS.debug("AuthenticatorService.<init>()");
+        super.setContextParams(uriInfo, headers, request, servletRequest);
     }
 
     public AuthenticatorInfo createAuthenticatorInfo(AuthenticatorRecord authenticatorRecord) {
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertService.java
index e0534e3f53f1032ccc7f7cba2a4a562086622033..d525dc2f20662ac2184bffaa119cf2d7d4d24d1d 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/cert/TPSCertService.java
@@ -23,6 +23,12 @@ import java.net.URI;
 import java.net.URLEncoder;
 import java.util.Iterator;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+
 import org.dogtagpki.server.tps.TPSSubsystem;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
@@ -37,10 +43,23 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class TPSCertService extends PKIService implements TPSCertResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public final static int DEFAULT_SIZE = 20;
 
     public TPSCertService() {
         System.out.println("TPSCertService.<init>()");
+        super.setContextParams(uriInfo, headers, request, servletRequest);
     }
 
     public TPSCertData createCertData(TPSCertRecord certRecord) {
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java
index a6ecbbadde75510e4866a8d3f971d91bd93a3a06..1ffa623c6ed7eee8bfea5f560e0852c8f8af5c8c 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/connection/ConnectionService.java
@@ -23,8 +23,13 @@ import java.net.URI;
 import java.net.URLEncoder;
 import java.util.Iterator;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
 import org.jboss.resteasy.plugins.providers.atom.Link;
@@ -43,10 +48,23 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class ConnectionService extends PKIService implements ConnectionResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public final static int DEFAULT_SIZE = 20;
 
     public ConnectionService() {
         CMS.debug("ConnectionService.<init>()");
+        super.setContextParams(uriInfo, headers, request, servletRequest);
     }
 
     public ConnectionInfo createConnectionInfo(ConnectionRecord connectionRecord) {
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityService.java
index 491447c614aac99bac629ba1adfddbb2d3dbfc4e..9cc7dac28ba743d2658a6cd5e10daf736abeab54 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/logging/ActivityService.java
@@ -23,6 +23,12 @@ import java.net.URI;
 import java.net.URLEncoder;
 import java.util.Iterator;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Request;
+import javax.ws.rs.core.UriInfo;
+
 import org.dogtagpki.server.tps.TPSSubsystem;
 import org.jboss.resteasy.plugins.providers.atom.Link;
 
@@ -38,10 +44,23 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class ActivityService extends PKIService implements ActivityResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public final static int DEFAULT_SIZE = 20;
 
     public ActivityService() {
         CMS.debug("ActivityService.<init>()");
+        super.setContextParams(uriInfo, headers, request, servletRequest);
     }
 
     public ActivityData createActivityData(ActivityRecord activityRecord) {
diff --git a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java b/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java
index 06c92b7ffc64885ce48815b29a8c30a3f7d1b795..8744badf70cff55727418e279e51abce7c84c520 100644
--- a/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java
+++ b/base/tps-tomcat/src/org/dogtagpki/server/tps/token/TokenService.java
@@ -23,8 +23,13 @@ import java.net.URI;
 import java.net.URLEncoder;
 import java.util.Iterator;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Request;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
 
 import org.dogtagpki.server.tps.TPSSubsystem;
 import org.jboss.resteasy.plugins.providers.atom.Link;
@@ -42,10 +47,23 @@ import com.netscape.cms.servlet.base.PKIService;
  */
 public class TokenService extends PKIService implements TokenResource {
 
+    @Context
+    private UriInfo uriInfo;
+
+    @Context
+    private HttpHeaders headers;
+
+    @Context
+    private Request request;
+
+    @Context
+    private HttpServletRequest servletRequest;
+
     public final static int DEFAULT_SIZE = 20;
 
     public TokenService() {
         CMS.debug("TokenService.<init>()");
+        super.setContextParams(uriInfo, headers, request, servletRequest);
     }
 
     public TokenData createTokenData(TokenRecord tokenRecord) {
-- 
1.8.3.1

