>From 70f7bd967121daea83047fe01f9d185041d194cd Mon Sep 17 00:00:00 2001
From: Ade Lee <alee@redhat.com>
Date: Tue, 17 Sep 2013 12:29:06 -0400
Subject: [PATCH] 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.
See https://issues.jboss.org/browse/RESTEASY-952
---
 .../cms/servlet/account/AccountService.java        | 17 ++++++++
 .../cms/servlet/admin/GroupMemberService.java      | 25 +++++++++--
 .../netscape/cms/servlet/admin/GroupService.java   | 33 +++++++++++----
 .../cms/servlet/admin/KRAConnectorService.java     | 21 +++++++++-
 .../cms/servlet/admin/SystemCertService.java       | 23 +++++++++-
 .../cms/servlet/admin/UserCertService.java         | 49 +++++++++++++++-------
 .../cms/servlet/admin/UserMembershipService.java   | 23 ++++++++--
 .../netscape/cms/servlet/admin/UserService.java    | 43 +++++++++++++------
 .../com/netscape/cms/servlet/base/PKIService.java  | 23 ++--------
 .../com/netscape/cms/servlet/cert/CertService.java | 24 +++++++++--
 .../cms/servlet/csadmin/SecurityDomainService.java | 22 +++++++++-
 .../cms/servlet/csadmin/SystemConfigService.java   | 17 ++++++++
 .../com/netscape/cms/servlet/key/KeyService.java   | 17 ++++++++
 .../cms/servlet/profile/ProfileService.java        | 46 +++++++++++++-------
 .../cms/servlet/request/CertRequestService.java    | 37 +++++++++++-----
 .../cms/servlet/request/KeyRequestService.java     | 17 ++++++++
 .../tps/authenticator/AuthenticatorService.java    | 17 ++++++++
 .../dogtagpki/server/tps/cert/TPSCertService.java  | 18 ++++++++
 .../server/tps/connection/ConnectionService.java   | 17 ++++++++
 .../server/tps/logging/ActivityService.java        | 18 ++++++++
 .../dogtagpki/server/tps/token/TokenService.java   | 17 ++++++++
 21 files changed, 428 insertions(+), 96 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..611c865aedae275ac7c492d60451ba9f0a52050a 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,18 @@ 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;
+
     @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..88702708cb28e9acca40a0c5dcbf64ab0b7bbba7 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,10 +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;
+
     @Override
     public GroupMemberCollection findGroupMembers(String groupID, Integer start, Integer size) {
         try {
-            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale());
+            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale(headers));
             processor.setUriInfo(uriInfo);
             return processor.findGroupMembers(groupID, start, size);
 
@@ -49,7 +66,7 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc
     @Override
     public GroupMemberData getGroupMember(String groupID, String memberID) {
         try {
-            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale());
+            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale(headers));
             processor.setUriInfo(uriInfo);
             return processor.getGroupMember(groupID, memberID);
 
@@ -71,7 +88,7 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc
 
     public Response addGroupMember(GroupMemberData groupMemberData) {
         try {
-            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale());
+            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale(headers));
             processor.setUriInfo(uriInfo);
             return processor.addGroupMember(groupMemberData);
 
@@ -86,7 +103,7 @@ public class GroupMemberService extends PKIService implements GroupMemberResourc
     @Override
     public void removeGroupMember(String groupID, String memberID) {
         try {
-            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale());
+            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale(headers));
             processor.setUriInfo(uriInfo);
             processor.removeGroupMember(groupID, memberID);
 
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..69573549f229c69e018a309f221391ea71a96c31 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,6 +56,18 @@ 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);
@@ -117,7 +134,7 @@ public class GroupService extends PKIService implements GroupResource {
             return response;
 
         } catch (Exception e) {
-            throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR"));
+            throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR", headers));
         }
     }
 
@@ -133,7 +150,7 @@ public class GroupService extends PKIService implements GroupResource {
         try {
             if (groupID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IGroup group = userGroupManager.getGroupFromName(groupID);
@@ -148,7 +165,7 @@ public class GroupService extends PKIService implements GroupResource {
             throw e;
 
         } catch (Exception e) {
-            throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR"));
+            throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR", headers));
         }
     }
 
@@ -175,7 +192,7 @@ public class GroupService extends PKIService implements GroupResource {
         try {
             if (groupID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IGroup group = userGroupManager.createGroup(groupID);
@@ -203,7 +220,7 @@ public class GroupService extends PKIService implements GroupResource {
                         .build();
 
             } catch (Exception e) {
-                throw new PKIException(getUserMessage("CMS_USRGRP_GROUP_ADD_FAILED"));
+                throw new PKIException(getUserMessage("CMS_USRGRP_GROUP_ADD_FAILED", headers));
             }
 
         } catch (PKIException e) {
@@ -239,7 +256,7 @@ public class GroupService extends PKIService implements GroupResource {
         try {
             if (groupID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IGroup group = userGroupManager.getGroupFromName(groupID);
@@ -263,7 +280,7 @@ public class GroupService extends PKIService implements GroupResource {
 
             } catch (Exception e) {
                 log(ILogger.LL_FAILURE, e.toString());
-                throw new PKIException(getUserMessage("CMS_USRGRP_GROUP_MODIFY_FAILED"));
+                throw new PKIException(getUserMessage("CMS_USRGRP_GROUP_MODIFY_FAILED", headers));
             }
 
         } catch (PKIException e) {
@@ -297,7 +314,7 @@ public class GroupService extends PKIService implements GroupResource {
         try {
             if (groupID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             // if fails, let the exception fall through
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..53ff8e9a2662aa30ae550ade070a5a49e5d4a740 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,10 +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;
+
     @Override
     public void addConnector(KRAConnectorInfo info) {
         try {
-            KRAConnectorProcessor processor = new KRAConnectorProcessor(getLocale());
+            KRAConnectorProcessor processor = new KRAConnectorProcessor(getLocale(headers));
             processor.addConnector(info);
         } catch (EBaseException e) {
             e.printStackTrace();
@@ -44,7 +61,7 @@ public class KRAConnectorService extends PKIService implements KRAConnectorResou
     @Override
     public void removeConnector(String host, String port) {
         try {
-            KRAConnectorProcessor processor = new KRAConnectorProcessor(getLocale());
+            KRAConnectorProcessor processor = new KRAConnectorProcessor(getLocale(headers));
             processor.removeConnector(host, port);
         } catch (EBaseException e) {
             e.printStackTrace();
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..d7113be0e164c7109024a08dd9af15c993946c1f 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,22 @@ 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>()");
+    }
+
     /**
      * Used to retrieve the transport certificate
      */
@@ -71,7 +92,7 @@ public class SystemCertService extends PKIService implements SystemCertResource
             e.printStackTrace();
             throw new PKIException("Unable to encode transport cert");
         }
-        return sendConditionalGetResponse(DEFAULT_LONG_CACHE_LIFETIME, cert);
+        return sendConditionalGetResponse(DEFAULT_LONG_CACHE_LIFETIME, cert, request);
     }
 
 }
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..374c8616a39e197147bf3577b96d893aea20b3d4 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,6 +68,18 @@ 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);
@@ -99,7 +116,7 @@ public class UserCertService extends PKIService implements UserCertResource {
 
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IUser user = null;
@@ -107,7 +124,7 @@ public class UserCertService extends PKIService implements UserCertResource {
             try {
                 user = userGroupManager.getUser(userID);
             } catch (Exception e) {
-                throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST"));
+                throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST", headers));
             }
 
             if (user == null) {
@@ -151,7 +168,7 @@ public class UserCertService extends PKIService implements UserCertResource {
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
 
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IUser user = null;
@@ -159,7 +176,7 @@ public class UserCertService extends PKIService implements UserCertResource {
             try {
                 user = userGroupManager.getUser(userID);
             } catch (Exception e) {
-                throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST"));
+                throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_NOT_EXIST", headers));
             }
 
             if (user == null) {
@@ -186,7 +203,7 @@ public class UserCertService extends PKIService implements UserCertResource {
                 if (!userCertData.getID().equals(certID)) continue;
 
                 ICertPrettyPrint print = CMS.getCertPrettyPrint(cert);
-                userCertData.setPrettyPrint(print.toString(getLocale()));
+                userCertData.setPrettyPrint(print.toString(getLocale(headers)));
 
                 // add base64 encoding
                 String base64 = CMS.getEncodedCert(cert);
@@ -226,7 +243,7 @@ public class UserCertService extends PKIService implements UserCertResource {
         try {
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IUser user = userGroupManager.createUser(userID);
@@ -269,7 +286,7 @@ public class UserCertService extends PKIService implements UserCertResource {
                     X509Certificate p7certs[] = pkcs7.getCertificates();
 
                     if (p7certs.length == 0) {
-                        throw new BadRequestException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR"));
+                        throw new BadRequestException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR", headers));
                     }
 
                     // fix for 370099 - cert ordering can not be assumed
@@ -295,7 +312,7 @@ public class UserCertService extends PKIService implements UserCertResource {
                     } else {
                         // not a chain, or in random order
                         CMS.debug("UserCertResourceService: " + CMS.getLogMessage("ADMIN_SRVLT_CERT_BAD_CHAIN"));
-                        throw new BadRequestException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR"));
+                        throw new BadRequestException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR", headers));
                     }
 
                     CMS.debug("UserCertResourceService: "
@@ -349,7 +366,7 @@ public class UserCertService extends PKIService implements UserCertResource {
                     throw e;
                 } catch (Exception e) {
                     log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_CERT_ERROR", e.toString()));
-                    throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR"));
+                    throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_CERT_ERROR", headers));
                 }
             }
 
@@ -381,18 +398,18 @@ public class UserCertService extends PKIService implements UserCertResource {
             } catch (CertificateExpiredException e) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_ADD_CERT_EXPIRED",
                         String.valueOf(cert.getSubjectDN())));
-                throw new BadRequestException(getUserMessage("CMS_USRGRP_SRVLT_CERT_EXPIRED"));
+                throw new BadRequestException(getUserMessage("CMS_USRGRP_SRVLT_CERT_EXPIRED", headers));
 
             } catch (CertificateNotYetValidException e) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("USRGRP_SRVLT_CERT_NOT_YET_VALID",
                         String.valueOf(cert.getSubjectDN())));
-                throw new BadRequestException(getUserMessage("CMS_USRGRP_SRVLT_CERT_NOT_YET_VALID"));
+                throw new BadRequestException(getUserMessage("CMS_USRGRP_SRVLT_CERT_NOT_YET_VALID", headers));
 
             } catch (LDAPException e) {
                 if (e.getLDAPResultCode() == LDAPException.ATTRIBUTE_OR_VALUE_EXISTS) {
-                    throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_CERT_EXISTS"));
+                    throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_USER_CERT_EXISTS", headers));
                 } else {
-                    throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED"));
+                    throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED", headers));
                 }
             }
 
@@ -403,7 +420,7 @@ public class UserCertService extends PKIService implements UserCertResource {
         } catch (Exception e) {
             log(ILogger.LL_FAILURE, e.toString());
             auditAddUserCert(userID, userCertData, ILogger.FAILURE);
-            throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED"));
+            throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED", headers));
         }
     }
 
@@ -444,7 +461,7 @@ public class UserCertService extends PKIService implements UserCertResource {
         try {
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IUser user = userGroupManager.createUser(userID);
@@ -469,7 +486,7 @@ public class UserCertService extends PKIService implements UserCertResource {
         } catch (Exception e) {
             log(ILogger.LL_FAILURE, e.toString());
             auditDeleteUserCert(userID, userCertData, ILogger.FAILURE);
-            throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED"));
+            throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED", headers));
         }
     }
 
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..35068f5a039110405495a23f0d8ed9e3bb1d7f12 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,6 +52,18 @@ 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);
@@ -76,7 +93,7 @@ public class UserMembershipService extends PKIService implements UserMembershipR
 
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IUser user = userGroupManager.getUser(userID);
@@ -131,7 +148,7 @@ public class UserMembershipService extends PKIService implements UserMembershipR
             groupMemberData.setID(userID);
             groupMemberData.setGroupID(groupID);
 
-            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale());
+            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale(headers));
             processor.setUriInfo(uriInfo);
             processor.addGroupMember(groupMemberData);
 
@@ -154,7 +171,7 @@ public class UserMembershipService extends PKIService implements UserMembershipR
     @Override
     public void removeUserMembership(String userID, String groupID) {
         try {
-            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale());
+            GroupMemberProcessor processor = new GroupMemberProcessor(getLocale(headers));
             processor.setUriInfo(uriInfo);
             processor.removeGroupMember(groupID, userID);
 
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..a6cd154e88dc0883f9437f4bda17ccd54c7cdf80 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,18 @@ 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 final static int DEFAULT_SIZE = 20;
 
     public final static String BACK_SLASH = "\\";
@@ -131,7 +148,7 @@ public class UserService extends PKIService implements UserResource {
             return response;
 
         } catch (Exception e) {
-            throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR"));
+            throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR", headers));
         }
     }
 
@@ -150,7 +167,7 @@ public class UserService extends PKIService implements UserResource {
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
 
-                throw new BadRequestDataException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestDataException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IUser user;
@@ -158,7 +175,7 @@ public class UserService extends PKIService implements UserResource {
             try {
                 user = userGroupManager.getUser(userID);
             } catch (Exception e) {
-                throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR"));
+                throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR", headers));
             }
 
             if (user == null) {
@@ -229,26 +246,26 @@ public class UserService extends PKIService implements UserResource {
         try {
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestDataException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestDataException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             if (userID.indexOf(BACK_SLASH) != -1) {
                 // backslashes (BS) are not allowed
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_RS_ID_BS"));
-                throw new BadRequestDataException(getUserMessage("CMS_ADMIN_SRVLT_RS_ID_BS"));
+                throw new BadRequestDataException(getUserMessage("CMS_ADMIN_SRVLT_RS_ID_BS", headers));
             }
 
             if (userID.equals(SYSTEM_USER)) {
                 // backslashes (BS) are not allowed
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_SPECIAL_ID", userID));
-                throw new ForbiddenException(getUserMessage("CMS_ADMIN_SRVLT_SPECIAL_ID", userID));
+                throw new ForbiddenException(getUserMessage("CMS_ADMIN_SRVLT_SPECIAL_ID", headers, userID));
             }
 
             IUser user = userGroupManager.createUser(userID);
 
             String fname = userData.getFullName();
             if (fname == null || fname.length() == 0) {
-                String msg = getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "full name");
+                String msg = getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", headers, "full name");
 
                 log(ILogger.LL_FAILURE, msg);
                 throw new BadRequestDataException(msg);
@@ -324,7 +341,7 @@ public class UserService extends PKIService implements UserResource {
                 log(ILogger.LL_FAILURE, e.toString());
 
                 if (user.getUserID() == null) {
-                    throw new BadRequestDataException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", "uid"));
+                    throw new BadRequestDataException(getUserMessage("CMS_USRGRP_USER_ADD_FAILED_1", headers, "uid"));
                 } else {
                     throw new PKIException(e.getMessage(), e);
                 }
@@ -370,7 +387,7 @@ public class UserService extends PKIService implements UserResource {
         try {
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestDataException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestDataException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             IUser user = userGroupManager.createUser(userID);
@@ -431,7 +448,7 @@ public class UserService extends PKIService implements UserResource {
 
             } catch (Exception e) {
                 log(ILogger.LL_FAILURE, e.toString());
-                throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED"));
+                throw new PKIException(getUserMessage("CMS_USRGRP_USER_MOD_FAILED", headers));
             }
 
         } catch (PKIException e) {
@@ -468,7 +485,7 @@ public class UserService extends PKIService implements UserResource {
         try {
             if (userID == null) {
                 log(ILogger.LL_FAILURE, CMS.getLogMessage("ADMIN_SRVLT_NULL_RS_ID"));
-                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID"));
+                throw new BadRequestException(getUserMessage("CMS_ADMIN_SRVLT_NULL_RS_ID", headers));
             }
 
             // get list of groups, and see if uid belongs to any
@@ -478,7 +495,7 @@ public class UserService extends PKIService implements UserResource {
                 groups = userGroupManager.findGroups("*");
 
             } catch (Exception e) {
-                throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR"));
+                throw new PKIException(getUserMessage("CMS_INTERNAL_ERROR", headers));
             }
 
             try {
@@ -495,7 +512,7 @@ public class UserService extends PKIService implements UserResource {
                 auditDeleteUser(userID, ILogger.SUCCESS);
 
             } catch (Exception e) {
-                throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_FAIL_USER_RMV"));
+                throw new PKIException(getUserMessage("CMS_USRGRP_SRVLT_FAIL_USER_RMV", headers));
             }
 
         } catch (PKIException e) {
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..23e540f0eb1809a4ec3901ed02166e917a809d5c 100644
--- a/base/common/src/com/netscape/cms/servlet/base/PKIService.java
+++ b/base/common/src/com/netscape/cms/servlet/base/PKIService.java
@@ -24,16 +24,13 @@ import java.util.List;
 import java.util.Locale;
 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;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.UriInfo;
 
 import com.netscape.certsrv.apps.CMS;
 import com.netscape.certsrv.cert.CertData;
@@ -54,18 +51,6 @@ 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();
 
@@ -73,7 +58,7 @@ public class PKIService {
         return Response.ok(object).build();
     }
 
-    public Response sendConditionalGetResponse(int ctime, Object object) {
+    public Response sendConditionalGetResponse(int ctime, Object object, Request request) {
         CacheControl cc = new CacheControl();
         cc.setMaxAge(ctime);
         EntityTag tag = new EntityTag(Integer.toString(object.hashCode()));
@@ -98,7 +83,7 @@ public class PKIService {
         return data;
     }
 
-    public Locale getLocale() {
+    public Locale getLocale(HttpHeaders headers) {
 
         if (headers == null) return Locale.getDefault();
 
@@ -108,8 +93,8 @@ public class PKIService {
         return locales.get(0);
     }
 
-    public String getUserMessage(String messageId, String... params) {
-        return CMS.getUserMessage(getLocale(), messageId, params);
+    public String getUserMessage(String messageId, HttpHeaders headers, String... params) {
+        return CMS.getUserMessage(getLocale(headers), messageId, params);
     }
 
     public void log(int source, int level, String message) {
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..68d218afefe2e7446990585f20a0cd64de18c4f2 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;
@@ -152,7 +170,7 @@ public class CertService extends PKIService implements CertResource {
 
         RevocationProcessor processor;
         try {
-            processor = new RevocationProcessor("caDoRevoke-agent", getLocale());
+            processor = new RevocationProcessor("caDoRevoke-agent", getLocale(headers));
             processor.setStartTime(CMS.getCurrentDate().getTime());
 
             // TODO: set initiative based on auth info
@@ -268,7 +286,7 @@ public class CertService extends PKIService implements CertResource {
     public CertRequestInfo unrevokeCert(CertId id, CertUnrevokeRequest request) {
         RevocationProcessor processor;
         try {
-            processor = new RevocationProcessor("caDoUnrevoke", getLocale());
+            processor = new RevocationProcessor("caDoUnrevoke", getLocale(headers));
 
             // TODO: set initiative based on auth info
             processor.setInitiative(AuditFormat.FROMAGENT);
@@ -464,7 +482,7 @@ public class CertService extends PKIService implements CertResource {
         certData.setEncoded(base64);
 
         ICertPrettyPrint print = CMS.getCertPrettyPrint(cert);
-        certData.setPrettyPrint(print.toString(getLocale()));
+        certData.setPrettyPrint(print.toString(getLocale(headers)));
 
         String p7Str = getCertChainData(cert);
         certData.setPkcs7CertChain(p7Str);
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..399c28a35f29e833f44fd8e399137aff70948816 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,13 +35,25 @@ 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;
+
     @Override
     public InstallToken getInstallToken(String hostname, String subsystem) {
         try {
             // Get uid from realm authentication.
             String user = servletRequest.getUserPrincipal().getName();
 
-            SecurityDomainProcessor processor = new SecurityDomainProcessor(getLocale());
+            SecurityDomainProcessor processor = new SecurityDomainProcessor(getLocale(headers));
             return processor.getInstallToken(user, hostname, subsystem);
 
         } catch (EBaseException e) {
@@ -46,7 +64,7 @@ public class SecurityDomainService extends PKIService implements SecurityDomainR
     @Override
     public DomainInfo getDomainInfo() throws PKIException {
         try {
-            SecurityDomainProcessor processor = new SecurityDomainProcessor(getLocale());
+            SecurityDomainProcessor processor = new SecurityDomainProcessor(getLocale(headers));
             return processor.getDomainInfo();
 
         } catch (EBaseException e) {
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..96c56f725dd06197cc67d5d09001ccd90418a6b9 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;
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..2aba7ab4045efed376b54c5d9388d0b19e6698d5 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;
 
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..3a5e63eee52ab9836e3068fadd283cc9758cac88 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");
@@ -108,7 +124,7 @@ public class ProfileService extends PKIService implements ProfileResource {
                 String id = profileIds.nextElement();
                 ProfileDataInfo info = null;
                 try {
-                    info = createProfileDataInfo(id, visibleOnly, uriInfo, getLocale());
+                    info = createProfileDataInfo(id, visibleOnly, uriInfo, getLocale(headers));
                 } catch (EBaseException e) {
                     continue;
                 }
@@ -197,11 +213,11 @@ public class ProfileService extends PKIService implements ProfileResource {
         data.setAuthenticatorId(profile.getAuthenticatorId());
         data.setAuthzAcl(profile.getAuthzAcl());
         data.setClassId(cs.getString(profileId + ".class_id"));
-        data.setDescription(profile.getDescription(getLocale()));
+        data.setDescription(profile.getDescription(getLocale(headers)));
         data.setEnabled(ps.isProfileEnable(profileId));
         data.setEnabledBy(ps.getProfileEnableBy(profileId));
         data.setId(profileId);
-        data.setName(profile.getName(getLocale()));
+        data.setName(profile.getName(getLocale(headers)));
         data.setRenewal(Boolean.getBoolean(profile.isRenewal()));
         data.setVisible(profile.isVisible());
         data.setXMLOutput(Boolean.getBoolean(profile.isXmlOutput()));
@@ -209,7 +225,7 @@ public class ProfileService extends PKIService implements ProfileResource {
         Enumeration<String> inputIds = profile.getProfileInputIds();
         if (inputIds != null) {
             while (inputIds.hasMoreElements()) {
-                ProfileInput input = createProfileInput(profile, inputIds.nextElement(), getLocale());
+                ProfileInput input = createProfileInput(profile, inputIds.nextElement(), getLocale(headers));
                 if (input == null)
                     continue;
                 data.addProfileInput(input);
@@ -220,7 +236,7 @@ public class ProfileService extends PKIService implements ProfileResource {
         Enumeration<String> outputIds = profile.getProfileOutputIds();
         if (outputIds != null) {
             while (outputIds.hasMoreElements()) {
-                ProfileOutput output = createProfileOutput(profile, outputIds.nextElement(), getLocale());
+                ProfileOutput output = createProfileOutput(profile, outputIds.nextElement(), getLocale(headers));
                 if (output == null)
                     continue;
                 data.addProfileOutput(output);
@@ -260,9 +276,9 @@ public class ProfileService extends PKIService implements ProfileResource {
 
         ProfilePolicy p = new ProfilePolicy();
         String constraintClassId = policyStore.getString("constraint.class_id");
-        p.setConstraint(PolicyConstraintFactory.create(getLocale(), policy.getConstraint(), constraintClassId));
+        p.setConstraint(PolicyConstraintFactory.create(getLocale(headers), policy.getConstraint(), constraintClassId));
         String defaultClassId = policyStore.getString("default.class_id");
-        p.setDef(PolicyDefaultFactory.create(getLocale(), policy.getDefault(), defaultClassId));
+        p.setDef(PolicyDefaultFactory.create(getLocale(headers), policy.getDefault(), defaultClassId));
         p.setId(policy.getId());
         return p;
     }
@@ -411,8 +427,8 @@ public class ProfileService extends PKIService implements ProfileResource {
             IPluginInfo info = registry.getPluginInfo("profile", data.getClassId());
 
             profile = ps.createProfile(profileId, data.getClassId(), info.getClassName(), config);
-            profile.setName(getLocale(), data.getName());
-            profile.setDescription(getLocale(), data.getDescription());
+            profile.setName(getLocale(headers), data.getName());
+            profile.setDescription(getLocale(headers), data.getDescription());
             profile.setVisible(data.isVisible());
             profile.getConfigStore().commit(false);
             ps.createProfileConfig(profileId, data.getClassId(), config);
@@ -490,8 +506,8 @@ public class ProfileService extends PKIService implements ProfileResource {
             auditParams.put("authzAcl", data.getAuthzAcl());
         }
 
-        if (differs(profile.getDescription(getLocale()), data.getDescription())) {
-            profile.setDescription(getLocale(), data.getDescription());
+        if (differs(profile.getDescription(getLocale(headers)), data.getDescription())) {
+            profile.setDescription(getLocale(headers), data.getDescription());
             auditParams.put("description", data.getDescription());
         }
 
@@ -500,8 +516,8 @@ public class ProfileService extends PKIService implements ProfileResource {
             auditParams.put("id", data.getId());
         }
 
-        if (differs(profile.getName(getLocale()), data.getName())) {
-            profile.setName(getLocale(), data.getName());
+        if (differs(profile.getName(getLocale(headers)), data.getName())) {
+            profile.setName(getLocale(headers), data.getName());
             auditParams.put("name", data.getName());
         }
 
@@ -690,7 +706,7 @@ public class ProfileService extends PKIService implements ProfileResource {
         Map<String, ProfileOutput> existingOutputs = new LinkedHashMap<String, ProfileOutput>();
         while (existingIds.hasMoreElements()) {
             String id = existingIds.nextElement();
-            ProfileOutput output = createProfileOutput(profile, id, getLocale());
+            ProfileOutput output = createProfileOutput(profile, id, getLocale(headers));
             if (output == null)
                 continue;
             existingOutputs.put(id, output);
@@ -781,7 +797,7 @@ public class ProfileService extends PKIService implements ProfileResource {
 
         while (existingIds.hasMoreElements()) {
             String id = existingIds.nextElement();
-            ProfileInput input = createProfileInput(profile, id, getLocale());
+            ProfileInput input = createProfileInput(profile, id, getLocale(headers));
             if (input == null)
                 continue;
             existingInputs.put(id, input);
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..dd3065427c811c980290d78a6cf4d3984d0d3161 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,6 +66,18 @@ 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;
@@ -104,7 +121,7 @@ public class CertRequestService extends PKIService implements CertRequestResourc
         CertRequestDAO dao = new CertRequestDAO();
 
         try {
-            infos = dao.submitRequest(data, servletRequest, uriInfo, getLocale());
+            infos = dao.submitRequest(data, servletRequest, uriInfo, getLocale(headers));
         } catch (EAuthException e) {
             CMS.debug("enrollCert: authentication failed: " + e);
             throw new UnauthorizedException(e.toString());
@@ -155,30 +172,30 @@ public class CertRequestService extends PKIService implements CertRequestResourc
         }
         CertRequestDAO dao = new CertRequestDAO();
         try {
-            dao.changeRequestState(id, servletRequest, data, getLocale(), op);
+            dao.changeRequestState(id, servletRequest, data, getLocale(headers), op);
         } catch (ERejectException e) {
             CMS.debug("changeRequestState: execution rejected " + e);
-            throw new BadRequestException(CMS.getUserMessage(getLocale(), "CMS_PROFILE_REJECTED", e.toString()));
+            throw new BadRequestException(CMS.getUserMessage(getLocale(headers), "CMS_PROFILE_REJECTED", e.toString()));
         } catch (EDeferException e) {
             CMS.debug("changeRequestState: execution defered " + e);
             // TODO do we throw an exception here?
-            throw new BadRequestException(CMS.getUserMessage(getLocale(), "CMS_PROFILE_DEFERRED", e.toString()));
+            throw new BadRequestException(CMS.getUserMessage(getLocale(headers), "CMS_PROFILE_DEFERRED", e.toString()));
         } catch (BadRequestDataException e) {
             CMS.debug("changeRequestState: bad request data: " + e);
             throw new BadRequestException(e.toString());
         } catch (EPropertyException e) {
             CMS.debug("changeRequestState: execution error " + e);
-            throw new PKIException(CMS.getUserMessage(getLocale(),
+            throw new PKIException(CMS.getUserMessage(getLocale(headers),
                     "CMS_PROFILE_PROPERTY_ERROR", e.toString()));
         } catch (EProfileException e) {
             CMS.debug("ProfileProcessServlet: execution error " + e);
-            throw new PKIException(CMS.getUserMessage(getLocale(), "CMS_INTERNAL_ERROR"));
+            throw new PKIException(CMS.getUserMessage(getLocale(headers), "CMS_INTERNAL_ERROR"));
         } catch (EBaseException e) {
             e.printStackTrace();
             throw new PKIException("Problem approving request in CertRequestResource.assignRequest! " + e);
         } catch (RequestNotFoundException e) {
             CMS.debug(e);
-            throw new BadRequestException(CMS.getUserMessage(getLocale(), "CMS_REQUEST_NOT_FOUND", id.toString()));
+            throw new BadRequestException(CMS.getUserMessage(getLocale(headers), "CMS_REQUEST_NOT_FOUND", id.toString()));
         }
     }
 
@@ -188,7 +205,7 @@ public class CertRequestService extends PKIService implements CertRequestResourc
 
         CertRequestDAO dao = new CertRequestDAO();
         try {
-            info = dao.reviewRequest(servletRequest, id, uriInfo, getLocale());
+            info = dao.reviewRequest(servletRequest, id, uriInfo, getLocale(headers));
         } catch (EBaseException e) {
             // log error
             e.printStackTrace();
@@ -301,7 +318,7 @@ public class CertRequestService extends PKIService implements CertRequestResourc
         while (inputIds.hasMoreElements()) {
             String id = inputIds.nextElement();
             try {
-                ProfileInput input = ProfileService.createProfileInput(profile, id, getLocale());
+                ProfileInput input = ProfileService.createProfileInput(profile, id, getLocale(headers));
                 for (ProfileAttribute attr: input.getAttrs()) {
                     attr.setValue("");
                 }
@@ -333,7 +350,7 @@ public class CertRequestService extends PKIService implements CertRequestResourc
                 String id = profileIds.nextElement();
                 ProfileDataInfo info = null;
                 try {
-                    info = ProfileService.createProfileDataInfo(id, visibleOnly, uriInfo, getLocale());
+                    info = ProfileService.createProfileDataInfo(id, visibleOnly, uriInfo, getLocale(headers));
                 } catch (EBaseException e) {
                     continue;
                 }
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..fce3e879eacc74961ada6d9631fab5f13353f66a 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,6 +46,18 @@ 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;
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..a2bb2ac04515a9de4e44bbd5e4a0021d6f403c5f 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,6 +48,18 @@ 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() {
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..8f4028237e212058a85cd6eae2bdc523233c2548 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,6 +43,18 @@ 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() {
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..23af22529f49852c5039bbf3d5cae6bab3a1039a 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,6 +48,18 @@ 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() {
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..8ce5d76a96b3e740b6736b66b2bfe3ea7629c0db 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,6 +44,18 @@ 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() {
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..16537e3566dc4a20eb47c7f5ec96de9ea1a95a56 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,6 +47,18 @@ 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() {
-- 
1.8.3.1

