summaryrefslogtreecommitdiffstats
path: root/base/common/src
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2017-04-26 01:27:17 +0200
committerEndi S. Dewata <edewata@redhat.com>2017-05-16 01:53:37 +0200
commit3abf731d9e6f02ac8d315978d31c28c2f9c85db9 (patch)
treed8ddcc5fa4e618833f2baccfa305316587bc4315 /base/common/src
parent587cfa90b3b065f4c9c5bd0292202d5d9a4c2f54 (diff)
downloadpki-3abf731d9e6f02ac8d315978d31c28c2f9c85db9.tar.gz
pki-3abf731d9e6f02ac8d315978d31c28c2f9c85db9.tar.xz
pki-3abf731d9e6f02ac8d315978d31c28c2f9c85db9.zip
Added AuditEvent attributes.
The AuditEvent class has been modified to support variable number of event attributes which can be used to generate more flexible audit log entries. https://pagure.io/dogtagpki/issue/2655 Change-Id: I565062bd7d635c0cbff0e6a7e71477648c9d3212
Diffstat (limited to 'base/common/src')
-rw-r--r--base/common/src/com/netscape/certsrv/logging/AuditEvent.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/base/common/src/com/netscape/certsrv/logging/AuditEvent.java b/base/common/src/com/netscape/certsrv/logging/AuditEvent.java
index 7a4aa9b08..9ba927123 100644
--- a/base/common/src/com/netscape/certsrv/logging/AuditEvent.java
+++ b/base/common/src/com/netscape/certsrv/logging/AuditEvent.java
@@ -18,7 +18,9 @@
package com.netscape.certsrv.logging;
import java.text.MessageFormat;
+import java.util.LinkedHashMap;
import java.util.Locale;
+import java.util.Map;
import com.netscape.certsrv.base.EBaseException;
import com.netscape.certsrv.base.MessageFormatter;
@@ -265,6 +267,7 @@ public class AuditEvent implements IBundleLogEvent {
private static final String INVALID_LOG_LEVEL = "log level: {0} is invalid, should be 0-6";
protected Object mParams[] = null;
+ protected Map<String, Object> attributes = new LinkedHashMap<>();
private String mEventType = null;
private String mMessage = null;
@@ -574,4 +577,25 @@ public class AuditEvent implements IBundleLogEvent {
} else
return toContent();
}
+
+ public void setAttribute(String name, Object value) {
+ attributes.put(name, value);
+ }
+
+ public String getAttributeList() {
+
+ StringBuilder sb = new StringBuilder();
+
+ for (String name : attributes.keySet()) {
+ Object value = attributes.get(name);
+
+ sb.append("[");
+ sb.append(name);
+ sb.append("=");
+ sb.append(value);
+ sb.append("]");
+ }
+
+ return sb.toString();
+ }
}