Merge branch 'reformat'

This commit is contained in:
Bernd Ahlers 2014-10-21 17:05:58 +02:00
commit 7380b94581
101 changed files with 9165 additions and 8926 deletions

View File

@ -14,20 +14,20 @@ import org.graylog2.syslog4j.util.SyslogUtility;
/**
* This class provides a Singleton interface for Syslog4j client implementations.
*
* <p/>
* <p>Usage examples:</p>
*
* <p/>
* <b>Direct</b>
* <pre>
* Syslog.getInstance("udp").info("log message");
* </pre>
*
* <p/>
* <b>Via Instance</b>
* <pre>
* SyslogIF syslog = Syslog.getInstance("udp");
* syslog.info();
* </pre>
*
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
@ -126,14 +126,14 @@ public final class Syslog implements SyslogConstants {
/**
* Use createInstance(protocol,config) to create your own Syslog instance.
*
* <p/>
* <p>First, create an implementation of SyslogConfigIF, such as UdpNetSyslogConfig.</p>
*
* <p/>
* <p>Second, configure that configuration instance.</p>
*
* <p/>
* <p>Third, call createInstance(protocol,config) using a short &amp; simple
* String for the protocol argument.</p>
*
* <p/>
* <p>Fourth, either use the returned instance of SyslogIF, or in later code
* call getInstance(protocol) with the protocol chosen in the previous step.</p>
*
@ -157,7 +157,7 @@ public final class Syslog implements SyslogConstants {
SyslogIF syslog = null;
synchronized(instances) {
synchronized (instances) {
if (instances.containsKey(syslogProtocol)) {
throwRuntimeException("Syslog protocol \"" + protocol + "\" already defined");
return null;
@ -193,9 +193,9 @@ public final class Syslog implements SyslogConstants {
}
}
syslog.initialize(syslogProtocol,config);
syslog.initialize(syslogProtocol, config);
instances.put(syslogProtocol,syslog);
instances.put(syslogProtocol, syslog);
}
return syslog;
@ -206,12 +206,12 @@ public final class Syslog implements SyslogConstants {
* well as UNIX_SYSLOG and UNIX_SOCKET (if running on a Unix-based system).
*/
public synchronized static final void initialize() {
createInstance(UDP,new UDPNetSyslogConfig());
createInstance(TCP,new TCPNetSyslogConfig());
createInstance(UDP, new UDPNetSyslogConfig());
createInstance(TCP, new TCPNetSyslogConfig());
if (OSDetectUtility.isUnix() && SyslogUtility.isClassExists(JNA_NATIVE_CLASS)) {
createInstance(UNIX_SYSLOG,new UnixSyslogConfig());
createInstance(UNIX_SOCKET,new UnixSocketSyslogConfig());
createInstance(UNIX_SYSLOG, new UnixSyslogConfig());
createInstance(UNIX_SOCKET, new UnixSocketSyslogConfig());
}
}
@ -240,7 +240,7 @@ public final class Syslog implements SyslogConstants {
SyslogUtility.sleep(SyslogConstants.THREAD_LOOP_INTERVAL_DEFAULT);
while(i.hasNext()) {
while (i.hasNext()) {
String protocol = (String) i.next();
SyslogIF syslog = (SyslogIF) instances.get(protocol);

View File

@ -1,16 +1,16 @@
package org.graylog2.syslog4j;
/**
* Syslog4jVersion provides a unique version identifier that is created during
* the build process.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: Syslog4jVersion.java,v 1.2 2008/10/28 01:07:06 cvs Exp $
*/
* Syslog4jVersion provides a unique version identifier that is created during
* the build process.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: Syslog4jVersion.java,v 1.2 2008/10/28 01:07:06 cvs Exp $
*/
public final class Syslog4jVersion {
public static final String VERSION = "Syslog4j-graylog2 0.9.48 kroepke";
}

View File

@ -1,22 +1,22 @@
package org.graylog2.syslog4j;
/**
* SyslogBackLogHandlerIF provides a last-chance mechanism to log messages that fail
* (for whatever reason) within the rest of Syslog.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* <p>Implementing the down(SyslogIF) method is an excellent way to add some sort of notification to
* your application when a Syslog service is unavailable.</p>
*
* <p>Implementing the up(SyslogIF) method can be used to notify your application when a Syslog
* service has returned.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogBackLogHandlerIF.java,v 1.2 2009/01/28 15:13:52 cvs Exp $
*/
* SyslogBackLogHandlerIF provides a last-chance mechanism to log messages that fail
* (for whatever reason) within the rest of Syslog.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
* <p/>
* <p>Implementing the down(SyslogIF) method is an excellent way to add some sort of notification to
* your application when a Syslog service is unavailable.</p>
* <p/>
* <p>Implementing the up(SyslogIF) method can be used to notify your application when a Syslog
* service has returned.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogBackLogHandlerIF.java,v 1.2 2009/01/28 15:13:52 cvs Exp $
*/
public interface SyslogBackLogHandlerIF {
/**
* Implement initialize() to handle one-time set-up for this backLog handler.

View File

@ -3,17 +3,18 @@ package org.graylog2.syslog4j;
import java.io.Serializable;
/**
* SyslogCharSetIF provides control of the encoding character set within
* several class of Syslog4j.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogCharSetIF.java,v 1.3 2008/11/07 15:15:41 cvs Exp $
*/
* SyslogCharSetIF provides control of the encoding character set within
* several class of Syslog4j.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogCharSetIF.java,v 1.3 2008/11/07 15:15:41 cvs Exp $
*/
public interface SyslogCharSetIF extends Serializable {
public String getCharSet();
public void setCharSet(String charSet);
}

View File

@ -1,69 +1,90 @@
package org.graylog2.syslog4j;
/**
* SyslogConfigIF provides a common, extensible configuration interface for all
* implementations of SyslogIF.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogConfigIF.java,v 1.19 2010/11/28 04:15:18 cvs Exp $
*/
* SyslogConfigIF provides a common, extensible configuration interface for all
* implementations of SyslogIF.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogConfigIF.java,v 1.19 2010/11/28 04:15:18 cvs Exp $
*/
public interface SyslogConfigIF extends SyslogConstants, SyslogCharSetIF {
public Class getSyslogClass();
public int getFacility();
public void setFacility(int facility);
public void setFacility(String facilityName);
public int getPort();
public void setPort(int port) throws SyslogRuntimeException;
public String getLocalName();
public void setLocalName(String localName) throws SyslogRuntimeException;
public String getHost();
public void setHost(String host) throws SyslogRuntimeException;
public String getIdent();
public void setIdent(String ident);
public String getCharSet();
public void setCharSet(String charSet);
public boolean isIncludeIdentInMessageModifier();
public void setIncludeIdentInMessageModifier(boolean throwExceptionOnInitialize);
public boolean isThrowExceptionOnInitialize();
public void setThrowExceptionOnInitialize(boolean throwExceptionOnInitialize);
public boolean isThrowExceptionOnWrite();
public void setThrowExceptionOnWrite(boolean throwExceptionOnWrite);
public boolean isSendLocalTimestamp();
public void setSendLocalTimestamp(boolean sendLocalTimestamp);
public boolean isSendLocalName();
public void setSendLocalName(boolean sendLocalName);
public boolean isTruncateMessage();
public void setTruncateMessage(boolean truncateMessage);
public boolean isUseStructuredData();
public void setUseStructuredData(boolean useStructuredData);
public int getMaxMessageLength();
public void setMaxMessageLength(int maxMessageLength);
public void addMessageModifier(SyslogMessageModifierIF messageModifier);
public void insertMessageModifier(int index, SyslogMessageModifierIF messageModifier);
public void removeMessageModifier(SyslogMessageModifierIF messageModifier);
public void removeAllMessageModifiers();
public void addBackLogHandler(SyslogBackLogHandlerIF backLogHandler);
public void insertBackLogHandler(int index, SyslogBackLogHandlerIF backLogHandler);
public void removeBackLogHandler(SyslogBackLogHandlerIF backLogHandler);
public void removeAllBackLogHandlers();
}

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j;
import java.io.Serializable;
/**
* SyslogConstants provides several global constant values for several
* classes within Syslog4j.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogConstants.java,v 1.33 2011/01/11 05:11:13 cvs Exp $
*/
* SyslogConstants provides several global constant values for several
* classes within Syslog4j.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogConstants.java,v 1.33 2011/01/11 05:11:13 cvs Exp $
*/
public interface SyslogConstants extends Serializable {
public static final String SYSLOG_PATH_DEFAULT = "/dev/log";
public static final String SYSLOG_HOST_DEFAULT = "localhost";
@ -75,27 +75,27 @@ public interface SyslogConstants extends Serializable {
public static final byte TCP_MAX_ACTIVE_SOCKETS_BEHAVIOR_DEFAULT = 0;
public static final int FACILITY_KERN = 0;
public static final int FACILITY_USER = 1<<3;
public static final int FACILITY_MAIL = 2<<3;
public static final int FACILITY_DAEMON = 3<<3;
public static final int FACILITY_AUTH = 4<<3;
public static final int FACILITY_SYSLOG = 5<<3;
public static final int FACILITY_USER = 1 << 3;
public static final int FACILITY_MAIL = 2 << 3;
public static final int FACILITY_DAEMON = 3 << 3;
public static final int FACILITY_AUTH = 4 << 3;
public static final int FACILITY_SYSLOG = 5 << 3;
public static final int FACILITY_LPR = 6<<3;
public static final int FACILITY_NEWS = 7<<3;
public static final int FACILITY_UUCP = 8<<3;
public static final int FACILITY_CRON = 9<<3;
public static final int FACILITY_AUTHPRIV = 10<<3;
public static final int FACILITY_FTP = 11<<3;
public static final int FACILITY_LPR = 6 << 3;
public static final int FACILITY_NEWS = 7 << 3;
public static final int FACILITY_UUCP = 8 << 3;
public static final int FACILITY_CRON = 9 << 3;
public static final int FACILITY_AUTHPRIV = 10 << 3;
public static final int FACILITY_FTP = 11 << 3;
public static final int FACILITY_LOCAL0 = 16<<3;
public static final int FACILITY_LOCAL1 = 17<<3;
public static final int FACILITY_LOCAL2 = 18<<3;
public static final int FACILITY_LOCAL3 = 19<<3;
public static final int FACILITY_LOCAL4 = 20<<3;
public static final int FACILITY_LOCAL5 = 21<<3;
public static final int FACILITY_LOCAL6 = 22<<3;
public static final int FACILITY_LOCAL7 = 23<<3;
public static final int FACILITY_LOCAL0 = 16 << 3;
public static final int FACILITY_LOCAL1 = 17 << 3;
public static final int FACILITY_LOCAL2 = 18 << 3;
public static final int FACILITY_LOCAL3 = 19 << 3;
public static final int FACILITY_LOCAL4 = 20 << 3;
public static final int FACILITY_LOCAL5 = 21 << 3;
public static final int FACILITY_LOCAL6 = 22 << 3;
public static final int FACILITY_LOCAL7 = 23 << 3;
public static final int SYSLOG_FACILITY_DEFAULT = FACILITY_USER;

View File

@ -1,52 +1,71 @@
package org.graylog2.syslog4j;
/**
* SyslogIF provides a common interface for all Syslog4j client implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogIF.java,v 1.9 2010/02/11 04:59:22 cvs Exp $
*/
* SyslogIF provides a common interface for all Syslog4j client implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogIF.java,v 1.9 2010/02/11 04:59:22 cvs Exp $
*/
public interface SyslogIF extends SyslogConstants {
public void initialize(String protocol, SyslogConfigIF config) throws SyslogRuntimeException;
public String getProtocol();
public SyslogConfigIF getConfig();
public void backLog(int level, String message, Throwable reasonThrowable);
public void backLog(int level, String message, String reason);
public void log(int level, String message);
public void debug(String message);
public void info(String message);
public void notice(String message);
public void warn(String message);
public void error(String message);
public void critical(String message);
public void alert(String message);
public void emergency(String message);
public void log(int level, SyslogMessageIF message);
public void debug(SyslogMessageIF message);
public void info(SyslogMessageIF message);
public void notice(SyslogMessageIF message);
public void warn(SyslogMessageIF message);
public void error(SyslogMessageIF message);
public void critical(SyslogMessageIF message);
public void alert(SyslogMessageIF message);
public void emergency(SyslogMessageIF message);
public void flush() throws SyslogRuntimeException;
public void shutdown() throws SyslogRuntimeException;
public void setMessageProcessor(SyslogMessageProcessorIF messageProcessor);
public SyslogMessageProcessorIF getMessageProcessor();
public void setStructuredMessageProcessor(SyslogMessageProcessorIF messageProcessor);
public SyslogMessageProcessorIF getStructuredMessageProcessor();
}

View File

@ -10,7 +10,7 @@ import java.io.InputStreamReader;
/**
* This class provides a command-line interface for Syslog4j
* server implementations.
*
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
@ -76,17 +76,55 @@ public class SyslogMain {
Options options = new Options();
int i = 0;
while(i < args.length) {
while (i < args.length) {
String arg = args[i++];
boolean match = false;
if ("-h".equals(arg)) { if (i == args.length) { options.usage = "Must specify host with -h"; return options; } match = true; options.host = args[i++]; }
if ("-p".equals(arg)) { if (i == args.length) { options.usage = "Must specify port with -p"; return options; } match = true; options.port = args[i++]; }
if ("-l".equals(arg)) { if (i == args.length) { options.usage = "Must specify level with -l"; return options; } match = true; options.level = args[i++]; }
if ("-f".equals(arg)) { if (i == args.length) { options.usage = "Must specify facility with -f"; return options; } match = true; options.facility = args[i++]; }
if ("-i".equals(arg)) { if (i == args.length) { options.usage = "Must specify file with -i"; return options; } match = true; options.fileName = args[i++]; }
if ("-h".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify host with -h";
return options;
}
match = true;
options.host = args[i++];
}
if ("-p".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify port with -p";
return options;
}
match = true;
options.port = args[i++];
}
if ("-l".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify level with -l";
return options;
}
match = true;
options.level = args[i++];
}
if ("-f".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify facility with -f";
return options;
}
match = true;
options.facility = args[i++];
}
if ("-i".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify file with -i";
return options;
}
match = true;
options.fileName = args[i++];
}
if ("-q".equals(arg)) { match = true; options.quiet = true; }
if ("-q".equals(arg)) {
match = true;
options.quiet = true;
}
if (options.protocol == null && !match) {
match = true;
@ -117,7 +155,7 @@ public class SyslogMain {
}
public static void main(String[] args) throws Exception {
main(args,true);
main(args, true);
}
public static void main(String[] args, boolean shutdown) throws Exception {
@ -125,7 +163,11 @@ public class SyslogMain {
if (options.usage != null) {
usage(options.usage);
if (CALL_SYSTEM_EXIT_ON_FAILURE) { System.exit(1); } else { return; }
if (CALL_SYSTEM_EXIT_ON_FAILURE) {
System.exit(1);
} else {
return;
}
}
if (!options.quiet) {
@ -134,7 +176,11 @@ public class SyslogMain {
if (!Syslog.exists(options.protocol)) {
usage("Protocol \"" + options.protocol + "\" not supported");
if (CALL_SYSTEM_EXIT_ON_FAILURE) { System.exit(1); } else { return; }
if (CALL_SYSTEM_EXIT_ON_FAILURE) {
System.exit(1);
} else {
return;
}
}
SyslogIF syslog = Syslog.getInstance(options.protocol);
@ -164,7 +210,7 @@ public class SyslogMain {
System.out.println("Sending " + options.facility + "." + options.level + " message \"" + options.message + "\"");
}
syslog.log(level,options.message);
syslog.log(level, options.message);
} else {
InputStream is = null;
@ -180,12 +226,12 @@ public class SyslogMain {
String line = br.readLine();
while(line != null && line.length() > 0) {
while (line != null && line.length() > 0) {
if (!options.quiet) {
System.out.println("Sending " + options.facility + "." + options.level + " message \"" + line + "\"");
}
syslog.log(level,line);
syslog.log(level, line);
line = br.readLine();
}

View File

@ -3,15 +3,15 @@ package org.graylog2.syslog4j;
import java.io.Serializable;
/**
* SyslogMessageIF provides a common interface for all Syslog4j event implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageIF.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
*/
* SyslogMessageIF provides a common interface for all Syslog4j event implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageIF.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
*/
public interface SyslogMessageIF extends Serializable {
public String createMessage();
}

View File

@ -1,20 +1,22 @@
package org.graylog2.syslog4j;
/**
* SyslogMessageModifierConfigIF provides a common configuration interface for all
* Syslog4j message modifier implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageModifierConfigIF.java,v 1.3 2010/10/28 05:10:57 cvs Exp $
*/
* SyslogMessageModifierConfigIF provides a common configuration interface for all
* Syslog4j message modifier implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageModifierConfigIF.java,v 1.3 2010/10/28 05:10:57 cvs Exp $
*/
public interface SyslogMessageModifierConfigIF extends SyslogConstants, SyslogCharSetIF {
public String getPrefix();
public void setPrefix(String prefix);
public String getSuffix();
public void setSuffix(String suffix);
}

View File

@ -1,17 +1,18 @@
package org.graylog2.syslog4j;
/**
* SyslogMessageModifierIF provides a common interface for all
* Syslog4j message modifier implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageModifierIF.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
*/
* SyslogMessageModifierIF provides a common interface for all
* Syslog4j message modifier implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageModifierIF.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
*/
public interface SyslogMessageModifierIF extends SyslogConstants {
public String modify(SyslogIF syslog, int facility, int level, String message);
public boolean verify(String message);
}

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j;
import java.io.Serializable;
/**
* SyslogMessageProcessorIF provides an extensible interface for writing custom
* Syslog4j message processors.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageProcessorIF.java,v 1.4 2010/11/28 04:15:18 cvs Exp $
*/
* SyslogMessageProcessorIF provides an extensible interface for writing custom
* Syslog4j message processors.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageProcessorIF.java,v 1.4 2010/11/28 04:15:18 cvs Exp $
*/
public interface SyslogMessageProcessorIF extends Serializable {
public String createSyslogHeader(int facility, int level, String localName, boolean sendLocalTimestamp, boolean sendLocalName);

View File

@ -3,50 +3,62 @@ package org.graylog2.syslog4j;
import java.io.Serializable;
/**
* SyslogPoolConfigIF is an interface which provides configuration support
* for the Apache Commons Pool.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogPoolConfigIF.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
*/
* SyslogPoolConfigIF is an interface which provides configuration support
* for the Apache Commons Pool.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogPoolConfigIF.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
*/
public interface SyslogPoolConfigIF extends Serializable {
public int getMaxActive();
public void setMaxActive(int maxActive);
public int getMaxIdle();
public void setMaxIdle(int maxIdle);
public long getMaxWait();
public void setMaxWait(long maxWait);
public long getMinEvictableIdleTimeMillis();
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis);
public int getMinIdle();
public void setMinIdle(int minIdle);
public int getNumTestsPerEvictionRun();
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun);
public long getSoftMinEvictableIdleTimeMillis();
public void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis);
public boolean isTestOnBorrow();
public void setTestOnBorrow(boolean testOnBorrow);
public boolean isTestOnReturn();
public void setTestOnReturn(boolean testOnReturn);
public boolean isTestWhileIdle();
public void setTestWhileIdle(boolean testWhileIdle);
public long getTimeBetweenEvictionRunsMillis();
public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis);
public byte getWhenExhaustedAction();
public void setWhenExhaustedAction(byte whenExhaustedAction);
}

View File

@ -1,16 +1,16 @@
package org.graylog2.syslog4j;
/**
* SyslogRuntimeException provides an extension of RuntimeException thrown
* by the majority of the classes within Syslog4j.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogRuntimeException.java,v 1.3 2008/11/13 14:48:36 cvs Exp $
*/
* SyslogRuntimeException provides an extension of RuntimeException thrown
* by the majority of the classes within Syslog4j.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogRuntimeException.java,v 1.3 2008/11/13 14:48:36 cvs Exp $
*/
public class SyslogRuntimeException extends RuntimeException {
private static final long serialVersionUID = 7278123987654320379L;

View File

@ -17,15 +17,15 @@ import org.graylog2.syslog4j.impl.message.structured.StructuredSyslogMessageIF;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* AbstractSyslog provides a base abstract implementation of the SyslogIF.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslog.java,v 1.29 2011/01/11 04:58:52 cvs Exp $
*/
* AbstractSyslog provides a base abstract implementation of the SyslogIF.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslog.java,v 1.29 2011/01/11 04:58:52 cvs Exp $
*/
public abstract class AbstractSyslog implements SyslogIF {
private static final long serialVersionUID = 2632017043774808264L;
@ -42,7 +42,7 @@ public abstract class AbstractSyslog implements SyslogIF {
protected List notifiedBackLogHandlers = new ArrayList();
protected boolean getBackLogStatus() {
synchronized(this.backLogStatusSyncObject) {
synchronized (this.backLogStatusSyncObject) {
return this.backLogStatus;
}
}
@ -52,9 +52,9 @@ public abstract class AbstractSyslog implements SyslogIF {
*/
public void setBackLogStatus(boolean backLogStatus) {
if (this.backLogStatus != backLogStatus) {
synchronized(this.backLogStatusSyncObject) {
synchronized (this.backLogStatusSyncObject) {
if (!backLogStatus) {
for(int i=0; i<this.notifiedBackLogHandlers.size(); i++) {
for (int i = 0; i < this.notifiedBackLogHandlers.size(); i++) {
SyslogBackLogHandlerIF backLogHandler = (SyslogBackLogHandlerIF) this.notifiedBackLogHandlers.get(i);
backLogHandler.up(this);
@ -115,91 +115,91 @@ public abstract class AbstractSyslog implements SyslogIF {
public void log(int level, String message) {
if (this.syslogConfig.isUseStructuredData()) {
StructuredSyslogMessageIF structuredMessage = new StructuredSyslogMessage(null,null,message);
StructuredSyslogMessageIF structuredMessage = new StructuredSyslogMessage(null, null, message);
log(getStructuredMessageProcessor(),level,structuredMessage.createMessage());
log(getStructuredMessageProcessor(), level, structuredMessage.createMessage());
} else {
log(getMessageProcessor(),level,message);
log(getMessageProcessor(), level, message);
}
}
public void log(int level, SyslogMessageIF message) {
if (message instanceof StructuredSyslogMessageIF) {
if (getMessageProcessor() instanceof StructuredSyslogMessageProcessor) {
log(getMessageProcessor(),level,message.createMessage());
log(getMessageProcessor(), level, message.createMessage());
} else {
log(getStructuredMessageProcessor(),level,message.createMessage());
log(getStructuredMessageProcessor(), level, message.createMessage());
}
} else {
log(getMessageProcessor(),level,message.createMessage());
log(getMessageProcessor(), level, message.createMessage());
}
}
public void debug(String message) {
log(LEVEL_DEBUG,message);
log(LEVEL_DEBUG, message);
}
public void notice(String message) {
log(LEVEL_NOTICE,message);
log(LEVEL_NOTICE, message);
}
public void info(String message) {
log(LEVEL_INFO,message);
log(LEVEL_INFO, message);
}
public void warn(String message) {
log(LEVEL_WARN,message);
log(LEVEL_WARN, message);
}
public void error(String message) {
log(LEVEL_ERROR,message);
log(LEVEL_ERROR, message);
}
public void critical(String message) {
log(LEVEL_CRITICAL,message);
log(LEVEL_CRITICAL, message);
}
public void alert(String message) {
log(LEVEL_ALERT,message);
log(LEVEL_ALERT, message);
}
public void emergency(String message) {
log(LEVEL_EMERGENCY,message);
log(LEVEL_EMERGENCY, message);
}
public void debug(SyslogMessageIF message) {
log(LEVEL_DEBUG,message);
log(LEVEL_DEBUG, message);
}
public void notice(SyslogMessageIF message) {
log(LEVEL_NOTICE,message);
log(LEVEL_NOTICE, message);
}
public void info(SyslogMessageIF message) {
log(LEVEL_INFO,message);
log(LEVEL_INFO, message);
}
public void warn(SyslogMessageIF message) {
log(LEVEL_WARN,message);
log(LEVEL_WARN, message);
}
public void error(SyslogMessageIF message) {
log(LEVEL_ERROR,message);
log(LEVEL_ERROR, message);
}
public void critical(SyslogMessageIF message) {
log(LEVEL_CRITICAL,message);
log(LEVEL_CRITICAL, message);
}
public void alert(SyslogMessageIF message) {
log(LEVEL_ALERT,message);
log(LEVEL_ALERT, message);
}
public void emergency(SyslogMessageIF message) {
log(LEVEL_EMERGENCY,message);
log(LEVEL_EMERGENCY, message);
}
protected String prefixMessage(String message, String suffix) {
@ -214,23 +214,23 @@ public abstract class AbstractSyslog implements SyslogIF {
String _message = null;
if (this.syslogConfig.isIncludeIdentInMessageModifier()) {
_message = prefixMessage(message,IDENT_SUFFIX_DEFAULT);
_message = modifyMessage(level,_message);
_message = prefixMessage(message, IDENT_SUFFIX_DEFAULT);
_message = modifyMessage(level, _message);
} else {
_message = modifyMessage(level,message);
_message = prefixMessage(_message,IDENT_SUFFIX_DEFAULT);
_message = modifyMessage(level, message);
_message = prefixMessage(_message, IDENT_SUFFIX_DEFAULT);
}
try {
write(messageProcessor, level,_message);
write(messageProcessor, level, _message);
} catch (SyslogRuntimeException sre) {
if (sre.getCause() != null) {
backLog(level,_message,sre.getCause());
backLog(level, _message, sre.getCause());
} else {
backLog(level,_message,sre);
backLog(level, _message, sre);
}
if (this.syslogConfig.isThrowExceptionOnWrite()) {
@ -240,10 +240,10 @@ public abstract class AbstractSyslog implements SyslogIF {
}
protected void write(SyslogMessageProcessorIF messageProcessor, int level, String message) throws SyslogRuntimeException {
String header = messageProcessor.createSyslogHeader(this.syslogConfig.getFacility(),level,this.syslogConfig.getLocalName(),this.syslogConfig.isSendLocalTimestamp(),this.syslogConfig.isSendLocalName());
String header = messageProcessor.createSyslogHeader(this.syslogConfig.getFacility(), level, this.syslogConfig.getLocalName(), this.syslogConfig.isSendLocalTimestamp(), this.syslogConfig.isSendLocalName());
byte[] h = SyslogUtility.getBytes(this.syslogConfig,header);
byte[] m = SyslogUtility.getBytes(this.syslogConfig,message);
byte[] h = SyslogUtility.getBytes(this.syslogConfig, header);
byte[] m = SyslogUtility.getBytes(this.syslogConfig, message);
int mLength = m.length;
@ -256,9 +256,9 @@ public abstract class AbstractSyslog implements SyslogIF {
}
if (mLength <= availableLen) {
byte[] data = messageProcessor.createPacketData(h,m,0,mLength);
byte[] data = messageProcessor.createPacketData(h, m, 0, mLength);
write(level,data);
write(level, data);
} else {
byte[] splitBeginText = this.syslogConfig.getSplitMessageBeginText();
@ -267,7 +267,7 @@ public abstract class AbstractSyslog implements SyslogIF {
int pos = 0;
int left = mLength;
while(left > 0) {
while (left > 0) {
boolean firstTime = (pos == 0);
boolean doSplitBeginText = splitBeginText != null && !firstTime;
@ -286,9 +286,9 @@ public abstract class AbstractSyslog implements SyslogIF {
throw new SyslogRuntimeException("Message length < 0; recommendation: increase the size of maxMessageLength");
}
byte[] data = messageProcessor.createPacketData(h,m,pos,actualAvailableLen,doSplitBeginText ? splitBeginText : null,doSplitEndText ? splitEndText : null);
byte[] data = messageProcessor.createPacketData(h, m, pos, actualAvailableLen, doSplitBeginText ? splitBeginText : null, doSplitEndText ? splitEndText : null);
write(level,data);
write(level, data);
pos += actualAvailableLen;
left -= actualAvailableLen;
@ -311,7 +311,7 @@ public abstract class AbstractSyslog implements SyslogIF {
int facility = this.syslogConfig.getFacility();
for(int i=0; i<_messageModifiers.size(); i++) {
for (int i = 0; i < _messageModifiers.size(); i++) {
SyslogMessageModifierIF messageModifier = (SyslogMessageModifierIF) _messageModifiers.get(i);
_message = messageModifier.modify(this, facility, level, _message);
@ -321,7 +321,7 @@ public abstract class AbstractSyslog implements SyslogIF {
}
public void backLog(int level, String message, Throwable reasonThrowable) {
backLog(level,message,reasonThrowable != null ? reasonThrowable.toString() : "UNKNOWN");
backLog(level, message, reasonThrowable != null ? reasonThrowable.toString() : "UNKNOWN");
}
public void backLog(int level, String message, String reason) {
@ -333,7 +333,7 @@ public abstract class AbstractSyslog implements SyslogIF {
List backLogHandlers = this.syslogConfig.getBackLogHandlers();
for(int i=0; i<backLogHandlers.size(); i++) {
for (int i = 0; i < backLogHandlers.size(); i++) {
SyslogBackLogHandlerIF backLogHandler = (SyslogBackLogHandlerIF) backLogHandlers.get(i);
try {
@ -342,7 +342,7 @@ public abstract class AbstractSyslog implements SyslogIF {
this.notifiedBackLogHandlers.add(backLogHandler);
}
backLogHandler.log(this,level,message,reason);
backLogHandler.log(this, level, message, reason);
break;
} catch (Exception e) {
@ -369,7 +369,7 @@ public abstract class AbstractSyslog implements SyslogIF {
}
public AbstractSyslogWriter createWriter(){
public AbstractSyslogWriter createWriter() {
Class clazz = this.syslogConfig.getSyslogWriterClass();
AbstractSyslogWriter newWriter = null;

View File

@ -10,16 +10,16 @@ import org.graylog2.syslog4j.impl.backlog.printstream.SystemErrSyslogBackLogHand
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* AbstractSyslog provides a base abstract implementation of the SyslogConfigIF
* configuration interface.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogConfig.java,v 1.24 2010/11/28 04:43:31 cvs Exp $
*/
* AbstractSyslog provides a base abstract implementation of the SyslogConfigIF
* configuration interface.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogConfig.java,v 1.24 2010/11/28 04:43:31 cvs Exp $
*/
public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
private static final long serialVersionUID = -3728308557871358111L;
@ -105,7 +105,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
}
public void setSplitMessageBeginText(String splitMessageBeginText) throws SyslogRuntimeException {
this.splitMessageBeginText = SyslogUtility.getBytes(this,splitMessageBeginText);
this.splitMessageBeginText = SyslogUtility.getBytes(this, splitMessageBeginText);
}
public byte[] getSplitMessageEndText() {
@ -117,7 +117,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
}
public void setSplitMessageEndText(String splitMessageEndText) throws SyslogRuntimeException {
this.splitMessageEndText = SyslogUtility.getBytes(this,splitMessageEndText);
this.splitMessageEndText = SyslogUtility.getBytes(this, splitMessageEndText);
}
public int getMaxMessageLength() {
@ -179,7 +179,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
List _messageModifiers = _getMessageModifiers();
synchronized(_messageModifiers) {
synchronized (_messageModifiers) {
_messageModifiers.add(messageModifier);
}
}
@ -191,9 +191,9 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
List _messageModifiers = _getMessageModifiers();
synchronized(_messageModifiers) {
synchronized (_messageModifiers) {
try {
_messageModifiers.add(index,messageModifier);
_messageModifiers.add(index, messageModifier);
} catch (IndexOutOfBoundsException ioobe) {
throw new SyslogRuntimeException(ioobe);
@ -208,7 +208,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
List _messageModifiers = _getMessageModifiers();
synchronized(_messageModifiers) {
synchronized (_messageModifiers) {
_messageModifiers.remove(messageModifier);
}
}
@ -244,7 +244,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
List _backLogHandlers = _getBackLogHandlers();
synchronized(_backLogHandlers) {
synchronized (_backLogHandlers) {
backLogHandler.initialize();
_backLogHandlers.add(backLogHandler);
}
@ -257,10 +257,10 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
List _backLogHandlers = _getBackLogHandlers();
synchronized(_backLogHandlers) {
synchronized (_backLogHandlers) {
try {
backLogHandler.initialize();
_backLogHandlers.add(index,backLogHandler);
_backLogHandlers.add(index, backLogHandler);
} catch (IndexOutOfBoundsException ioobe) {
throw new SyslogRuntimeException(ioobe);
@ -275,7 +275,7 @@ public abstract class AbstractSyslogConfig implements AbstractSyslogConfigIF {
List _backLogHandlers = _getBackLogHandlers();
synchronized(_backLogHandlers) {
synchronized (_backLogHandlers) {
_backLogHandlers.remove(backLogHandler);
}
}

View File

@ -5,16 +5,16 @@ import java.util.List;
import org.graylog2.syslog4j.SyslogConfigIF;
/**
* AbstractSyslogConfigIF provides an interface for all Abstract Syslog
* configuration implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogConfigIF.java,v 1.7 2010/10/29 03:14:20 cvs Exp $
*/
* AbstractSyslogConfigIF provides an interface for all Abstract Syslog
* configuration implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogConfigIF.java,v 1.7 2010/10/29 03:14:20 cvs Exp $
*/
public interface AbstractSyslogConfigIF extends SyslogConfigIF {
public Class getSyslogWriterClass();
@ -23,30 +23,39 @@ public interface AbstractSyslogConfigIF extends SyslogConfigIF {
public List getMessageModifiers();
public byte[] getSplitMessageBeginText();
public void setSplitMessageBeginText(byte[] beginText);
public byte[] getSplitMessageEndText();
public void setSplitMessageEndText(byte[] endText);
public boolean isThreaded();
public void setThreaded(boolean threaded);
public boolean isUseDaemonThread();
public void setUseDaemonThread(boolean useDaemonThread);
public int getThreadPriority();
public void setThreadPriority(int threadPriority);
public long getThreadLoopInterval();
public void setThreadLoopInterval(long threadLoopInterval);
public long getMaxShutdownWait();
public void setMaxShutdownWait(long maxShutdownWait);
public int getWriteRetries();
public void setWriteRetries(int writeRetries);
public int getMaxQueueSize();
/**
* Use the (default) value of -1 to allow for a queue of indefinite depth (size).
*

View File

@ -9,19 +9,19 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* AbstractSyslogWriter is an implementation of Runnable that supports sending
* syslog messages within a separate Thread or an object pool.
*
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
* a queuing mechanism is used (via LinkedList).</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogWriter.java,v 1.9 2010/10/25 03:50:25 cvs Exp $
*/
* AbstractSyslogWriter is an implementation of Runnable that supports sending
* syslog messages within a separate Thread or an object pool.
* <p/>
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
* a queuing mechanism is used (via LinkedList).</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogWriter.java,v 1.9 2010/10/25 03:50:25 cvs Exp $
*/
public abstract class AbstractSyslogWriter implements Runnable, Serializable {
private static final long serialVersionUID = 836468466009035847L;
@ -51,12 +51,12 @@ public abstract class AbstractSyslogWriter implements Runnable, Serializable {
}
public void queue(int level, byte[] message) {
synchronized(this.queuedMessages) {
synchronized (this.queuedMessages) {
if (this.syslogConfig.getMaxQueueSize() == -1 || this.queuedMessages.size() < this.syslogConfig.getMaxQueueSize()) {
this.queuedMessages.add(message);
} else {
this.syslog.backLog(level,SyslogUtility.newString(syslogConfig,message),"MaxQueueSize (" + this.syslogConfig.getMaxQueueSize() + ") reached");
this.syslog.backLog(level, SyslogUtility.newString(syslogConfig, message), "MaxQueueSize (" + this.syslogConfig.getMaxQueueSize() + ") reached");
}
}
}
@ -78,16 +78,16 @@ public abstract class AbstractSyslogWriter implements Runnable, Serializable {
protected abstract void runCompleted();
public void run() {
while(!this.shutdown || !this.queuedMessages.isEmpty()) {
while (!this.shutdown || !this.queuedMessages.isEmpty()) {
List queuedMessagesCopy = null;
synchronized(this.queuedMessages) {
synchronized (this.queuedMessages) {
queuedMessagesCopy = new LinkedList(this.queuedMessages);
this.queuedMessages.clear();
}
if (queuedMessagesCopy != null) {
while(!queuedMessagesCopy.isEmpty()) {
while (!queuedMessagesCopy.isEmpty()) {
byte[] message = (byte[]) queuedMessagesCopy.remove(0);
try {
@ -96,7 +96,7 @@ public abstract class AbstractSyslogWriter implements Runnable, Serializable {
this.syslog.setBackLogStatus(false);
} catch (SyslogRuntimeException sre) {
this.syslog.backLog(SyslogConstants.LEVEL_INFO,SyslogUtility.newString(this.syslog.getConfig(),message),sre);
this.syslog.backLog(SyslogConstants.LEVEL_INFO, SyslogUtility.newString(this.syslog.getConfig(), message), sre);
}
}
}

View File

@ -5,17 +5,17 @@ import org.graylog2.syslog4j.SyslogIF;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* AbstractSyslogBackLogHandler is an implementation of SyslogBackLogHandlerIF
* that mainly provides the helpful "combine" method for handling the "reason"
* why a BackLog has occurred.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogBackLogHandler.java,v 1.1 2009/01/24 22:00:18 cvs Exp $
*/
* AbstractSyslogBackLogHandler is an implementation of SyslogBackLogHandlerIF
* that mainly provides the helpful "combine" method for handling the "reason"
* why a BackLog has occurred.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogBackLogHandler.java,v 1.1 2009/01/24 22:00:18 cvs Exp $
*/
public abstract class AbstractSyslogBackLogHandler implements SyslogBackLogHandlerIF {
protected boolean appendReason = true;

View File

@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogBackLogHandlerIF;
import org.graylog2.syslog4j.SyslogIF;
/**
* NullSyslogBackLogHandler can be used if there's no need for a last-chance
* logging mechanism whenever the Syslog protocol fails.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: NullSyslogBackLogHandler.java,v 1.2 2010/10/25 03:50:25 cvs Exp $
*/
* NullSyslogBackLogHandler can be used if there's no need for a last-chance
* logging mechanism whenever the Syslog protocol fails.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: NullSyslogBackLogHandler.java,v 1.2 2010/10/25 03:50:25 cvs Exp $
*/
public class NullSyslogBackLogHandler implements SyslogBackLogHandlerIF {
public static final NullSyslogBackLogHandler INSTANCE = new NullSyslogBackLogHandler();

View File

@ -6,16 +6,16 @@ import org.graylog2.syslog4j.SyslogIF;
import org.graylog2.syslog4j.SyslogRuntimeException;
/**
* Syslog4jBackLogHandler is used to send Syslog backLog messages to
* another Syslog4j protocol whenever the main Syslog protocol fails.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: Syslog4jBackLogHandler.java,v 1.1 2009/07/25 18:42:47 cvs Exp $
*/
* Syslog4jBackLogHandler is used to send Syslog backLog messages to
* another Syslog4j protocol whenever the main Syslog protocol fails.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: Syslog4jBackLogHandler.java,v 1.1 2009/07/25 18:42:47 cvs Exp $
*/
public class Syslog4jBackLogHandler extends AbstractSyslogBackLogHandler {
protected SyslogIF syslog = null;
protected int downLevel = SyslogConstants.LEVEL_WARN;
@ -48,20 +48,20 @@ public class Syslog4jBackLogHandler extends AbstractSyslogBackLogHandler {
throw new SyslogRuntimeException("Ignoring this log entry since the backLog protocol \"" + this.syslog.getProtocol() + "\" is the same as the main protocol");
}
String combinedMessage = combine(syslog,level,message,reason);
String combinedMessage = combine(syslog, level, message, reason);
this.syslog.log(level,combinedMessage);
this.syslog.log(level, combinedMessage);
}
public void down(SyslogIF syslog, String reason) {
if (!this.syslog.getProtocol().equals(syslog.getProtocol())) {
this.syslog.log(this.downLevel,"Syslog protocol \"" + syslog.getProtocol() + "\" is down: " + reason);
this.syslog.log(this.downLevel, "Syslog protocol \"" + syslog.getProtocol() + "\" is down: " + reason);
}
}
public void up(SyslogIF syslog) {
if (!this.syslog.getProtocol().equals(syslog.getProtocol())) {
this.syslog.log(this.downLevel,"Syslog protocol \"" + syslog.getProtocol() + "\" is up");
this.syslog.log(this.downLevel, "Syslog protocol \"" + syslog.getProtocol() + "\" is up");
}
}
}

View File

@ -9,16 +9,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
import org.graylog2.syslog4j.impl.backlog.AbstractSyslogBackLogHandler;
/**
* Log4jSyslogBackLogHandler is used to send Syslog backLog messages to
* Log4j whenever the Syslog protocol fails.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: Log4jSyslogBackLogHandler.java,v 1.2 2009/07/22 15:54:23 cvs Exp $
*/
* Log4jSyslogBackLogHandler is used to send Syslog backLog messages to
* Log4j whenever the Syslog protocol fails.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: Log4jSyslogBackLogHandler.java,v 1.2 2009/07/22 15:54:23 cvs Exp $
*/
public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
protected Logger logger = null;
protected Level downLevel = Level.WARN;
@ -88,7 +88,7 @@ public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
throw new SyslogRuntimeException("loggerFactory cannot be null");
}
this.logger = Logger.getLogger(loggerName,loggerFactory);
this.logger = Logger.getLogger(loggerName, loggerFactory);
initialize();
}
@ -102,7 +102,7 @@ public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
throw new SyslogRuntimeException("loggerFactory cannot be null");
}
this.logger = Logger.getLogger(loggerName,loggerFactory);
this.logger = Logger.getLogger(loggerName, loggerFactory);
this.appendReason = appendReason;
initialize();
@ -115,15 +115,23 @@ public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
}
protected static Level getLog4jLevel(int level) {
switch(level) {
case SyslogConstants.LEVEL_DEBUG: return Level.DEBUG;
case SyslogConstants.LEVEL_INFO: return Level.INFO;
case SyslogConstants.LEVEL_NOTICE: return Level.INFO;
case SyslogConstants.LEVEL_WARN: return Level.WARN;
case SyslogConstants.LEVEL_ERROR: return Level.ERROR;
case SyslogConstants.LEVEL_CRITICAL: return Level.ERROR;
case SyslogConstants.LEVEL_ALERT: return Level.ERROR;
case SyslogConstants.LEVEL_EMERGENCY: return Level.FATAL;
switch (level) {
case SyslogConstants.LEVEL_DEBUG:
return Level.DEBUG;
case SyslogConstants.LEVEL_INFO:
return Level.INFO;
case SyslogConstants.LEVEL_NOTICE:
return Level.INFO;
case SyslogConstants.LEVEL_WARN:
return Level.WARN;
case SyslogConstants.LEVEL_ERROR:
return Level.ERROR;
case SyslogConstants.LEVEL_CRITICAL:
return Level.ERROR;
case SyslogConstants.LEVEL_ALERT:
return Level.ERROR;
case SyslogConstants.LEVEL_EMERGENCY:
return Level.FATAL;
default:
return Level.WARN;
@ -131,18 +139,18 @@ public class Log4jSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
}
public void down(SyslogIF syslog, String reason) {
this.logger.log(this.downLevel,"Syslog protocol \"" + syslog.getProtocol() + "\" is down: " + reason);
this.logger.log(this.downLevel, "Syslog protocol \"" + syslog.getProtocol() + "\" is down: " + reason);
}
public void up(SyslogIF syslog) {
this.logger.log(this.upLevel,"Syslog protocol \"" + syslog.getProtocol() + "\" is up");
this.logger.log(this.upLevel, "Syslog protocol \"" + syslog.getProtocol() + "\" is up");
}
public void log(SyslogIF syslog, int level, String message, String reason) throws SyslogRuntimeException {
Level log4jLevel = getLog4jLevel(level);
String combinedMessage = combine(syslog,level,message,reason);
String combinedMessage = combine(syslog, level, message, reason);
this.logger.log(log4jLevel,combinedMessage);
this.logger.log(log4jLevel, combinedMessage);
}
}

View File

@ -7,16 +7,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
import org.graylog2.syslog4j.impl.backlog.AbstractSyslogBackLogHandler;
/**
* PrintStreamSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
* (for whatever reason) within the rest of Syslog to a PrintStream.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PrintStreamSyslogBackLogHandler.java,v 1.1 2009/01/24 22:00:18 cvs Exp $
*/
* PrintStreamSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
* (for whatever reason) within the rest of Syslog to a PrintStream.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PrintStreamSyslogBackLogHandler.java,v 1.1 2009/01/24 22:00:18 cvs Exp $
*/
public class PrintStreamSyslogBackLogHandler extends AbstractSyslogBackLogHandler {
protected PrintStream printStream = null;
protected boolean appendLinefeed = false;
@ -57,7 +57,7 @@ public class PrintStreamSyslogBackLogHandler extends AbstractSyslogBackLogHandle
}
public void log(SyslogIF syslog, int level, String message, String reason) {
String combinedMessage = combine(syslog,level,message,reason);
String combinedMessage = combine(syslog, level, message, reason);
if (this.appendLinefeed) {
this.printStream.println(combinedMessage);

View File

@ -3,25 +3,26 @@ package org.graylog2.syslog4j.impl.backlog.printstream;
import org.graylog2.syslog4j.SyslogBackLogHandlerIF;
/**
* SystemErrSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
* (for whatever reason) within the rest of Syslog to System.err.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SystemErrSyslogBackLogHandler.java,v 1.2 2009/03/29 17:38:59 cvs Exp $
*/
* SystemErrSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
* (for whatever reason) within the rest of Syslog to System.err.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SystemErrSyslogBackLogHandler.java,v 1.2 2009/03/29 17:38:59 cvs Exp $
*/
public class SystemErrSyslogBackLogHandler extends PrintStreamSyslogBackLogHandler {
public static final SyslogBackLogHandlerIF create() {
return new SystemErrSyslogBackLogHandler();
}
public SystemErrSyslogBackLogHandler() {
super(System.err,true);
super(System.err, true);
}
public SystemErrSyslogBackLogHandler(boolean appendReason) {
super(System.err,true,appendReason);
super(System.err, true, appendReason);
}
}

View File

@ -3,25 +3,26 @@ package org.graylog2.syslog4j.impl.backlog.printstream;
import org.graylog2.syslog4j.SyslogBackLogHandlerIF;
/**
* SystemOutSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
* (for whatever reason) within the rest of Syslog to System.out.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SystemOutSyslogBackLogHandler.java,v 1.2 2009/03/29 17:38:59 cvs Exp $
*/
* SystemOutSyslogBackLogHandler provides a last-chance mechanism to log messages that fail
* (for whatever reason) within the rest of Syslog to System.out.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SystemOutSyslogBackLogHandler.java,v 1.2 2009/03/29 17:38:59 cvs Exp $
*/
public class SystemOutSyslogBackLogHandler extends PrintStreamSyslogBackLogHandler {
public static final SyslogBackLogHandlerIF create() {
return new SystemOutSyslogBackLogHandler();
}
public SystemOutSyslogBackLogHandler() {
super(System.out,true);
super(System.out, true);
}
public SystemOutSyslogBackLogHandler(boolean appendReason) {
super(System.out,true,appendReason);
super(System.out, true, appendReason);
}
}

View File

@ -4,26 +4,26 @@ import org.apache.log4j.helpers.LogLog;
/**
* Syslog4jAppender provides a Log4j Appender wrapper for Syslog4j.
*
* <p/>
* <p>Note: Syslog4jAppender does NOT extend Log4j's SyslogAppender.</p>
*
* <p/>
* <p>Example log4j.xml configuration:</p>
*
* <p/>
* <pre>
* <code>
&lt;appender name="Syslog4j" class="org.graylog2.syslog4j.impl.log4j.Syslog4jAppender"&gt;
&lt;param name="Facility" value="user"/&gt;
&lt;param name="Protocol" value="tcp"/&gt;
&lt;param name="Host" value="192.168.0.1"/&gt;
&lt;layout class="org.apache.log4j.PatternLayout"&gt;
&lt;param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m"/&gt;
&lt;/layout&gt;
&lt;/appender&gt;
* &lt;appender name="Syslog4j" class="org.graylog2.syslog4j.impl.log4j.Syslog4jAppender"&gt;
* &lt;param name="Facility" value="user"/&gt;
* &lt;param name="Protocol" value="tcp"/&gt;
* &lt;param name="Host" value="192.168.0.1"/&gt;
* &lt;layout class="org.apache.log4j.PatternLayout"&gt;
* &lt;param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m"/&gt;
* &lt;/layout&gt;
* &lt;/appender&gt;
* </code>
* </pre>
*
* <p/>
* <p>All available parameters are:</p>
*
* <p/>
* <ul>
* <li>ident</li>
* <li>localName</li>
@ -42,7 +42,7 @@ import org.apache.log4j.helpers.LogLog;
* <li>truncateMessage</li>
* <li>useStructuredData</li>
* </ul>
*
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>

View File

@ -12,10 +12,10 @@ import org.graylog2.syslog4j.util.SyslogUtility;
/**
* Syslog4jAppenderSkeleton provides an extensible Log4j Appender wrapper for Syslog4j.
*
* <p/>
* <p>Classes which inherit Syslog4jAppenderSkeleton must implement the "initialize()" method,
* which sets up Syslog4j for use by the Log4j Appender.</p>
*
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
@ -134,11 +134,11 @@ public abstract class Syslog4jAppenderSkeleton extends AppenderSkeleton implemen
}
if (this.splitMessageBeginText != null) {
abstractSyslogConfig.setSplitMessageBeginText(SyslogUtility.getBytes(abstractSyslogConfig,this.splitMessageBeginText));
abstractSyslogConfig.setSplitMessageBeginText(SyslogUtility.getBytes(abstractSyslogConfig, this.splitMessageBeginText));
}
if (this.splitMessageEndText != null) {
abstractSyslogConfig.setSplitMessageEndText(SyslogUtility.getBytes(abstractSyslogConfig,this.splitMessageEndText));
abstractSyslogConfig.setSplitMessageEndText(SyslogUtility.getBytes(abstractSyslogConfig, this.splitMessageEndText));
}
if (this.maxShutdownWait != null && this.maxShutdownWait.length() > 0) {
@ -189,12 +189,12 @@ public abstract class Syslog4jAppenderSkeleton extends AppenderSkeleton implemen
if (this.layout != null) {
String message = this.layout.format(event);
this.syslog.log(level,message);
this.syslog.log(level, message);
} else {
String message = event.getRenderedMessage();
this.syslog.log(level,message);
this.syslog.log(level, message);
}
}
}

View File

@ -8,20 +8,20 @@ import java.util.Date;
import org.graylog2.syslog4j.SyslogMessageIF;
/**
* AbstractSyslogMessage provides support for turning POJO (Plain Ol'
* Java Objects) into Syslog messages.
*
* <p>More information on the PCI DSS specification is available here:</p>
*
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogMessage.java,v 1.2 2009/04/17 02:37:04 cvs Exp $
*/
* AbstractSyslogMessage provides support for turning POJO (Plain Ol'
* Java Objects) into Syslog messages.
* <p/>
* <p>More information on the PCI DSS specification is available here:</p>
* <p/>
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogMessage.java,v 1.2 2009/04/17 02:37:04 cvs Exp $
*/
public abstract class AbstractSyslogMessage implements SyslogMessageIF {
private static final long serialVersionUID = 414124277626756491L;

View File

@ -13,7 +13,7 @@ public abstract class AbstractSyslogMessageModifier implements SyslogMessageModi
}
public String[] parseInlineModifier(String message) {
return parseInlineModifier(message,this.messageModifierConfig.getPrefix(),this.messageModifierConfig.getSuffix());
return parseInlineModifier(message, this.messageModifierConfig.getPrefix(), this.messageModifierConfig.getSuffix());
}
public static String[] parseInlineModifier(String message, String prefix, String suffix) {
@ -31,17 +31,17 @@ public abstract class AbstractSyslogMessageModifier implements SyslogMessageModi
int pi = message.lastIndexOf(prefix);
if (pi > -1) {
messageAndModifier = new String[] { message.substring(0,pi), message.substring(pi+prefix.length()) };
messageAndModifier = new String[]{message.substring(0, pi), message.substring(pi + prefix.length())};
}
} else {
int si = message.lastIndexOf(suffix);
if (si > -1) {
int pi = message.lastIndexOf(prefix,si);
int pi = message.lastIndexOf(prefix, si);
if (pi > -1) {
messageAndModifier = new String[] { message.substring(0,pi), message.substring(pi+prefix.length(),si) };
messageAndModifier = new String[]{message.substring(0, pi), message.substring(pi + prefix.length(), si)};
}
}
}
@ -58,6 +58,6 @@ public abstract class AbstractSyslogMessageModifier implements SyslogMessageModi
return false;
}
return verify(messageAndModifier[0],messageAndModifier[1]);
return verify(messageAndModifier[0], messageAndModifier[1]);
}
}

View File

@ -5,16 +5,16 @@ import org.graylog2.syslog4j.SyslogConstants;
import org.graylog2.syslog4j.SyslogMessageModifierConfigIF;
/**
* AbstractSyslogMessageModifierConfig provides a base abstract implementation of the
* SyslogMessageModifierConfigIF.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogMessageModifierConfig.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
*/
* AbstractSyslogMessageModifierConfig provides a base abstract implementation of the
* SyslogMessageModifierConfigIF.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogMessageModifierConfig.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
*/
public abstract class AbstractSyslogMessageModifierConfig implements SyslogMessageModifierConfigIF, SyslogCharSetIF {
private static final long serialVersionUID = 5036574188079124884L;

View File

@ -6,16 +6,16 @@ import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifier
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* ChecksumSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for Java Checksum algorithms (java.util.zip.Checksum).
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: ChecksumSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
* ChecksumSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for Java Checksum algorithms (java.util.zip.Checksum).
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: ChecksumSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
public class ChecksumSyslogMessageModifier extends AbstractSyslogMessageModifier {
private static final long serialVersionUID = -3268914290497005065L;
@ -26,6 +26,7 @@ public class ChecksumSyslogMessageModifier extends AbstractSyslogMessageModifier
return crc32;
}
public static final ChecksumSyslogMessageModifier createADLER32() {
ChecksumSyslogMessageModifier adler32 = new ChecksumSyslogMessageModifier(ChecksumSyslogMessageModifierConfig.createADLER32());
@ -60,36 +61,36 @@ public class ChecksumSyslogMessageModifier extends AbstractSyslogMessageModifier
public boolean verify(String message, String hexChecksum) {
continuousCheckForVerify();
long checksum = Long.parseLong(hexChecksum,16);
long checksum = Long.parseLong(hexChecksum, 16);
return verify(message,checksum);
return verify(message, checksum);
}
public boolean verify(String message, long checksum) {
continuousCheckForVerify();
synchronized(this.config.getChecksum()) {
synchronized (this.config.getChecksum()) {
this.config.getChecksum().reset();
byte[] messageBytes = SyslogUtility.getBytes(this.config,message);
byte[] messageBytes = SyslogUtility.getBytes(this.config, message);
this.config.getChecksum().update(messageBytes,0,message.length());
this.config.getChecksum().update(messageBytes, 0, message.length());
return this.config.getChecksum().getValue() == checksum;
}
}
public String modify(SyslogIF syslog, int facility, int level, String message) {
synchronized(this.config.getChecksum()) {
synchronized (this.config.getChecksum()) {
StringBuffer messageBuffer = new StringBuffer(message);
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(),message);
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(), message);
if (!this.config.isContinuous()) {
this.config.getChecksum().reset();
}
this.config.getChecksum().update(messageBytes,0,message.length());
this.config.getChecksum().update(messageBytes, 0, message.length());
messageBuffer.append(this.config.getPrefix());
messageBuffer.append(Long.toHexString(this.config.getChecksum().getValue()).toUpperCase());

View File

@ -7,16 +7,16 @@ import java.util.zip.Checksum;
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
/**
* ChecksumSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
* that provides configuration for ChecksumSyslogMessageModifier.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: ChecksumSyslogMessageModifierConfig.java,v 1.2 2010/02/04 03:41:38 cvs Exp $
*/
* ChecksumSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
* that provides configuration for ChecksumSyslogMessageModifier.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: ChecksumSyslogMessageModifierConfig.java,v 1.2 2010/02/04 03:41:38 cvs Exp $
*/
public class ChecksumSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
private static final long serialVersionUID = -8298600135683882489L;

View File

@ -4,19 +4,19 @@ import org.graylog2.syslog4j.SyslogIF;
import org.graylog2.syslog4j.SyslogMessageModifierIF;
/**
* HTMLEntityEscapeSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that safely escapes HTML entity characters.
*
* <p>This modifier is useful for applications that display log content in browsers without
* properly escaping HTML characters.</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: HTMLEntityEscapeSyslogMessageModifier.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
*/
* HTMLEntityEscapeSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that safely escapes HTML entity characters.
* <p/>
* <p>This modifier is useful for applications that display log content in browsers without
* properly escaping HTML characters.</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: HTMLEntityEscapeSyslogMessageModifier.java,v 1.4 2010/10/28 05:10:57 cvs Exp $
*/
public class HTMLEntityEscapeSyslogMessageModifier implements SyslogMessageModifierIF {
private static final long serialVersionUID = -8481773209240762293L;

View File

@ -11,16 +11,16 @@ import org.graylog2.syslog4j.util.Base64;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* HashSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for Java Cryptographic hashes (MD5, SHA1, SHA256, etc.).
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: HashSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
* HashSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for Java Cryptographic hashes (MD5, SHA1, SHA256, etc.).
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: HashSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
private static final long serialVersionUID = 7335757344826206953L;
@ -76,7 +76,7 @@ public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
try {
MessageDigest.getInstance(config.getHashAlgorithm());
} catch (NoSuchAlgorithmException nsae){
} catch (NoSuchAlgorithmException nsae) {
throw new SyslogRuntimeException(nsae);
}
}
@ -99,12 +99,12 @@ public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
}
public String modify(SyslogIF syslog, int facility, int level, String message) {
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(),message);
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(), message);
MessageDigest digest = obtainMessageDigest();
byte[] digestBytes = digest.digest(messageBytes);
String digestString = Base64.encodeBytes(digestBytes,Base64.DONT_BREAK_LINES);
String digestString = Base64.encodeBytes(digestBytes, Base64.DONT_BREAK_LINES);
StringBuffer buffer = new StringBuffer(message);
@ -118,15 +118,15 @@ public class HashSyslogMessageModifier extends AbstractSyslogMessageModifier {
public boolean verify(String message, String base64Hash) {
byte[] hash = Base64.decode(base64Hash);
return verify(message,hash);
return verify(message, hash);
}
public boolean verify(String message, byte[] hash) {
byte[] messageBytes = SyslogUtility.getBytes(this.config,message);
byte[] messageBytes = SyslogUtility.getBytes(this.config, message);
MessageDigest digest = obtainMessageDigest();
byte[] digestBytes = digest.digest(messageBytes);
return Arrays.equals(digestBytes,hash);
return Arrays.equals(digestBytes, hash);
}
}

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.message.modifier.hash;
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
/**
* HashSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
* that provides configuration for HashSyslogMessageModifier.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: HashSyslogMessageModifierConfig.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
*/
* HashSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
* that provides configuration for HashSyslogMessageModifier.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: HashSyslogMessageModifierConfig.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
*/
public class HashSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
private static final long serialVersionUID = -3148300281439874231L;

View File

@ -14,16 +14,16 @@ import org.graylog2.syslog4j.util.Base64;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* MacSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for Java Cryptographic signed hashes (HmacSHA1, etc.)
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: MacSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
* MacSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for Java Cryptographic signed hashes (HmacSHA1, etc.)
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: MacSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
public class MacSyslogMessageModifier extends AbstractSyslogMessageModifier {
private static final long serialVersionUID = 5054979194802197540L;
@ -85,14 +85,14 @@ public class MacSyslogMessageModifier extends AbstractSyslogMessageModifier {
}
public String modify(SyslogIF syslog, int facility, int level, String message) {
synchronized(this.mac) {
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(),message);
synchronized (this.mac) {
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(), message);
StringBuffer buffer = new StringBuffer(message);
byte[] macBytes = this.mac.doFinal(messageBytes);
String macString = Base64.encodeBytes(macBytes,Base64.DONT_BREAK_LINES);
String macString = Base64.encodeBytes(macBytes, Base64.DONT_BREAK_LINES);
buffer.append(this.config.getPrefix());
buffer.append(macString);
@ -105,16 +105,16 @@ public class MacSyslogMessageModifier extends AbstractSyslogMessageModifier {
public boolean verify(String message, String base64Signature) {
byte[] signature = Base64.decode(base64Signature);
return verify(message,signature);
return verify(message, signature);
}
public boolean verify(String message, byte[] signature) {
synchronized(this.mac) {
byte[] messageBytes = SyslogUtility.getBytes(this.config,message);
synchronized (this.mac) {
byte[] messageBytes = SyslogUtility.getBytes(this.config, message);
byte[] macBytes = this.mac.doFinal(messageBytes);
return Arrays.equals(macBytes,signature);
return Arrays.equals(macBytes, signature);
}
}
}

View File

@ -9,16 +9,16 @@ import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifier
import org.graylog2.syslog4j.util.Base64;
/**
* MacSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
* that provides configuration for HashSyslogMessageModifier.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: MacSyslogMessageModifierConfig.java,v 1.3 2009/04/17 02:37:04 cvs Exp $
*/
* MacSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
* that provides configuration for HashSyslogMessageModifier.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: MacSyslogMessageModifierConfig.java,v 1.3 2009/04/17 02:37:04 cvs Exp $
*/
public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
private static final long serialVersionUID = 4524180892377960695L;
@ -37,7 +37,7 @@ public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifie
this.keyAlgorithm = keyAlgorithm;
try {
this.key = new SecretKeySpec(keyBytes,keyAlgorithm);
this.key = new SecretKeySpec(keyBytes, keyAlgorithm);
} catch (IllegalArgumentException iae) {
throw new SyslogRuntimeException(iae);
@ -51,7 +51,7 @@ public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifie
byte[] keyBytes = Base64.decode(base64Key);
try {
this.key = new SecretKeySpec(keyBytes,keyAlgorithm);
this.key = new SecretKeySpec(keyBytes, keyAlgorithm);
} catch (IllegalArgumentException iae) {
throw new SyslogRuntimeException(iae);
@ -59,35 +59,35 @@ public class MacSyslogMessageModifierConfig extends AbstractSyslogMessageModifie
}
public static MacSyslogMessageModifierConfig createHmacSHA1(Key key) {
return new MacSyslogMessageModifierConfig("HmacSHA1","SHA1",key);
return new MacSyslogMessageModifierConfig("HmacSHA1", "SHA1", key);
}
public static MacSyslogMessageModifierConfig createHmacSHA1(String base64Key) {
return new MacSyslogMessageModifierConfig("HmacSHA1","SHA1",base64Key);
return new MacSyslogMessageModifierConfig("HmacSHA1", "SHA1", base64Key);
}
public static MacSyslogMessageModifierConfig createHmacSHA256(Key key) {
return new MacSyslogMessageModifierConfig("HmacSHA256","SHA-256",key);
return new MacSyslogMessageModifierConfig("HmacSHA256", "SHA-256", key);
}
public static MacSyslogMessageModifierConfig createHmacSHA256(String base64Key) {
return new MacSyslogMessageModifierConfig("HmacSHA256","SHA-256",base64Key);
return new MacSyslogMessageModifierConfig("HmacSHA256", "SHA-256", base64Key);
}
public static MacSyslogMessageModifierConfig createHmacSHA512(Key key) {
return new MacSyslogMessageModifierConfig("HmacSHA512","SHA-512",key);
return new MacSyslogMessageModifierConfig("HmacSHA512", "SHA-512", key);
}
public static MacSyslogMessageModifierConfig createHmacSHA512(String base64Key) {
return new MacSyslogMessageModifierConfig("HmacSHA512","SHA-512",base64Key);
return new MacSyslogMessageModifierConfig("HmacSHA512", "SHA-512", base64Key);
}
public static MacSyslogMessageModifierConfig createHmacMD5(Key key) {
return new MacSyslogMessageModifierConfig("HmacMD5","MD5",key);
return new MacSyslogMessageModifierConfig("HmacMD5", "MD5", key);
}
public static MacSyslogMessageModifierConfig createHmacMD5(String base64Key) {
return new MacSyslogMessageModifierConfig("HmacMD5","MD5",base64Key);
return new MacSyslogMessageModifierConfig("HmacMD5", "MD5", base64Key);
}
public String getMacAlgorithm() {

View File

@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogIF;
import org.graylog2.syslog4j.SyslogMessageModifierIF;
/**
* SequentialSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that adds an incremented number at the end.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SequentialSyslogMessageModifier.java,v 1.8 2010/11/28 04:43:31 cvs Exp $
*/
* SequentialSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that adds an incremented number at the end.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SequentialSyslogMessageModifier.java,v 1.8 2010/11/28 04:43:31 cvs Exp $
*/
public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF {
private static final long serialVersionUID = 6107735010240030785L;
@ -30,7 +30,7 @@ public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF
public SequentialSyslogMessageModifier(SequentialSyslogMessageModifierConfig config) {
this.config = config;
for(int i=0; i<(LEVEL_DEBUG + 1); i++) {
for (int i = 0; i < (LEVEL_DEBUG + 1); i++) {
this.currentSequence[i] = config.getFirstNumber();
}
}
@ -39,7 +39,7 @@ public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF
StringBuffer buffer = new StringBuffer(Long.toString(number));
while (buffer.length() < this.config.getLastNumberDigits()) {
buffer.insert(0,this.config.getPadChar());
buffer.insert(0, this.config.getPadChar());
}
return buffer.toString();
@ -47,7 +47,7 @@ public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF
public void setNextSequence(int level, long nextSequence) {
if (nextSequence >= this.config.getFirstNumber() && nextSequence < this.config.getLastNumber()) {
synchronized(this) {
synchronized (this) {
this.currentSequence[level] = nextSequence;
}
}
@ -56,7 +56,7 @@ public class SequentialSyslogMessageModifier implements SyslogMessageModifierIF
protected String nextSequence(int level) {
long sequence = -1;
synchronized(this) {
synchronized (this) {
sequence = this.currentSequence[level];
if (this.currentSequence[level] >= this.config.getLastNumber()) {

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.message.modifier.sequential;
import org.graylog2.syslog4j.impl.message.modifier.AbstractSyslogMessageModifierConfig;
/**
* SequentialSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
* that provides configuration for SequentialSyslogMessageModifier.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SequentialSyslogMessageModifierConfig.java,v 1.4 2009/03/29 17:38:58 cvs Exp $
*/
* SequentialSyslogMessageModifierConfig is an implementation of AbstractSyslogMessageModifierConfig
* that provides configuration for SequentialSyslogMessageModifier.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SequentialSyslogMessageModifierConfig.java,v 1.4 2009/03/29 17:38:58 cvs Exp $
*/
public class SequentialSyslogMessageModifierConfig extends AbstractSyslogMessageModifierConfig {
private static final long serialVersionUID = 1570930406228960303L;

View File

@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogIF;
import org.graylog2.syslog4j.SyslogMessageModifierIF;
/**
* PrefixSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for adding static text to the beginning of a Syslog message.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PrefixSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
* PrefixSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for adding static text to the beginning of a Syslog message.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PrefixSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
public class PrefixSyslogMessageModifier implements SyslogMessageModifierIF {
private static final long serialVersionUID = 6718826215583513972L;

View File

@ -5,17 +5,17 @@ import org.graylog2.syslog4j.SyslogMessageModifierIF;
import org.graylog2.syslog4j.SyslogRuntimeException;
/**
* StringCaseSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for shifting a Syslog message to all upper case or all
* lower case.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: StringCaseSyslogMessageModifier.java,v 1.3 2010/10/28 05:10:57 cvs Exp $
*/
* StringCaseSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for shifting a Syslog message to all upper case or all
* lower case.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: StringCaseSyslogMessageModifier.java,v 1.3 2010/10/28 05:10:57 cvs Exp $
*/
public class StringCaseSyslogMessageModifier implements SyslogMessageModifierIF {
private static final long serialVersionUID = 8383234811585957460L;

View File

@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogIF;
import org.graylog2.syslog4j.SyslogMessageModifierIF;
/**
* SuffixSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for adding static text to the end of a Syslog message.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SuffixSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
* SuffixSyslogMessageModifier is an implementation of SyslogMessageModifierIF
* that provides support for adding static text to the end of a Syslog message.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SuffixSyslogMessageModifier.java,v 1.5 2010/10/28 05:10:57 cvs Exp $
*/
public class SuffixSyslogMessageModifier implements SyslogMessageModifierIF {
private static final long serialVersionUID = 7160593302741507576L;

View File

@ -6,23 +6,23 @@ import java.util.Map;
import org.graylog2.syslog4j.impl.message.AbstractSyslogMessage;
/**
* PCISyslogMessage provides support for audit trails defined by section
* 10.3 of the PCI Data Security Standard (PCI DSS) versions 1.1 and 1.2.
*
* <p>More information on the PCI DSS specification is available here:</p>
*
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
*
* <p>The PCI DSS specification is Copyright 2008 PCI Security Standards
* Council LLC.</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PCISyslogMessage.java,v 1.3 2008/11/14 04:32:00 cvs Exp $
*/
* PCISyslogMessage provides support for audit trails defined by section
* 10.3 of the PCI Data Security Standard (PCI DSS) versions 1.1 and 1.2.
* <p/>
* <p>More information on the PCI DSS specification is available here:</p>
* <p/>
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
* <p/>
* <p>The PCI DSS specification is Copyright 2008 PCI Security Standards
* Council LLC.</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PCISyslogMessage.java,v 1.3 2008/11/14 04:32:00 cvs Exp $
*/
public class PCISyslogMessage extends AbstractSyslogMessage implements PCISyslogMessageIF {
private static final long serialVersionUID = 3571696218386879119L;
@ -65,14 +65,38 @@ public class PCISyslogMessage extends AbstractSyslogMessage implements PCISyslog
}
protected void init(Map fields) {
if (fields.containsKey(USER_ID)) { this.userId = (String) fields.get(USER_ID); };
if (fields.containsKey(EVENT_TYPE)) { this.eventType = (String) fields.get(EVENT_TYPE); };
if (fields.containsKey(DATE) && fields.get(DATE) instanceof String) { this.date = (String) fields.get(DATE); };
if (fields.containsKey(DATE) && fields.get(DATE) instanceof Date) { setDate((Date) fields.get(DATE)); };
if (fields.containsKey(TIME)) { this.time = (String) fields.get(TIME); };
if (fields.containsKey(STATUS)) { this.status = (String) fields.get(STATUS); };
if (fields.containsKey(ORIGINATION)) { this.origination = (String) fields.get(ORIGINATION); };
if (fields.containsKey(AFFECTED_RESOURCE)) { this.affectedResource = (String) fields.get(AFFECTED_RESOURCE); };
if (fields.containsKey(USER_ID)) {
this.userId = (String) fields.get(USER_ID);
}
;
if (fields.containsKey(EVENT_TYPE)) {
this.eventType = (String) fields.get(EVENT_TYPE);
}
;
if (fields.containsKey(DATE) && fields.get(DATE) instanceof String) {
this.date = (String) fields.get(DATE);
}
;
if (fields.containsKey(DATE) && fields.get(DATE) instanceof Date) {
setDate((Date) fields.get(DATE));
}
;
if (fields.containsKey(TIME)) {
this.time = (String) fields.get(TIME);
}
;
if (fields.containsKey(STATUS)) {
this.status = (String) fields.get(STATUS);
}
;
if (fields.containsKey(ORIGINATION)) {
this.origination = (String) fields.get(ORIGINATION);
}
;
if (fields.containsKey(AFFECTED_RESOURCE)) {
this.affectedResource = (String) fields.get(AFFECTED_RESOURCE);
}
;
}
public PCISyslogMessage(String userId, String eventType, String status, String affectedResource) {
@ -237,19 +261,19 @@ public class PCISyslogMessage extends AbstractSyslogMessage implements PCISyslog
char delimiter = getDelimiter();
String replaceDelimiter = getReplaceDelimiter();
buffer.append(replaceDelimiter(USER_ID,getUserId(),delimiter,replaceDelimiter));
buffer.append(replaceDelimiter(USER_ID, getUserId(), delimiter, replaceDelimiter));
buffer.append(delimiter);
buffer.append(replaceDelimiter(EVENT_TYPE,getEventType(),delimiter,replaceDelimiter));
buffer.append(replaceDelimiter(EVENT_TYPE, getEventType(), delimiter, replaceDelimiter));
buffer.append(delimiter);
buffer.append(replaceDelimiter(DATE,getDate(),delimiter,replaceDelimiter));
buffer.append(replaceDelimiter(DATE, getDate(), delimiter, replaceDelimiter));
buffer.append(delimiter);
buffer.append(replaceDelimiter(TIME,getTime(),delimiter,replaceDelimiter));
buffer.append(replaceDelimiter(TIME, getTime(), delimiter, replaceDelimiter));
buffer.append(delimiter);
buffer.append(replaceDelimiter(STATUS,getStatus(),delimiter,replaceDelimiter));
buffer.append(replaceDelimiter(STATUS, getStatus(), delimiter, replaceDelimiter));
buffer.append(delimiter);
buffer.append(replaceDelimiter(ORIGINATION,getOrigination(),delimiter,replaceDelimiter));
buffer.append(replaceDelimiter(ORIGINATION, getOrigination(), delimiter, replaceDelimiter));
buffer.append(delimiter);
buffer.append(replaceDelimiter(AFFECTED_RESOURCE,getAffectedResource(),delimiter,replaceDelimiter));
buffer.append(replaceDelimiter(AFFECTED_RESOURCE, getAffectedResource(), delimiter, replaceDelimiter));
return buffer.toString();
}

View File

@ -1,30 +1,36 @@
package org.graylog2.syslog4j.impl.message.pci;
/**
* PCISyslogMessageIF provides a definition of the fields for audit trails
* defined by section 10.3 of the PCI Data Security Standard (PCI DSS)
* versions 1.1 and 1.2.
*
* <p>More information on the PCI DSS specification is available here:</p>
*
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
*
* <p>The PCI DSS specification is Copyright 2008 PCI Security Standards
* Council LLC.</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PCISyslogMessageIF.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
*/
* PCISyslogMessageIF provides a definition of the fields for audit trails
* defined by section 10.3 of the PCI Data Security Standard (PCI DSS)
* versions 1.1 and 1.2.
* <p/>
* <p>More information on the PCI DSS specification is available here:</p>
* <p/>
* <p>https://www.pcisecuritystandards.org/security_standards/pci_dss.shtml</p>
* <p/>
* <p>The PCI DSS specification is Copyright 2008 PCI Security Standards
* Council LLC.</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PCISyslogMessageIF.java,v 1.1 2008/11/10 04:38:37 cvs Exp $
*/
public interface PCISyslogMessageIF {
public String getUserId();
public String getEventType();
public String getDate();
public String getTime();
public String getStatus();
public String getOrigination();
public String getAffectedResource();
}

View File

@ -9,17 +9,17 @@ import org.graylog2.syslog4j.SyslogMessageProcessorIF;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* AbstractSyslogMessageProcessor provides the ability to split a syslog message
* into multiple messages when the message is greater than the syslog
* maximum message length (1024 bytes including the header).
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogMessageProcessor.java,v 1.2 2010/11/28 04:15:18 cvs Exp $
*/
* AbstractSyslogMessageProcessor provides the ability to split a syslog message
* into multiple messages when the message is greater than the syslog
* maximum message length (1024 bytes including the header).
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogMessageProcessor.java,v 1.2 2010/11/28 04:15:18 cvs Exp $
*/
public abstract class AbstractSyslogMessageProcessor implements SyslogMessageProcessorIF, SyslogConstants {
private static final long serialVersionUID = -5413127301924500938L;
protected String localName = null;
@ -29,7 +29,7 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
}
public byte[] createPacketData(byte[] header, byte[] message, int start, int length) {
return createPacketData(header,message,start,length,null,null);
return createPacketData(header, message, start, length, null, null);
}
public byte[] createPacketData(byte[] header, byte[] message, int start, int length, byte[] splitBeginText, byte[] splitEndText) {
@ -48,19 +48,19 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
byte[] data = new byte[dataLength];
System.arraycopy(header,0,data,0,header.length);
System.arraycopy(header, 0, data, 0, header.length);
int pos = header.length;
if (splitBeginText != null) {
System.arraycopy(splitBeginText,0,data,pos,splitBeginText.length);
System.arraycopy(splitBeginText, 0, data, pos, splitBeginText.length);
pos += splitBeginText.length;
}
System.arraycopy(message,start,data,pos,length);
System.arraycopy(message, start, data, pos, length);
pos += length;
if (splitEndText != null) {
System.arraycopy(splitEndText,0,data,pos,splitEndText.length);
System.arraycopy(splitEndText, 0, data, pos, splitEndText.length);
}
return data;
@ -75,7 +75,7 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
}
protected void appendLocalTimestamp(StringBuffer buffer) {
SimpleDateFormat dateFormat = new SimpleDateFormat(SYSLOG_DATEFORMAT,Locale.ENGLISH);
SimpleDateFormat dateFormat = new SimpleDateFormat(SYSLOG_DATEFORMAT, Locale.ENGLISH);
String datePrefix = dateFormat.format(new Date());
@ -85,7 +85,7 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
// RFC 3164 requires leading space for days 1-9
if (buffer.charAt(pos) == '0') {
buffer.setCharAt(pos,' ');
buffer.setCharAt(pos, ' ');
}
}
@ -103,14 +103,14 @@ public abstract class AbstractSyslogMessageProcessor implements SyslogMessagePro
public String createSyslogHeader(int facility, int level, String localName, boolean sendLocalTimestamp, boolean sendLocalName) {
StringBuffer buffer = new StringBuffer();
appendPriority(buffer,facility,level);
appendPriority(buffer, facility, level);
if (sendLocalTimestamp) {
appendLocalTimestamp(buffer);
}
if (sendLocalName) {
appendLocalName(buffer,localName);
appendLocalName(buffer, localName);
}
return buffer.toString();

View File

@ -2,20 +2,20 @@ package org.graylog2.syslog4j.impl.message.processor;
/**
* SyslogMessageProcessor wraps AbstractSyslogMessageProcessor.
*
* <p>Those wishing to replace (or improve upon) this implementation
* can write a custom SyslogMessageProcessorIF and set it per
* instance via the SyslogIF.setMessageProcessor(..) method or set it globally
* via the SyslogMessageProcessor.setDefault(..) method.</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageProcessor.java,v 1.7 2010/02/04 03:41:37 cvs Exp $
*/
* SyslogMessageProcessor wraps AbstractSyslogMessageProcessor.
* <p/>
* <p>Those wishing to replace (or improve upon) this implementation
* can write a custom SyslogMessageProcessorIF and set it per
* instance via the SyslogIF.setMessageProcessor(..) method or set it globally
* via the SyslogMessageProcessor.setDefault(..) method.</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogMessageProcessor.java,v 1.7 2010/02/04 03:41:37 cvs Exp $
*/
public class SyslogMessageProcessor extends AbstractSyslogMessageProcessor {
private static final long serialVersionUID = -4232803978024990353L;

View File

@ -11,14 +11,14 @@ import org.graylog2.syslog4j.impl.message.structured.StructuredSyslogMessage;
* than the syslog maximum message length (1024 bytes including the header). It
* adds support for structured syslog messages as specified by
* draft-ietf-syslog-protocol-23. More information here:
*
* <p/>
* <p>http://tools.ietf.org/html/draft-ietf-syslog-protocol-23</p>
*
* <p/>
* <p>Those wishing to replace (or improve upon) this implementation
* can write a custom SyslogMessageProcessorIF and set it per
* instance via the SyslogIF.setStructuredMessageProcessor(..) method or set it globally
* via the StructuredSyslogMessageProcessor.setDefault(..) method.</p>
*
* <p/>
* <p>
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
* LGPL license is available in the META-INF folder in all distributions of
@ -87,14 +87,14 @@ public class StructuredSyslogMessageProcessor extends AbstractSyslogMessageProce
public String createSyslogHeader(final int facility, final int level, String localName, final boolean sendLocalTimestamp, final boolean sendLocalName) {
final StringBuffer buffer = new StringBuffer();
appendPriority(buffer,facility,level);
appendPriority(buffer, facility, level);
buffer.append(VERSION);
buffer.append(' ');
getDateTimeFormatter().printTo(buffer,System.currentTimeMillis());
getDateTimeFormatter().printTo(buffer, System.currentTimeMillis());
buffer.append(' ');
appendLocalName(buffer,localName);
appendLocalName(buffer, localName);
buffer.append(StructuredSyslogMessage.nilProtect(this.applicationName))
.append(' ');

View File

@ -13,11 +13,11 @@ import org.graylog2.syslog4j.impl.message.AbstractSyslogMessage;
* support for turning POJO (Plain Ol' Java Objects) into Syslog messages. It
* adds support for structured syslog messages as specified by
* draft-ietf-syslog-protocol-23. More information here:
*
* <p/>
* <p>
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
* </p>
*
* <p/>
* <p>
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
* LGPL license is available in the META-INF folder in all distributions of
@ -43,11 +43,11 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
/**
* Constructs the {@link StructuredSyslogMessage} using MSGID,
* STRUCTURED-DATA and MSG fields, as described in:
*
* <p/>
* <p>
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
* </p>
*
* <p/>
* The Map must be a String -> (Map of String -> String), which encompasses
* the STRUCTURED-DATA field described in above document.
*
@ -68,7 +68,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
private void ensureCorrectMapType() {
if (!(getStructuredData() == null)) {
Set sdEntrySet = getStructuredData().entrySet();
for (Iterator it = sdEntrySet.iterator(); it.hasNext();) {
for (Iterator it = sdEntrySet.iterator(); it.hasNext(); ) {
Map.Entry sdEntry = (Map.Entry) it.next();
if (!(sdEntry.getKey() instanceof String)) {
throw new IllegalArgumentException(
@ -80,7 +80,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
}
Set entrySet = ((Map) sdEntry.getValue()).entrySet();
for (Iterator it2 = entrySet.iterator(); it2.hasNext();) {
for (Iterator it2 = entrySet.iterator(); it2.hasNext(); ) {
Map.Entry entry = (Map.Entry) it2.next();
if (!(entry.getKey() instanceof String)) {
@ -194,7 +194,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
/**
* Returns the MSGID field of the structured message format, as described
* in:
*
* <p/>
* <p>
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
* </p>
@ -208,7 +208,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
/**
* Returns the structured data map. The Map is a String -> (Map of String ->
* String), which encompasses the STRUCTURED-DATA field, as described in:
*
* <p/>
* <p>
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
* </p>
@ -221,7 +221,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
/**
* Returns the MSG field of the structured message format, as described in:
*
* <p/>
* <p>
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
* </p>
@ -260,7 +260,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
sb.append(SyslogConstants.STRUCTURED_DATA_EMPTY_VALUE);
} else {
Set sdEntrySet = getStructuredData().entrySet();
for (Iterator it = sdEntrySet.iterator(); it.hasNext();) {
for (Iterator it = sdEntrySet.iterator(); it.hasNext(); ) {
final Map.Entry sdElement = (Map.Entry) it.next();
final String sdId = (String) sdElement.getKey();
@ -276,7 +276,7 @@ public class StructuredSyslogMessage extends AbstractSyslogMessage implements St
if (sdParams != null) {
Set entrySet = sdParams.entrySet();
for (Iterator it2 = entrySet.iterator(); it2.hasNext();) {
for (Iterator it2 = entrySet.iterator(); it2.hasNext(); ) {
Map.Entry entry = (Map.Entry) it2.next();
final String paramName = (String) entry.getKey();
final String paramValue = (String) entry.getValue();

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.message.structured;
import org.graylog2.syslog4j.SyslogMessageIF;
/**
* StructuredSyslogMessageIF is a "marker" interface to identify structured
* SyslogMessageIF implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: StructuredSyslogMessageIF.java,v 1.1 2009/07/22 15:54:23 cvs Exp $
*/
* StructuredSyslogMessageIF is a "marker" interface to identify structured
* SyslogMessageIF implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: StructuredSyslogMessageIF.java,v 1.1 2009/07/22 15:54:23 cvs Exp $
*/
public interface StructuredSyslogMessageIF extends SyslogMessageIF {
//
}

View File

@ -9,16 +9,16 @@ import org.graylog2.syslog4j.SyslogMessageProcessorIF;
import org.graylog2.syslog4j.SyslogRuntimeException;
/**
* MultipleSyslog is an aggregator Syslog implementation for allowing a single
* Syslog call to send to multiple Syslog implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: MultipleSyslog.java,v 1.10 2010/02/11 05:00:55 cvs Exp $
*/
* MultipleSyslog is an aggregator Syslog implementation for allowing a single
* Syslog call to send to multiple Syslog implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: MultipleSyslog.java,v 1.10 2010/02/11 05:00:55 cvs Exp $
*/
public class MultipleSyslog implements SyslogIF {
private static final long serialVersionUID = 587308197526365108L;
@ -41,91 +41,91 @@ public class MultipleSyslog implements SyslogIF {
}
public void debug(String message) {
log(SyslogConstants.LEVEL_DEBUG,message);
log(SyslogConstants.LEVEL_DEBUG, message);
}
public void debug(SyslogMessageIF message) {
log(SyslogConstants.LEVEL_DEBUG,message);
log(SyslogConstants.LEVEL_DEBUG, message);
}
public void critical(String message) {
log(SyslogConstants.LEVEL_CRITICAL,message);
log(SyslogConstants.LEVEL_CRITICAL, message);
}
public void critical(SyslogMessageIF message) {
log(SyslogConstants.LEVEL_CRITICAL,message);
log(SyslogConstants.LEVEL_CRITICAL, message);
}
public void error(String message) {
log(SyslogConstants.LEVEL_ERROR,message);
log(SyslogConstants.LEVEL_ERROR, message);
}
public void error(SyslogMessageIF message) {
log(SyslogConstants.LEVEL_ERROR,message);
log(SyslogConstants.LEVEL_ERROR, message);
}
public void alert(String message) {
log(SyslogConstants.LEVEL_ALERT,message);
log(SyslogConstants.LEVEL_ALERT, message);
}
public void alert(SyslogMessageIF message) {
log(SyslogConstants.LEVEL_ALERT,message);
log(SyslogConstants.LEVEL_ALERT, message);
}
public void notice(String message) {
log(SyslogConstants.LEVEL_NOTICE,message);
log(SyslogConstants.LEVEL_NOTICE, message);
}
public void notice(SyslogMessageIF message) {
log(SyslogConstants.LEVEL_NOTICE,message);
log(SyslogConstants.LEVEL_NOTICE, message);
}
public void emergency(String message) {
log(SyslogConstants.LEVEL_EMERGENCY,message);
log(SyslogConstants.LEVEL_EMERGENCY, message);
}
public void emergency(SyslogMessageIF message) {
log(SyslogConstants.LEVEL_EMERGENCY,message);
log(SyslogConstants.LEVEL_EMERGENCY, message);
}
public void info(String message) {
log(SyslogConstants.LEVEL_INFO,message);
log(SyslogConstants.LEVEL_INFO, message);
}
public void info(SyslogMessageIF message) {
log(SyslogConstants.LEVEL_INFO,message);
log(SyslogConstants.LEVEL_INFO, message);
}
public void warn(String message) {
log(SyslogConstants.LEVEL_WARN,message);
log(SyslogConstants.LEVEL_WARN, message);
}
public void warn(SyslogMessageIF message) {
log(SyslogConstants.LEVEL_WARN,message);
log(SyslogConstants.LEVEL_WARN, message);
}
public void log(int level, String message) {
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
for (int i = 0; i < this.multipleSyslogConfig.getProtocols().size(); i++) {
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
SyslogIF syslog = Syslog.getInstance(protocol);
syslog.log(level,message);
syslog.log(level, message);
}
}
public void log(int level, SyslogMessageIF message) {
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
for (int i = 0; i < this.multipleSyslogConfig.getProtocols().size(); i++) {
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
SyslogIF syslog = Syslog.getInstance(protocol);
syslog.log(level,message);
syslog.log(level, message);
}
}
public void flush() throws SyslogRuntimeException {
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
for (int i = 0; i < this.multipleSyslogConfig.getProtocols().size(); i++) {
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
SyslogIF syslog = Syslog.getInstance(protocol);
@ -135,7 +135,7 @@ public class MultipleSyslog implements SyslogIF {
}
public void shutdown() throws SyslogRuntimeException {
for(int i=0; i<this.multipleSyslogConfig.getProtocols().size(); i++) {
for (int i = 0; i < this.multipleSyslogConfig.getProtocols().size(); i++) {
String protocol = (String) this.multipleSyslogConfig.getProtocols().get(i);
SyslogIF syslog = Syslog.getInstance(protocol);

View File

@ -10,16 +10,16 @@ import org.graylog2.syslog4j.SyslogMessageModifierIF;
import org.graylog2.syslog4j.SyslogRuntimeException;
/**
* MultipleSyslogConfig is a configuration Object for allowing a single
* Syslog call to send to multiple Syslog implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: MultipleSyslogConfig.java,v 1.8 2010/11/28 04:15:18 cvs Exp $
*/
* MultipleSyslogConfig is a configuration Object for allowing a single
* Syslog call to send to multiple Syslog implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: MultipleSyslogConfig.java,v 1.8 2010/11/28 04:15:18 cvs Exp $
*/
public class MultipleSyslogConfig implements SyslogConfigIF {
private static final long serialVersionUID = 753704522364959612L;
@ -42,7 +42,7 @@ public class MultipleSyslogConfig implements SyslogConfigIF {
if (protocols != null) {
this.syslogProtocols = new ArrayList(protocols.length);
for(int i=0; i<protocols.length; i++) {
for (int i = 0; i < protocols.length; i++) {
this.syslogProtocols.add(protocols[i]);
}
@ -60,7 +60,7 @@ public class MultipleSyslogConfig implements SyslogConfigIF {
}
public void insertProtocol(int index, String protocol) {
this.syslogProtocols.add(index,protocol);
this.syslogProtocols.add(index, protocol);
}
public void removeProtocol(String protocol) {

View File

@ -7,16 +7,16 @@ import org.graylog2.syslog4j.impl.AbstractSyslog;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* AbstractNetSyslog is an abstract extension of AbstractSyslog
* that provides support for network-based syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractNetSyslog.java,v 1.7 2009/01/24 22:00:18 cvs Exp $
*/
* AbstractNetSyslog is an abstract extension of AbstractSyslog
* that provides support for network-based syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractNetSyslog.java,v 1.7 2009/01/24 22:00:18 cvs Exp $
*/
public abstract class AbstractNetSyslog extends AbstractSyslog {
private static final long serialVersionUID = -3250858945515853967L;
@ -43,7 +43,7 @@ public abstract class AbstractNetSyslog extends AbstractSyslog {
if (this.netSyslogConfig.isCacheHostAddress()) {
if (this.cachedHostAddress == null) {
synchronized(cachedHostAddressSyncObject) {
synchronized (cachedHostAddressSyncObject) {
if (this.cachedHostAddress == null) {
this.cachedHostAddress = SyslogUtility.getInetAddress(this.syslogConfig.getHost());
}

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.net;
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
/**
* AbstractNetSyslogConfig is an abstract extension of AbstractSyslogConfig
* that provides configuration support for network-based syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractNetSyslogConfig.java,v 1.12 2010/10/25 03:50:25 cvs Exp $
*/
* AbstractNetSyslogConfig is an abstract extension of AbstractSyslogConfig
* that provides configuration support for network-based syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractNetSyslogConfig.java,v 1.12 2010/10/25 03:50:25 cvs Exp $
*/
public abstract class AbstractNetSyslogConfig extends AbstractSyslogConfig implements AbstractNetSyslogConfigIF {
private static final long serialVersionUID = 7240133962159244924L;

View File

@ -3,17 +3,18 @@ package org.graylog2.syslog4j.impl.net;
import org.graylog2.syslog4j.impl.AbstractSyslogConfigIF;
/**
* AbstractNetSyslogConfigIF is a configuration interface supporting network-based
* Syslog implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractNetSyslogConfigIF.java,v 1.4 2009/06/06 19:11:02 cvs Exp $
*/
* AbstractNetSyslogConfigIF is a configuration interface supporting network-based
* Syslog implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractNetSyslogConfigIF.java,v 1.4 2009/06/06 19:11:02 cvs Exp $
*/
public interface AbstractNetSyslogConfigIF extends AbstractSyslogConfigIF {
public boolean isCacheHostAddress();
public void setCacheHostAddress(boolean cacheHostAddress);
}

View File

@ -5,16 +5,16 @@ import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
import org.graylog2.syslog4j.impl.net.AbstractNetSyslog;
/**
* TCPNetSyslog is an extension of AbstractSyslog that provides support for
* TCP/IP-based syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslog.java,v 1.21 2010/11/28 04:43:31 cvs Exp $
*/
* TCPNetSyslog is an extension of AbstractSyslog that provides support for
* TCP/IP-based syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslog.java,v 1.21 2010/11/28 04:43:31 cvs Exp $
*/
public class TCPNetSyslog extends AbstractNetSyslog {
private static final long serialVersionUID = -2157528355215068721L;
@ -56,10 +56,10 @@ public class TCPNetSyslog extends AbstractNetSyslog {
try {
if (syslogWriter.hasThread()) {
syslogWriter.queue(level,message);
syslogWriter.queue(level, message);
} else {
synchronized(syslogWriter) {
synchronized (syslogWriter) {
syslogWriter.write(message);
}
}

View File

@ -5,16 +5,16 @@ import org.graylog2.syslog4j.impl.net.AbstractNetSyslogConfig;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* TCPNetSyslogConfig is an extension of AbstractNetSyslogConfig that provides
* configuration support for TCP/IP-based syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogConfig.java,v 1.18 2010/10/29 03:14:12 cvs Exp $
*/
* TCPNetSyslogConfig is an extension of AbstractNetSyslogConfig that provides
* configuration support for TCP/IP-based syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogConfig.java,v 1.18 2010/10/29 03:14:12 cvs Exp $
*/
public class TCPNetSyslogConfig extends AbstractNetSyslogConfig implements TCPNetSyslogConfigIF {
private static final long serialVersionUID = 9023152050686365460L;
@ -91,7 +91,7 @@ public class TCPNetSyslogConfig extends AbstractNetSyslogConfig implements TCPNe
}
public void setDelimiterSequence(String delimiterSequence) {
this.delimiterSequence = SyslogUtility.getBytes(this,delimiterSequence);
this.delimiterSequence = SyslogUtility.getBytes(this, delimiterSequence);
}
public boolean isPersistentConnection() {

View File

@ -3,38 +3,46 @@ package org.graylog2.syslog4j.impl.net.tcp;
import org.graylog2.syslog4j.impl.net.AbstractNetSyslogConfigIF;
/**
* TCPNetSyslogConfigIF is a configuration interface supporting TCP/IP-based
* Syslog implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogConfigIF.java,v 1.6 2010/10/29 03:14:12 cvs Exp $
*/
* TCPNetSyslogConfigIF is a configuration interface supporting TCP/IP-based
* Syslog implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogConfigIF.java,v 1.6 2010/10/29 03:14:12 cvs Exp $
*/
public interface TCPNetSyslogConfigIF extends AbstractNetSyslogConfigIF {
public byte[] getDelimiterSequence();
public void setDelimiterSequence(byte[] delimiterSequence);
public boolean isPersistentConnection();
public void setPersistentConnection(boolean persistentConnection);
public boolean isSoLinger();
public void setSoLinger(boolean soLinger);
public int getSoLingerSeconds();
public void setSoLingerSeconds(int soLingerSeconds);
public boolean isKeepAlive();
public void setKeepAlive(boolean keepAlive);
public boolean isReuseAddress();
public void setReuseAddress(boolean reuseAddress);
public boolean isSetBufferSize();
public void setSetBufferSize(boolean setBufferSize);
public int getFreshConnectionInterval();
public void setFreshConnectionInterval(int interval);
}

View File

@ -14,19 +14,19 @@ import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* TCPNetSyslogWriter is an implementation of Runnable that supports sending
* TCP-based messages within a separate Thread.
*
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
* a queuing mechanism is used (via LinkedList).</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogWriter.java,v 1.20 2010/11/28 01:38:08 cvs Exp $
*/
* TCPNetSyslogWriter is an implementation of Runnable that supports sending
* TCP-based messages within a separate Thread.
* <p/>
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
* a queuing mechanism is used (via LinkedList).</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogWriter.java,v 1.20 2010/11/28 01:38:08 cvs Exp $
*/
public class TCPNetSyslogWriter extends AbstractSyslogWriter {
private static final long serialVersionUID = -6388813866108482855L;
@ -57,10 +57,10 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
protected Socket createSocket(InetAddress hostAddress, int port, boolean keepalive) throws IOException {
SocketFactory socketFactory = obtainSocketFactory();
Socket newSocket = socketFactory.createSocket(hostAddress,port);
Socket newSocket = socketFactory.createSocket(hostAddress, port);
if (this.tcpNetSyslogConfig.isSoLinger()) {
newSocket.setSoLinger(true,this.tcpNetSyslogConfig.getSoLingerSeconds());
newSocket.setSoLinger(true, this.tcpNetSyslogConfig.getSoLingerSeconds());
}
if (this.tcpNetSyslogConfig.isKeepAlive()) {
@ -96,7 +96,7 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
try {
InetAddress hostAddress = this.tcpNetSyslog.getHostAddress();
this.socket = createSocket(hostAddress,this.syslog.getConfig().getPort(),this.tcpNetSyslogConfig.isPersistentConnection());
this.socket = createSocket(hostAddress, this.syslog.getConfig().getPort(), this.tcpNetSyslogConfig.isPersistentConnection());
lastSocketCreationTimeMs = System.currentTimeMillis();
} catch (IOException ioe) {
@ -131,7 +131,7 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
Socket currentSocket = null;
int attempts = 0;
while(attempts != -1 && attempts < (this.tcpNetSyslogConfig.getWriteRetries() + 1)) {
while (attempts != -1 && attempts < (this.tcpNetSyslogConfig.getWriteRetries() + 1)) {
try {
currentSocket = getSocket();
@ -192,7 +192,7 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
long timeStart = System.currentTimeMillis();
boolean done = false;
while(!done) {
while (!done) {
if (this.socket == null || this.socket.isClosed()) {
done = true;

View File

@ -7,16 +7,16 @@ import org.graylog2.syslog4j.impl.pool.AbstractSyslogPoolFactory;
import org.graylog2.syslog4j.impl.pool.generic.GenericSyslogPoolFactory;
/**
* PooledTCPNetSyslog is an extension of TCPNetSyslog which provides support
* for Apache Commons Pool.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PooledTCPNetSyslog.java,v 1.5 2008/12/10 04:30:15 cvs Exp $
*/
* PooledTCPNetSyslog is an extension of TCPNetSyslog which provides support
* for Apache Commons Pool.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PooledTCPNetSyslog.java,v 1.5 2008/12/10 04:30:15 cvs Exp $
*/
public class PooledTCPNetSyslog extends TCPNetSyslog {
private static final long serialVersionUID = 4279960451141784200L;

View File

@ -5,16 +5,16 @@ import org.graylog2.syslog4j.SyslogPoolConfigIF;
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfig;
/**
* NetSyslogPoolFactory is an implementation of SyslogPoolConfigIF
* which provides configuration support for the Apache Commons Pool.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PooledTCPNetSyslogConfig.java,v 1.3 2008/11/26 15:01:47 cvs Exp $
*/
* NetSyslogPoolFactory is an implementation of SyslogPoolConfigIF
* which provides configuration support for the Apache Commons Pool.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PooledTCPNetSyslogConfig.java,v 1.3 2008/11/26 15:01:47 cvs Exp $
*/
public class PooledTCPNetSyslogConfig extends TCPNetSyslogConfig implements SyslogPoolConfigIF {
private static final long serialVersionUID = 2283355983363422888L;

View File

@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslog;
/**
* SSLTCPNetSyslog is an extension of AbstractSyslog that provides support for
* TCP/IP-based (over SSL/TLS) syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslog.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
* SSLTCPNetSyslog is an extension of AbstractSyslog that provides support for
* TCP/IP-based (over SSL/TLS) syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslog.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
public class SSLTCPNetSyslog extends TCPNetSyslog {
private static final long serialVersionUID = 2766654802524487317L;
@ -25,25 +25,25 @@ public class SSLTCPNetSyslog extends TCPNetSyslog {
String keyStore = sslTcpNetSyslogConfig.getKeyStore();
if (keyStore != null && !"".equals(keyStore.trim())) {
System.setProperty("javax.net.ssl.keyStore",keyStore);
System.setProperty("javax.net.ssl.keyStore", keyStore);
}
String keyStorePassword = sslTcpNetSyslogConfig.getKeyStorePassword();
if (keyStorePassword != null && !"".equals(keyStorePassword.trim())) {
System.setProperty("javax.net.ssl.keyStorePassword",keyStorePassword);
System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
}
String trustStore = sslTcpNetSyslogConfig.getTrustStore();
if (trustStore != null && !"".equals(trustStore.trim())) {
System.setProperty("javax.net.ssl.trustStore",trustStore);
System.setProperty("javax.net.ssl.trustStore", trustStore);
}
String trustStorePassword = sslTcpNetSyslogConfig.getTrustStorePassword();
if (trustStorePassword != null && !"".equals(trustStorePassword.trim())) {
System.setProperty("javax.net.ssl.trustStorePassword",trustStorePassword);
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
}
}
}

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.net.tcp.ssl;
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfig;
/**
* SSLTCPNetSyslogConfig is an extension of TCPNetSyslogConfig that provides
* configuration support for TCP/IP-based (over SSL/TLS) syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogConfig.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
*/
* SSLTCPNetSyslogConfig is an extension of TCPNetSyslogConfig that provides
* configuration support for TCP/IP-based (over SSL/TLS) syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogConfig.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
*/
public class SSLTCPNetSyslogConfig extends TCPNetSyslogConfig implements SSLTCPNetSyslogConfigIF {
private static final long serialVersionUID = 5569086213824510834L;

View File

@ -3,26 +3,30 @@ package org.graylog2.syslog4j.impl.net.tcp.ssl;
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogConfigIF;
/**
* SSLTCPNetSyslogConfigIF is a configuration interface supporting TCP/IP-based
* (over SSL/TLS) Syslog implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogConfigIF.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
* SSLTCPNetSyslogConfigIF is a configuration interface supporting TCP/IP-based
* (over SSL/TLS) Syslog implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogConfigIF.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
public interface SSLTCPNetSyslogConfigIF extends TCPNetSyslogConfigIF {
public String getKeyStore();
public void setKeyStore(String keyStore);
public String getKeyStorePassword();
public void setKeyStorePassword(String keyStorePassword);
public String getTrustStore();
public void setTrustStore(String trustStore);
public String getTrustStorePassword();
public void setTrustStorePassword(String trustStorePassword);
}

View File

@ -6,19 +6,19 @@ import javax.net.ssl.SSLSocketFactory;
import org.graylog2.syslog4j.impl.net.tcp.TCPNetSyslogWriter;
/**
* SSLTCPNetSyslogWriter is an implementation of Runnable that supports sending
* TCP/IP-based (over SSL/TLS) messages within a separate Thread.
*
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
* a queuing mechanism is used (via LinkedList).</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogWriter.java,v 1.4 2009/03/29 17:38:58 cvs Exp $
*/
* SSLTCPNetSyslogWriter is an implementation of Runnable that supports sending
* TCP/IP-based (over SSL/TLS) messages within a separate Thread.
* <p/>
* <p>When used in "threaded" mode (see TCPNetSyslogConfig for the option),
* a queuing mechanism is used (via LinkedList).</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogWriter.java,v 1.4 2009/03/29 17:38:58 cvs Exp $
*/
public class SSLTCPNetSyslogWriter extends TCPNetSyslogWriter {
private static final long serialVersionUID = 8944446235285662244L;

View File

@ -6,16 +6,16 @@ import org.graylog2.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogConfigIF;
import org.graylog2.syslog4j.impl.net.tcp.ssl.SSLTCPNetSyslogWriter;
/**
* PooledSSLTCPNetSyslogConfig is an extension of PooledTCPNetSyslogConfig
* which provides configuration support for the Apache Commons Pool.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PooledSSLTCPNetSyslogConfig.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
*/
* PooledSSLTCPNetSyslogConfig is an extension of PooledTCPNetSyslogConfig
* which provides configuration support for the Apache Commons Pool.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PooledSSLTCPNetSyslogConfig.java,v 1.2 2009/03/29 17:38:58 cvs Exp $
*/
public class PooledSSLTCPNetSyslogConfig extends PooledTCPNetSyslogConfig implements SSLTCPNetSyslogConfigIF {
private static final long serialVersionUID = 2092268298395023976L;

View File

@ -11,16 +11,16 @@ import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
import org.graylog2.syslog4j.impl.net.AbstractNetSyslog;
/**
* UDPNetSyslog is an extension of AbstractSyslog that provides support for
* UDP/IP-based syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UDPNetSyslog.java,v 1.18 2010/10/27 06:18:10 cvs Exp $
*/
* UDPNetSyslog is an extension of AbstractSyslog that provides support for
* UDP/IP-based syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UDPNetSyslog.java,v 1.18 2010/10/27 06:18:10 cvs Exp $
*/
public class UDPNetSyslog extends AbstractNetSyslog {
private static final long serialVersionUID = 5259485504549037999L;
@ -68,7 +68,7 @@ public class UDPNetSyslog extends AbstractNetSyslog {
int attempts = 0;
while(attempts != -1 && attempts < (this.netSyslogConfig.getWriteRetries() + 1)) {
while (attempts != -1 && attempts < (this.netSyslogConfig.getWriteRetries() + 1)) {
try {
this.socket.send(packet);
attempts = -1;

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j.impl.net.udp;
import org.graylog2.syslog4j.impl.net.AbstractNetSyslogConfig;
/**
* UDPNetSyslogConfig is an extension of AbstractNetSyslogConfig that provides
* configuration support for UDP/IP-based syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UDPNetSyslogConfig.java,v 1.6 2008/11/14 04:32:00 cvs Exp $
*/
* UDPNetSyslogConfig is an extension of AbstractNetSyslogConfig that provides
* configuration support for UDP/IP-based syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UDPNetSyslogConfig.java,v 1.6 2008/11/14 04:32:00 cvs Exp $
*/
public class UDPNetSyslogConfig extends AbstractNetSyslogConfig {
private static final long serialVersionUID = 4465067182562754345L;
@ -21,11 +21,11 @@ public class UDPNetSyslogConfig extends AbstractNetSyslogConfig {
}
public UDPNetSyslogConfig(int facility, String host, int port) {
super(facility,host,port);
super(facility, host, port);
}
public UDPNetSyslogConfig(int facility, String host) {
super(facility,host);
super(facility, host);
}
public UDPNetSyslogConfig(int facility) {
@ -33,7 +33,7 @@ public class UDPNetSyslogConfig extends AbstractNetSyslogConfig {
}
public UDPNetSyslogConfig(String host, int port) {
super(host,port);
super(host, port);
}
public UDPNetSyslogConfig(String host) {

View File

@ -8,17 +8,17 @@ import org.graylog2.syslog4j.impl.AbstractSyslogConfigIF;
import org.graylog2.syslog4j.impl.AbstractSyslogWriter;
/**
* AbstractSyslogPoolFactory is an abstract implementation of the Apache Commons Pool
* BasePoolableObjectFactory.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogPoolFactory.java,v 1.5 2008/12/10 04:15:11 cvs Exp $
* @see org.graylog2.syslog4j.impl.pool.generic.GenericSyslogPoolFactory
*/
* AbstractSyslogPoolFactory is an abstract implementation of the Apache Commons Pool
* BasePoolableObjectFactory.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogPoolFactory.java,v 1.5 2008/12/10 04:15:11 cvs Exp $
* @see org.graylog2.syslog4j.impl.pool.generic.GenericSyslogPoolFactory
*/
public abstract class AbstractSyslogPoolFactory extends BasePoolableObjectFactory {
private static final long serialVersionUID = -7441569603980981508L;

View File

@ -7,16 +7,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
import org.graylog2.syslog4j.impl.pool.AbstractSyslogPoolFactory;
/**
* GenericSyslogPoolFactory is an implementation of the Apache Commons Pool
* BasePoolableObjectFactory using a GenericObjectPool.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: GenericSyslogPoolFactory.java,v 1.5 2008/12/10 04:15:10 cvs Exp $
*/
* GenericSyslogPoolFactory is an implementation of the Apache Commons Pool
* BasePoolableObjectFactory using a GenericObjectPool.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: GenericSyslogPoolFactory.java,v 1.5 2008/12/10 04:15:10 cvs Exp $
*/
public class GenericSyslogPoolFactory extends AbstractSyslogPoolFactory {
protected void configureGenericObjectPool(GenericObjectPool genericObjectPool) throws SyslogRuntimeException {
SyslogPoolConfigIF poolConfig = null;

View File

@ -11,19 +11,19 @@ import com.sun.jna.Memory;
import com.sun.jna.Native;
/**
* UnixSyslog is an extension of AbstractSyslog that provides support for
* Unix-based syslog clients.
*
* <p>This class requires the JNA (Java Native Access) library to directly
* access the native C libraries utilized on Unix platforms.</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UnixSyslog.java,v 1.27 2010/10/25 04:21:19 cvs Exp $
*/
* UnixSyslog is an extension of AbstractSyslog that provides support for
* Unix-based syslog clients.
* <p/>
* <p>This class requires the JNA (Java Native Access) library to directly
* access the native C libraries utilized on Unix platforms.</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UnixSyslog.java,v 1.27 2010/10/25 04:21:19 cvs Exp $
*/
public class UnixSyslog extends AbstractSyslog {
private static final long serialVersionUID = 4973353204252276740L;
@ -31,7 +31,9 @@ public class UnixSyslog extends AbstractSyslog {
protected interface CLibrary extends Library {
public void openlog(final Memory ident, int option, int facility);
public void syslog(int priority, final String format, final String message);
public void closelog();
}
@ -46,7 +48,7 @@ public class UnixSyslog extends AbstractSyslog {
}
if (libraryInstance == null) {
libraryInstance = (CLibrary) Native.loadLibrary(config.getLibrary(),CLibrary.class);
libraryInstance = (CLibrary) Native.loadLibrary(config.getLibrary(), CLibrary.class);
}
}
@ -62,7 +64,7 @@ public class UnixSyslog extends AbstractSyslog {
}
protected static void write(int level, String message, UnixSyslogConfig config) throws SyslogRuntimeException {
synchronized(libraryInstance) {
synchronized (libraryInstance) {
if (currentFacility != config.getFacility()) {
if (openlogCalled) {
libraryInstance.closelog();
@ -86,13 +88,13 @@ public class UnixSyslog extends AbstractSyslog {
identBuffer.setString(0, ident, false);
}
libraryInstance.openlog(identBuffer,config.getOption(),currentFacility);
libraryInstance.openlog(identBuffer, config.getOption(), currentFacility);
openlogCalled = true;
}
int priority = currentFacility | level;
libraryInstance.syslog(priority,"%s",message);
libraryInstance.syslog(priority, "%s", message);
}
}
@ -101,11 +103,11 @@ public class UnixSyslog extends AbstractSyslog {
}
public void log(SyslogMessageProcessorIF messageProcessor, int level, String message) {
write(level,message,this.unixSyslogConfig);
write(level, message, this.unixSyslogConfig);
}
public void flush() throws SyslogRuntimeException {
synchronized(libraryInstance) {
synchronized (libraryInstance) {
libraryInstance.closelog();
openlogCalled = false;
}

View File

@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
/**
* UnixSyslogConfig is an extension of AbstractNetSyslogConfig that provides
* configuration support for Unix-based syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UnixSyslogConfig.java,v 1.13 2010/10/25 03:50:25 cvs Exp $
*/
* UnixSyslogConfig is an extension of AbstractNetSyslogConfig that provides
* configuration support for Unix-based syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UnixSyslogConfig.java,v 1.13 2010/10/25 03:50:25 cvs Exp $
*/
public class UnixSyslogConfig extends AbstractSyslogConfig {
private static final long serialVersionUID = -4805767812011660656L;

View File

@ -12,40 +12,44 @@ import com.sun.jna.Native;
import com.sun.jna.Structure;
/**
* UnixSocketSyslog is an extension of AbstractSyslog that provides support for
* Unix socket-based syslog clients.
*
* <p>This class requires the JNA (Java Native Access) library to directly
* access the native C libraries utilized on Unix platforms.</p>
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UnixSocketSyslog.java,v 1.13 2010/11/16 00:52:01 cvs Exp $
*/
* UnixSocketSyslog is an extension of AbstractSyslog that provides support for
* Unix socket-based syslog clients.
* <p/>
* <p>This class requires the JNA (Java Native Access) library to directly
* access the native C libraries utilized on Unix platforms.</p>
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UnixSocketSyslog.java,v 1.13 2010/11/16 00:52:01 cvs Exp $
*/
public class UnixSocketSyslog extends AbstractSyslog {
private static final long serialVersionUID = 39878807911936785L;
protected static class SockAddr extends Structure {
public final static int SUN_PATH_SIZE = 108;
public final static byte[] ZERO_BYTE = new byte[] { 0 };
public final static byte[] ZERO_BYTE = new byte[]{0};
public short sun_family = 1;
public byte[] sun_path = new byte[SUN_PATH_SIZE];
public void setSunPath(String sunPath) {
System.arraycopy(sunPath.getBytes(), 0,this.sun_path, 0, sunPath.length());
System.arraycopy(ZERO_BYTE,0,this.sun_path,sunPath.length(),1);
System.arraycopy(sunPath.getBytes(), 0, this.sun_path, 0, sunPath.length());
System.arraycopy(ZERO_BYTE, 0, this.sun_path, sunPath.length(), 1);
}
}
protected interface CLibrary extends Library {
public int socket(int domain, int type, int protocol);
public int connect(int sockfd, SockAddr sockaddr, int addrlen);
public int write(int fd, ByteBuffer buffer, int count);
public int close(int fd);
public String strerror(int errno);
}
@ -61,7 +65,7 @@ public class UnixSocketSyslog extends AbstractSyslog {
}
if (!this.libraryLoaded) {
this.libraryInstance = (CLibrary) Native.loadLibrary(this.unixSocketSyslogConfig.getLibrary(),CLibrary.class);
this.libraryInstance = (CLibrary) Native.loadLibrary(this.unixSocketSyslogConfig.getLibrary(), CLibrary.class);
this.libraryLoaded = true;
}
}
@ -83,7 +87,7 @@ public class UnixSocketSyslog extends AbstractSyslog {
return;
}
this.fd = this.libraryInstance.socket(this.unixSocketSyslogConfig.getFamily(),this.unixSocketSyslogConfig.getType(),this.unixSocketSyslogConfig.getProtocol());
this.fd = this.libraryInstance.socket(this.unixSocketSyslogConfig.getFamily(), this.unixSocketSyslogConfig.getType(), this.unixSocketSyslogConfig.getProtocol());
if (this.fd == -1) {
this.fd = -1;
@ -114,13 +118,13 @@ public class UnixSocketSyslog extends AbstractSyslog {
ByteBuffer byteBuffer = ByteBuffer.wrap(message);
this.libraryInstance.write(this.fd,byteBuffer,message.length);
this.libraryInstance.write(this.fd, byteBuffer, message.length);
}
public void flush() throws SyslogRuntimeException {
shutdown();
this.fd = this.libraryInstance.socket(this.unixSocketSyslogConfig.getFamily(),this.unixSocketSyslogConfig.getType(),this.unixSocketSyslogConfig.getProtocol());
this.fd = this.libraryInstance.socket(this.unixSocketSyslogConfig.getFamily(), this.unixSocketSyslogConfig.getType(), this.unixSocketSyslogConfig.getProtocol());
}
public void shutdown() throws SyslogRuntimeException {

View File

@ -4,16 +4,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
import org.graylog2.syslog4j.impl.AbstractSyslogConfig;
/**
* UnixSocketSyslogConfig is an extension of AbstractNetSyslogConfig that provides
* configuration support for Unix socket-based syslog clients.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UnixSocketSyslogConfig.java,v 1.8 2010/11/12 03:43:12 cvs Exp $
*/
* UnixSocketSyslogConfig is an extension of AbstractNetSyslogConfig that provides
* configuration support for Unix socket-based syslog clients.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UnixSocketSyslogConfig.java,v 1.8 2010/11/12 03:43:12 cvs Exp $
*/
public class UnixSocketSyslogConfig extends AbstractSyslogConfig {
private static final long serialVersionUID = -3145794243736015707L;

View File

@ -15,7 +15,7 @@ import org.graylog2.syslog4j.util.SyslogUtility;
/**
* This class provides a Singleton-based interface for Syslog4j
* server implementations.
*
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
@ -128,7 +128,7 @@ public class SyslogServer implements SyslogConstants {
SyslogServerIF syslogServer = null;
synchronized(instances) {
synchronized (instances) {
if (instances.containsKey(syslogProtocol)) {
throwRuntimeException("SyslogServer instance \"" + syslogProtocol + "\" already defined.");
return null;
@ -149,16 +149,16 @@ public class SyslogServer implements SyslogConstants {
throw new SyslogRuntimeException(ie);
}
syslogServer.initialize(syslogProtocol,config);
syslogServer.initialize(syslogProtocol, config);
instances.put(syslogProtocol,syslogServer);
instances.put(syslogProtocol, syslogServer);
}
return syslogServer;
}
public static final SyslogServerIF createThreadedInstance(String protocol, SyslogServerConfigIF config) throws SyslogRuntimeException {
createInstance(protocol,config);
createInstance(protocol, config);
SyslogServerIF server = getThreadedInstance(protocol);
@ -213,8 +213,8 @@ public class SyslogServer implements SyslogConstants {
}
public synchronized static void initialize() {
createInstance(UDP,new UDPNetSyslogServerConfig());
createInstance(TCP,new TCPNetSyslogServerConfig());
createInstance(UDP, new UDPNetSyslogServerConfig());
createInstance(TCP, new TCPNetSyslogServerConfig());
}
public synchronized static final void shutdown() throws SyslogRuntimeException {
@ -222,7 +222,7 @@ public class SyslogServer implements SyslogConstants {
Iterator i = protocols.iterator();
while(i.hasNext()) {
while (i.hasNext()) {
String protocol = (String) i.next();
SyslogServerIF syslogServer = (SyslogServerIF) instances.get(protocol);

View File

@ -7,44 +7,54 @@ import org.graylog2.syslog4j.SyslogConstants;
import org.graylog2.syslog4j.SyslogRuntimeException;
/**
* SyslogServerConfigIF provides a common, extensible configuration interface for all
* implementations of SyslogServerIF.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerConfigIF.java,v 1.12 2011/01/11 05:11:13 cvs Exp $
*/
* SyslogServerConfigIF provides a common, extensible configuration interface for all
* implementations of SyslogServerIF.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerConfigIF.java,v 1.12 2011/01/11 05:11:13 cvs Exp $
*/
public interface SyslogServerConfigIF extends SyslogConstants, SyslogCharSetIF {
public Class getSyslogServerClass();
public String getHost();
public void setHost(String host) throws SyslogRuntimeException;
public int getPort();
public void setPort(int port) throws SyslogRuntimeException;
public boolean isUseDaemonThread();
public void setUseDaemonThread(boolean useDaemonThread);
public int getThreadPriority();
public void setThreadPriority(int threadPriority);
public List getEventHandlers();
public long getShutdownWait();
public void setShutdownWait(long shutdownWait);
public void addEventHandler(SyslogServerEventHandlerIF eventHandler);
public void insertEventHandler(int pos, SyslogServerEventHandlerIF eventHandler);
public void removeEventHandler(SyslogServerEventHandlerIF eventHandler);
public void removeAllEventHandlers();
public boolean isUseStructuredData();
public void setUseStructuredData(boolean useStructuredData);
public Object getDateTimeFormatter();
public void setDateTimeFormatter(Object dateTimeFormatter);
}

View File

@ -4,5 +4,6 @@ import java.io.Serializable;
public abstract interface SyslogServerEventHandlerIF extends Serializable {
public void initialize(SyslogServerIF syslogServer);
public void destroy(SyslogServerIF syslogServer);
}

View File

@ -5,16 +5,16 @@ import java.util.Date;
import org.graylog2.syslog4j.SyslogCharSetIF;
/**
* SyslogServerEventIF provides an extensible interface for Syslog4j
* server events.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerEventIF.java,v 1.4 2010/11/28 01:38:08 cvs Exp $
*/
* SyslogServerEventIF provides an extensible interface for Syslog4j
* server events.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerEventIF.java,v 1.4 2010/11/28 01:38:08 cvs Exp $
*/
public interface SyslogServerEventIF extends SyslogCharSetIF {
/**
* Note: getRaw() may use System.arraycopy(..) each time it is called; best to call it once and store the result.
@ -24,18 +24,24 @@ public interface SyslogServerEventIF extends SyslogCharSetIF {
public byte[] getRaw();
public int getFacility();
public void setFacility(int facility);
public Date getDate();
public void setDate(Date date);
public int getLevel();
public void setLevel(int level);
public String getHost();
public void setHost(String host);
public boolean isHostStrippedFromMessage();
public String getMessage();
public void setMessage(String message);
}

View File

@ -3,24 +3,26 @@ package org.graylog2.syslog4j.server;
import org.graylog2.syslog4j.SyslogRuntimeException;
/**
* SyslogServerIF provides a common interface for all Syslog4j server implementations.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerIF.java,v 1.5 2008/11/07 15:15:41 cvs Exp $
*/
* SyslogServerIF provides a common interface for all Syslog4j server implementations.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerIF.java,v 1.5 2008/11/07 15:15:41 cvs Exp $
*/
public interface SyslogServerIF extends Runnable {
public void initialize(String protocol, SyslogServerConfigIF config) throws SyslogRuntimeException;
public String getProtocol();
public SyslogServerConfigIF getConfig();
public void run();
public Thread getThread();
public void setThread(Thread thread);
public void shutdown();

View File

@ -8,7 +8,7 @@ import org.graylog2.syslog4j.util.SyslogUtility;
/**
* This class provides a command-line interface for Syslog4j
* server implementations.
*
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
@ -57,17 +57,51 @@ public class SyslogServerMain {
Options options = new Options();
int i = 0;
while(i < args.length) {
while (i < args.length) {
String arg = args[i++];
boolean match = false;
if ("-h".equals(arg)) { if (i == args.length) { options.usage = "Must specify host with -h"; return options; } match = true; options.host = args[i++]; }
if ("-p".equals(arg)) { if (i == args.length) { options.usage = "Must specify port with -p"; return options; } match = true; options.port = args[i++]; }
if ("-t".equals(arg)) { if (i == args.length) { options.usage = "Must specify value (in milliseconds)"; return options; } match = true; options.timeout = args[i++]; }
if ("-o".equals(arg)) { if (i == args.length) { options.usage = "Must specify file with -o"; return options; } match = true; options.fileName = args[i++]; }
if ("-h".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify host with -h";
return options;
}
match = true;
options.host = args[i++];
}
if ("-p".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify port with -p";
return options;
}
match = true;
options.port = args[i++];
}
if ("-t".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify value (in milliseconds)";
return options;
}
match = true;
options.timeout = args[i++];
}
if ("-o".equals(arg)) {
if (i == args.length) {
options.usage = "Must specify file with -o";
return options;
}
match = true;
options.fileName = args[i++];
}
if ("-a".equals(arg)) { match = true; options.append = true; }
if ("-q".equals(arg)) { match = true; options.quiet = true; }
if ("-a".equals(arg)) {
match = true;
options.append = true;
}
if ("-q".equals(arg)) {
match = true;
options.quiet = true;
}
if (!match) {
if (options.protocol != null) {
@ -97,7 +131,11 @@ public class SyslogServerMain {
if (options.usage != null) {
usage(options.usage);
if (CALL_SYSTEM_EXIT_ON_FAILURE) { System.exit(1); } else { return; }
if (CALL_SYSTEM_EXIT_ON_FAILURE) {
System.exit(1);
} else {
return;
}
}
if (!options.quiet) {
@ -106,7 +144,11 @@ public class SyslogServerMain {
if (!SyslogServer.exists(options.protocol)) {
usage("Protocol \"" + options.protocol + "\" not supported");
if (CALL_SYSTEM_EXIT_ON_FAILURE) { System.exit(1); } else { return; }
if (CALL_SYSTEM_EXIT_ON_FAILURE) {
System.exit(1);
} else {
return;
}
}
SyslogServerIF syslogServer = SyslogServer.getInstance(options.protocol);
@ -140,7 +182,7 @@ public class SyslogServerMain {
}
if (options.fileName != null) {
SyslogServerEventHandlerIF eventHandler = new FileSyslogServerEventHandler(options.fileName,options.append);
SyslogServerEventHandlerIF eventHandler = new FileSyslogServerEventHandler(options.fileName, options.append);
syslogServerConfig.addEventHandler(eventHandler);
if (!options.quiet) {
System.out.println((options.append ? "Appending" : "Writing") + " to file: " + options.fileName);
@ -158,7 +200,7 @@ public class SyslogServerMain {
SyslogServer.getThreadedInstance(options.protocol);
while(true) {
while (true) {
SyslogUtility.sleep(1000);
}
}

View File

@ -4,7 +4,10 @@ import java.net.SocketAddress;
public interface SyslogServerSessionEventHandlerIF extends SyslogServerEventHandlerIF {
public Object sessionOpened(SyslogServerIF syslogServer, SocketAddress socketAddress);
public void event(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, SyslogServerEventIF event);
public void exception(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception);
public void sessionClosed(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, boolean timeout);
}

View File

@ -4,17 +4,18 @@ import java.net.SocketAddress;
/**
* SyslogServerEventHandlerIF provides an extensible interface for Syslog4j
* server event handlers.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerSessionlessEventHandlerIF.java,v 1.1 2010/11/12 02:56:44 cvs Exp $
*/
* SyslogServerEventHandlerIF provides an extensible interface for Syslog4j
* server event handlers.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerSessionlessEventHandlerIF.java,v 1.1 2010/11/12 02:56:44 cvs Exp $
*/
public interface SyslogServerSessionlessEventHandlerIF extends SyslogServerEventHandlerIF {
public void event(SyslogServerIF syslogServer, SocketAddress socketAddress, SyslogServerEventIF event);
public void exception(SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception);
}

View File

@ -22,15 +22,15 @@ import org.graylog2.syslog4j.server.impl.event.structured.StructuredSyslogServer
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* AbstractSyslogServer provides a base abstract implementation of the SyslogServerIF.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogServer.java,v 1.12 2011/01/11 05:11:13 cvs Exp $
*/
* AbstractSyslogServer provides a base abstract implementation of the SyslogServerIF.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogServer.java,v 1.12 2011/01/11 05:11:13 cvs Exp $
*/
public abstract class AbstractSyslogServer implements SyslogServerIF {
public static class Sessions extends HashMap {
private static final long serialVersionUID = -4438949276263772580L;
@ -38,8 +38,8 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
public static final Object syncObject = new Object();
public void addSocket(Socket socket) {
synchronized(syncObject) {
put(socket,new HashMap());
synchronized (syncObject) {
put(socket, new HashMap());
}
}
@ -53,19 +53,19 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
}
public void addSession(Socket socket, SyslogServerEventHandlerIF eventHandler, Object session) {
synchronized(syncObject) {
synchronized (syncObject) {
Map handlerMap = getHandlerMap(socket);
if (handlerMap == null) {
handlerMap = new HashMap();
}
handlerMap.put(eventHandler,session);
handlerMap.put(eventHandler, session);
}
}
public void removeSocket(Socket socket) {
synchronized(syncObject) {
synchronized (syncObject) {
Map handlerMap = getHandlerMap(socket);
if (handlerMap != null) {
@ -85,7 +85,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
}
public Object getSession(Socket socket, SyslogServerEventHandlerIF eventHandler) {
synchronized(syncObject) {
synchronized (syncObject) {
Map handlerMap = getHandlerMap(socket);
Object session = handlerMap.get(eventHandler);
@ -139,7 +139,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
protected static boolean isStructuredMessage(SyslogCharSetIF syslogCharSet, byte[] receiveData) {
String receiveDataString = SyslogUtility.newString(syslogCharSet, receiveData);
boolean isStructuredMessage = isStructuredMessage(syslogCharSet,receiveDataString);
boolean isStructuredMessage = isStructuredMessage(syslogCharSet, receiveDataString);
return isStructuredMessage;
}
@ -160,15 +160,15 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
protected static SyslogServerEventIF createEvent(SyslogServerConfigIF serverConfig, byte[] lineBytes, int lineBytesLength, InetAddress inetAddr) {
SyslogServerEventIF event = null;
if (serverConfig.isUseStructuredData() && AbstractSyslogServer.isStructuredMessage(serverConfig,lineBytes)) {
event = new StructuredSyslogServerEvent(lineBytes,lineBytesLength,inetAddr);
if (serverConfig.isUseStructuredData() && AbstractSyslogServer.isStructuredMessage(serverConfig, lineBytes)) {
event = new StructuredSyslogServerEvent(lineBytes, lineBytesLength, inetAddr);
if (serverConfig.getDateTimeFormatter() != null) {
((StructuredSyslogServerEvent) event).setDateTimeFormatter(serverConfig.getDateTimeFormatter());
}
} else {
event = new SyslogServerEvent(lineBytes,lineBytesLength,inetAddr);
event = new SyslogServerEvent(lineBytes, lineBytesLength, inetAddr);
}
return event;
@ -177,11 +177,11 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
protected static SyslogServerEventIF createEvent(SyslogServerConfigIF serverConfig, String line, InetAddress inetAddr) {
SyslogServerEventIF event = null;
if (serverConfig.isUseStructuredData() && AbstractSyslogServer.isStructuredMessage(serverConfig,line)) {
event = new StructuredSyslogServerEvent(line,inetAddr);
if (serverConfig.isUseStructuredData() && AbstractSyslogServer.isStructuredMessage(serverConfig, line)) {
event = new StructuredSyslogServerEvent(line, inetAddr);
} else {
event = new SyslogServerEvent(line,inetAddr);
event = new SyslogServerEvent(line, inetAddr);
}
return event;
@ -190,7 +190,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
public static void handleInitialize(SyslogServerIF syslogServer) {
List eventHandlers = syslogServer.getConfig().getEventHandlers();
for(int i=0; i<eventHandlers.size(); i++) {
for (int i = 0; i < eventHandlers.size(); i++) {
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
try {
@ -205,7 +205,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
public static void handleDestroy(SyslogServerIF syslogServer) {
List eventHandlers = syslogServer.getConfig().getEventHandlers();
for(int i=0; i<eventHandlers.size(); i++) {
for (int i = 0; i < eventHandlers.size(); i++) {
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
try {
@ -220,20 +220,20 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
public static void handleSessionOpen(Sessions sessions, SyslogServerIF syslogServer, Socket socket) {
List eventHandlers = syslogServer.getConfig().getEventHandlers();
for(int i=0; i<eventHandlers.size(); i++) {
for (int i = 0; i < eventHandlers.size(); i++) {
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
try {
Object session = ((SyslogServerSessionEventHandlerIF) eventHandler).sessionOpened(syslogServer,socket.getRemoteSocketAddress());
Object session = ((SyslogServerSessionEventHandlerIF) eventHandler).sessionOpened(syslogServer, socket.getRemoteSocketAddress());
if (session != null) {
sessions.addSession(socket,eventHandler,session);
sessions.addSession(socket, eventHandler, session);
}
} catch (Exception exception) {
try {
((SyslogServerSessionEventHandlerIF) eventHandler).exception(null,syslogServer,socket.getRemoteSocketAddress(),exception);
((SyslogServerSessionEventHandlerIF) eventHandler).exception(null, syslogServer, socket.getRemoteSocketAddress(), exception);
} catch (Exception e) {
//
@ -246,18 +246,18 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
public static void handleSessionClosed(Sessions sessions, SyslogServerIF syslogServer, Socket socket, boolean timeout) {
List eventHandlers = syslogServer.getConfig().getEventHandlers();
for(int i=0; i<eventHandlers.size(); i++) {
for (int i = 0; i < eventHandlers.size(); i++) {
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
Object session = sessions.getSession(socket,eventHandler);
Object session = sessions.getSession(socket, eventHandler);
try {
((SyslogServerSessionEventHandlerIF) eventHandler).sessionClosed(session,syslogServer,socket.getRemoteSocketAddress(),timeout);
((SyslogServerSessionEventHandlerIF) eventHandler).sessionClosed(session, syslogServer, socket.getRemoteSocketAddress(), timeout);
} catch (Exception exception) {
try {
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session,syslogServer,socket.getRemoteSocketAddress(),exception);
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session, syslogServer, socket.getRemoteSocketAddress(), exception);
} catch (Exception e) {
//
@ -268,28 +268,28 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
}
public static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, DatagramPacket packet, SyslogServerEventIF event) {
handleEvent(sessions,syslogServer,null,packet.getSocketAddress(),event);
handleEvent(sessions, syslogServer, null, packet.getSocketAddress(), event);
}
public static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, Socket socket, SyslogServerEventIF event) {
handleEvent(sessions,syslogServer,socket,socket.getRemoteSocketAddress(),event);
handleEvent(sessions, syslogServer, socket, socket.getRemoteSocketAddress(), event);
}
protected static void handleEvent(Sessions sessions, SyslogServerIF syslogServer, Socket socket, SocketAddress socketAddress, SyslogServerEventIF event) {
List eventHandlers = syslogServer.getConfig().getEventHandlers();
for(int i=0; i<eventHandlers.size(); i++) {
for (int i = 0; i < eventHandlers.size(); i++) {
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
Object session = (sessions != null && socket != null) ? sessions.getSession(socket,eventHandler) : null;
Object session = (sessions != null && socket != null) ? sessions.getSession(socket, eventHandler) : null;
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
try {
((SyslogServerSessionEventHandlerIF) eventHandler).event(session,syslogServer,socketAddress,event);
((SyslogServerSessionEventHandlerIF) eventHandler).event(session, syslogServer, socketAddress, event);
} catch (Exception exception) {
try {
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session,syslogServer,socketAddress,exception);
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session, syslogServer, socketAddress, exception);
} catch (Exception e) {
//
@ -298,11 +298,11 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
} else if (eventHandler instanceof SyslogServerSessionlessEventHandlerIF) {
try {
((SyslogServerSessionlessEventHandlerIF) eventHandler).event(syslogServer,socketAddress,event);
((SyslogServerSessionlessEventHandlerIF) eventHandler).event(syslogServer, socketAddress, event);
} catch (Exception exception) {
try {
((SyslogServerSessionlessEventHandlerIF) eventHandler).exception(syslogServer,socketAddress,exception);
((SyslogServerSessionlessEventHandlerIF) eventHandler).exception(syslogServer, socketAddress, exception);
} catch (Exception e) {
//
@ -315,12 +315,12 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
public static void handleException(Object session, SyslogServerIF syslogServer, SocketAddress socketAddress, Exception exception) {
List eventHandlers = syslogServer.getConfig().getEventHandlers();
for(int i=0; i<eventHandlers.size(); i++) {
for (int i = 0; i < eventHandlers.size(); i++) {
SyslogServerEventHandlerIF eventHandler = (SyslogServerEventHandlerIF) eventHandlers.get(i);
if (eventHandler instanceof SyslogServerSessionEventHandlerIF) {
try {
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session,syslogServer,socketAddress,exception);
((SyslogServerSessionEventHandlerIF) eventHandler).exception(session, syslogServer, socketAddress, exception);
} catch (Exception e) {
//
@ -328,7 +328,7 @@ public abstract class AbstractSyslogServer implements SyslogServerIF {
} else if (eventHandler instanceof SyslogServerSessionlessEventHandlerIF) {
try {
((SyslogServerSessionlessEventHandlerIF) eventHandler).exception(syslogServer,socketAddress,exception);
((SyslogServerSessionlessEventHandlerIF) eventHandler).exception(syslogServer, socketAddress, exception);
} catch (Exception e) {
//

View File

@ -8,16 +8,16 @@ import org.graylog2.syslog4j.server.SyslogServerConfigIF;
import org.graylog2.syslog4j.server.SyslogServerEventHandlerIF;
/**
* AbstractSyslogServerConfig provides a base abstract implementation of the SyslogServerConfigIF
* configuration interface.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogServerConfig.java,v 1.9 2011/01/11 05:11:13 cvs Exp $
*/
* AbstractSyslogServerConfig provides a base abstract implementation of the SyslogServerConfigIF
* configuration interface.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractSyslogServerConfig.java,v 1.9 2011/01/11 05:11:13 cvs Exp $
*/
public abstract class AbstractSyslogServerConfig implements SyslogServerConfigIF {
private static final long serialVersionUID = 870248648801259856L;

View File

@ -12,15 +12,15 @@ import org.graylog2.syslog4j.server.SyslogServerEventIF;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* SyslogServerEvent provides an implementation of the SyslogServerEventIF interface.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerEvent.java,v 1.9 2011/01/11 06:21:15 cvs Exp $
*/
* SyslogServerEvent provides an implementation of the SyslogServerEventIF interface.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogServerEvent.java,v 1.9 2011/01/11 06:21:15 cvs Exp $
*/
public class SyslogServerEvent implements SyslogServerEventIF {
private static final long serialVersionUID = 6136043067089899962L;
@ -39,16 +39,17 @@ public class SyslogServerEvent implements SyslogServerEventIF {
protected String message = null;
protected InetAddress inetAddress = null;
protected SyslogServerEvent() { }
protected SyslogServerEvent() {
}
public SyslogServerEvent(final String message, InetAddress inetAddress) {
initialize(message,inetAddress);
initialize(message, inetAddress);
parse();
}
public SyslogServerEvent(final byte[] message, int length, InetAddress inetAddress) {
initialize(message,length,inetAddress);
initialize(message, length, inetAddress);
parse();
}
@ -71,7 +72,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
int i = this.message.indexOf(' ');
if (i > -1) {
this.host = this.message.substring(0,i).trim();
this.host = this.message.substring(0, i).trim();
}
}
@ -89,7 +90,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
String year = Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
String originalDate = this.message.substring(0,datelength-1) + " " + year;
String originalDate = this.message.substring(0, datelength - 1) + " " + year;
DateFormat dateFormat = new SimpleDateFormat(dateFormatS);
try {
this.date = dateFormat.parse(originalDate);
@ -109,7 +110,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
int i = this.message.indexOf(">");
if (i <= 4 && i > -1) {
String priorityStr = this.message.substring(1,i);
String priorityStr = this.message.substring(1, i);
int priority = 0;
try {
@ -117,7 +118,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
this.facility = priority >> 3;
this.level = priority - (this.facility << 3);
this.message = this.message.substring(i+1);
this.message = this.message.substring(i + 1);
parseDate();
@ -132,7 +133,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
protected void parse() {
if (this.message == null) {
this.message = SyslogUtility.newString(this,this.rawBytes,this.rawLength);
this.message = SyslogUtility.newString(this, this.rawBytes, this.rawLength);
}
parsePriority();
@ -148,7 +149,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
public byte[] getRaw() {
if (this.rawString != null) {
byte[] rawStringBytes = SyslogUtility.getBytes(this,this.rawString);
byte[] rawStringBytes = SyslogUtility.getBytes(this, this.rawString);
return rawStringBytes;
@ -157,7 +158,7 @@ public class SyslogServerEvent implements SyslogServerEventIF {
} else {
byte[] newRawBytes = new byte[this.rawLength];
System.arraycopy(this.rawBytes,0,newRawBytes,0,this.rawLength);
System.arraycopy(this.rawBytes, 0, newRawBytes, 0, this.rawLength);
return newRawBytes;
}

View File

@ -12,7 +12,7 @@ public class FileSyslogServerEventHandler extends PrintStreamSyslogServerEventHa
protected static PrintStream createPrintStream(String fileName, boolean append) throws IOException {
File file = new File(fileName);
OutputStream os = new FileOutputStream(file,append);
OutputStream os = new FileOutputStream(file, append);
PrintStream printStream = new PrintStream(os);
@ -20,10 +20,10 @@ public class FileSyslogServerEventHandler extends PrintStreamSyslogServerEventHa
}
public FileSyslogServerEventHandler(String fileName) throws IOException {
super(createPrintStream(fileName,true));
super(createPrintStream(fileName, true));
}
public FileSyslogServerEventHandler(String fileName, boolean append) throws IOException {
super(createPrintStream(fileName,append));
super(createPrintStream(fileName, append));
}
}

View File

@ -10,16 +10,16 @@ import org.graylog2.syslog4j.server.SyslogServerSessionEventHandlerIF;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* SystemOutSyslogServerEventHandler provides a simple example implementation
* of the SyslogServerEventHandlerIF which writes the events to System.out.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PrintStreamSyslogServerEventHandler.java,v 1.7 2010/11/28 22:07:57 cvs Exp $
*/
* SystemOutSyslogServerEventHandler provides a simple example implementation
* of the SyslogServerEventHandlerIF which writes the events to System.out.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: PrintStreamSyslogServerEventHandler.java,v 1.7 2010/11/28 22:07:57 cvs Exp $
*/
public class PrintStreamSyslogServerEventHandler implements SyslogServerSessionEventHandlerIF {
private static final long serialVersionUID = 6036415838696050746L;

View File

@ -13,11 +13,11 @@ import org.graylog2.syslog4j.server.impl.event.SyslogServerEvent;
* SyslogServerStructuredEvent provides an implementation of the
* SyslogServerEventIF interface that supports receiving of structured syslog
* messages, as defined in:
*
* <p/>
* <p>
* http://tools.ietf.org/html/draft-ietf-syslog-protocol-23#section-6
* </p>
*
* <p/>
* <p>
* Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy of the
* LGPL license is available in the META-INF folder in all distributions of
@ -38,14 +38,14 @@ public class StructuredSyslogServerEvent extends SyslogServerEvent {
public StructuredSyslogServerEvent(final byte[] message, int length, InetAddress inetAddress) {
super();
initialize(message,length,inetAddress);
initialize(message, length, inetAddress);
parse();
}
public StructuredSyslogServerEvent(final String message, InetAddress inetAddress) {
super();
initialize(message,inetAddress);
initialize(message, inetAddress);
parse();
}
@ -118,8 +118,8 @@ public class StructuredSyslogServerEvent extends SyslogServerEvent {
int i = this.message.indexOf(' ');
if (i > -1) {
this.host = this.message.substring(0,i).trim();
this.message = this.message.substring(i+1);
this.host = this.message.substring(0, i).trim();
this.message = this.message.substring(i + 1);
parseApplicationName();
}
@ -145,7 +145,7 @@ public class StructuredSyslogServerEvent extends SyslogServerEvent {
// throw new SyslogRuntimeException(
// "Message received is not a valid structured message: "
// + getMessage(), e);
return new StructuredSyslogMessage(null,null,getMessage());
return new StructuredSyslogMessage(null, null, getMessage());
}
}
}

View File

@ -3,16 +3,16 @@ package org.graylog2.syslog4j.server.impl.net;
import org.graylog2.syslog4j.server.impl.AbstractSyslogServerConfig;
/**
* AbstractNetSyslogServerConfig provides a base abstract implementation of the AbstractSyslogServerConfig
* configuration interface.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractNetSyslogServerConfig.java,v 1.4 2008/11/07 15:15:41 cvs Exp $
*/
* AbstractNetSyslogServerConfig provides a base abstract implementation of the AbstractSyslogServerConfig
* configuration interface.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: AbstractNetSyslogServerConfig.java,v 1.4 2008/11/07 15:15:41 cvs Exp $
*/
public abstract class AbstractNetSyslogServerConfig extends AbstractSyslogServerConfig {
private static final long serialVersionUID = -3363374941938350263L;

View File

@ -20,15 +20,15 @@ import org.graylog2.syslog4j.server.impl.AbstractSyslogServer;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* TCPNetSyslogServer provides a simple threaded TCP/IP server implementation.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogServer.java,v 1.23 2010/11/28 22:07:57 cvs Exp $
*/
* TCPNetSyslogServer provides a simple threaded TCP/IP server implementation.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogServer.java,v 1.23 2010/11/28 22:07:57 cvs Exp $
*/
public class TCPNetSyslogServer extends AbstractSyslogServer {
public static class TCPNetSyslogSocketHandler implements Runnable {
protected SyslogServerIF server = null;
@ -40,7 +40,7 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
this.server = server;
this.socket = socket;
synchronized(this.sessions) {
synchronized (this.sessions) {
this.sessions.addSocket(socket);
}
}
@ -54,13 +54,13 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
String line = br.readLine();
if (line != null) {
AbstractSyslogServer.handleSessionOpen(this.sessions,this.server,this.socket);
AbstractSyslogServer.handleSessionOpen(this.sessions, this.server, this.socket);
}
while (line != null && line.length() != 0) {
SyslogServerEventIF event = createEvent(this.server.getConfig(),line,this.socket.getInetAddress());
SyslogServerEventIF event = createEvent(this.server.getConfig(), line, this.socket.getInetAddress());
AbstractSyslogServer.handleEvent(this.sessions,this.server,this.socket,event);
AbstractSyslogServer.handleEvent(this.sessions, this.server, this.socket, event);
line = br.readLine();
}
@ -69,7 +69,7 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
timeout = true;
} catch (SocketException se) {
AbstractSyslogServer.handleException(this.sessions,this.server,this.socket.getRemoteSocketAddress(),se);
AbstractSyslogServer.handleException(this.sessions, this.server, this.socket.getRemoteSocketAddress(), se);
if ("Socket closed".equals(se.getMessage())) {
//
@ -79,18 +79,18 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
}
} catch (IOException ioe) {
AbstractSyslogServer.handleException(this.sessions,this.server,this.socket.getRemoteSocketAddress(),ioe);
AbstractSyslogServer.handleException(this.sessions, this.server, this.socket.getRemoteSocketAddress(), ioe);
}
try {
AbstractSyslogServer.handleSessionClosed(this.sessions,this.server,this.socket,timeout);
AbstractSyslogServer.handleSessionClosed(this.sessions, this.server, this.socket, timeout);
this.sessions.removeSocket(this.socket);
this.socket.close();
} catch (IOException ioe) {
AbstractSyslogServer.handleException(this.sessions,this.server,this.socket.getRemoteSocketAddress(),ioe);
AbstractSyslogServer.handleException(this.sessions, this.server, this.socket.getRemoteSocketAddress(), ioe);
}
}
}
@ -136,11 +136,11 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
this.serverSocket.close();
}
synchronized(this.sessions) {
synchronized (this.sessions) {
Iterator i = this.sessions.getSockets();
if (i != null) {
while(i.hasNext()) {
while (i.hasNext()) {
Socket s = (Socket) i.next();
s.close();
@ -172,14 +172,14 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
if (this.syslogServerConfig.getHost() != null) {
InetAddress inetAddress = InetAddress.getByName(this.syslogServerConfig.getHost());
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort(),this.tcpNetSyslogServerConfig.getBacklog(),inetAddress);
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort(), this.tcpNetSyslogServerConfig.getBacklog(), inetAddress);
} else {
if (this.tcpNetSyslogServerConfig.getBacklog() < 1) {
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort());
} else {
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort(),this.tcpNetSyslogServerConfig.getBacklog());
newServerSocket = factory.createServerSocket(this.syslogServerConfig.getPort(), this.tcpNetSyslogServerConfig.getBacklog());
}
}
@ -200,7 +200,7 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
handleInitialize(this);
while(!this.shutdown) {
while (!this.shutdown) {
try {
Socket socket = this.serverSocket.accept();
@ -227,7 +227,7 @@ public class TCPNetSyslogServer extends AbstractSyslogServer {
}
if (socket != null) {
TCPNetSyslogSocketHandler handler = new TCPNetSyslogSocketHandler(this.sessions,this,socket);
TCPNetSyslogSocketHandler handler = new TCPNetSyslogSocketHandler(this.sessions, this, socket);
Thread t = new Thread(handler);

View File

@ -3,15 +3,15 @@ package org.graylog2.syslog4j.server.impl.net.tcp;
import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig;
/**
* TCPNetSyslogServerConfig provides configuration for TCPNetSyslogServer.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogServerConfig.java,v 1.8 2010/11/28 01:38:08 cvs Exp $
*/
* TCPNetSyslogServerConfig provides configuration for TCPNetSyslogServer.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogServerConfig.java,v 1.8 2010/11/28 01:38:08 cvs Exp $
*/
public class TCPNetSyslogServerConfig extends AbstractNetSyslogServerConfig implements TCPNetSyslogServerConfigIF {
private static final long serialVersionUID = -1546696301177599370L;

View File

@ -3,28 +3,32 @@ package org.graylog2.syslog4j.server.impl.net.tcp;
import org.graylog2.syslog4j.server.SyslogServerConfigIF;
/**
* TCPNetSyslogServerConfigIF provides configuration for TCPNetSyslogServer.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogServerConfigIF.java,v 1.3 2010/11/28 01:38:08 cvs Exp $
*/
* TCPNetSyslogServerConfigIF provides configuration for TCPNetSyslogServer.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: TCPNetSyslogServerConfigIF.java,v 1.3 2010/11/28 01:38:08 cvs Exp $
*/
public interface TCPNetSyslogServerConfigIF extends SyslogServerConfigIF {
public final static byte MAX_ACTIVE_SOCKETS_BEHAVIOR_BLOCK = 0;
public final static byte MAX_ACTIVE_SOCKETS_BEHAVIOR_REJECT = 1;
public int getTimeout();
public void setTimeout(int timeout);
public int getBacklog();
public void setBacklog(int backlog);
public int getMaxActiveSockets();
public void setMaxActiveSockets(int maxActiveSockets);
public byte getMaxActiveSocketsBehavior();
public void setMaxActiveSocketsBehavior(byte maxActiveSocketsBehavior);
}

View File

@ -9,16 +9,16 @@ import org.graylog2.syslog4j.SyslogRuntimeException;
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServer;
/**
* SSLTCPNetSyslogServer provides a simple threaded TCP/IP server implementation
* which uses SSL/TLS.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogServer.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
* SSLTCPNetSyslogServer provides a simple threaded TCP/IP server implementation
* which uses SSL/TLS.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogServer.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
public class SSLTCPNetSyslogServer extends TCPNetSyslogServer {
public void initialize() throws SyslogRuntimeException {
super.initialize();
@ -28,25 +28,25 @@ public class SSLTCPNetSyslogServer extends TCPNetSyslogServer {
String keyStore = sslTcpNetSyslogServerConfig.getKeyStore();
if (keyStore != null && !"".equals(keyStore.trim())) {
System.setProperty("javax.net.ssl.keyStore",keyStore);
System.setProperty("javax.net.ssl.keyStore", keyStore);
}
String keyStorePassword = sslTcpNetSyslogServerConfig.getKeyStorePassword();
if (keyStorePassword != null && !"".equals(keyStorePassword.trim())) {
System.setProperty("javax.net.ssl.keyStorePassword",keyStorePassword);
System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);
}
String trustStore = sslTcpNetSyslogServerConfig.getTrustStore();
if (trustStore != null && !"".equals(trustStore.trim())) {
System.setProperty("javax.net.ssl.trustStore",trustStore);
System.setProperty("javax.net.ssl.trustStore", trustStore);
}
String trustStorePassword = sslTcpNetSyslogServerConfig.getTrustStorePassword();
if (trustStorePassword != null && !"".equals(trustStorePassword.trim())) {
System.setProperty("javax.net.ssl.trustStorePassword",trustStorePassword);
System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
}
}

View File

@ -3,15 +3,15 @@ package org.graylog2.syslog4j.server.impl.net.tcp.ssl;
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServerConfig;
/**
* SSLTCPNetSyslogServerConfig provides configuration for SSLTCPNetSyslogServer.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogServerConfig.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
* SSLTCPNetSyslogServerConfig provides configuration for SSLTCPNetSyslogServer.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogServerConfig.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
public class SSLTCPNetSyslogServerConfig extends TCPNetSyslogServerConfig implements SSLTCPNetSyslogServerConfigIF {
private static final long serialVersionUID = -840102682868286462L;

View File

@ -3,25 +3,29 @@ package org.graylog2.syslog4j.server.impl.net.tcp.ssl;
import org.graylog2.syslog4j.server.impl.net.tcp.TCPNetSyslogServerConfigIF;
/**
* SSLTCPNetSyslogServerConfigIF provides configuration for SSLTCPNetSyslogServer.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogServerConfigIF.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
* SSLTCPNetSyslogServerConfigIF provides configuration for SSLTCPNetSyslogServer.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SSLTCPNetSyslogServerConfigIF.java,v 1.1 2009/03/29 17:38:58 cvs Exp $
*/
public interface SSLTCPNetSyslogServerConfigIF extends TCPNetSyslogServerConfigIF {
public String getKeyStore();
public void setKeyStore(String keyStore);
public String getKeyStorePassword();
public void setKeyStorePassword(String keyStorePassword);
public String getTrustStore();
public void setTrustStore(String trustStore);
public String getTrustStorePassword();
public void setTrustStorePassword(String trustStorePassword);
}

View File

@ -14,15 +14,15 @@ import org.graylog2.syslog4j.server.impl.AbstractSyslogServer;
import org.graylog2.syslog4j.util.SyslogUtility;
/**
* UDPNetSyslogServer provides a simple non-threaded UDP/IP server implementation.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UDPNetSyslogServer.java,v 1.16 2010/11/12 03:43:15 cvs Exp $
*/
* UDPNetSyslogServer provides a simple non-threaded UDP/IP server implementation.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UDPNetSyslogServer.java,v 1.16 2010/11/12 03:43:15 cvs Exp $
*/
public class UDPNetSyslogServer extends AbstractSyslogServer {
protected DatagramSocket ds = null;
@ -48,7 +48,7 @@ public class UDPNetSyslogServer extends AbstractSyslogServer {
if (this.syslogServerConfig.getHost() != null) {
InetAddress inetAddress = InetAddress.getByName(this.syslogServerConfig.getHost());
datagramSocket = new DatagramSocket(this.syslogServerConfig.getPort(),inetAddress);
datagramSocket = new DatagramSocket(this.syslogServerConfig.getPort(), inetAddress);
} else {
datagramSocket = new DatagramSocket(this.syslogServerConfig.getPort());
@ -73,27 +73,27 @@ public class UDPNetSyslogServer extends AbstractSyslogServer {
handleInitialize(this);
while(!this.shutdown) {
while (!this.shutdown) {
DatagramPacket dp = null;
try {
dp = new DatagramPacket(receiveData,receiveData.length);
dp = new DatagramPacket(receiveData, receiveData.length);
this.ds.receive(dp);
SyslogServerEventIF event = createEvent(this.getConfig(),receiveData,dp.getLength(),dp.getAddress());
SyslogServerEventIF event = createEvent(this.getConfig(), receiveData, dp.getLength(), dp.getAddress());
handleEvent(null,this,dp,event);
handleEvent(null, this, dp, event);
} catch (SocketException se) {
int i = se.getMessage() == null ? -1 : se.getMessage().toLowerCase().indexOf("socket closed");
if (i == -1) {
handleException(null,this,dp.getSocketAddress(),se);
handleException(null, this, dp.getSocketAddress(), se);
}
} catch (IOException ioe) {
handleException(null,this,dp.getSocketAddress(),ioe);
handleException(null, this, dp.getSocketAddress(), ioe);
}
}

View File

@ -3,15 +3,15 @@ package org.graylog2.syslog4j.server.impl.net.udp;
import org.graylog2.syslog4j.server.impl.net.AbstractNetSyslogServerConfig;
/**
* UDPNetSyslogServerConfig provides configuration for UDPNetSyslogServer.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UDPNetSyslogServerConfig.java,v 1.6 2010/10/28 05:10:57 cvs Exp $
*/
* UDPNetSyslogServerConfig provides configuration for UDPNetSyslogServer.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: UDPNetSyslogServerConfig.java,v 1.6 2010/10/28 05:10:57 cvs Exp $
*/
public class UDPNetSyslogServerConfig extends AbstractNetSyslogServerConfig {
private static final long serialVersionUID = -2005919161187055486L;

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +1,16 @@
package org.graylog2.syslog4j.util;
/**
* OSDetectUtility provides operating system detection used to determine
* whether Syslog4j is running on a Unix platform.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: OSDetectUtility.java,v 1.4 2008/11/14 04:31:59 cvs Exp $
*/
* OSDetectUtility provides operating system detection used to determine
* whether Syslog4j is running on a Unix platform.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: OSDetectUtility.java,v 1.4 2008/11/14 04:31:59 cvs Exp $
*/
public final class OSDetectUtility {
private final static String[] UNIX_PLATFORMS = {
"Linux",
@ -49,7 +49,7 @@ public final class OSDetectUtility {
if (osName != null && !"".equals(osName.trim())) {
osName = osName.toLowerCase();
for(int i=0; i<platforms.length; i++) {
for (int i = 0; i < platforms.length; i++) {
String platform = platforms[i].toLowerCase();
if (osName.indexOf(platform) > -1) {

View File

@ -9,16 +9,16 @@ import org.graylog2.syslog4j.SyslogConstants;
import org.graylog2.syslog4j.SyslogRuntimeException;
/**
* SyslogUtility provides several common utility methods used within
* Syslog4j.
*
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogUtility.java,v 1.21 2010/11/28 01:38:08 cvs Exp $
*/
* SyslogUtility provides several common utility methods used within
* Syslog4j.
* <p/>
* <p>Syslog4j is licensed under the Lesser GNU Public License v2.1. A copy
* of the LGPL license is available in the META-INF folder in all
* distributions of Syslog4j and in the base directory of the "doc" ZIP.</p>
*
* @author &lt;syslog4j@productivity.org&gt;
* @version $Id: SyslogUtility.java,v 1.21 2010/11/28 01:38:08 cvs Exp $
*/
public final class SyslogUtility implements SyslogConstants {
private static final long serialVersionUID = 915031554586613648L;
@ -40,29 +40,50 @@ public final class SyslogUtility implements SyslogConstants {
}
public static final String getFacilityString(int syslogFacility) {
switch(syslogFacility) {
case FACILITY_KERN: return "kern";
case FACILITY_USER: return "user";
case FACILITY_MAIL: return "mail";
case FACILITY_DAEMON: return "daemon";
case FACILITY_AUTH: return "auth";
case FACILITY_SYSLOG: return "syslog";
case FACILITY_LPR: return "lpr";
case FACILITY_NEWS: return "news";
case FACILITY_UUCP: return "uucp";
case FACILITY_CRON: return "cron";
case FACILITY_AUTHPRIV: return "authpriv";
case FACILITY_FTP: return "ftp";
case FACILITY_LOCAL0: return "local0";
case FACILITY_LOCAL1: return "local1";
case FACILITY_LOCAL2: return "local2";
case FACILITY_LOCAL3: return "local3";
case FACILITY_LOCAL4: return "local4";
case FACILITY_LOCAL5: return "local5";
case FACILITY_LOCAL6: return "local6";
case FACILITY_LOCAL7: return "local7";
switch (syslogFacility) {
case FACILITY_KERN:
return "kern";
case FACILITY_USER:
return "user";
case FACILITY_MAIL:
return "mail";
case FACILITY_DAEMON:
return "daemon";
case FACILITY_AUTH:
return "auth";
case FACILITY_SYSLOG:
return "syslog";
case FACILITY_LPR:
return "lpr";
case FACILITY_NEWS:
return "news";
case FACILITY_UUCP:
return "uucp";
case FACILITY_CRON:
return "cron";
case FACILITY_AUTHPRIV:
return "authpriv";
case FACILITY_FTP:
return "ftp";
case FACILITY_LOCAL0:
return "local0";
case FACILITY_LOCAL1:
return "local1";
case FACILITY_LOCAL2:
return "local2";
case FACILITY_LOCAL3:
return "local3";
case FACILITY_LOCAL4:
return "local4";
case FACILITY_LOCAL5:
return "local5";
case FACILITY_LOCAL6:
return "local6";
case FACILITY_LOCAL7:
return "local7";
default: return "UNKNOWN";
default:
return "UNKNOWN";
}
}
@ -76,27 +97,48 @@ public final class SyslogUtility implements SyslogConstants {
_facilityName = facilityName.trim();
}
if("KERN".equalsIgnoreCase(_facilityName)) { return FACILITY_KERN;
} else if("USER".equalsIgnoreCase(facilityName)) { return FACILITY_USER;
} else if("MAIL".equalsIgnoreCase(facilityName)) { return FACILITY_MAIL;
} else if("DAEMON".equalsIgnoreCase(facilityName)) { return FACILITY_DAEMON;
} else if("AUTH".equalsIgnoreCase(facilityName)) { return FACILITY_AUTH;
} else if("SYSLOG".equalsIgnoreCase(facilityName)) { return FACILITY_SYSLOG;
} else if("LPR".equalsIgnoreCase(facilityName)) { return FACILITY_LPR;
} else if("NEWS".equalsIgnoreCase(facilityName)) { return FACILITY_NEWS;
} else if("UUCP".equalsIgnoreCase(facilityName)) { return FACILITY_UUCP;
} else if("CRON".equalsIgnoreCase(facilityName)) { return FACILITY_CRON;
} else if("AUTHPRIV".equalsIgnoreCase(facilityName)) { return FACILITY_AUTHPRIV;
} else if("FTP".equalsIgnoreCase(facilityName)) { return FACILITY_FTP;
} else if("LOCAL0".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL0;
} else if("LOCAL1".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL1;
} else if("LOCAL2".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL2;
} else if("LOCAL3".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL3;
} else if("LOCAL4".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL4;
} else if("LOCAL5".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL5;
} else if("LOCAL6".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL6;
} else if("LOCAL7".equalsIgnoreCase(facilityName)) { return FACILITY_LOCAL7;
} else { return -1;
if ("KERN".equalsIgnoreCase(_facilityName)) {
return FACILITY_KERN;
} else if ("USER".equalsIgnoreCase(facilityName)) {
return FACILITY_USER;
} else if ("MAIL".equalsIgnoreCase(facilityName)) {
return FACILITY_MAIL;
} else if ("DAEMON".equalsIgnoreCase(facilityName)) {
return FACILITY_DAEMON;
} else if ("AUTH".equalsIgnoreCase(facilityName)) {
return FACILITY_AUTH;
} else if ("SYSLOG".equalsIgnoreCase(facilityName)) {
return FACILITY_SYSLOG;
} else if ("LPR".equalsIgnoreCase(facilityName)) {
return FACILITY_LPR;
} else if ("NEWS".equalsIgnoreCase(facilityName)) {
return FACILITY_NEWS;
} else if ("UUCP".equalsIgnoreCase(facilityName)) {
return FACILITY_UUCP;
} else if ("CRON".equalsIgnoreCase(facilityName)) {
return FACILITY_CRON;
} else if ("AUTHPRIV".equalsIgnoreCase(facilityName)) {
return FACILITY_AUTHPRIV;
} else if ("FTP".equalsIgnoreCase(facilityName)) {
return FACILITY_FTP;
} else if ("LOCAL0".equalsIgnoreCase(facilityName)) {
return FACILITY_LOCAL0;
} else if ("LOCAL1".equalsIgnoreCase(facilityName)) {
return FACILITY_LOCAL1;
} else if ("LOCAL2".equalsIgnoreCase(facilityName)) {
return FACILITY_LOCAL2;
} else if ("LOCAL3".equalsIgnoreCase(facilityName)) {
return FACILITY_LOCAL3;
} else if ("LOCAL4".equalsIgnoreCase(facilityName)) {
return FACILITY_LOCAL4;
} else if ("LOCAL5".equalsIgnoreCase(facilityName)) {
return FACILITY_LOCAL5;
} else if ("LOCAL6".equalsIgnoreCase(facilityName)) {
return FACILITY_LOCAL6;
} else if ("LOCAL7".equalsIgnoreCase(facilityName)) {
return FACILITY_LOCAL7;
} else {
return -1;
}
}
@ -110,15 +152,24 @@ public final class SyslogUtility implements SyslogConstants {
_levelName = levelName.trim();
}
if("DEBUG".equalsIgnoreCase(_levelName)) { return LEVEL_DEBUG;
} else if("INFO".equalsIgnoreCase(_levelName)) { return LEVEL_INFO;
} else if("NOTICE".equalsIgnoreCase(_levelName)) { return LEVEL_NOTICE;
} else if("WARN".equalsIgnoreCase(_levelName)) { return LEVEL_WARN;
} else if("ERROR".equalsIgnoreCase(_levelName)) { return LEVEL_ERROR;
} else if("CRITICAL".equalsIgnoreCase(_levelName)) { return LEVEL_CRITICAL;
} else if("ALERT".equalsIgnoreCase(_levelName)) { return LEVEL_ALERT;
} else if("EMERGENCY".equalsIgnoreCase(_levelName)) { return LEVEL_EMERGENCY;
} else { return -1;
if ("DEBUG".equalsIgnoreCase(_levelName)) {
return LEVEL_DEBUG;
} else if ("INFO".equalsIgnoreCase(_levelName)) {
return LEVEL_INFO;
} else if ("NOTICE".equalsIgnoreCase(_levelName)) {
return LEVEL_NOTICE;
} else if ("WARN".equalsIgnoreCase(_levelName)) {
return LEVEL_WARN;
} else if ("ERROR".equalsIgnoreCase(_levelName)) {
return LEVEL_ERROR;
} else if ("CRITICAL".equalsIgnoreCase(_levelName)) {
return LEVEL_CRITICAL;
} else if ("ALERT".equalsIgnoreCase(_levelName)) {
return LEVEL_ALERT;
} else if ("EMERGENCY".equalsIgnoreCase(_levelName)) {
return LEVEL_EMERGENCY;
} else {
return -1;
}
}
@ -162,7 +213,7 @@ public final class SyslogUtility implements SyslogConstants {
}
public static final String newString(SyslogCharSetIF syslogCharSet, byte[] dataBytes) {
String data = newString(syslogCharSet,dataBytes,dataBytes.length);
String data = newString(syslogCharSet, dataBytes, dataBytes.length);
return data;
}
@ -171,7 +222,7 @@ public final class SyslogUtility implements SyslogConstants {
String data = null;
try {
data = new String(dataBytes,0,dataLength,syslogCharSet.getCharSet());
data = new String(dataBytes, 0, dataLength, syslogCharSet.getCharSet());
} catch (UnsupportedEncodingException uee) {
data = new String(dataBytes);
@ -181,15 +232,23 @@ public final class SyslogUtility implements SyslogConstants {
}
public static final String getLevelString(int level) {
switch(level) {
case SyslogConstants.LEVEL_DEBUG: return "DEBUG";
case SyslogConstants.LEVEL_INFO: return "INFO";
case SyslogConstants.LEVEL_NOTICE: return "NOTICE";
case SyslogConstants.LEVEL_WARN: return "WARN";
case SyslogConstants.LEVEL_ERROR: return "ERROR";
case SyslogConstants.LEVEL_CRITICAL: return "CRITICAL";
case SyslogConstants.LEVEL_ALERT: return "ALERT";
case SyslogConstants.LEVEL_EMERGENCY: return "EMERGENCY";
switch (level) {
case SyslogConstants.LEVEL_DEBUG:
return "DEBUG";
case SyslogConstants.LEVEL_INFO:
return "INFO";
case SyslogConstants.LEVEL_NOTICE:
return "NOTICE";
case SyslogConstants.LEVEL_WARN:
return "WARN";
case SyslogConstants.LEVEL_ERROR:
return "ERROR";
case SyslogConstants.LEVEL_CRITICAL:
return "CRITICAL";
case SyslogConstants.LEVEL_ALERT:
return "ALERT";
case SyslogConstants.LEVEL_EMERGENCY:
return "EMERGENCY";
default:
return "UNKNOWN";