summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/certsrv/logging
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/common/src/com/netscape/certsrv/logging')
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/AuditEvent.java331
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/AuditFormat.java112
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ConsoleError.java42
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ConsoleLog.java121
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ELogException.java148
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ELogNotFound.java35
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ELogPluginNotFound.java36
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/IBundleLogEvent.java41
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ILogEvent.java106
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ILogEventFactory.java55
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ILogEventListener.java125
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ILogQueue.java74
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ILogSubsystem.java105
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/ILogger.java496
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/LogPlugin.java38
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/LogResources.java59
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java334
-rw-r--r--pki/base/common/src/com/netscape/certsrv/logging/SystemEvent.java330
18 files changed, 2588 insertions, 0 deletions
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/AuditEvent.java b/pki/base/common/src/com/netscape/certsrv/logging/AuditEvent.java
new file mode 100644
index 000000000..8fa1249f6
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/AuditEvent.java
@@ -0,0 +1,331 @@
+// --- 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.certsrv.logging;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * The log event object that carries message detail of a log event
+ * that goes into the Transaction log. Note that the name of this
+ * class "AuditEvent" is legacy and has nothing to do with the signed
+ * audit log events, whcih are represented by SignedAuditEvent.
+ *
+ * @version $Revision$, $Date$
+ * @see java.text.MessageFormat
+ * @see com.netscape.certsrv.logging.LogResources
+ */
+public class AuditEvent implements IBundleLogEvent {
+
+ protected Object mParams[] = null;
+
+ private String mEventType = null;
+ private String mMessage = null;
+ private int mLevel = -1;
+ private int mNTEventType = -1;
+ private int mSource = -1;
+ private boolean mMultiline = false;
+ private long mTimeStamp = System.currentTimeMillis();
+
+ /**
+ * The bundle name for this event.
+ */
+ private String mBundleName = LogResources.class.getName();
+ private static final String INVALID_LOG_LEVEL="log level: {0} is invalid, should be 0-6";
+
+ /**
+ * Constructs a message event
+ * <P>
+ *
+ * @param msgFormat the message string
+ */
+ public AuditEvent(String msgFormat) {
+ mMessage = msgFormat;
+ mParams = null;
+ }
+
+ /**
+ * Constructs a message with a parameter. For example,
+ * <PRE>
+ * new AuditEvent("failed to load {0}", fileName);
+ * </PRE>
+ * <P>
+ *
+ * @param msgFormat details in message string format
+ * @param param message string parameter
+ */
+ public AuditEvent(String msgFormat, String param) {
+ this(msgFormat);
+ mParams = new String[1];
+ mParams[0] = param;
+ }
+
+ /**
+ * Constructs a message from an exception. It can be used to carry
+ * a system exception that may contain information about
+ * the context. For example,
+ * <PRE>
+ * try {
+ * ...
+ * } catch (IOExeption e) {
+ * logHandler.log(new AuditEvent("Encountered System Error {0}", e);
+ * }
+ * </PRE>
+ * <P>
+ *
+ * @param msgFormat exception details in message string format
+ * @param exception system exception
+ */
+ public AuditEvent(String msgFormat, Exception exception) {
+ this(msgFormat);
+ mParams = new Exception[1];
+ mParams[0] = exception;
+ }
+
+ /**
+ * Constructs a message from a base exception. This will use the msgFormat
+ * from the exception itself.
+ * <PRE>
+ * try {
+ * ...
+ * } catch (Exception e) {
+ * logHandler.log(new AuditEvent(e));
+ * }
+ * </PRE>
+ * <P>
+ *
+ * @param e CMS exception
+ */
+ public AuditEvent(Exception e) {
+ this(e.getMessage());
+ if (e instanceof EBaseException) {
+ mParams = ((EBaseException) e).getParameters();
+ } else {
+ mParams = new Exception[1];
+ mParams[0] = e;
+ }
+ }
+
+ /**
+ * Constructs a message event with a list of parameters
+ * that will be substituted into the message format.
+ * <P>
+ *
+ * @param msgFormat message string format
+ * @param params list of message format parameters
+ */
+ public AuditEvent(String msgFormat, Object params[]) {
+ this(msgFormat);
+ mParams = params;
+ }
+
+ /**
+ * Returns the current message format string.
+ * <P>
+ *
+ * @return details message
+ */
+ public String getMessage() {
+ return mMessage;
+ }
+
+ /**
+ * Returns a list of parameters.
+ * <P>
+ *
+ * @return list of message format parameters
+ */
+ public Object[] getParameters() {
+ return mParams;
+ }
+
+ /**
+ * Returns localized message string. This method should
+ * only be called if a localized string is necessary.
+ * <P>
+ *
+ * @return details message
+ */
+ public String toContent() {
+ return toContent(Locale.getDefault());
+ }
+
+ /**
+ * Returns the string based on the given locale.
+ * <P>
+ *
+ * @param locale locale
+ * @return details message
+ */
+ public String toContent(Locale locale) {
+ return MessageFormatter.getLocalizedString(locale, getBundleName(),
+ getMessage(),
+ getParameters());
+ }
+
+ /**
+ * Gets the resource bundle name for this class instance. This should
+ * be overridden by subclasses who have their own resource bundles.
+ * @param bundle String that represents the resource bundle name to be set
+ */
+ public void setBundleName(String bundle) {
+ mBundleName = bundle;
+ }
+
+ /**
+ * Retrieves bundle name.
+ * @return a String that represents the resource bundle name
+ */
+ protected String getBundleName() {
+ return mBundleName;
+ }
+
+ /**
+ * Retrieves log source.
+ * @return an integer that indicates the component source
+ * where this message event was triggered
+ */
+ public int getSource() {
+ return mSource;
+ }
+
+ /**
+ * Sets log source.
+ * @param source an integer that represents the component source
+ * where this message event was triggered
+ */
+ public void setSource(int source) {
+ mSource = source;
+ }
+
+
+ /**
+ * Retrieves log level.
+ * The log level of an event represents its relative importance
+ * or severity within CMS.
+ * @return Integer log level value.
+ */
+ public int getLevel() {
+ return mLevel;
+ }
+
+ /**
+ * Retrieves NT specific log event type.
+ * @return Integer NTEventType value.
+ */
+ public int getNTEventType() {
+ return mNTEventType;
+ }
+
+ /**
+ * Sets log level, NT log event type.
+ * For certain log levels the NT log event type gets
+ * set as well.
+ * @param level Integer log level value.
+ */
+ public void setLevel(int level) {
+ mLevel = level;
+ switch (level) {
+ case ILogger.LL_DEBUG:
+ case ILogger.LL_INFO:
+ mNTEventType = ILogger.NT_INFO;
+ break;
+
+ case ILogger.LL_WARN:
+ mNTEventType = ILogger.NT_WARN;
+ break;
+
+ case ILogger.LL_FAILURE:
+ case ILogger.LL_MISCONF:
+ case ILogger.LL_CATASTRPHE:
+ case ILogger.LL_SECURITY:
+ mNTEventType = ILogger.NT_ERROR;
+ break;
+
+ default:
+ ConsoleError.send(new SystemEvent(INVALID_LOG_LEVEL,
+ Integer.toString(level)));
+ break;
+ }
+ }
+
+ /**
+ * Retrieves log multiline attribute.
+ * @return Boolean whether or not this event is multiline.
+ * A multiline message simply consists of more than one line.
+ */
+ public boolean getMultiline() {
+ return mMultiline;
+ }
+
+ /**
+ * Sets log multiline attribute. A multiline message consists of
+ * more than one line.
+ * @param multiline Boolean multiline value.
+ */
+ public void setMultiline(boolean multiline) {
+ mMultiline = multiline;
+ }
+
+ /**
+ * Retrieves event time stamp.
+ * @return Long integer of the time the event was created.
+ */
+ public long getTimeStamp() {
+ return mTimeStamp;
+ }
+
+
+ /**
+ * Retrieves log event type. Each type of event
+ * has an associated String type value.
+ * @return String containing the type of event.
+ */
+ public String getEventType() {
+ return mEventType;
+ }
+
+
+ /**
+ * Sets log event type. Each type of event
+ * has an associated String type value.
+ * @param eventType String containing the type of event.
+ */
+ public void setEventType(String eventType) {
+ mEventType = eventType;
+ }
+
+ /**
+ * Return string representation of log message.
+ * @return String containing log message.
+ */
+ public String toString() {
+ if (getBundleName() == null) {
+ MessageFormat detailMessage = new MessageFormat(mMessage);
+
+ return detailMessage.format(mParams);
+ //return getMessage();
+ } else
+ return toContent();
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/AuditFormat.java b/pki/base/common/src/com/netscape/certsrv/logging/AuditFormat.java
new file mode 100644
index 000000000..8d870ad90
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/AuditFormat.java
@@ -0,0 +1,112 @@
+// --- 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.certsrv.logging;
+
+
+/**
+ * Define audit log message format. Note that the name of this
+ * class "AuditFormat" is legacy and has nothing to do with the signed
+ * audit log events format
+ *
+ * @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 =
+ "Enrollment request reqID {0} {1} authenticated by {2} is {3}. DN requested: {4} {5}";
+ public static final String RENEWALFORMAT =
+ "Renewal request reqID {0} {1} authenticated by {2} is {3}. DN requested: {4} old serial number: 0x{5} {6}";
+ public static final String REVOCATIONFORMAT =
+ "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 =
+ "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 =
+ "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}";
+
+ // LDAP publishing
+ public static final String LDAP_PUBLISHED_FORMAT =
+ "{0} successfully published serial number: 0x{1} with DN: {2}";
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ConsoleError.java b/pki/base/common/src/com/netscape/certsrv/logging/ConsoleError.java
new file mode 100644
index 000000000..750e35807
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ConsoleError.java
@@ -0,0 +1,42 @@
+// --- 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.certsrv.logging;
+
+
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * A static class to log error messages to the Console
+ *
+ * @version $Revision$, $Date$
+ */
+public class ConsoleError {
+ private static final ConsoleLog console = new ConsoleLog();
+
+ /**
+ * Send the given event to the Console.
+ *
+ * @param ev log event to be sent to the console
+ */
+ public static void send(ILogEvent ev) {
+ console.log(ev);
+ console.flush();
+ }
+
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ConsoleLog.java b/pki/base/common/src/com/netscape/certsrv/logging/ConsoleLog.java
new file mode 100644
index 000000000..c45b5d129
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ConsoleLog.java
@@ -0,0 +1,121 @@
+// --- 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.certsrv.logging;
+
+
+import javax.servlet.*;
+import javax.servlet.http.*;
+import java.io.*;
+import java.util.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.common.*;
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * A log event listener which sends all log events to the system console/tty
+ *
+ * @version $Revision$, $Date$
+ */
+public class ConsoleLog implements ILogEventListener {
+
+ /**
+ * Log the given event. Usually called from a log manager.
+ *
+ * @param ev log event
+ */
+ public void log(ILogEvent ev) {
+ System.err.println(Thread.currentThread().getName() + ": " + ev);
+ }
+
+ /**
+ * Flush the system output stream.
+ *
+ */
+ public void flush() {
+ System.err.flush();
+ }
+
+ /**
+ * All operations need to be cleaned up for shutdown are done here
+ */
+ public void shutdown() {
+ }
+
+ /**
+ * get the configuration store that is associated with this
+ * log listener
+ * @return the configuration store that is associated with this
+ * log listener
+ */
+ public IConfigStore getConfigStore() {
+ return null;
+ }
+
+ public void init(ISubsystem owner, IConfigStore config)
+ throws EBaseException {
+ }
+
+ public void startup() throws EBaseException {
+ }
+
+ /**
+ * Retrieve last "maxLine" number of system log with log lever >"level"
+ * and from source "source". If the parameter is omitted. All entries
+ * are sent back.
+ * @param req a Hashtable containing the required information such as
+ * log entry, log level, log source, and log name
+ * @return the content of the log that match the criteria in req
+ * @exception servletException
+ * @exception IOException
+ * @exception EBaseException
+ */
+ public synchronized NameValuePairs retrieveLogContent(Hashtable req) throws ServletException,
+ IOException, EBaseException {
+ return null;
+ }
+
+ /**
+ * Retrieve log file list.
+ * <br> unimplemented
+ */
+ public synchronized NameValuePairs retrieveLogList(Hashtable req) throws ServletException,
+ IOException, EBaseException {
+ return null;
+ }
+
+ public String getImplName() {
+ return "ConsoleLog";
+ }
+
+ public String getDescription() {
+ return "ConsoleLog";
+ }
+
+ public Vector getDefaultParams() {
+ Vector v = new Vector();
+
+ return v;
+ }
+
+ public Vector getInstanceParams() {
+ Vector v = new Vector();
+
+ return v;
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ELogException.java b/pki/base/common/src/com/netscape/certsrv/logging/ELogException.java
new file mode 100644
index 000000000..d15033657
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ELogException.java
@@ -0,0 +1,148 @@
+// --- 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.certsrv.logging;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import com.netscape.certsrv.base.EBaseException;
+import com.netscape.certsrv.base.MessageFormatter;
+
+
+/**
+ * This class implements a Log exception. LogExceptions
+ * should be caught by LogSubsystem managers.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ * @see java.text.MessageFormat
+ */
+public class ELogException extends EBaseException {
+
+ /**
+ * Resource bundle class name.
+ */
+ private static final String LOG_RESOURCES = LogResources.class.getName();
+
+ /**
+ * Constructs a log exception.
+ * <P>
+ *
+ * @param msgFormat Exception details.
+ */
+ public ELogException(String msgFormat) {
+ super(msgFormat);
+ mParams = null;
+ }
+
+ /**
+ * Constructs a log exception with a parameter. For example,
+ * <PRE>
+ * new ELogException("failed to load {0}", fileName);
+ * </PRE>
+ * <P>
+ *
+ * @param msgFormat Exception details in message string format.
+ * @param param Message string parameter.
+ */
+ public ELogException(String msgFormat, String param) {
+ super(msgFormat);
+ mParams = new String[1];
+ mParams[0] = param;
+ }
+
+ /**
+ * Constructs a log exception. It can be used to carry
+ * a system exception that may contain information about
+ * the context. For example,
+ * <PRE>
+ * try {
+ * ...
+ * } catch (IOExeption e) {
+ * throw new ELogException("Encountered System Error {0}", e);
+ * }
+ * </PRE>
+ * <P>
+ *
+ * @param msgFormat Exception details in message string format.
+ * @param param System exception.
+ */
+ public ELogException(String msgFormat, Exception param) {
+ super(msgFormat);
+ mParams = new Exception[1];
+ mParams[0] = param;
+ }
+
+ /**
+ * Constructs a log exception with a list of parameters
+ * that will be substituted into the message format.
+ * <P>
+ *
+ * @param msgFormat Exception details in message string format.
+ * @param params List of message format parameters.
+ */
+ public ELogException(String msgFormat, Object params[]) {
+ super(msgFormat);
+ mParams = params;
+ }
+
+ /**
+ * Returns a list of parameters.
+ * <P>
+ *
+ * @return list of message format parameters.
+ */
+ public Object[] getParameters() {
+ return mParams;
+ }
+
+ /**
+ * Returns localized exception string. This method should
+ * only be called if a localized string is necessary.
+ * <P>
+ *
+ * @return Details message.
+ */
+ public String toString() {
+ return toString(Locale.getDefault());
+ }
+
+ /**
+ * Returns the string based on the given locale.
+ * <P>
+ *
+ * @param locale Locale.
+ * @return Details message.
+ */
+ public String toString(Locale locale) {
+ return MessageFormatter.getLocalizedString(locale, getBundleName(),
+ super.getMessage(), mParams);
+ }
+
+ /**
+ * Retrieves resource bundle name.
+ * Subclasses should override this as necessary
+ * @return String containing name of resource bundle.
+ */
+
+ protected String getBundleName() {
+ return LOG_RESOURCES;
+ }
+
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ELogNotFound.java b/pki/base/common/src/com/netscape/certsrv/logging/ELogNotFound.java
new file mode 100644
index 000000000..49d55f360
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ELogNotFound.java
@@ -0,0 +1,35 @@
+// --- 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.certsrv.logging;
+
+
+/**
+ * Exception for log not found.
+ *
+ * @version $Revision$, $Date$
+ */
+public class ELogNotFound extends ELogException {
+
+ /**
+ * Constructs a exception for a missing required log.
+ * @param errorString Detailed error message.
+ */
+ public ELogNotFound(String errorString) {
+ super(errorString);
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ELogPluginNotFound.java b/pki/base/common/src/com/netscape/certsrv/logging/ELogPluginNotFound.java
new file mode 100644
index 000000000..1775c8644
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ELogPluginNotFound.java
@@ -0,0 +1,36 @@
+// --- 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.certsrv.logging;
+
+
+/**
+ * Exception for log plugin not found.
+ *
+ * @version $Revision$, $Date$
+ */
+public class ELogPluginNotFound extends ELogException {
+
+ /**
+ * Constructs a exception for a missing log plugin.
+ * @param errorString Detailed error message.
+ */
+ public ELogPluginNotFound(String errorString) {
+ super(errorString);
+ }
+}
+
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/IBundleLogEvent.java b/pki/base/common/src/com/netscape/certsrv/logging/IBundleLogEvent.java
new file mode 100644
index 000000000..fc9540e55
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/IBundleLogEvent.java
@@ -0,0 +1,41 @@
+// --- 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.certsrv.logging;
+
+
+import java.io.Serializable;
+import java.util.Locale;
+
+
+/**
+ * An interface which all loggable events must implement.
+ * See ILogEvent class.
+ * This class maintains a resource bundle name for given
+ * event type.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface IBundleLogEvent extends ILogEvent {
+
+ /**
+ * Sets the name of the resource bundle to be associated
+ * with this event type.
+ * @param bundle name of resource bundle.
+ */
+ public void setBundleName(String bundle);
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ILogEvent.java b/pki/base/common/src/com/netscape/certsrv/logging/ILogEvent.java
new file mode 100644
index 000000000..d0caca71d
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ILogEvent.java
@@ -0,0 +1,106 @@
+// --- 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.certsrv.logging;
+
+
+import java.io.Serializable;
+import java.util.Locale;
+
+
+/**
+ * An interface which all loggable events must implement. CMS comes
+ * with a limited set of ILogEvent types to implement: audit, system, and
+ * signed audit. This is the base class of all the subsequent implemented types.
+ * A log event represents a certain kind of log message designed for a specific purpose.
+ * For instance, an audit type event represents messages having to do with auditable CMS
+ * actions. The resulting message will ultimately appear into a specific log file.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ILogEvent extends Serializable {
+
+ /**
+ * Retrieves event time stamp.
+ * @return Long integer of the time the event was created.
+ */
+ public long getTimeStamp();
+
+ /**
+ * Retrieves log source.
+ * This is an id of the subsystem responsible
+ * for creating the log event.
+ * @return Integer source id.
+ */
+ public int getSource();
+
+
+ /**
+ * Retrieves log level.
+ * The log level of an event represents its relative importance
+ * or severity within CMS.
+ * @return Integer log level value.
+ */
+ public int getLevel();
+
+ /**
+ * Retrieves NT specific log event type.
+ * @return Integer NTEventType value.
+ */
+ public int getNTEventType();
+
+ /**
+ * Retrieves multiline attribute.
+ * Does this message consiste of more than one line.
+ * @return Boolean of multiline status.
+ */
+ public boolean getMultiline();
+
+
+ /**
+ * Retrieves log event type. Each type of event
+ * has an associated String type value.
+ * @return String containing the type of event.
+ */
+ public String getEventType();
+
+ /**
+ * Sets log event type. Each type of event
+ * has an associated String type value.
+ * @param eventType String containing the type of event.
+ */
+ public void setEventType(String eventType);
+
+
+ /**
+ * Returns localized message string. This method should
+ * only be called if a localized string is necessary.
+ * <P>
+ *
+ * @return Details message.
+ */
+ public String toContent();
+
+ /**
+ * Returns the string based on the given locale.
+ * <P>
+ *
+ * @param locale locale
+ * @return Details message.
+ */
+ public String toContent(Locale locale);
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ILogEventFactory.java b/pki/base/common/src/com/netscape/certsrv/logging/ILogEventFactory.java
new file mode 100644
index 000000000..b0fd0ce18
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ILogEventFactory.java
@@ -0,0 +1,55 @@
+// --- 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.certsrv.logging;
+
+
+import java.io.*;
+import java.util.*;
+
+
+/**
+ * An interface represents a log event factory. This
+ * factory will be responsible for creating and returning ILogEvent objects
+ * on demand.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ILogEventFactory {
+
+ /**
+ * Creates an event of a particular event type/class.
+ *
+ * @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.
+ * @return The created ILogEvent object.
+ */
+ public ILogEvent create(int evtClass, Properties prop, int source,
+ int level, boolean multiline, String msg, Object params[]);
+
+ /**
+ * Releases previously created event.
+ *
+ * @param event The log event.
+ */
+ public void release(ILogEvent event);
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ILogEventListener.java b/pki/base/common/src/com/netscape/certsrv/logging/ILogEventListener.java
new file mode 100644
index 000000000..e970d4182
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ILogEventListener.java
@@ -0,0 +1,125 @@
+// --- 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.certsrv.logging;
+
+
+import com.netscape.certsrv.base.*;
+import java.util.*;
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import com.netscape.certsrv.common.*;
+
+
+/**
+ * An interface reprensents a log event listener.
+ * A ILogEventListener is registered to a specific
+ * ILogQueue to be notified of created ILogEvents.
+ * the log queue will notify all its registered listeners
+ * of the logged event. The listener will then proceed to
+ * process the event accordingly which will result in a log
+ * message existing in some file.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ILogEventListener extends EventListener {
+
+ /**
+ * The event notification method: Logs event.
+ *
+ * @param event The log event to be processed.
+ */
+ public void log(ILogEvent event) throws ELogException;
+
+ /**
+ * Flushes the log buffers (if any). Will result in the messages
+ * being actually written to their destination.
+ */
+ public void flush();
+
+ /**
+ * Closes the log file and destroys any associated threads.
+ */
+ public void shutdown();
+
+ /**
+ * Get the configuration store for the log event listener.
+ * @return The configuration store of this log event listener.
+ */
+ public IConfigStore getConfigStore();
+
+ /**
+ * Initialize this log listener
+ * @param owner The subsystem.
+ * @param config Configuration store for this log listener.
+ * @exception Any initialization error.
+ */
+ public void init(ISubsystem owner, IConfigStore config)
+ throws EBaseException;
+
+ /**
+ * Startup the instance.
+ */
+ public void startup()
+ throws EBaseException;
+
+ /**
+ * Retrieve last "maxLine" number of system logs with log level >"level"
+ * and from source "source". If the parameter is omitted. All entries
+ * are sent back.
+ * @param req a Hashtable containing the required information such as
+ * log entry, log level, log source, and log name.
+ * @return NameValue pair list of log messages.
+ * @exception ServletException For Servelet errros.
+ * @exception IOException For input/output problems.
+ * @exception EBaseException For other problems.
+ */
+ public NameValuePairs retrieveLogContent(Hashtable req) throws ServletException,
+ IOException, EBaseException;
+
+ /**
+ * Retrieve list of log files.
+ *
+ */
+ public NameValuePairs retrieveLogList(Hashtable req) throws ServletException,
+ IOException, EBaseException;
+
+ /**
+ * Returns implementation name.
+ * @return String name of event listener implementation.
+ */
+ public String getImplName();
+
+ /**
+ * Returns the description of this log event listener.
+ * @return String with listener description.
+ */
+ public String getDescription();
+
+ /**
+ * Return list of default config parameters for this log event listener.
+ * @return Vector of default parameters.
+ */
+ public Vector getDefaultParams();
+
+ /**
+ * Return list of instance config parameters for this log event listener.
+ * @return Vector of instance parameters.
+ */
+ public Vector getInstanceParams();
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ILogQueue.java b/pki/base/common/src/com/netscape/certsrv/logging/ILogQueue.java
new file mode 100644
index 000000000..65d4136c7
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ILogQueue.java
@@ -0,0 +1,74 @@
+// --- 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.certsrv.logging;
+
+
+import java.util.*;
+
+
+/**
+ * An interface represents a log queue. A log queue
+ * is a queue of pending log events to be dispatched
+ * to a set of registered ILogEventListeners.
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ILogQueue {
+
+ /**
+ * Dispatch the log event to all registered log event listeners.
+ *
+ * @param evt the log event
+ */
+ public void log(ILogEvent evt);
+
+ /**
+ * Flushes log queue, flushes all registered listeners.
+ * Messages should be written to their destination.
+ */
+ public void flush();
+
+ /**
+ * Registers an event listener.
+ *
+ * @param listener The log event listener to be registered
+ * to this queue.
+ */
+ public void addLogEventListener(ILogEventListener listener);
+
+ /**
+ * Removes an event listener.
+ *
+ * @param listener The log event listener to be removed from this queue.
+ */
+ public void removeLogEventListener(ILogEventListener listener);
+
+ /**
+ * Initializes the log queue.
+ * <P>
+ *
+ */
+ public void init();
+
+ /**
+ * Stops this log queue:shuts down all registered log event listeners.
+ * <P>
+ */
+ public void shutdown();
+
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ILogSubsystem.java b/pki/base/common/src/com/netscape/certsrv/logging/ILogSubsystem.java
new file mode 100644
index 000000000..82bde43f4
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ILogSubsystem.java
@@ -0,0 +1,105 @@
+// --- 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.certsrv.logging;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.MessageFormat;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * An interface that represents a logging component. The logging
+ * component is a framework that handles different types of log types,
+ * each represented by an ILogEventListener, and each implements a log
+ * plugin. CMS comes
+ * with three standard log types: "signedAudit", "system", and
+ * "transaction". Each log plugin can be instantiated into log
+ * instances. Each log instance can be individually configured and is
+ * associated with its own configuration entries in the configuration file.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ILogSubsystem extends ISubsystem {
+
+ /**
+ * The ID of this component
+ */
+ public static final String ID = "log";
+
+ /**
+ * Retrieve plugin name (implementation name) of the log event
+ * listener. If no plug name found, an empty string is returned
+ * @param log the log event listener
+ * @return the log event listener's plugin name
+ */
+ public String getLogPluginName(ILogEventListener log);
+
+ /**
+ * Retrieve the log event listener by instance name
+ * @param insName the log instance name in String
+ * @return the log instance in ILogEventListener
+ */
+ public ILogEventListener getLogInstance(String insName);
+
+ /**
+ * get the list of log plugins that are available
+ * @return log plugins in a Hashtable. Each entry in the
+ * Hashtable contains the name/value pair of pluginName/LogPlugin
+ * @see LogPlugin
+ */
+ public Hashtable getLogPlugins();
+
+ /**
+ * get the list of log instances that are available
+ * @return log instances in a Hashtable. Each entry in the
+ * Hashtable contains the name/value pair of instName/ILogEventListener
+ * @see LogPlugin
+ */
+ public Hashtable getLogInsts();
+
+ /**
+ * Get the default configuration parameter names associated with a
+ * plugin. It is used by
+ * administration servlet to handle log configuration when a new
+ * log instance is added.
+ * @param implName The implementation name for which the
+ * configuration parameters are to be configured
+ * @return a Vector of default configuration paramter names
+ * associated with this log plugin
+ * @exception ELogException when instantiation of the plugin
+ * implementation fails.
+ */
+ public Vector getLogDefaultParams(String implName) throws
+ ELogException;
+
+ /**
+ * Get the default configuration parameter names associated with a
+ * log instance. It is used by administration servlet to handle
+ * log instance configuration.
+ * @param insName The instance name for which the configuration
+ * parameters are to be configured
+ * @return a Vector of default configuration paramter names
+ * associated with this log instance.
+ */
+ public Vector getLogInstanceParams(String insName)
+ throws ELogException;
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/ILogger.java b/pki/base/common/src/com/netscape/certsrv/logging/ILogger.java
new file mode 100644
index 000000000..b4a7070a7
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/ILogger.java
@@ -0,0 +1,496 @@
+// --- 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.certsrv.logging;
+
+
+import java.util.*;
+import com.netscape.certsrv.common.*;
+
+
+/**
+ * An interface represents a logger for certificate server. This object is used to
+ * issue log messages for the various types of logging event types. A log message results
+ * in a ILogEvent being created. This event is then placed on a ILogQueue to be ultimately
+ * written to the destination log file. This object also maintains a collection of ILogFactory objects
+ * which are used to create the supported types of ILogEvents. CMS comes out of the box with three event
+ * types: "signedAudit", "system", and "audit".
+ *
+ * @version $Revision$, $Date$
+ */
+public interface ILogger {
+
+ //List of defined log classes.
+ /**
+ * log class: audit event.
+ */
+ public static final int EV_AUDIT = 0;
+ public static final String PROP_AUDIT = "transaction";
+
+ /**
+ * log class: system event.
+ * System event with log level >= LL_FAILURE will also be logged in error log
+ */
+ public static final int EV_SYSTEM = 1;
+ public static final String PROP_SYSTEM = "system";
+
+ /**
+ * log class: SignedAudit event.
+ */
+ public static final int EV_SIGNED_AUDIT = 2;
+ public static final String PROP_SIGNED_AUDIT = "signedAudit";
+
+ //List of defined log sources.
+
+ /**
+ * log source: used by servlet to retrieve all logs
+ */
+ public static final int S_ALL = 0; //used by servlet only
+
+ /**
+ * log source: identify the log entry is from KRA
+ */
+ public static final int S_KRA = 1;
+
+ /**
+ * log source: identify the log entry is from RA
+ */
+ public static final int S_RA = 2;
+
+ /**
+ * log source: identify the log entry is from CA
+ */
+ public static final int S_CA = 3;
+
+ /**
+ * log source: identify the log entry is from http subsystem
+ */
+ public static final int S_HTTP = 4;
+
+ /**
+ * log source: identify the log entry is from database subsystem
+ */
+ public static final int S_DB = 5;
+
+ /**
+ * log source: identify the log entry is from authentication subsystem
+ */
+ public static final int S_AUTHENTICATION = 6;
+
+ /**
+ * log source: identify the log entry is from admin subsystem
+ */
+ public static final int S_ADMIN = 7;
+
+ /**
+ * log source: identify the log entry is from ldap subsystem
+ */
+ public static final int S_LDAP = 8;
+
+ /**
+ * log source: identify the log entry is from request queue subsystem
+ */
+ public static final int S_REQQUEUE = 9;
+
+ /**
+ * log source: identify the log entry is from acl subsystem
+ */
+ public static final int S_ACLS = 10;
+
+ /**
+ * log source: identify the log entry is from usergrp subsystem
+ */
+ public static final int S_USRGRP = 11;
+ public static final int S_OCSP = 12;
+
+ /**
+ * log source: identify the log entry is from authorization subsystem
+ */
+ public static final int S_AUTHORIZATION = 13;
+
+ /**
+ * log source: identify the log entry is from signed audit
+ */
+ public static final int S_SIGNED_AUDIT = 14;
+
+ /**
+ * log source: identify the log entry is from CrossCertPair subsystem
+ */
+ public static final int S_XCERT = 15;
+
+ /**
+ * log source: identify the log entry is from CrossCertPair subsystem
+ */
+
+ public static final int S_TKS = 16;
+
+ /**
+ * log source: identify the log entry is from other subsystem
+ * eg. policy, security, connector,registration
+ */
+ public static final int S_OTHER = 20;
+
+
+ // List of defined log levels.
+ /**
+ * log level: used by servlet to retrieve all level logs
+ */
+ public static final int LL_ALL = -1; //used by servlet only
+ public static final String LL_ALL_STRING = "All"; //used by servlet only
+
+ /**
+ * log level: indicate this log entry is debug info
+ */
+
+ /**
+ * Debug level is depreciated since CMS6.1. Please use
+ * CMS.debug() to output messages to debugging file.
+ */
+ public static final int LL_DEBUG = 0; // depreciated
+ public static final String LL_DEBUG_STRING = "Debug";
+
+ /**
+ * log level: indicate this log entry is for info note
+ */
+ public static final int LL_INFO = 1;
+ public static final String LL_INFO_STRING = "Information";
+
+ /**
+ * log level: indicate this log entry is warning info
+ */
+ public static final int LL_WARN = 2;
+ public static final String LL_WARN_STRING = "Warning";
+
+ /**
+ * log level: indicate this log entry is fail/error info
+ */
+ public static final int LL_FAILURE = 3;
+ public static final String LL_FAILURE_STRING = "Failure";
+
+ /**
+ * log level: indicate this log entry is about misconfiguration
+ */
+ public static final int LL_MISCONF = 4;
+ public static final String LL_MISCONF_STRING = "Misconfiguration";
+
+ /**
+ * log level: indicate this log entry is catastrphe info
+ */
+ public static final int LL_CATASTRPHE = 5;
+ public static final String LL_CATASTRPHE_STRING = "Catastrophe";
+
+ /**
+ * log level: indicate this log entry is security info
+ */
+ public static final int LL_SECURITY = 6;
+ public static final String LL_SECURITY_STRING = "Security";
+
+ /**
+ * "SubjectID" for system-initiated events logged
+ * in signed audit log messages
+ */
+ public static final String SYSTEM_UID = "$System$";
+
+ /**
+ * A constant string value used to denote a single "unknown" identity
+ * in signed audit log messages
+ */
+ public static final String UNIDENTIFIED = "$Unidentified$";
+
+ /**
+ * A constant string value used to denote a single "non-role" identity
+ * in signed audit log messages
+ */
+ public static final String NONROLEUSER = "$NonRoleUser$";
+
+ /**
+ * "Outcome" for events logged in signed audit log messages
+ */
+ public static final String SUCCESS = "Success";
+ public static final String FAILURE = "Failure";
+
+ /**
+ * A constant string value used to denote a "non-applicable"
+ * data value in signed audit log messages
+ */
+ public final static String SIGNED_AUDIT_NON_APPLICABLE = "N/A";
+
+ /**
+ * A constant string value used to denote an "empty", or "null",
+ * data value in signed audit log messages
+ */
+ public final static String SIGNED_AUDIT_EMPTY_VALUE = "<null>";
+
+ /**
+ * Constant string values associated with the type of certificate
+ * processing stored in the "InfoName" field in certain signed
+ * audit log messages
+ */
+ public final static String SIGNED_AUDIT_ACCEPTANCE = "certificate";
+ public final static String SIGNED_AUDIT_CANCELLATION = "cancelReason";
+ public final static String SIGNED_AUDIT_REJECTION = "rejectReason";
+
+ // List of all NT event type
+ /**
+ * NT event type: correspond to log level LL_DEBUG or LL_INFO
+ */
+ public static final int NT_INFO = 4;
+
+ /**
+ * NT event type: correspond to log level LL_WARNING
+ */
+ public static final int NT_WARN = 2;
+
+ /**
+ * NT event type: correspont to log level LL_FAILURE and above
+ */
+ public static final int NT_ERROR = 1;
+
+ // List of defined log multiline attribute.
+ /**
+ * indicate the log message has more than one line
+ */
+ public static final boolean L_MULTILINE = true;
+
+ /**
+ * indicate the log message has one line
+ */
+ public static final boolean L_SINGLELINE = false;
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param source The source of the log event.
+ * @param msg The detail message to be logged.
+ */
+ public void log(int evtClass, int source, String msg);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param props The resource bundle used for the detailed message.
+ * @param source The source of the log event.
+ * @param msg The detail message to be logged.
+ */
+ public void log(int evtClass, Properties props, int source, String msg);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param source The source of the log event.
+ * @param level The level of the log event.
+ * @param msg The detail message to be logged.
+ */
+ public void log(int evtClass, int source, int level, String msg);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @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 detail message to be logged.
+ */
+ public void log(int evtClass, Properties props, int source, int level, String msg);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param source The source of the log event.
+ * @param level The level of the log event.
+ * @param msg The 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param source The source of the log event.
+ * @param level The level of the log event.
+ * @param msg The 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[]);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param props The resource bundle used for the detailed message.
+ * @param source The source of the log event.
+ * @param msg The detail message to be logged.
+ * @param param The parameters in the detail message.
+ */
+ public void log(int evtClass, Properties props, int source, String msg, Object param);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @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 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param prop 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 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[]);
+
+ //multiline log
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param source The source of the log event.
+ * @param msg The 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param props The resource bundle used for the detailed message.
+ * @param source The source of the log event.
+ * @param msg The 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param source The source of the log event.
+ * @param level The level of the log event.
+ * @param msg The 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @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 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param source The source of the log event.
+ * @param level The level of the log event.
+ * @param msg The 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param props The resource bundle used for the detailed message.
+ * @param source TTTTsource of the log event.
+ * @param msg The 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @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 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);
+
+ /**
+ * Logs an event to the log queue.
+ *
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @param prop 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 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);
+
+ /*
+ * Generates an ILogEvent
+ * @param evtClass What kind of event it is: EV_AUDIT or EV_SYSTEM or EV_SIGNED_AUDIT.
+ * @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 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.
+ * @return ILogEvent, a log event.
+ */
+ public ILogEvent create(int evtClass, Properties prop, int source, int level,
+ String msg, Object params[], boolean multiline);
+
+ /**
+ * Register a log event factory. Which will create the desired ILogEvents.
+ */
+ public void register(int evtClass, ILogEventFactory f);
+
+ /**
+ * Retrieves the associated log queue. The log queue is where issued log events
+ * are collected for later processing.
+ */
+ public ILogQueue getLogQueue();
+
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/LogPlugin.java b/pki/base/common/src/com/netscape/certsrv/logging/LogPlugin.java
new file mode 100644
index 000000000..30ee30836
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/LogPlugin.java
@@ -0,0 +1,38 @@
+// --- 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.certsrv.logging;
+
+
+import java.util.*;
+import java.lang.*;
+
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * This class represents a registered logger plugin.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ */
+public class LogPlugin extends Plugin {
+ public LogPlugin (String id, String path) {
+ super(id, path);
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/LogResources.java b/pki/base/common/src/com/netscape/certsrv/logging/LogResources.java
new file mode 100644
index 000000000..942b570db
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/LogResources.java
@@ -0,0 +1,59 @@
+// --- 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.certsrv.logging;
+
+
+import java.util.*;
+import com.netscape.certsrv.base.*;
+
+
+/**
+ * This is the fallback resource bundle for all log events.
+ * <P>
+ *
+ * @version $Revision$, $Date$
+ * @see java.util.ListResourceBundle
+ */
+public class LogResources extends ListResourceBundle {
+ public static final String BASE_RESOURCES = BaseResources.class.getName();
+
+ /**
+ * Contructs a log resource bundle and sets it's parent to the base
+ * resource bundle.
+ *
+ * @see com.netscape.certsrv.base.BaseResources
+ */
+ public LogResources() {
+ super();
+ setParent(ResourceBundle.getBundle(BASE_RESOURCES));
+ }
+
+ /**
+ * Returns the content of this resource.
+ * @return Array of objects making up the contents of this resource.
+ */
+ public Object[][] getContents() {
+ return contents;
+ }
+
+ /*
+ * Contents.
+ */
+
+ static final Object[][] contents = {};
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java b/pki/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java
new file mode 100644
index 000000000..ea97fe3d6
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/SignedAuditEvent.java
@@ -0,0 +1,334 @@
+// --- 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.certsrv.logging;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * The log event object that carries message detail of a log event
+ * that goes into the Signed Audit Event log. This log has the
+ * property of being digitally signed for security considerations.
+ *
+ *
+ * @version $Revision$, $Date$
+ * @see java.text.MessageFormat
+ * @see com.netscape.certsrv.logging.LogResources
+ */
+public class SignedAuditEvent implements IBundleLogEvent {
+
+ protected Object mParams[] = null;
+
+ private String mEventType = null;
+ private String mMessage = null;
+ private int mLevel = -1;
+ private int mNTEventType = -1;
+ private int mSource = -1;
+ private boolean mMultiline = false;
+ private long mTimeStamp = System.currentTimeMillis();
+
+ private static final String INVALID_LOG_LEVEL="log level: {0} is invalid, should be 0-6";
+
+ /**
+ * The bundle name for this event.
+ * ....not anymore...keep for now and clean up later
+ */
+ private String mBundleName = LogResources.class.getName();
+
+ /**
+ * Constructs a SignedAuditEvent message event.
+ * <P>
+ *
+ * @param msgFormat The message string.
+ */
+ public SignedAuditEvent(String msgFormat) {
+ mMessage = msgFormat;
+ mParams = null;
+ }
+
+ /**
+ * Constructs a message with a parameter. For example,
+ * <PRE>
+ * new SignedAuditEvent("failed to load {0}", fileName);
+ * </PRE>
+ * <P>
+ *
+ * @param msgFormat Details in message string format.
+ * @param param Message string parameter.
+ */
+ public SignedAuditEvent(String msgFormat, String param) {
+ this(msgFormat);
+ mParams = new String[1];
+ mParams[0] = param;
+ }
+
+ /**
+ * Constructs a message from an exception. It can be used to carry
+ * a signed audit exception that may contain information about
+ * the context. For example,
+ * <PRE>
+ * try {
+ * ...
+ * } catch (IOExeption e) {
+ * logHandler.log(new SignedAuditEvent("Encountered Signed Audit Error {0}", e);
+ * }
+ * </PRE>
+ * <P>
+ *
+ * @param msgFormat Exception details in message string format.
+ * @param exception System exception.
+ */
+ public SignedAuditEvent(String msgFormat, Exception exception) {
+ this(msgFormat);
+ mParams = new Exception[1];
+ mParams[0] = exception;
+ }
+
+ /**
+ * Constructs a message from a base exception. This will use the msgFormat
+ * from the exception itself.
+ * <PRE>
+ * try {
+ * ...
+ * } catch (Exception e) {
+ * logHandler.log(new SignedAuditEvent(e));
+ * }
+ * </PRE>
+ * <P>
+ *
+ * @param e CMS exception.
+ */
+ public SignedAuditEvent(Exception e) {
+ this(e.getMessage());
+ if (e instanceof EBaseException) {
+ mParams = ((EBaseException) e).getParameters();
+ } else {
+ mParams = new Exception[1];
+ mParams[0] = e;
+ }
+ }
+
+ /**
+ * Constructs a message event with a list of parameters
+ * that will be substituted into the message format.
+ * <P>
+ *
+ * @param msgFormat Message string format.
+ * @param params List of message format parameters.
+ */
+ public SignedAuditEvent(String msgFormat, Object params[]) {
+ this(msgFormat);
+ mParams = params;
+ }
+
+ /**
+ * Returns the current message format string.
+ * <P>
+ *
+ * @return Details message.
+ */
+ public String getMessage() {
+ return mMessage;
+ }
+
+ /**
+ * Returns a list of parameters. These parameters can be
+ * used to assist in formatting the message.
+ * <P>
+ *
+ * @return List of message format parameters.
+ */
+ public Object[] getParameters() {
+ return mParams;
+ }
+
+ /**
+ * Returns localized message string. This method should
+ * only be called if a localized string is necessary.
+ * <P>
+ *
+ * @return Details message.
+ */
+ public String toContent() {
+ return toContent(Locale.getDefault());
+ }
+
+ /**
+ * Returns the string based on the given locale.
+ * <P>
+ *
+ * @param locale Locale.
+ * @return Details message.
+ */
+ public String toContent(Locale locale) {
+ return MessageFormatter.getLocalizedString(locale, getBundleName(),
+ getMessage(),
+ getParameters());
+ }
+
+ /**
+ * Sets the resource bundle name for this class instance. This should
+ * be overridden by subclasses who have their own resource bundles.
+ * @param bundle String with name of resource bundle.
+ */
+ public void setBundleName(String bundle) {
+ mBundleName = bundle;
+ }
+
+ /**
+ * Retrieves bundle name.
+ * @return String with name of resource bundle.
+ */
+ protected String getBundleName() {
+ return mBundleName;
+ }
+
+ /**
+ * Retrieves log source.
+ * This is an id of the subsystem responsible
+ * for creating the log event.
+ * @return Integer source id.
+ */
+ public int getSource() {
+ return mSource;
+ }
+
+ /**
+ * Sets log source.
+ * @param source Integer id of log source.
+ */
+ public void setSource(int source) {
+ mSource = source;
+ }
+
+ /**
+ * Retrieves log level.
+ * The log level of an event represents its relative importance
+ * or severity within CMS.
+ * @return Integer log level value.
+ */
+ public int getLevel() {
+ return mLevel;
+ }
+
+
+ /**
+ * Retrieves NT specific log event type.
+ * @return Integer NTEventType value.
+ */
+ public int getNTEventType() {
+ return mNTEventType;
+ }
+
+ /**
+ * Sets log level, NT log event type.
+ * For certain log levels the NT log event type gets
+ * set as well.
+ * @param level Integer log level value.
+ */
+ public void setLevel(int level) {
+ mLevel = level;
+ switch (level) {
+ case ILogger.LL_DEBUG:
+ case ILogger.LL_INFO:
+ mNTEventType = ILogger.NT_INFO;
+ break;
+
+ case ILogger.LL_WARN:
+ mNTEventType = ILogger.NT_WARN;
+ break;
+
+ case ILogger.LL_FAILURE:
+ case ILogger.LL_MISCONF:
+ case ILogger.LL_CATASTRPHE:
+ case ILogger.LL_SECURITY:
+ mNTEventType = ILogger.NT_ERROR;
+ break;
+
+ default:
+ ConsoleError.send(new SignedAuditEvent(INVALID_LOG_LEVEL,
+ Integer.toString(level)));
+ break;
+ }
+ }
+
+ /**
+ * Retrieves log multiline attribute.
+ * @return Boolean whether or not this event is multiline.
+ * A multiline message simply consists of more than one line.
+ */
+ public boolean getMultiline() {
+ return mMultiline;
+ }
+
+ /**
+ * Sets log multiline attribute. A multiline message consists of
+ * more than one line.
+ * @param multiline Boolean multiline value.
+ */
+ public void setMultiline(boolean multiline) {
+ mMultiline = multiline;
+ }
+
+
+ /**
+ * Retrieves event time stamp.
+ * @return Long integer of the time the event was created.
+ */
+ public long getTimeStamp() {
+ return mTimeStamp;
+ }
+
+
+ /**
+ * Retrieves log event type. Each type of event
+ * has an associated String type value.
+ * @return String containing the type of event.
+ */
+ public String getEventType() {
+ return mEventType;
+ }
+
+
+ /**
+ * Sets log event type. Each type of event
+ * has an associated String type value.
+ * @param eventType String containing the type of event.
+ */
+ public void setEventType(String eventType) {
+ mEventType = eventType;
+ }
+
+ /**
+ * Return string representation of log message.
+ * @return String containing log message.
+ */
+ public String toString() {
+ if (getBundleName() == null) {
+ MessageFormat detailMessage = new MessageFormat(mMessage);
+
+ return detailMessage.format(mParams);
+ } else
+ return toContent();
+ }
+}
diff --git a/pki/base/common/src/com/netscape/certsrv/logging/SystemEvent.java b/pki/base/common/src/com/netscape/certsrv/logging/SystemEvent.java
new file mode 100644
index 000000000..648d3b18c
--- /dev/null
+++ b/pki/base/common/src/com/netscape/certsrv/logging/SystemEvent.java
@@ -0,0 +1,330 @@
+// --- 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.certsrv.logging;
+
+
+import java.io.*;
+import java.util.*;
+import java.text.*;
+import com.netscape.certsrv.base.*;
+import com.netscape.certsrv.logging.*;
+
+
+/**
+ * The log event object that carries a log message.
+ * This class represents System events which are CMS events
+ * which need to be logged to a log file.
+ *
+ * @version $Revision$, $Date$
+ * @see java.text.MessageFormat
+ * @see com.netscape.certsrv.logging.LogResources
+ */
+public class SystemEvent implements IBundleLogEvent {
+
+ protected Object mParams[] = null;
+
+ private String mEventType = null;
+ private String mMessage = null;
+ private int mLevel = -1;
+ private int mNTEventType = -1;
+ private int mSource = -1;
+ private boolean mMultiline = false;
+ private long mTimeStamp = System.currentTimeMillis();
+
+ /**
+ * The bundle name for this event.
+ */
+ private String mBundleName = LogResources.class.getName();
+
+ private static final String INVALID_LOG_LEVEL="log level: {0} is invalid, should be 0-6";
+
+ /**
+ * Constructs a SystemEvent message event.
+ * <P>
+ *
+ * @param msgFormat The message string.
+ */
+ public SystemEvent(String msgFormat) {
+ mMessage = msgFormat;
+ mParams = null;
+ }
+
+ /**
+ * Constructs a SystemEvent message with a parameter. For example,
+ * <PRE>
+ * new SystemEvent("failed to load {0}", fileName);
+ * </PRE>
+ * <P>
+ *
+ * @param msgFormat Details in message string format.
+ * @param param Message string parameter.
+ */
+ public SystemEvent(String msgFormat, String param) {
+ this(msgFormat);
+ mParams = new String[1];
+ mParams[0] = param;
+ }
+
+ /**
+ * Constructs a SystemEvent message from an exception. It can be used to carry
+ * a system exception that may contain information about
+ * the context. For example,
+ * <PRE>
+ * try {
+ * ...
+ * } catch (IOExeption e) {
+ * logHandler.log(new SystemEvent("Encountered System Error {0}", e);
+ * }
+ * </PRE>
+ * <P>
+ *
+ * @param msgFormat Exception details in message string format.
+ * @param exception System exception.
+ */
+ public SystemEvent(String msgFormat, Exception exception) {
+ this(msgFormat);
+ mParams = new Exception[1];
+ mParams[0] = exception;
+ }
+
+ /**
+ * Constructs a SystemEvent message from a base exception. This will use the msgFormat
+ * from the exception itself.
+ * <PRE>
+ * try {
+ * ...
+ * } catch (Exception e) {
+ * logHandler.log(new SystemEvent(e));
+ * }
+ * </PRE>
+ * <P>
+ *
+ * @param e CMS exception.
+ */
+ public SystemEvent(Exception e) {
+ this(e.getMessage());
+ if (e instanceof EBaseException) {
+ mParams = ((EBaseException) e).getParameters();
+ } else {
+ mParams = new Exception[1];
+ mParams[0] = e;
+ }
+ }
+
+ /**
+ * Constructs a SystemEvent message event with a list of parameters
+ * that will be substituted into the message format.
+ * <P>
+ *
+ * @param msgFormat Message string format.
+ * @param params List of message format parameters.
+ */
+ public SystemEvent(String msgFormat, Object params[]) {
+ this(msgFormat);
+ mParams = params;
+ }
+
+ /**
+ * Returns the current message format string.
+ * <P>
+ *
+ * @return Details message.
+ */
+ public String getMessage() {
+ return mMessage;
+ }
+
+ /**
+ * Returns a list of parameters. These parameters can be
+ * used to assist in formatting the message.
+ * <P>
+ *
+ * @return List of message format parameters.
+ */
+ public Object[] getParameters() {
+ return mParams;
+ }
+
+ /**
+ * Returns localized message string. This method should
+ * only be called if a localized string is necessary.
+ * <P>
+ *
+ * @return Details message.
+ */
+ public String toContent() {
+ return toContent(Locale.getDefault());
+ }
+
+ /**
+ * Returns the string based on the given locale.
+ * <P>
+ *
+ * @param locale Locale.
+ * @return Details message.
+ */
+ public String toContent(Locale locale) {
+ return MessageFormatter.getLocalizedString(locale, getBundleName(),
+ getMessage(),
+ getParameters());
+ }
+
+ /**
+ * Sets the resource bundle name for this class instance. This should
+ * be overridden by subclasses who have their own resource bundles.
+ * @param bundle String with the name of resource bundle.
+ */
+ public void setBundleName(String bundle) {
+ mBundleName = bundle;
+ }
+
+ /**
+ * Retrieves bundle name.
+ * @return String with name of resource bundle.
+ */
+ protected String getBundleName() {
+ return mBundleName;
+ }
+
+ /**
+ * Retrieves log source.
+ * This is an id of the subsystem responsible
+ * for creating the log event.
+ * @return Integer source id.
+ */
+ public int getSource() {
+ return mSource;
+ }
+
+ /**
+ * Sets log source.
+ * Sets the id of the subsystem issuing the event.
+ * @param source Integer source id.
+ */
+ public void setSource(int source) {
+ mSource = source;
+ }
+
+ /**
+ * Retrieves log level.
+ * The log level of an event represents its relative importance
+ * or severity within CMS.
+ * @return Integer log level value.
+ */
+ public int getLevel() {
+ return mLevel;
+ }
+
+ /**
+ * Retrieves NT specific log event type.
+ * @return Integer NTEventType value.
+ */
+ public int getNTEventType() {
+ return mNTEventType;
+ }
+
+ /**
+ * Sets log level, NT log event type.
+ * For certain log levels the NT log event type gets
+ * set as well.
+ * @param level Integer log level value.
+ */
+ public void setLevel(int level) {
+ mLevel = level;
+ switch (level) {
+ case ILogger.LL_DEBUG:
+ case ILogger.LL_INFO:
+ mNTEventType = ILogger.NT_INFO;
+ break;
+
+ case ILogger.LL_WARN:
+ mNTEventType = ILogger.NT_WARN;
+ break;
+
+ case ILogger.LL_FAILURE:
+ case ILogger.LL_MISCONF:
+ case ILogger.LL_CATASTRPHE:
+ case ILogger.LL_SECURITY:
+ mNTEventType = ILogger.NT_ERROR;
+ break;
+
+ default:
+ ConsoleError.send(new SystemEvent(INVALID_LOG_LEVEL,
+ Integer.toString(level)));
+ break;
+ }
+ }
+
+ /**
+ * Retrieves log multiline attribute.
+ * @return Boolean whether or not this event is multiline.
+ * A multiline message simply consists of more than one line.
+ */
+ public boolean getMultiline() {
+ return mMultiline;
+ }
+
+ /**
+ * Sets log multiline attribute. A multiline message consists of
+ * more than one line.
+ * @param multiline Boolean multiline value.
+ */
+ public void setMultiline(boolean multiline) {
+ mMultiline = multiline;
+ }
+
+ /**
+ * Retrieves event time stamp.
+ * @return Long integer of the time the event was created.
+ */
+ public long getTimeStamp() {
+ return mTimeStamp;
+ }
+
+ /**
+ * Retrieves log event type. Each type of event
+ * has an associated String type value.
+ * @return String containing the type of event.
+ */
+ public String getEventType() {
+ return mEventType;
+ }
+
+
+ /**
+ * Sets log event type. Each type of event
+ * has an associated String type value.
+ * @param eventType String containing the type of event.
+ */
+ public void setEventType(String eventType) {
+ mEventType = eventType;
+ }
+
+ /**
+ * Return string representation of log message.
+ * @return String containing log message.
+ */
+ public String toString() {
+ if (getBundleName() == null) {
+ MessageFormat detailMessage = new MessageFormat(mMessage);
+
+ return detailMessage.format(mParams);
+ } else
+ return toContent();
+ }
+}