summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cms/servlet/processors/Processor.java
diff options
context:
space:
mode:
Diffstat (limited to 'base/common/src/com/netscape/cms/servlet/processors/Processor.java')
-rw-r--r--base/common/src/com/netscape/cms/servlet/processors/Processor.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/cms/servlet/processors/Processor.java b/base/common/src/com/netscape/cms/servlet/processors/Processor.java
index 2349b48ea..5a3b27063 100644
--- a/base/common/src/com/netscape/cms/servlet/processors/Processor.java
+++ b/base/common/src/com/netscape/cms/servlet/processors/Processor.java
@@ -18,6 +18,7 @@
package com.netscape.cms.servlet.processors;
+import java.lang.reflect.Method;
import java.math.BigInteger;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
@@ -33,6 +34,7 @@ import java.util.Map.Entry;
import java.util.StringTokenizer;
import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.FormParam;
import netscape.security.x509.X509CertImpl;
@@ -1260,4 +1262,51 @@ public class Processor {
CMS.debug("Processor: Nonce verified");
}
+
+ public String getUserMessage(String messageId, String... params) {
+ return CMS.getUserMessage(locale, messageId, params);
+ }
+
+ public void audit(String message, String scope, String type, String id, Map<String, String> params, String status) {
+
+ if (auditor == null) return;
+
+ String auditMessage = CMS.getLogMessage(
+ message,
+ auditor.getSubjectID(),
+ status,
+ auditor.getParamString(scope, type, id, params));
+
+ auditor.log(auditMessage);
+ }
+
+ /**
+ * Get the values of the fields annotated with @FormParam.
+ */
+ public Map<String, String> getParams(Object object) {
+
+ Map<String, String> map = new HashMap<String, String>();
+
+ // for each fields in the object
+ for (Method method : object.getClass().getMethods()) {
+ FormParam element = method.getAnnotation(FormParam.class);
+ if (element == null) continue;
+
+ String name = element.value();
+
+ try {
+ // get the value from the object
+ Object value = method.invoke(object);
+
+ // put the value in the map
+ map.put(name, value == null ? null : value.toString());
+
+ } catch (Exception e) {
+ // ignore inaccessible fields
+ e.printStackTrace();
+ }
+ }
+
+ return map;
+ }
}