summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/cmscore/logging
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/cmscore/logging')
-rw-r--r--pki/base/common/src/com/netscape/cmscore/logging/AuditEventFactory.java97
-rw-r--r--pki/base/common/src/com/netscape/cmscore/logging/AuditFormat.java110
-rw-r--r--pki/base/common/src/com/netscape/cmscore/logging/LogQueue.java127
-rw-r--r--pki/base/common/src/com/netscape/cmscore/logging/LogSubsystem.java272
-rw-r--r--pki/base/common/src/com/netscape/cmscore/logging/Logger.java374
-rw-r--r--pki/base/common/src/com/netscape/cmscore/logging/SignedAuditEventFactory.java124
-rw-r--r--pki/base/common/src/com/netscape/cmscore/logging/SignedAuditLogger.java47
-rw-r--r--pki/base/common/src/com/netscape/cmscore/logging/SystemEventFactory.java98
8 files changed, 1249 insertions, 0 deletions
diff --git a/pki/base/common/src/com/netscape/cmscore/logging/AuditEventFactory.java b/pki/base/common/src/com/netscape/cmscore/logging/AuditEventFactory.java
new file mode 100644
index 000000000..e8c7032d1
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/logging/AuditEventFactory.java
@@ -0,0 +1,97 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cmscore.logging;
+
+
+import java.util.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * A log event object for handling audit messages
+ * <P>
+ *
+ * @author mikep
+ * @author mzhao
+ * @version $Revision$, $Date$
+ */
+public class AuditEventFactory implements ILogEventFactory {
+
+ /**
+ * List of supported properties.
+ */
+ public static final String PROP_BUNDLE = "bundleName";
+
+ /**
+ * Constructs a audit event factory.
+ */
+ public AuditEventFactory() {
+ }
+
+ /**
+ * Creates an log event.
+ *
+ * @param evtClass the event type
+ * @param prop the resource bundle
+ * @param source the subsystem ID who creates the log event
+ * @param level the severity of the log event
+ * @param multiline the log message has more than one line or not
+ * @param msg the detail message of the log
+ * @param params the parameters in the detail log message
+ */
+ public ILogEvent create(int evtClass, Properties prop, int source,
+ int level, boolean multiline, String msg, Object params[]) {
+ if (evtClass != ILogger.EV_AUDIT)
+ return null;
+ AuditEvent event = new AuditEvent(msg, params);
+
+ event.setLevel(level);
+ event.setSource(source);
+ event.setMultiline(multiline);
+ setProperties(prop, event);
+ return event;
+ }
+
+ /**
+ * Set the resource bundle of the log event.
+ *
+ * @param prop the properties
+ * @param event the log event
+ */
+ protected void setProperties(Properties prop, IBundleLogEvent event) {
+ if (prop == null) {
+ event.setBundleName(null);
+ } else {
+ String bundleName = (String) prop.get(PROP_BUNDLE);
+
+ if (bundleName != null) {
+ event.setBundleName(bundleName);
+ }
+ }
+ }
+
+ /**
+ * Releases an log event.
+ *
+ * @param e the log event
+ */
+ public void release(ILogEvent e) {
+ // do nothing
+ }
+}
diff --git a/pki/base/common/src/com/netscape/cmscore/logging/AuditFormat.java b/pki/base/common/src/com/netscape/cmscore/logging/AuditFormat.java
new file mode 100644
index 000000000..0af38f168
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/logging/AuditFormat.java
@@ -0,0 +1,110 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cmscore.logging;
+
+
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.request.IRequest;
+
+
+/**
+ * Define audit log message format
+ *
+ * @author mzhao
+ * @version $Revision$, $Date$
+ */
+public class AuditFormat {
+
+ /**
+ * default log level for writing audit log
+ */
+ public static final int LEVEL = ILogger.LL_INFO;
+
+ /**
+ * initiative: the event is from EE
+ */
+ public static final String FROMUSER = "fromUser";
+
+ /**
+ * initiative: the event is from agent
+ */
+ public static final String FROMAGENT = "fromAgent";
+
+ /**
+ * initiative: the event is from router
+ */
+ public static final String FROMROUTER = "fromRouter";
+
+ /**
+ * initiative: the event is from remote authority
+ */
+ public static final String FROMRA = "fromRemoteAuthority";
+
+ /**
+ * authentication module: no Authentication manager
+ */
+ public static final String NOAUTH = "noAuthManager";
+
+ // for ProcessCertReq.java ,kra
+ /* 0: request type
+ 1: request ID
+ 2: initiative
+ 3: auth module
+ 4: status
+ 5: cert dn
+ 6: other info. eg cert serial number, violation policies
+ */
+ public static final String FORMAT =
+ "{0} reqID {1} {2} authenticated by {3} is {4} DN requested: {5} {6}";
+ public static final String NODNFORMAT =
+ "{0} reqID {1} {2} authenticated by {3} is {4}";
+
+ public static final String ENROLLMENTFORMAT =
+ IRequest.ENROLLMENT_REQUEST + " reqID {0} {1} authenticated by {2} is {3}. DN requested: {4} {5}";
+ public static final String RENEWALFORMAT =
+ IRequest.RENEWAL_REQUEST + " reqID {0} {1} authenticated by {2} is {3}. DN requested: {4} old serial number: 0x{5} {6}";
+ public static final String REVOCATIONFORMAT =
+ IRequest.REVOCATION_REQUEST + " reqID {0} {1} authenticated by {2} is {3}. DN requested: {4} serial number: 0x{5} revocation reason: {6} {7}";
+
+ // 1: fromAgent AgentID: xxx authenticated by xxx
+ public static final String DOREVOKEFORMAT =
+ IRequest.REVOCATION_REQUEST + " reqID {0} {1} is {2}. DN requested: {3} serial number: 0x{4} revocation reason: {5}";
+ // 1: fromAgent AgentID: xxx authenticated by xxx
+ public static final String DOUNREVOKEFORMAT =
+ IRequest.UNREVOCATION_REQUEST + " reqID {0} {1} is {2}. DN requested: {3} serial number: 0x{4}";
+
+ // 0:initiative
+ public static final String CRLUPDATEFORMAT =
+ "CRLUpdate request {0} authenticated by {1} is {2}. Id: {3}\ncrl Number: {4} last update time: {5} next update time: {6} number of entries in the CRL: {7}";
+
+ // audit user/group
+ public static final String ADDUSERFORMAT =
+ "Admin UID: {0} added User UID: {1}";
+ public static final String REMOVEUSERFORMAT =
+ "Admin UID: {0} removed User UID: {1} ";
+ public static final String MODIFYUSERFORMAT =
+ "Admin UID: {0} modified User UID: {1}";
+ public static final String ADDUSERCERTFORMAT =
+ "Admin UID: {0} added cert for User UID: {1}. cert DN: {2} serial number: 0x{3}";
+ public static final String REMOVEUSERCERTFORMAT =
+ "Admin UID: {0} removed cert of User UID: {1}. cert DN: {2} serial number: 0x{3}";
+ public static final String ADDUSERGROUPFORMAT =
+ "Admin UID: {0} added User UID: {1} to group: {2}";
+ public static final String REMOVEUSERGROUPFORMAT =
+ "Admin UID: {0} removed User UID: {1} from group: {2}";
+}
diff --git a/pki/base/common/src/com/netscape/cmscore/logging/LogQueue.java b/pki/base/common/src/com/netscape/cmscore/logging/LogQueue.java
new file mode 100644
index 000000000..24336d308
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/logging/LogQueue.java
@@ -0,0 +1,127 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cmscore.logging;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.MessageFormat;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.apps.CMS;
+
+
+/**
+ * A class represents a log queue.
+ * <P>
+ *
+ * @author mzhao
+ * @version $Revision$, $Date$
+ */
+public class LogQueue implements ILogQueue {
+
+ private static LogQueue mLogQueue = new LogQueue();
+ protected Vector mListeners = null;
+
+ /**
+ * Constructs a log queue.
+ */
+ public LogQueue() {
+ }
+
+ public static ILogQueue getLogQueue() {
+ return mLogQueue;
+ }
+
+ /**
+ * Initializes the log queue.
+ * <P>
+ *
+ */
+ public void init() {
+ mListeners = new Vector();
+
+ }
+
+ /**
+ * Stops this log queue: shuts down all registered listeners
+ * <P>
+ */
+ public void shutdown() {
+ if (mListeners == null)
+ return;
+ for (int i = 0; i < mListeners.size(); i++) {
+ ((ILogEventListener) mListeners.elementAt(i)).shutdown();
+ }
+ mListeners = null;
+ }
+
+ /**
+ * Adds an event listener.
+ *
+ * @param listener the log event listener
+ */
+ public void addLogEventListener(ILogEventListener listener) {
+ //Make sure we don't have duplicated listener
+ if (!mListeners.contains(listener))
+ mListeners.addElement(listener);
+ }
+
+ /**
+ * Removes an event listener.
+ *
+ * @param listener the log event listener
+ */
+ public void removeLogEventListener(ILogEventListener listener) {
+ mListeners.removeElement(listener);
+ }
+
+ /**
+ * Logs an event, and notifies logger to reuse the event.
+ *
+ * @param event the log event
+ */
+ public void log(ILogEvent event) {
+ if (mListeners == null)
+ return;
+ for (int i = 0; i < mListeners.size(); i++) {
+ try {
+ ((ILogEventListener) mListeners.elementAt(i)).log(event);
+ } catch (ELogException e) {
+ // Raidzilla Bug #57592: Don't display potentially
+ // incorrect log message.
+ // ConsoleError.send(new SystemEvent(CMS.getUserMessage("CMS_LOG_EVENT_FAILED",
+ // event.getEventType(), e.toString())));
+
+ // Don't do this again.
+ removeLogEventListener((ILogEventListener)
+ mListeners.elementAt(i));
+ }
+ }
+ }
+
+ /**
+ * Flushes the log buffers (if any)
+ */
+ public void flush() {
+ for (int i = 0; i < mListeners.size(); i++) {
+ ((ILogEventListener) mListeners.elementAt(i)).flush();
+ }
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/cmscore/logging/LogSubsystem.java b/pki/base/common/src/com/netscape/cmscore/logging/LogSubsystem.java
new file mode 100644
index 000000000..9a9d4bd4f
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/logging/LogSubsystem.java
@@ -0,0 +1,272 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cmscore.logging;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.MessageFormat;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.certsrv.apps.CMS;
+import com.netscape.cmscore.util.Debug;
+
+
+/**
+ * A class represents a log subsystem.
+ * <P>
+ *
+ * @author thomask
+ * @author mzhao
+ * @version $Revision$, $Date$
+ */
+public class LogSubsystem implements ILogSubsystem {
+
+ private static LogSubsystem mInstance = new LogSubsystem();
+ private static ILogQueue mLogQueue = LogQueue.getLogQueue();
+ private IConfigStore mConfig = null;
+
+ public static final String PROP_LOGGING = "log";
+
+ public static final String ID = "log";
+
+ public static final String PROP_CLASS = "class";
+ public static final String PROP_IMPL = "impl";
+ public static final String PROP_PLUGIN = "pluginName";
+ public static final String PROP_INSTANCE = "instance";
+
+ public Hashtable mLogPlugins = new Hashtable();
+ public Hashtable mLogInsts = new Hashtable();
+
+ /**
+ * Constructs a log subsystem.
+ */
+ private LogSubsystem() {
+ }
+
+ public String getId() {
+ return ID;
+ }
+
+ public void setId(String id) throws EBaseException {
+ throw new EBaseException(CMS.getUserMessage("CMS_BASE_INVALID_OPERATION"));
+ }
+
+ /**
+ * Initializes the log subsystem.
+ * <P>
+ *
+ * @param owner owner of this subsystem
+ * @param config configuration store
+ */
+ public void init(ISubsystem owner, IConfigStore config)
+ throws EBaseException {
+ mConfig = config;
+ mLogQueue.init();
+
+ // load log plugin implementation
+ IConfigStore c = config.getSubStore(PROP_IMPL);
+ Enumeration mImpls = c.getSubStoreNames();
+
+ while (mImpls.hasMoreElements()) {
+ String id = (String) mImpls.nextElement();
+ String pluginPath = c.getString(id + "." + PROP_CLASS);
+ LogPlugin plugin = new LogPlugin(id, pluginPath);
+
+ mLogPlugins.put(id, plugin);
+ }
+ if (Debug.ON)
+ Debug.trace("loaded logger plugins");
+
+ // load log instances
+ c = config.getSubStore(PROP_INSTANCE);
+ Enumeration instances = c.getSubStoreNames();
+
+ while (instances.hasMoreElements()) {
+ String insName = (String) instances.nextElement();
+ String implName = c.getString(insName + "." +
+ PROP_PLUGIN);
+ LogPlugin plugin =
+ (LogPlugin) mLogPlugins.get(implName);
+
+ if (plugin == null) {
+ throw new EBaseException(implName);
+ }
+ String className = plugin.getClassPath();
+ // Instantiate and init the log listener.
+ ILogEventListener logInst = null;
+
+ try {
+ logInst = (ILogEventListener)
+ Class.forName(className).newInstance();
+ IConfigStore pConfig =
+ c.getSubStore(insName);
+
+ logInst.init(this, pConfig);
+ // for view from console
+
+ } catch (ClassNotFoundException e) {
+ String errMsg = "LogSubsystem:: init()-" + e.toString();
+
+ throw new EBaseException(insName + ":Failed to instantiate class " + className);
+ } catch (IllegalAccessException e) {
+ String errMsg = "LogSubsystem:: init()-" + e.toString();
+
+ throw new EBaseException(insName + ":Failed to instantiate class " + className);
+ } catch (InstantiationException e) {
+ String errMsg = "LogSubsystem:: init()-" + e.toString();
+
+ throw new EBaseException(insName + ":Failed to instantiate class " + className);
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new EBaseException(insName + ":Failed to instantiate class " + className + " error: " + e.getMessage());
+ }
+
+ if (logInst == null) {
+ throw new EBaseException("Failed to instantiate class " + className);
+ }
+
+ if (insName == null) {
+ throw new EBaseException("Failed to instantiate class " + insName);
+ }
+
+ // add log instance to list.
+ mLogInsts.put(insName, logInst);
+ if (Debug.ON)
+ Debug.trace("loaded log instance " + insName + " impl " + implName);
+ }
+
+ }
+
+ public void startup() throws EBaseException {
+ Debug.trace("entering LogSubsystem.startup()");
+ Enumeration enum1 = mLogInsts.keys();
+
+ while (enum1.hasMoreElements()) {
+ String instName = (String) enum1.nextElement();
+
+ Debug.trace("about to call inst=" + instName + " in LogSubsystem.startup()");
+ ILogEventListener inst = (ILogEventListener)
+ mLogInsts.get(instName);
+
+ inst.startup();
+ }
+ }
+
+ /**
+ * Stops this subsystem.
+ * <P>
+ */
+ public void shutdown() {
+ mLogQueue.shutdown();
+ }
+
+ /**
+ * Returns the root configuration storage of this system.
+ * <P>
+ *
+ * @return configuration store of this subsystem
+ */
+ public IConfigStore getConfigStore() {
+ return mConfig;
+ }
+
+ /**
+ * Retrieves singleton: the LogSubsystem.
+ */
+ public static LogSubsystem getInstance() {
+ return mInstance;
+ }
+
+ /**
+ * Retrieves LogQueue.
+ */
+ public static ILogQueue getLogQueue() {
+ return mLogQueue;
+ }
+
+ public String getLogPluginName(ILogEventListener log) {
+ IConfigStore cs = log.getConfigStore();
+
+ try {
+ return cs.getString("pluginName", "");
+ } catch (EBaseException e) {
+ return "";
+ }
+ }
+
+ /**
+ * Retrieve log instance by it's name
+ */
+ public ILogEventListener getLogInstance(String insName) {
+ return (ILogEventListener) mLogInsts.get(insName);
+ }
+
+ public Hashtable getLogPlugins() {
+ return mLogPlugins;
+ }
+
+ public Hashtable getLogInsts() {
+ return mLogInsts;
+ }
+
+ public Vector getLogDefaultParams(String implName) throws
+ ELogException {
+ // is this a registered implname?
+ LogPlugin plugin = (LogPlugin)
+ mLogPlugins.get(implName);
+
+ if (plugin == null) {
+ throw new ELogException(implName);
+ }
+
+ // a temporary instance
+ ILogEventListener LogInst = null;
+ String className = plugin.getClassPath();
+
+ try {
+ LogInst = (ILogEventListener)
+ Class.forName(className).newInstance();
+ Vector v = LogInst.getDefaultParams();
+
+ return v;
+ } catch (InstantiationException e) {
+ throw new ELogException(
+ CMS.getUserMessage("CMS_LOG_LOAD_CLASS_FAIL", className));
+ } catch (ClassNotFoundException e) {
+ throw new ELogException(
+ CMS.getUserMessage("CMS_LOG_LOAD_CLASS_FAIL", className));
+ } catch (IllegalAccessException e) {
+ throw new ELogException(
+ CMS.getUserMessage("CMS_LOG_LOAD_CLASS_FAIL", className));
+ }
+ }
+
+ public Vector getLogInstanceParams(String insName) throws
+ ELogException {
+ ILogEventListener logInst = getLogInstance(insName);
+
+ if (logInst == null) {
+ return null;
+ }
+ Vector v = logInst.getInstanceParams();
+
+ return v;
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/cmscore/logging/Logger.java b/pki/base/common/src/com/netscape/cmscore/logging/Logger.java
new file mode 100644
index 000000000..b15717ca4
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/logging/Logger.java
@@ -0,0 +1,374 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cmscore.logging;
+
+
+import java.io.*;
+import java.util.*;
+import com.netscape.certsrv.logging.*;
+
+import com.netscape.cmscore.util.*;
+
+
+/**
+ * A class represents certificate server logger
+ * implementation.
+ * <P>
+ *
+ * @author thomask
+ * @author mzhao
+ * @version $Revision$, $Date$
+ */
+public class Logger implements ILogger {
+
+ protected static Logger mLogger = new Logger();
+ protected ILogQueue mLogQueue = null;
+ protected Hashtable mFactories = new Hashtable();
+
+ /**
+ * Constructs a generic logger, and registers a list
+ * of resident event factories.
+ */
+ public Logger() {
+ mLogQueue = LogSubsystem.getLogQueue();
+
+ // register standard event factories
+ register(EV_AUDIT, new AuditEventFactory());
+ register(EV_SYSTEM, new SystemEventFactory());
+ register(EV_SIGNED_AUDIT, new SignedAuditEventFactory());
+ }
+
+ /**
+ * get default single global logger
+ */
+ static public Logger getLogger() {
+ return mLogger;
+ }
+
+ /**
+ * Retrieves the associated log queue.
+ */
+ public ILogQueue getLogQueue() {
+ return mLogQueue;
+ }
+
+ /**
+ * Registers log factory.
+ * @param evtClass the event class name: ILogger.EV_SYSTEM or ILogger.EV_AUDIT
+ * @param f the event factory name
+ */
+ public void register(int evtClass, ILogEventFactory f) {
+ mFactories.put(Integer.toString(evtClass), f);
+ }
+
+ //************** default level ****************
+ /**
+ * Logs an event using default log level: ILogger.LL_INFO
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param source the source of the log event
+ * @param msg the one line detail message to be logged
+ */
+ public void log(int evtClass, int source, String msg) {
+ log(evtClass, null, source, ILogger.LL_INFO, msg, null);
+ }
+
+ /**
+ * Logs an event using default log level: ILogger.LL_INFO
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param msg the one line detail message to be logged
+ */
+ public void log(int evtClass, Properties props, int source, String msg) {
+ log(evtClass, props, source, ILogger.LL_INFO, msg, null);
+ }
+
+ //************** no param ****************
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ */
+ public void log(int evtClass, int source, int level, String msg) {
+ log(evtClass, null, source, level, msg, null);
+ }
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ */
+ public void log(int evtClass, Properties props, int source, int level, String msg) {
+ log(evtClass, props, source, level, msg, null);
+ }
+
+ //********************* one param **********************
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param msg the one line detail message to be logged
+ * @param param the parameter in the detail message
+ */
+ public void log(int evtClass, int source, int level, String msg, Object param) {
+ log(evtClass, null, source, level, msg, param);
+ }
+
+ /**
+ * Logs an event using default log level: ILogger.LL_INFO
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param msg the one line detail message to be logged
+ * @param param the parameter in the detail message
+ */
+ public void log(int evtClass, Properties props, int source, String msg, Object param) {
+ log(evtClass, props, source, ILogger.LL_INFO, msg, param);
+ }
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ * @param param the parameter in the detail message
+ */
+ public void log(int evtClass, Properties props, int source, int level, String msg,
+ Object param) {
+ Object o[] = new Object[1];
+
+ o[0] = param;
+ log(evtClass, props, source, level, msg, o);
+ }
+
+ //******************* multiple param **************************
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ * @param params the parameters in the detail message
+ */
+ public void log(int evtClass, int source, int level, String msg,
+ Object params[]) {
+ log(evtClass, null, source, level, msg, params);
+ }
+
+ //*************** the real implementation *****************
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ * @param params the parameters in the detail message
+ */
+ public void log(int evtClass, Properties prop, int source, int level, String msg,
+ Object params[]) {
+ mLogQueue.log(create(evtClass, prop, source, level, msg, params, ILogger.L_SINGLELINE));
+ }
+
+ //******************** multiline log *************************
+ //************** default level ****************
+ /**
+ * Logs an event using default log level: ILogger.LL_INFO
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param source the source of the log event
+ * @param msg the one line detail message to be logged
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, int source, String msg, boolean multiline) {
+ log(evtClass, null, source, ILogger.LL_INFO, msg, null, multiline);
+ }
+
+ /**
+ * Logs an event using default log level: ILogger.LL_INFO
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param msg the one line detail message to be logged
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, Properties props, int source, String msg, boolean multiline) {
+ log(evtClass, props, source, ILogger.LL_INFO, msg, null, multiline);
+ }
+
+ //************** no param ****************
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, int source, int level, String msg, boolean multiline) {
+ log(evtClass, null, source, level, msg, null, multiline);
+ }
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, Properties props, int source, int level, String msg, boolean multiline) {
+ log(evtClass, props, source, level, msg, null, multiline);
+ }
+
+ //********************* one param **********************
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param msg the one line detail message to be logged
+ * @param param the parameter in the detail message
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, int source, int level, String msg, Object param, boolean multiline) {
+ log(evtClass, null, source, level, msg, param, multiline);
+ }
+
+ /**
+ * Logs an event using default log level: ILogger.LL_INFO
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param msg the one line detail message to be logged
+ * @param param the parameter in the detail message
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, Properties props, int source, String msg, Object param, boolean multiline) {
+ log(evtClass, props, source, ILogger.LL_INFO, msg, param, multiline);
+ }
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ * @param param the parameter in the detail message
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, Properties props, int source, int level, String msg,
+ Object param, boolean multiline) {
+ Object o[] = new Object[1];
+
+ o[0] = param;
+ log(evtClass, props, source, level, msg, o, multiline);
+ }
+
+ //******************* multiple param **************************
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ * @param params the parameters in the detail message
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, int source, int level, String msg,
+ Object params[], boolean multiline) {
+ log(evtClass, null, source, level, msg, params, multiline);
+ }
+
+ //*************** the real implementation *****************
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM.
+ * @param props the resource bundle used for the detailed message
+ * @param source the source of the log event
+ * @param level the level of the log event
+ * @param msg the one line detail message to be logged
+ * @param params the parameters in the detail message
+ * @param multiline true if the message has more than one line, otherwise false
+ */
+ public void log(int evtClass, Properties prop, int source, int level, String msg,
+ Object params[], boolean multiline) {
+ mLogQueue.log(create(evtClass, prop, source, level, msg, params, multiline));
+ }
+
+ //******************** end multiline log *************************
+
+
+ /**
+ * Creates generic log event. If required, we can recycle
+ * events here.
+ */
+ //XXXXXXXXXXX prop is out dated!!!! XXXXXXXXXXXXXXX
+ public ILogEvent create(int evtClass, Properties prop, int source, int level,
+ String msg, Object params[], boolean multiline) {
+ ILogEventFactory f = (ILogEventFactory) mFactories.get(
+ Integer.toString(evtClass));
+
+ if (f == null)
+ return null;
+ return f.create(evtClass, prop, source, level, multiline, msg, params);
+ }
+
+ /**
+ * Notifies logger to reuse the event. This framework
+ * opens up possibility to reuse event.
+ * @param event a log event
+ */
+ public void release(ILogEvent event) {
+ // do nothing for now.
+ }
+
+}
diff --git a/pki/base/common/src/com/netscape/cmscore/logging/SignedAuditEventFactory.java b/pki/base/common/src/com/netscape/cmscore/logging/SignedAuditEventFactory.java
new file mode 100644
index 000000000..5faa0baba
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/logging/SignedAuditEventFactory.java
@@ -0,0 +1,124 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cmscore.logging;
+
+
+import java.util.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+import com.netscape.cmscore.util.Debug;
+
+
+/**
+ * A log event object for handling system messages
+ * <P>
+ *
+ * @author mikep
+ * @author mzhao
+ * @author cfu
+ * @version $Revision$, $Date$
+ */
+public class SignedAuditEventFactory implements ILogEventFactory {
+
+ /**
+ * List of supported properties.
+ */
+ public static final String PROP_BUNDLE = "bundleName";
+
+ /**
+ * Constructs a system event factory.
+ */
+ public SignedAuditEventFactory() {
+ }
+
+ /**
+ * Creates an log event.
+ *
+ * @param evtClass the event type
+ * @param prop the resource bundle
+ * @param source the subsystem ID who creates the log event
+ * @param level the severity of the log event
+ * @param multiline the log message has more than one line or not
+ * @param msg the detail message of the log
+ * @param params the parameters in the detail log message
+
+ */
+ public ILogEvent create(int evtClass, Properties prop, int source,
+ int level, boolean multiline, String msg, Object params[]) {
+ if (evtClass != ILogger.EV_SIGNED_AUDIT)
+ return null;
+
+ String message = null;
+ // assume msg format <type=...>:message
+ String typeMessage = msg.trim();
+ String eventType = null;
+ int typeBegin = typeMessage.indexOf("<type=");
+
+ if (typeBegin != -1) {
+ // type is specified
+ int colon = typeMessage.indexOf(">:");
+
+ eventType = typeMessage.substring(typeBegin + 6, colon);
+ message = typeMessage.substring(colon + 2);
+ Debug.trace("SignedAuditEventFactory: create() message=" + message + "\n");
+
+ } else {
+ // no type specified
+ message = msg;
+ }
+
+ SignedAuditEvent event = new SignedAuditEvent(message.trim(), params);
+
+ if (eventType != null)
+ event.setEventType(eventType.trim());
+
+ event.setLevel(level);
+ event.setSource(source);
+ event.setMultiline(multiline);
+ setProperties(prop, event);
+
+ return event;
+ }
+
+ /**
+ * Set the resource bundle of the log event.
+ *
+ * @param prop the properties
+ * @param event the log event
+ */
+ protected void setProperties(Properties prop, IBundleLogEvent event) {
+ if (prop == null) {
+ event.setBundleName(null);
+ } else {
+ String bundleName = (String) prop.get(PROP_BUNDLE);
+
+ if (bundleName != null) {
+ event.setBundleName(bundleName);
+ }
+ }
+ }
+
+ /**
+ * Releases an log event.
+ *
+ * @param e the log event
+ */
+ public void release(ILogEvent e) {
+ // do nothing
+ }
+}
diff --git a/pki/base/common/src/com/netscape/cmscore/logging/SignedAuditLogger.java b/pki/base/common/src/com/netscape/cmscore/logging/SignedAuditLogger.java
new file mode 100644
index 000000000..0bb99fb5b
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/logging/SignedAuditLogger.java
@@ -0,0 +1,47 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cmscore.logging;
+
+
+import java.io.*;
+import java.util.*;
+import com.netscape.certsrv.logging.*;
+
+import com.netscape.cmscore.util.*;
+
+
+/**
+ * A class represents certificate server logger
+ * implementation.
+ * <P>
+ *
+ * @author thomask
+ * @author mzhao
+ * @version $Revision$, $Date$
+ */
+public class SignedAuditLogger extends Logger {
+
+ /**
+ * Constructs a generic logger, and registers a list
+ * of resident event factories.
+ */
+ public SignedAuditLogger() {
+ super();
+ register(EV_SIGNED_AUDIT, new SignedAuditEventFactory());
+ }
+}
diff --git a/pki/base/common/src/com/netscape/cmscore/logging/SystemEventFactory.java b/pki/base/common/src/com/netscape/cmscore/logging/SystemEventFactory.java
new file mode 100644
index 000000000..4e5131311
--- /dev/null
+++ b/pki/base/common/src/com/netscape/cmscore/logging/SystemEventFactory.java
@@ -0,0 +1,98 @@
+// --- BEGIN COPYRIGHT BLOCK ---
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; version 2 of the License.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// (C) 2007 Red Hat, Inc.
+// All rights reserved.
+// --- END COPYRIGHT BLOCK ---
+package com.netscape.cmscore.logging;
+
+
+import java.util.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * A log event object for handling system messages
+ * <P>
+ *
+ * @author mikep
+ * @author mzhao
+ * @version $Revision$, $Date$
+ */
+public class SystemEventFactory implements ILogEventFactory {
+
+ /**
+ * List of supported properties.
+ */
+ public static final String PROP_BUNDLE = "bundleName";
+
+ /**
+ * Constructs a system event factory.
+ */
+ public SystemEventFactory() {
+ }
+
+ /**
+ * Creates an log event.
+ *
+ * @param evtClass the event type
+ * @param prop the resource bundle
+ * @param source the subsystem ID who creates the log event
+ * @param level the severity of the log event
+ * @param multiline the log message has more than one line or not
+ * @param msg the detail message of the log
+ * @param params the parameters in the detail log message
+
+ */
+ public ILogEvent create(int evtClass, Properties prop, int source,
+ int level, boolean multiline, String msg, Object params[]) {
+ if (evtClass != ILogger.EV_SYSTEM)
+ return null;
+ SystemEvent event = new SystemEvent(msg, params);
+
+ event.setLevel(level);
+ event.setSource(source);
+ event.setMultiline(multiline);
+ setProperties(prop, event);
+ return event;
+ }
+
+ /**
+ * Set the resource bundle of the log event.
+ *
+ * @param prop the properties
+ * @param event the log event
+ */
+ protected void setProperties(Properties prop, IBundleLogEvent event) {
+ if (prop == null) {
+ event.setBundleName(null);
+ } else {
+ String bundleName = (String) prop.get(PROP_BUNDLE);
+
+ if (bundleName != null) {
+ event.setBundleName(bundleName);
+ }
+ }
+ }
+
+ /**
+ * Releases an log event.
+ *
+ * @param e the log event
+ */
+ public void release(ILogEvent e) {
+ // do nothing
+ }
+}