diff options
Diffstat (limited to 'pki/base/common/src/com/netscape/cms/logging/LogFile.java')
-rw-r--r-- | pki/base/common/src/com/netscape/cms/logging/LogFile.java | 787 |
1 files changed, 403 insertions, 384 deletions
diff --git a/pki/base/common/src/com/netscape/cms/logging/LogFile.java b/pki/base/common/src/com/netscape/cms/logging/LogFile.java index 284ff02d7..cf5a4d2b5 100644 --- a/pki/base/common/src/com/netscape/cms/logging/LogFile.java +++ b/pki/base/common/src/com/netscape/cms/logging/LogFile.java @@ -17,7 +17,6 @@ // --- END COPYRIGHT BLOCK --- package com.netscape.cms.logging; - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -81,7 +80,7 @@ import com.netscape.cmsutil.util.Utils; /** * A log event listener which write logs to log files - * + * * @version $Revision$, $Date$ **/ public class LogFile implements ILogEventListener, IExtendedPluginInfo { @@ -90,8 +89,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { public static final String PROP_ON = "enable"; public static final String PROP_TRACE = "trace"; public static final String PROP_SIGNED_AUDIT_LOG_SIGNING = "logSigning"; - public static final String PROP_SIGNED_AUDIT_CERT_NICKNAME = - "signedAuditCertNickname"; + public static final String PROP_SIGNED_AUDIT_CERT_NICKNAME = "signedAuditCertNickname"; public static final String PROP_SIGNED_AUDIT_EVENTS = "events"; public static final String PROP_LEVEL = "level"; static final String PROP_FILE_NAME = "fileName"; @@ -99,16 +97,12 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { static final String PROP_BUFFER_SIZE = "bufferSize"; static final String PROP_FLUSH_INTERVAL = "flushInterval"; - private final static String LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP = - "LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP_2"; - private final static String LOGGING_SIGNED_AUDIT_SIGNING = - "LOGGING_SIGNED_AUDIT_SIGNING_3"; - private final static String LOGGING_SIGNED_AUDIT_AUDIT_LOG_SHUTDOWN = - "LOGGING_SIGNED_AUDIT_AUDIT_LOG_SHUTDOWN_2"; - private final static String LOG_SIGNED_AUDIT_EXCEPTION = - "LOG_SIGNED_AUDIT_EXCEPTION_1"; + private final static String LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP = "LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP_2"; + private final static String LOGGING_SIGNED_AUDIT_SIGNING = "LOGGING_SIGNED_AUDIT_SIGNING_3"; + private final static String LOGGING_SIGNED_AUDIT_AUDIT_LOG_SHUTDOWN = "LOGGING_SIGNED_AUDIT_AUDIT_LOG_SHUTDOWN_2"; + private final static String LOG_SIGNED_AUDIT_EXCEPTION = "LOG_SIGNED_AUDIT_EXCEPTION_1"; - protected ILogger mSignedAuditLogger = CMS.getSignedAuditLogger(); + protected ILogger mSignedAuditLogger = CMS.getSignedAuditLogger(); protected IConfigStore mConfig = null; /** @@ -116,8 +110,9 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { */ static final String DATE_PATTERN = "yyyyMMddHHmmss"; - //It may be interesting to make this flexable someday.... - protected SimpleDateFormat mLogFileDateFormat = new SimpleDateFormat(DATE_PATTERN); + // It may be interesting to make this flexable someday.... + protected SimpleDateFormat mLogFileDateFormat = new SimpleDateFormat( + DATE_PATTERN); /** * The default output stream buffer size in bytes @@ -152,7 +147,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * The log date entry format */ - protected SimpleDateFormat mLogDateFormat = new SimpleDateFormat(mDatePattern); + protected SimpleDateFormat mLogDateFormat = new SimpleDateFormat( + mDatePattern); /** * The date object used for log entries @@ -228,53 +224,55 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { static final String CRYPTO_PROVIDER = "Mozilla-JSS"; /** - * The log level threshold - * Only logs with level greater or equal than this value will be written + * The log level threshold Only logs with level greater or equal than this + * value will be written */ protected long mLevel = 1; /** * Constructor for a LogFile. - * + * */ public LogFile() { } - public void init(ISubsystem owner, IConfigStore config) - throws EBaseException { + public void init(ISubsystem owner, IConfigStore config) + throws EBaseException { mConfig = config; try { mOn = config.getBoolean(PROP_ON, true); } catch (EBaseException e) { - throw new ELogException(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." + PROP_ON)); + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_ON)); } try { mLogSigning = config.getBoolean(PROP_SIGNED_AUDIT_LOG_SIGNING, - false); + false); } catch (EBaseException e) { - throw new ELogException(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." + PROP_SIGNED_AUDIT_LOG_SIGNING)); + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_SIGNED_AUDIT_LOG_SIGNING)); } if (mOn && mLogSigning) { try { - mSAuditCertNickName = config.getString( - PROP_SIGNED_AUDIT_CERT_NICKNAME); - CMS.debug("LogFile: init(): audit log signing enabled. signedAuditCertNickname="+ mSAuditCertNickName); + mSAuditCertNickName = config + .getString(PROP_SIGNED_AUDIT_CERT_NICKNAME); + CMS.debug("LogFile: init(): audit log signing enabled. signedAuditCertNickname=" + + mSAuditCertNickName); } catch (EBaseException e) { - throw new ELogException(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." - + PROP_SIGNED_AUDIT_CERT_NICKNAME)); + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_SIGNED_AUDIT_CERT_NICKNAME)); } - if (mSAuditCertNickName == null || - mSAuditCertNickName.trim().equals("")) { + if (mSAuditCertNickName == null + || mSAuditCertNickName.trim().equals("")) { throw new ELogException(CMS.getUserMessage( - "CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." - + PROP_SIGNED_AUDIT_CERT_NICKNAME)); + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_SIGNED_AUDIT_CERT_NICKNAME)); } } @@ -290,7 +288,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { try { init(config); } catch (IOException e) { - throw new ELogException(CMS.getUserMessage("CMS_LOG_UNEXPECTED_EXCEPTION", e.toString())); + throw new ELogException(CMS.getUserMessage( + "CMS_LOG_UNEXPECTED_EXCEPTION", e.toString())); } } @@ -303,19 +302,19 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { return theVector; } - StringTokenizer tokens = new StringTokenizer(theString, - ","); + StringTokenizer tokens = new StringTokenizer(theString, ","); while (tokens.hasMoreTokens()) { String eventId = tokens.nextToken().trim(); theVector.addElement(eventId); - CMS.debug("LogFile: log event type selected: "+eventId); + CMS.debug("LogFile: log event type selected: " + eventId); } return theVector; } /** * add the event to the selected events list + * * @param event to be selected */ public void selectEvent(String event) { @@ -325,6 +324,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * remove the event from the selected events list + * * @param event to be de-selected */ public void deselectEvent(String event) { @@ -334,6 +334,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * replace the selected events list + * * @param events comma-separated event list */ public void replaceEvents(String events) { @@ -346,11 +347,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { // All this streaming is lame, but Base64OutputStream needs a // PrintStream ByteArrayOutputStream output = new ByteArrayOutputStream(); - Base64OutputStream b64 = new Base64OutputStream(new - PrintStream(new - FilterOutputStream(output) - ) - ); + Base64OutputStream b64 = new Base64OutputStream(new PrintStream( + new FilterOutputStream(output))); b64.write(bytes); b64.flush(); @@ -363,7 +361,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { private static boolean mInSignedAuditLogFailureMode = false; private static synchronized void shutdownCMS() { - if( mInSignedAuditLogFailureMode == false ) { + if (mInSignedAuditLogFailureMode == false) { // Set signed audit log failure mode true // No, this isn't a race condition, because the method is @@ -371,7 +369,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { mInSignedAuditLogFailureMode = true; // Block all new incoming requests - if( CMS.areRequestsDisabled() == false ) { + if (CMS.areRequestsDisabled() == false) { // XXX is this a race condition? CMS.disableRequests(); } @@ -389,11 +387,10 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Initialize and open the log using the parameters from a config store - * + * * @param config The property config store to find values in */ - public void init(IConfigStore config) throws IOException, - EBaseException { + public void init(IConfigStore config) throws IOException, EBaseException { String fileName = null; String defaultFileName = null; String signedAuditDefaultFileName = ""; @@ -403,22 +400,25 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { try { mTrace = config.getBoolean(PROP_TRACE, false); } catch (EBaseException e) { - throw new ELogException(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." + PROP_TRACE)); + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_TRACE)); } try { mType = config.getString(PROP_TYPE, "system"); } catch (EBaseException e) { - throw new ELogException(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." + PROP_TYPE)); + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_TYPE)); } try { mRegister = config.getBoolean(PROP_REGISTER, true); } catch (EBaseException e) { - throw new ELogException(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." + PROP_REGISTER)); + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_REGISTER)); } if (mOn) { @@ -437,94 +437,97 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { mLevel = config.getInteger(PROP_LEVEL, 3); } catch (EBaseException e) { e.printStackTrace(); - throw new ELogException(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." + PROP_LEVEL)); + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_LEVEL)); } try { // retrieve the subsystem String subsystem = ""; - ISubsystem caSubsystem = CMS.getSubsystem( "ca" ); - if( caSubsystem != null ) { + ISubsystem caSubsystem = CMS.getSubsystem("ca"); + if (caSubsystem != null) { subsystem = "ca"; } - ISubsystem raSubsystem = CMS.getSubsystem( "ra" ); - if( raSubsystem != null ) { + ISubsystem raSubsystem = CMS.getSubsystem("ra"); + if (raSubsystem != null) { subsystem = "ra"; } - ISubsystem kraSubsystem = CMS.getSubsystem( "kra" ); - if( kraSubsystem != null ) { + ISubsystem kraSubsystem = CMS.getSubsystem("kra"); + if (kraSubsystem != null) { subsystem = "kra"; } - ISubsystem ocspSubsystem = CMS.getSubsystem( "ocsp" ); - if( ocspSubsystem != null ) { + ISubsystem ocspSubsystem = CMS.getSubsystem("ocsp"); + if (ocspSubsystem != null) { subsystem = "ocsp"; } // retrieve the instance name String instIDPath = CMS.getInstanceDir(); - int index = instIDPath.lastIndexOf( "/" ); - String instID = instIDPath.substring( index + 1 ); + int index = instIDPath.lastIndexOf("/"); + String instID = instIDPath.substring(index + 1); // build the default signedAudit file name - signedAuditDefaultFileName = subsystem + "_" - + instID + "_" + "audit"; - - } catch( Exception e2 ) { - throw new ELogException( - CMS.getUserMessage( "CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." + - PROP_FILE_NAME ) ); + signedAuditDefaultFileName = subsystem + "_" + instID + "_" + + "audit"; + + } catch (Exception e2) { + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_FILE_NAME)); } // the default value is determined by the eventType. if (mType.equals(ILogger.PROP_SIGNED_AUDIT)) { defaultFileName = "logs/signedAudit/" + signedAuditDefaultFileName; - }else if (mType.equals(ILogger.PROP_SYSTEM)) { + } else if (mType.equals(ILogger.PROP_SYSTEM)) { defaultFileName = "logs/system"; - }else if (mType.equals(ILogger.PROP_AUDIT)) { + } else if (mType.equals(ILogger.PROP_AUDIT)) { defaultFileName = "logs/transactions"; - }else { - //wont get here - throw new ELogException(CMS.getUserMessage("CMS_LOG_INVALID_LOG_TYPE", - config.getName())); + } else { + // wont get here + throw new ELogException(CMS.getUserMessage( + "CMS_LOG_INVALID_LOG_TYPE", config.getName())); } try { fileName = config.getString(PROP_FILE_NAME, defaultFileName); } catch (EBaseException e) { - throw new ELogException(CMS.getUserMessage("CMS_BASE_GET_PROPERTY_FAILED", - config.getName() + "." + PROP_FILE_NAME)); + throw new ELogException(CMS.getUserMessage( + "CMS_BASE_GET_PROPERTY_FAILED", config.getName() + "." + + PROP_FILE_NAME)); } if (mOn) { - init(fileName, config.getInteger(PROP_BUFFER_SIZE, BUFFER_SIZE), - config.getInteger(PROP_FLUSH_INTERVAL, FLUSH_INTERVAL)); + init(fileName, config.getInteger(PROP_BUFFER_SIZE, BUFFER_SIZE), + config.getInteger(PROP_FLUSH_INTERVAL, FLUSH_INTERVAL)); } } /** * Initialize and open the log - * - * @param bufferSize The buffer size for the output stream in bytes - * @param flushInterval The interval in seconds to flush the log + * + * @param bufferSize The buffer size for the output stream in bytes + * @param flushInterval The interval in seconds to flush the log */ - public void init(String fileName, int bufferSize, int flushInterval) throws IOException,ELogException { + public void init(String fileName, int bufferSize, int flushInterval) + throws IOException, ELogException { if (fileName == null) - throw new ELogException(CMS.getUserMessage("CMS_LOG_INVALID_FILE_NAME", "null")); + throw new ELogException(CMS.getUserMessage( + "CMS_LOG_INVALID_FILE_NAME", "null")); - //If we want to reuse the old log files - //mFileName = fileName + "." + mLogFileDateFormat.format(mDate); + // If we want to reuse the old log files + // mFileName = fileName + "." + mLogFileDateFormat.format(mDate); mFileName = fileName; - if( !Utils.isNT() ) { + if (!Utils.isNT()) { // Always insure that a physical file exists! - Utils.exec( "touch " + mFileName ); - Utils.exec( "chmod 00640 " + mFileName ); + Utils.exec("touch " + mFileName); + Utils.exec("chmod 00640 " + mFileName); } mFile = new File(mFileName); mBufferSize = bufferSize; @@ -540,25 +543,28 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { Provider[] providers = java.security.Security.getProviders(); int ps = providers.length; - for (int i = 0; i<ps; i++) { - CMS.debug("LogFile: provider "+i+"= "+providers[i].getName()); + for (int i = 0; i < ps; i++) { + CMS.debug("LogFile: provider " + i + "= " + + providers[i].getName()); } CryptoManager cm = CryptoManager.getInstance(); // find CertServer's private key - X509Certificate cert = cm.findCertByNickname( mSAuditCertNickName ); + X509Certificate cert = cm.findCertByNickname(mSAuditCertNickName); if (cert != null) { - CMS.debug("LogFile: setupSignig(): found cert:"+mSAuditCertNickName); + CMS.debug("LogFile: setupSignig(): found cert:" + + mSAuditCertNickName); } else { - CMS.debug("LogFile: setupSignig(): cert not found:"+mSAuditCertNickName); + CMS.debug("LogFile: setupSignig(): cert not found:" + + mSAuditCertNickName); } mSigningKey = cm.findPrivKeyByCert(cert); String sigAlgorithm; - if( mSigningKey instanceof RSAPrivateKey ) { + if (mSigningKey instanceof RSAPrivateKey) { sigAlgorithm = "SHA-256/RSA"; - } else if( mSigningKey instanceof DSAPrivateKey ) { + } else if (mSigningKey instanceof DSAPrivateKey) { sigAlgorithm = "SHA-256/DSA"; } else { throw new NoSuchAlgorithmException("Unknown private key type"); @@ -566,12 +572,11 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { CryptoToken savedToken = cm.getThreadToken(); try { - CryptoToken keyToken = - ((org.mozilla.jss.pkcs11.PK11PrivKey)mSigningKey) - .getOwningToken(); + CryptoToken keyToken = ((org.mozilla.jss.pkcs11.PK11PrivKey) mSigningKey) + .getOwningToken(); cm.setThreadToken(keyToken); mSignature = java.security.Signature.getInstance(sigAlgorithm, - CRYPTO_PROVIDER); + CRYPTO_PROVIDER); } finally { cm.setThreadToken(savedToken); } @@ -580,7 +585,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { // get the last signature from the currently-opened file String entry = getLastSignature(mFile); - if( entry != null ) { + if (entry != null) { mSignature.update(entry.getBytes("UTF-8")); mSignature.update(LINE_SEP_BYTE); } @@ -614,12 +619,11 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { } private static void setupSigningFailure(String logMessageCode, Exception e) - throws EBaseException - { + throws EBaseException { try { - ConsoleError.send( new SystemEvent( - CMS.getLogMessage(logMessageCode))); - } catch(Exception e2) { + ConsoleError + .send(new SystemEvent(CMS.getLogMessage(logMessageCode))); + } catch (Exception e2) { // don't allow an exception while printing to the console // prevent us from running the rest of this function. e2.printStackTrace(); @@ -632,36 +636,32 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Startup the instance * <P> - * + * * <ul> * <li>signed.audit LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP used at audit * function startup * </ul> + * * @exception EBaseException if an internal error occurred */ public void startup() throws EBaseException { // ensure that any low-level exceptions are reported // to the signed audit log and stored as failures CMS.debug("LogFile: entering LogFile.startup()"); - if( mOn && mLogSigning ) { + if (mOn && mLogSigning) { try { setupSigning(); - audit( CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP, - ILogger.SYSTEM_UID, - ILogger.SUCCESS) ); - } catch(EBaseException e) { - audit( CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP, - ILogger.SYSTEM_UID, - ILogger.FAILURE) ); + audit(CMS.getLogMessage(LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP, + ILogger.SYSTEM_UID, ILogger.SUCCESS)); + } catch (EBaseException e) { + audit(CMS.getLogMessage(LOGGING_SIGNED_AUDIT_AUDIT_LOG_STARTUP, + ILogger.SYSTEM_UID, ILogger.FAILURE)); throw e; } } } - /** * Retrieves the eventType this log is triggered. */ @@ -673,7 +673,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { * Retrieves the log on/off. */ public String getOn() { - return String.valueOf( mOn ); + return String.valueOf(mOn); } /** @@ -695,22 +695,22 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Record that the signed audit log has been signed * <P> - * + * * <ul> - * <li>signed.audit LOGGING_SIGNED_AUDIT_SIGNING used when a signature on the - * audit log is generated (same as "flush" time) + * <li>signed.audit LOGGING_SIGNED_AUDIT_SIGNING used when a signature on + * the audit log is generated (same as "flush" time) * </ul> + * * @exception IOException for input/output problems * @exception ELogException when plugin implementation fails * @exception SignatureException when signing fails * @exception InvalidKeyException when an invalid key is utilized */ private void pushSignature() throws IOException, ELogException, - SignatureException, InvalidKeyException - { + SignatureException, InvalidKeyException { byte[] sigBytes = null; - if( mSignature == null ) { + if (mSignature == null) { return; } @@ -723,35 +723,27 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { // cook up a signed audit log message to record mac // so as to avoid infinite recursiveness of calling // the log() method - String auditMessage = CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_SIGNING, - ILogger.SYSTEM_UID, - ILogger.SUCCESS, - base64Encode( sigBytes ) ); + String auditMessage = CMS.getLogMessage(LOGGING_SIGNED_AUDIT_SIGNING, + ILogger.SYSTEM_UID, ILogger.SUCCESS, base64Encode(sigBytes)); - if( mSignedAuditLogger == null ) { + if (mSignedAuditLogger == null) { return; } - ILogEvent ev = mSignedAuditLogger.create( - ILogger.EV_SIGNED_AUDIT, - ( Properties ) null, - ILogger.S_SIGNED_AUDIT, - ILogger.LL_SECURITY, - auditMessage, - o, - ILogger.L_SINGLELINE ); + ILogEvent ev = mSignedAuditLogger.create(ILogger.EV_SIGNED_AUDIT, + (Properties) null, ILogger.S_SIGNED_AUDIT, ILogger.LL_SECURITY, + auditMessage, o, ILogger.L_SINGLELINE); - String logMesg = logEvt2String(ev); + String logMesg = logEvt2String(ev); doLog(logMesg, true); } private static String getLastSignature(File f) throws IOException { - BufferedReader r = new BufferedReader( new FileReader(f) ); + BufferedReader r = new BufferedReader(new FileReader(f)); String lastSig = null; String curLine = null; - while( (curLine = r.readLine()) != null ) { - if( curLine.indexOf("AUDIT_LOG_SIGNING") != -1 ) { + while ((curLine = r.readLine()) != null) { + if (curLine.indexOf("AUDIT_LOG_SIGNING") != -1) { lastSig = curLine; } } @@ -760,8 +752,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { } /** - * Open the log file. This creates the buffered FileWriter - * + * Open the log file. This creates the buffered FileWriter + * */ protected synchronized void open() throws IOException { RandomAccessFile out; @@ -769,36 +761,34 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { try { out = new RandomAccessFile(mFile, "rw"); out.seek(out.length()); - //XXX int or long? + // XXX int or long? mBytesWritten = (int) out.length(); - if( !Utils.isNT() ) { + if (!Utils.isNT()) { try { - Utils.exec( "chmod 00640 " + mFile.getCanonicalPath() ); - } catch( IOException e ) { - CMS.debug( "Unable to change file permissions on " - + mFile.toString() ); + Utils.exec("chmod 00640 " + mFile.getCanonicalPath()); + } catch (IOException e) { + CMS.debug("Unable to change file permissions on " + + mFile.toString()); } } - mLogWriter = new BufferedWriter( - new FileWriter(out.getFD()), mBufferSize); + mLogWriter = new BufferedWriter(new FileWriter(out.getFD()), + mBufferSize); // The first time we open, mSignature will not have been // initialized yet. That's ok, we will push our first signature // in setupSigning(). - if( mLogSigning && (mSignature != null)) { + if (mLogSigning && (mSignature != null)) { try { pushSignature(); } catch (ELogException le) { - ConsoleError.send( - new SystemEvent(CMS.getUserMessage("CMS_LOG_ILLEGALARGUMENT", - mFileName))); + ConsoleError.send(new SystemEvent(CMS.getUserMessage( + "CMS_LOG_ILLEGALARGUMENT", mFileName))); } } } catch (IllegalArgumentException iae) { - ConsoleError.send( - new SystemEvent(CMS.getUserMessage("CMS_LOG_ILLEGALARGUMENT", - mFileName))); - } catch(GeneralSecurityException gse) { + ConsoleError.send(new SystemEvent(CMS.getUserMessage( + "CMS_LOG_ILLEGALARGUMENT", mFileName))); + } catch (GeneralSecurityException gse) { // error with signed audit log, shutdown CMS gse.printStackTrace(); shutdownCMS(); @@ -808,16 +798,18 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { } /** - * Flush the log file. Also update the MAC for hash protected logs - * + * Flush the log file. Also update the MAC for hash protected logs + * */ public synchronized void flush() { try { - if( mLogSigning ) { + if (mLogSigning) { try { pushSignature(); } catch (ELogException le) { - ConsoleError.send(new SystemEvent(CMS.getUserMessage("CMS_LOG_FLUSH_LOG_FAILED", mFileName, le.toString()))); + ConsoleError.send(new SystemEvent(CMS.getUserMessage( + "CMS_LOG_FLUSH_LOG_FAILED", mFileName, + le.toString()))); } } @@ -825,13 +817,14 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { mLogWriter.flush(); } } catch (IOException e) { - ConsoleError.send(new SystemEvent(CMS.getUserMessage("CMS_LOG_FLUSH_LOG_FAILED", mFileName, e.toString()))); + ConsoleError.send(new SystemEvent(CMS.getUserMessage( + "CMS_LOG_FLUSH_LOG_FAILED", mFileName, e.toString()))); if (mLogSigning) { - //error in writing to signed audit log, shut down CMS + // error in writing to signed audit log, shut down CMS e.printStackTrace(); shutdownCMS(); } - } catch(GeneralSecurityException gse) { + } catch (GeneralSecurityException gse) { // error with signed audit log, shutdown CMS gse.printStackTrace(); shutdownCMS(); @@ -842,7 +835,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Close the log file - * + * */ protected synchronized void close() { try { @@ -851,7 +844,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { mLogWriter.close(); } } catch (IOException e) { - ConsoleError.send(new SystemEvent(CMS.getUserMessage("CMS_LOG_CLOSE_FAILED", mFileName, e.toString()))); + ConsoleError.send(new SystemEvent(CMS.getUserMessage( + "CMS_LOG_CLOSE_FAILED", mFileName, e.toString()))); } mLogWriter = null; } @@ -859,7 +853,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Shutdown this log file. * <P> - * + * * <ul> * <li>signed.audit LOGGING_SIGNED_AUDIT_AUDIT_LOG_SHUTDOWN used at audit * function shutdown @@ -874,11 +868,10 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { // log signed audit shutdown success auditMessage = CMS.getLogMessage( - LOGGING_SIGNED_AUDIT_AUDIT_LOG_SHUTDOWN, - ILogger.SYSTEM_UID, - ILogger.SUCCESS ); + LOGGING_SIGNED_AUDIT_AUDIT_LOG_SHUTDOWN, ILogger.SYSTEM_UID, + ILogger.SUCCESS); - audit( auditMessage ); + audit(auditMessage); close(); } @@ -886,9 +879,10 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Set the flush interval * <P> - * @param flushInterval The amount of time in seconds until the log - * is flush. A value of 0 will disable autoflush. This will also set - * the update period for hash protected logs. + * + * @param flushInterval The amount of time in seconds until the log is + * flush. A value of 0 will disable autoflush. This will also set + * the update period for hash protected logs. **/ public synchronized void setFlushInterval(int flushInterval) { mFlushInterval = flushInterval * 1000; @@ -903,8 +897,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { } /** - * Log flush thread. Sleep for the flush interval and flush the - * log. Changing flush interval to 0 will cause this thread to exit. + * Log flush thread. Sleep for the flush interval and flush the log. + * Changing flush interval to 0 will cause this thread to exit. */ final class FlushThread extends Thread { @@ -924,8 +918,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { LogFile.this.wait(mFlushInterval); } catch (InterruptedException e) { // This shouldn't happen very often - ConsoleError.send(new - SystemEvent(CMS.getUserMessage("CMS_LOG_THREAD_INTERRUPT", "flush"))); + ConsoleError.send(new SystemEvent(CMS.getUserMessage( + "CMS_LOG_THREAD_INTERRUPT", "flush"))); } } @@ -942,10 +936,10 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { } /** - * Synchronized method to write a string to the log file. All I18N - * should take place before this call. - * - * @param entry The log entry string + * Synchronized method to write a string to the log file. All I18N should + * take place before this call. + * + * @param entry The log entry string */ protected synchronized void log(String entry) throws ELogException { doLog(entry, false); @@ -957,93 +951,99 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { private static final byte LINE_SEP_BYTE = 0x0a; /** - * This method actually does the logging, and is not overridden - * by subclasses, so you can call it and know that it will do exactly - * what you see below. + * This method actually does the logging, and is not overridden by + * subclasses, so you can call it and know that it will do exactly what you + * see below. */ private synchronized void doLog(String entry, boolean noFlush) throws ELogException { if (mLogWriter == null) { String[] params = { mFileName, entry }; - throw new ELogException(CMS.getUserMessage("CMS_LOG_LOGFILE_CLOSED", params)); + throw new ELogException(CMS.getUserMessage( + "CMS_LOG_LOGFILE_CLOSED", params)); } else { try { - mLogWriter.write(entry, 0/*offset*/, entry.length()); + mLogWriter.write(entry, 0/* offset */, entry.length()); - if (mLogSigning==true) { - if(mSignature != null) { + if (mLogSigning == true) { + if (mSignature != null) { // include newline for calculating MAC mSignature.update(entry.getBytes("UTF-8")); } else { CMS.debug("LogFile: mSignature is not yet ready... null in log()"); } } - if (mTrace) { - CharArrayWriter cw = new CharArrayWriter(200); + if (mTrace) { + CharArrayWriter cw = new CharArrayWriter(200); PrintWriter pw = new PrintWriter(cw); Exception e = new Exception(); - e.printStackTrace(pw); - char[] c = cw.toCharArray(); - cw.close(); + e.printStackTrace(pw); + char[] c = cw.toCharArray(); + cw.close(); pw.close(); - CharArrayReader cr = new CharArrayReader(c); + CharArrayReader cr = new CharArrayReader(c); LineNumberReader lr = new LineNumberReader(cr); - String text = null; - String method = null; + String text = null; + String method = null; String fileAndLine = null; - if (lr.ready()) { - text = lr.readLine(); - do { - text = lr.readLine(); + if (lr.ready()) { + text = lr.readLine(); + do { + text = lr.readLine(); } while (text.indexOf("logging") != -1); - int p = text.indexOf("("); + int p = text.indexOf("("); fileAndLine = text.substring(p); - String classandmethod = text.substring(0, p); - int q = classandmethod.lastIndexOf("."); - method = classandmethod.substring(q + 1); - mLogWriter.write(fileAndLine, 0/*offset*/, fileAndLine.length()); - mLogWriter.write(" ", 0/*offset*/, " ".length()); - mLogWriter.write(method, 0/*offset*/, method.length()); + String classandmethod = text.substring(0, p); + int q = classandmethod.lastIndexOf("."); + method = classandmethod.substring(q + 1); + mLogWriter.write(fileAndLine, 0/* offset */, + fileAndLine.length()); + mLogWriter.write(" ", 0/* offset */, " ".length()); + mLogWriter + .write(method, 0/* offset */, method.length()); } } mLogWriter.newLine(); - if (mLogSigning==true){ - if(mSignature != null) { + if (mLogSigning == true) { + if (mSignature != null) { mSignature.update(LINE_SEP_BYTE); } else { CMS.debug("LogFile: mSignature is null in log() 2"); } } } catch (IOException e) { - ConsoleError.send(new SystemEvent(CMS.getUserMessage("CMS_LOG_WRITE_FAILED", mFileName, entry, e.toString()))); + ConsoleError + .send(new SystemEvent(CMS.getUserMessage( + "CMS_LOG_WRITE_FAILED", mFileName, entry, + e.toString()))); if (mLogSigning) { // Failed to write to audit log, shut down CMS e.printStackTrace(); shutdownCMS(); } } catch (IllegalStateException e) { - CMS.debug("LogFile: exception thrown in log(): "+e.toString()); - ConsoleError.send(new SignedAuditEvent(CMS.getLogMessage(LOG_SIGNED_AUDIT_EXCEPTION,e.toString()))); - } catch( GeneralSecurityException gse ) { + CMS.debug("LogFile: exception thrown in log(): " + e.toString()); + ConsoleError.send(new SignedAuditEvent(CMS.getLogMessage( + LOG_SIGNED_AUDIT_EXCEPTION, e.toString()))); + } catch (GeneralSecurityException gse) { // DJN: handle error CMS.debug("LogFile: exception thrown in log(): " - + gse.toString()); + + gse.toString()); gse.printStackTrace(); ConsoleError.send(new SignedAuditEvent(CMS.getLogMessage( - LOG_SIGNED_AUDIT_EXCEPTION,gse.toString()))); + LOG_SIGNED_AUDIT_EXCEPTION, gse.toString()))); } - // XXX // Although length will be in Unicode dual-bytes, the PrintWriter - // will only print out 1 byte per character. I suppose this could + // will only print out 1 byte per character. I suppose this could // be dependent on the encoding of your log file, but it ain't that - // smart yet. Also, add one for the newline. (hmm, on NT, CR+LF) + // smart yet. Also, add one for the newline. (hmm, on NT, CR+LF) int nBytes = entry.length() + 1; mBytesWritten += nBytes; @@ -1057,20 +1057,22 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Write an event to the log file - * - * @param ev The event to be logged. + * + * @param ev The event to be logged. */ public void log(ILogEvent ev) throws ELogException { if (ev instanceof AuditEvent) { - if (!mType.equals("transaction") || (!mOn) || mLevel > ev.getLevel()) { + if (!mType.equals("transaction") || (!mOn) + || mLevel > ev.getLevel()) { return; } } else if (ev instanceof SystemEvent) { if (!mType.equals("system") || (!mOn) || mLevel > ev.getLevel()) { return; } - } else if (ev instanceof SignedAuditEvent) { - if (!mType.equals("signedAudit") || (!mOn) || mLevel > ev.getLevel()) { + } else if (ev instanceof SignedAuditEvent) { + if (!mType.equals("signedAudit") || (!mOn) + || mLevel > ev.getLevel()) { return; } } @@ -1082,7 +1084,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { String type = ev.getEventType(); if (type != null) { if (!mSelectedEvents.contains(type)) { - CMS.debug("LogFile: event type not selected: "+type); + CMS.debug("LogFile: event type not selected: " + type); return; } } @@ -1105,14 +1107,15 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { // some work. if (ev.getMultiline() == ILogger.L_MULTILINE) { entry = mPid + "." + Thread.currentThread().getName() + " - [" - + mLogDateFormat.format(mDate) + "] [" + - Integer.toString(ev.getSource()) + "] [" + Integer.toString(ev.getLevel()) - + "] " + prepareMultiline(ev.toString()); + + mLogDateFormat.format(mDate) + "] [" + + Integer.toString(ev.getSource()) + "] [" + + Integer.toString(ev.getLevel()) + "] " + + prepareMultiline(ev.toString()); } else { entry = mPid + "." + Thread.currentThread().getName() + " - [" - + mLogDateFormat.format(mDate) + "] [" + - Integer.toString(ev.getSource()) + "] [" + Integer.toString(ev.getLevel()) - + "] " + ev.toString(); + + mLogDateFormat.format(mDate) + "] [" + + Integer.toString(ev.getSource()) + "] [" + + Integer.toString(ev.getLevel()) + "] " + ev.toString(); } return entry; @@ -1120,30 +1123,31 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * change multi-line log entry by replace "\n" with "\n " - * - * @param original The original multi-line log entry. + * + * @param original The original multi-line log entry. */ private String prepareMultiline(String original) { int i, last = 0; - //NT: \r\n, unix: \n + // NT: \r\n, unix: \n while ((i = original.indexOf("\n", last)) != -1) { last = i + 1; - original = original.substring(0, i + 1) + " " + original.substring(i + 1); + original = original.substring(0, i + 1) + " " + + original.substring(i + 1); } return original; } /** - * Read all entries whose logLevel>=lowLevel && log source = source - * to at most maxLine entries(from end) - * If the parameter is -1, it's ignored and return all entries - * + * Read all entries whose logLevel>=lowLevel && log source = source to at + * most maxLine entries(from end) If the parameter is -1, it's ignored and + * return all entries + * * @param maxLine The maximum lines to be returned * @param lowLevel The lowest log level to be returned * @param source The particular log source to be returned * @param fName The log file name to be read. If it's null, read the current - * log file + * log file */ public Vector readEntry(int maxLine, int lowLevel, int source, String fName) { Vector mEntries = new Vector(); @@ -1152,33 +1156,35 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { int lineNo = 0; // lineNo of the current entry in the log file int line = 0; // line of readed valid entries String firstLine = null; // line buffer - String nextLine = null; + String nextLine = null; String entry = null; LogEntry logEntry = null; /* - this variable is added to accormodate misplaced multiline entries - write out buffered log entry when next entry is parsed successfully - this implementation is assuming parsing is more time consuming than - condition check + * this variable is added to accormodate misplaced multiline entries + * write out buffered log entry when next entry is parsed successfully + * this implementation is assuming parsing is more time consuming than + * condition check */ - LogEntry preLogEntry = null; + LogEntry preLogEntry = null; if (fName != null) { fileName = fName; } try { - //XXX think about this + // XXX think about this fBuffer = new BufferedReader(new FileReader(fileName)); do { try { nextLine = fBuffer.readLine(); if (nextLine != null) { - if ((nextLine.length() == 0) || (nextLine.charAt(0) == ' ')) { + if ((nextLine.length() == 0) + || (nextLine.charAt(0) == ' ')) { // It's a continuous line entry = null; if (nextLine.length() > 1) - firstLine = firstLine + "\n" + nextLine.substring(1); + firstLine = firstLine + "\n" + + nextLine.substring(1); else firstLine = firstLine + "\n"; @@ -1193,10 +1199,10 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { logEntry = new LogEntry(entry); // if parse succeed, write out previous entry if (preLogEntry != null) { - if ((Integer.parseInt(preLogEntry.getLevel()) >= lowLevel) && - ((Integer.parseInt(preLogEntry.getSource()) == source) || - (source == ILogger.S_ALL) - )) { + if ((Integer.parseInt(preLogEntry + .getLevel()) >= lowLevel) + && ((Integer.parseInt(preLogEntry + .getSource()) == source) || (source == ILogger.S_ALL))) { mEntries.addElement(preLogEntry); if (maxLine == -1) { line++; @@ -1222,14 +1228,15 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { lineNo++; } catch (IOException e) { - CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - ILogger.LL_FAILURE, - CMS.getLogMessage("LOGGING_READ_ERROR", fileName, - Integer.toString(lineNo))); + CMS.getLogger().log( + ILogger.EV_SYSTEM, + ILogger.S_OTHER, + ILogger.LL_FAILURE, + CMS.getLogMessage("LOGGING_READ_ERROR", fileName, + Integer.toString(lineNo))); } - } - while (nextLine != null); + } while (nextLine != null); // need to process the last 2 entries of the file if (firstLine != null) { @@ -1240,17 +1247,16 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { try { logEntry = new LogEntry(entry); - /* System.out.println( - Integer.toString(Integer.parseInt(logEntry.getLevel())) - +","+Integer.toString(lowLevel)+","+ - Integer.toString(Integer.parseInt(logEntry.getSource())) - +","+Integer.toString(source) ); + /* + * System.out.println( + * Integer.toString(Integer.parseInt(logEntry.getLevel())) + * +","+Integer.toString(lowLevel)+","+ + * Integer.toString(Integer.parseInt(logEntry.getSource())) + * +","+Integer.toString(source) ); */ if (preLogEntry != null) { - if ((Integer.parseInt(preLogEntry.getLevel()) >= lowLevel) && - ((Integer.parseInt(preLogEntry.getSource()) == source) || - (source == ILogger.S_ALL) - )) { + if ((Integer.parseInt(preLogEntry.getLevel()) >= lowLevel) + && ((Integer.parseInt(preLogEntry.getSource()) == source) || (source == ILogger.S_ALL))) { mEntries.addElement(preLogEntry); if (maxLine == -1) { line++; @@ -1268,11 +1274,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { if (preLogEntry != null) { if ((Integer.parseInt(preLogEntry.getLevel()) >= lowLevel) - && - ((Integer.parseInt(preLogEntry.getSource()) == source) - || - (source == ILogger.S_ALL) - )) { + && ((Integer.parseInt(preLogEntry.getSource()) == source) || (source == ILogger.S_ALL))) { // parse the entry, pass to UI mEntries.addElement(preLogEntry); if (maxLine == -1) { @@ -1291,15 +1293,14 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { fBuffer.close(); } catch (IOException e) { CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - ILogger.LL_FAILURE, "logging:" + fileName + - " failed to close for reading"); + ILogger.LL_FAILURE, + "logging:" + fileName + " failed to close for reading"); } } catch (FileNotFoundException e) { CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - ILogger.LL_FAILURE, - CMS.getLogMessage("LOGGING_FILE_NOT_FOUND", - fileName)); + ILogger.LL_FAILURE, + CMS.getLogMessage("LOGGING_FILE_NOT_FOUND", fileName)); } return mEntries; } @@ -1307,7 +1308,7 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Retrieves the configuration store of this subsystem. * <P> - * + * * @return configuration store */ public IConfigStore getConfigStore() { @@ -1315,27 +1316,27 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { } /** - * 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. + * 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. */ - public synchronized NameValuePairs retrieveLogContent(Hashtable req) throws ServletException, - IOException, EBaseException { + public synchronized NameValuePairs retrieveLogContent(Hashtable req) + throws ServletException, IOException, EBaseException { NameValuePairs params = new NameValuePairs(); String tmp, fName = null; int maxLine = -1, level = -1, source = -1; Vector entries = null; - if ((tmp = (String)req.get(Constants.PR_LOG_ENTRY)) != null) { + if ((tmp = (String) req.get(Constants.PR_LOG_ENTRY)) != null) { maxLine = Integer.parseInt(tmp); } - if ((tmp = (String)req.get(Constants.PR_LOG_LEVEL)) != null) { + if ((tmp = (String) req.get(Constants.PR_LOG_LEVEL)) != null) { level = Integer.parseInt(tmp); } - if ((tmp = (String)req.get(Constants.PR_LOG_SOURCE)) != null) { + if ((tmp = (String) req.get(Constants.PR_LOG_SOURCE)) != null) { source = Integer.parseInt(tmp); } - tmp = (String)req.get(Constants.PR_LOG_NAME); + tmp = (String) req.get(Constants.PR_LOG_NAME); if (!(tmp.equals(Constants.PR_CURRENT_LOG))) { fName = tmp; } else { @@ -1345,13 +1346,14 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { try { entries = readEntry(maxLine, level, source, fName); for (int i = 0; i < entries.size(); i++) { - params.add(Integer.toString(i) + - ((LogEntry) entries.elementAt(i)).getEntry(), ""); + params.add( + Integer.toString(i) + + ((LogEntry) entries.elementAt(i)).getEntry(), + ""); } } catch (Exception e) { CMS.getLogger().log(ILogger.EV_SYSTEM, ILogger.S_OTHER, - ILogger.LL_WARN, - "System log parse error"); + ILogger.LL_WARN, "System log parse error"); } return params; } @@ -1359,8 +1361,8 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Retrieve log file list. */ - public synchronized NameValuePairs retrieveLogList(Hashtable req) throws ServletException, - IOException, EBaseException { + public synchronized NameValuePairs retrieveLogList(Hashtable req) + throws ServletException, IOException, EBaseException { return null; } @@ -1385,11 +1387,11 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { // needs to find a way to determine what type you want. if this // is not for the signed audit type, then we should not show the // following parameters. - //if( mType.equals( ILogger.PROP_SIGNED_AUDIT ) ) { - v.addElement( PROP_SIGNED_AUDIT_LOG_SIGNING + "=" ); - v.addElement( PROP_SIGNED_AUDIT_CERT_NICKNAME + "=" ); - v.addElement( PROP_SIGNED_AUDIT_EVENTS + "=" ); - //} + // if( mType.equals( ILogger.PROP_SIGNED_AUDIT ) ) { + v.addElement(PROP_SIGNED_AUDIT_LOG_SIGNING + "="); + v.addElement(PROP_SIGNED_AUDIT_CERT_NICKNAME + "="); + v.addElement(PROP_SIGNED_AUDIT_EVENTS + "="); + // } return v; } @@ -1401,11 +1403,10 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { if (mType == null) { v.addElement(PROP_TYPE + "="); - }else { - v.addElement(PROP_TYPE + "=" + - mConfig.getString(PROP_TYPE)); + } else { + v.addElement(PROP_TYPE + "=" + mConfig.getString(PROP_TYPE)); } - v.addElement(PROP_ON + "=" + String.valueOf( mOn ) ); + v.addElement(PROP_ON + "=" + String.valueOf(mOn)); if (mLevel == 0) v.addElement(PROP_LEVEL + "=" + ILogger.LL_DEBUG_STRING); else if (mLevel == 1) @@ -1423,29 +1424,28 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { if (mFileName == null) { v.addElement(PROP_FILE_NAME + "="); - }else { - v.addElement(PROP_FILE_NAME + "=" + - mFileName); + } else { + v.addElement(PROP_FILE_NAME + "=" + mFileName); } v.addElement(PROP_BUFFER_SIZE + "=" + mBufferSize); v.addElement(PROP_FLUSH_INTERVAL + "=" + mFlushInterval / 1000); - if( (mType != null) && mType.equals( ILogger.PROP_SIGNED_AUDIT ) ) { - v.addElement( PROP_SIGNED_AUDIT_LOG_SIGNING + "=" - + String.valueOf( mLogSigning ) ); + if ((mType != null) && mType.equals(ILogger.PROP_SIGNED_AUDIT)) { + v.addElement(PROP_SIGNED_AUDIT_LOG_SIGNING + "=" + + String.valueOf(mLogSigning)); - if( mSAuditCertNickName == null ) { - v.addElement( PROP_SIGNED_AUDIT_CERT_NICKNAME + "=" ); + if (mSAuditCertNickName == null) { + v.addElement(PROP_SIGNED_AUDIT_CERT_NICKNAME + "="); } else { - v.addElement( PROP_SIGNED_AUDIT_CERT_NICKNAME + "=" - + mSAuditCertNickName ); + v.addElement(PROP_SIGNED_AUDIT_CERT_NICKNAME + "=" + + mSAuditCertNickName); } - if( mSelectedEventsList == null ) { - v.addElement( PROP_SIGNED_AUDIT_EVENTS + "=" ); + if (mSelectedEventsList == null) { + v.addElement(PROP_SIGNED_AUDIT_EVENTS + "="); } else { - v.addElement( PROP_SIGNED_AUDIT_EVENTS + "=" - + mSelectedEventsList ); + v.addElement(PROP_SIGNED_AUDIT_EVENTS + "=" + + mSelectedEventsList); } } } catch (Exception e) { @@ -1454,54 +1454,78 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { } public String[] getExtendedPluginInfo(Locale locale) { - if( mType.equals( ILogger.PROP_SIGNED_AUDIT ) ) { + if (mType.equals(ILogger.PROP_SIGNED_AUDIT)) { String[] params = { - PROP_TYPE + ";choice(transaction,signedAudit,system);The log event type this instance is listening to", - PROP_ON + ";boolean;Turn on the listener", - PROP_LEVEL + ";choice(" + ILogger.LL_DEBUG_STRING + "," + - ILogger.LL_INFO_STRING + "," + - ILogger.LL_WARN_STRING + "," + - ILogger.LL_FAILURE_STRING + "," + - ILogger.LL_MISCONF_STRING + "," + - ILogger.LL_CATASTRPHE_STRING + "," + - ILogger.LL_SECURITY_STRING + ");Only log message with level higher than this filter will be written by this listener", - PROP_FILE_NAME + ";string;The name of the file the log is written to", - PROP_BUFFER_SIZE + ";integer;The size of the buffer to receive log messages in kilobytes(KB)", - PROP_FLUSH_INTERVAL + ";integer;The maximum time in seconds before the buffer is flushed to the file", - IExtendedPluginInfo.HELP_TOKEN + - ";configuration-logrules-logfile", - IExtendedPluginInfo.HELP_TEXT + - ";Write the log messages to a file", - PROP_SIGNED_AUDIT_LOG_SIGNING + - ";boolean;Enable audit logs to be signed", - PROP_SIGNED_AUDIT_CERT_NICKNAME + - ";string;The nickname of the certificate to be used to sign audit logs", - PROP_SIGNED_AUDIT_EVENTS + - ";string;A comma-separated list of strings used to specify particular signed audit log events", - }; + PROP_TYPE + + ";choice(transaction,signedAudit,system);The log event type this instance is listening to", + PROP_ON + ";boolean;Turn on the listener", + PROP_LEVEL + + ";choice(" + + ILogger.LL_DEBUG_STRING + + "," + + ILogger.LL_INFO_STRING + + "," + + ILogger.LL_WARN_STRING + + "," + + ILogger.LL_FAILURE_STRING + + "," + + ILogger.LL_MISCONF_STRING + + "," + + ILogger.LL_CATASTRPHE_STRING + + "," + + ILogger.LL_SECURITY_STRING + + ");Only log message with level higher than this filter will be written by this listener", + PROP_FILE_NAME + + ";string;The name of the file the log is written to", + PROP_BUFFER_SIZE + + ";integer;The size of the buffer to receive log messages in kilobytes(KB)", + PROP_FLUSH_INTERVAL + + ";integer;The maximum time in seconds before the buffer is flushed to the file", + IExtendedPluginInfo.HELP_TOKEN + + ";configuration-logrules-logfile", + IExtendedPluginInfo.HELP_TEXT + + ";Write the log messages to a file", + PROP_SIGNED_AUDIT_LOG_SIGNING + + ";boolean;Enable audit logs to be signed", + PROP_SIGNED_AUDIT_CERT_NICKNAME + + ";string;The nickname of the certificate to be used to sign audit logs", + PROP_SIGNED_AUDIT_EVENTS + + ";string;A comma-separated list of strings used to specify particular signed audit log events", }; return params; } else { - // mType.equals( ILogger.PROP_AUDIT ) || + // mType.equals( ILogger.PROP_AUDIT ) || // mType.equals( ILogger.PROP_SYSTEM ) String[] params = { - PROP_TYPE + ";choice(transaction,signedAudit,system);The log event type this instance is listening to", - PROP_ON + ";boolean;Turn on the listener", - PROP_LEVEL + ";choice(" + ILogger.LL_DEBUG_STRING + "," + - ILogger.LL_INFO_STRING + "," + - ILogger.LL_WARN_STRING + "," + - ILogger.LL_FAILURE_STRING + "," + - ILogger.LL_MISCONF_STRING + "," + - ILogger.LL_CATASTRPHE_STRING + "," + - ILogger.LL_SECURITY_STRING + ");Only log message with level higher than this filter will be written by this listener", - PROP_FILE_NAME + ";string;The name of the file the log is written to", - PROP_BUFFER_SIZE + ";integer;The size of the buffer to receive log messages in kilobytes(KB)", - PROP_FLUSH_INTERVAL + ";integer;The maximum time in seconds before the buffer is flushed to the file", - IExtendedPluginInfo.HELP_TOKEN + - ";configuration-logrules-logfile", - IExtendedPluginInfo.HELP_TEXT + - ";Write the log messages to a file" - }; + PROP_TYPE + + ";choice(transaction,signedAudit,system);The log event type this instance is listening to", + PROP_ON + ";boolean;Turn on the listener", + PROP_LEVEL + + ";choice(" + + ILogger.LL_DEBUG_STRING + + "," + + ILogger.LL_INFO_STRING + + "," + + ILogger.LL_WARN_STRING + + "," + + ILogger.LL_FAILURE_STRING + + "," + + ILogger.LL_MISCONF_STRING + + "," + + ILogger.LL_CATASTRPHE_STRING + + "," + + ILogger.LL_SECURITY_STRING + + ");Only log message with level higher than this filter will be written by this listener", + PROP_FILE_NAME + + ";string;The name of the file the log is written to", + PROP_BUFFER_SIZE + + ";integer;The size of the buffer to receive log messages in kilobytes(KB)", + PROP_FLUSH_INTERVAL + + ";integer;The maximum time in seconds before the buffer is flushed to the file", + IExtendedPluginInfo.HELP_TOKEN + + ";configuration-logrules-logfile", + IExtendedPluginInfo.HELP_TEXT + + ";Write the log messages to a file" }; return params; } @@ -1509,27 +1533,22 @@ public class LogFile implements ILogEventListener, IExtendedPluginInfo { /** * Signed Audit Log - * - * This method is inherited by all classes that extend this "LogFile" - * class, and is called to store messages to the signed audit log. + * + * This method is inherited by all classes that extend this "LogFile" class, + * and is called to store messages to the signed audit log. * <P> - * + * * @param msg signed audit log message */ - protected void audit( String msg ) - { + protected void audit(String msg) { // in this case, do NOT strip preceding/trailing whitespace // from passed-in String parameters - if( mSignedAuditLogger == null ) { + if (mSignedAuditLogger == null) { return; } - mSignedAuditLogger.log( ILogger.EV_SIGNED_AUDIT, - null, - ILogger.S_SIGNED_AUDIT, - ILogger.LL_SECURITY, - msg ); + mSignedAuditLogger.log(ILogger.EV_SIGNED_AUDIT, null, + ILogger.S_SIGNED_AUDIT, ILogger.LL_SECURITY, msg); } } - |