summaryrefslogtreecommitdiffstats
path: root/base/server/cms/src/com/netscape/cms/servlet/base
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-02-03 19:20:31 +0100
committerEndi S. Dewata <edewata@redhat.com>2016-02-05 22:40:44 +0100
commit9bd94a0a54793a0720b803846ce2291e5064c2ae (patch)
tree0e0d5731923844454c23fc89e7a10b5abb708a58 /base/server/cms/src/com/netscape/cms/servlet/base
parent987dda15acdd6e6f4c7c477fed122a76ad40260c (diff)
downloadpki-9bd94a0a54793a0720b803846ce2291e5064c2ae.tar.gz
pki-9bd94a0a54793a0720b803846ce2291e5064c2ae.tar.xz
pki-9bd94a0a54793a0720b803846ce2291e5064c2ae.zip
Added resource bundle for token state labels.
The labels for token states and the transitions are now stored in token-states.properties. The default file will be stored in the /usr/share/pki/tps/conf, but it can be overriden by copying and customizing the file into <instance>/tps/conf. When the UI retrieves the token data the labels for the current state and the valid transitions will be loaded from the file and returned to the UI. The UI will show the transition labels in the dropdown list for changing token status. https://fedorahosted.org/pki/ticket/1289 https://fedorahosted.org/pki/ticket/1291
Diffstat (limited to 'base/server/cms/src/com/netscape/cms/servlet/base')
-rw-r--r--base/server/cms/src/com/netscape/cms/servlet/base/PKIService.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/base/server/cms/src/com/netscape/cms/servlet/base/PKIService.java b/base/server/cms/src/com/netscape/cms/servlet/base/PKIService.java
index fe77fd567..d2e55b5a3 100644
--- a/base/server/cms/src/com/netscape/cms/servlet/base/PKIService.java
+++ b/base/server/cms/src/com/netscape/cms/servlet/base/PKIService.java
@@ -17,14 +17,19 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cms.servlet.base;
+import java.io.File;
import java.lang.reflect.Method;
import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.ResourceBundle;
+import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.FormParam;
import javax.ws.rs.core.CacheControl;
@@ -77,10 +82,46 @@ public class PKIService {
@Context
protected HttpServletRequest servletRequest;
+ @Context
+ protected ServletContext servletContext;
public ILogger logger = CMS.getLogger();
public IAuditor auditor = CMS.getAuditor();
+ public String getInstanceDir() {
+ return System.getProperty("catalina.base");
+ }
+
+ public String getSubsystemName() {
+ // get web application path: /<subsystem>
+ String path = servletContext.getContextPath();
+
+ // get subsystem name by removing the / prefix from the path
+ return path.startsWith("/") ? path.substring(1) : path;
+ }
+
+ public String getSubsystemConfDir() {
+ return getInstanceDir() + File.separator + getSubsystemName() + File.separator + "conf";
+ }
+
+ public String getSharedSubsystemConfDir() {
+ return File.separator + "usr" + File.separator + "share" + File.separator + "pki" +
+ File.separator + getSubsystemName() + File.separator + "conf";
+ }
+
+ public ResourceBundle getResourceBundle(String name) throws Exception {
+
+ // Look in <instance>/<subsystem>/conf first,
+ // then fallback to /usr/share/pki/<subsystem>/conf.
+ URL[] urls = {
+ new File(getSubsystemConfDir()).toURI().toURL(),
+ new File(getSharedSubsystemConfDir()).toURI().toURL()
+ };
+
+ ClassLoader loader = new URLClassLoader(urls);
+ return ResourceBundle.getBundle(name, servletRequest.getLocale(), loader);
+ }
+
public static MediaType resolveFormat(MediaType format) {
if (format == null) return null;