org.productivity.java.syslog4j.server.SyslogServerConfigIF Java Examples
The following examples show how to use
org.productivity.java.syslog4j.server.SyslogServerConfigIF.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractSyslogServer.java From syslog4j with GNU Lesser General Public License v2.1 | 6 votes |
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.getDateTimeFormatter() != null) { ((StructuredSyslogServerEvent) event).setDateTimeFormatter(serverConfig.getDateTimeFormatter()); } } else { event = new SyslogServerEvent(lineBytes,lineBytesLength,inetAddr); } return event; }
Example #2
Source File: Server.java From simple-syslog-server with GNU Lesser General Public License v2.1 | 5 votes |
private static SyslogServerConfigIF getSyslogConfig(String syslogProtocol) { SyslogServerConfigIF config = null; if ("udp".equals(syslogProtocol)) { config = new UDPSyslogServerConfig(); } else if ("tcp".equals(syslogProtocol)) { config = new TCPSyslogServerConfig(); } else if ("tls".equals(syslogProtocol)) { config = new TLSSyslogServerConfig(); } return config; }
Example #3
Source File: AbstractSyslogServer.java From syslog4j with GNU Lesser General Public License v2.1 | 5 votes |
public void initialize(String protocol, SyslogServerConfigIF config) throws SyslogRuntimeException { this.syslogProtocol = protocol; try { this.syslogServerConfig = (AbstractSyslogServerConfig) config; } catch (ClassCastException cce) { throw new SyslogRuntimeException(cce); } initialize(); }
Example #4
Source File: AbstractSyslogServer.java From syslog4j with GNU Lesser General Public License v2.1 | 5 votes |
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); } else { event = new SyslogServerEvent(line,inetAddr); } return event; }
Example #5
Source File: AuditLogToTLSSyslogSetup.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected SyslogServerConfigIF getSyslogConfig() { TLSSyslogServerConfig config = new TLSSyslogServerConfig(); config.setKeyStore(SERVER_KEYSTORE_FILE.getAbsolutePath()); config.setKeyStorePassword(PASSWORD); config.setTrustStore(SERVER_TRUSTSTORE_FILE.getAbsolutePath()); config.setTrustStorePassword(PASSWORD); return config; }
Example #6
Source File: AuditLogToSyslogSetup.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Starts Syslog server and configures syslog handler in the AS. * */ @Override public void setup(ManagementClient managementClient) throws Exception { // clear created server instances (TCP/UDP) SyslogServer.shutdown(); // start and set syslog server final String host = managementClient.getMgmtAddress(); SyslogServerConfigIF config = getSyslogConfig(); config.setUseStructuredData(true); config.setHost(host); config.setPort(SYSLOG_PORT); config.addEventHandler(new BlockedSyslogServerEventHandler()); final String syslogProtocol = getSyslogProtocol(); server = SyslogServer.createInstance(syslogProtocol, config); // start syslog server SyslogServer.getThreadedInstance(syslogProtocol); // Add the normal syslog handler addSyslogHandler(managementClient, AUDIT_SYSLOG_HANDLER_ADDR, host, null, null); // Add the syslog handler we will switch to addSyslogHandler(managementClient, AUDIT_SYSLOG_HANDLER_ADDR2, host, "TestApp", Facility.LINE_PRINTER); // Reference the first audit logger for now ModelNode op = Util.createAddOperation(AUDIT_LOG_LOGGER_SYSLOG_HANDLER_ADDR); CoreUtils.applyUpdate(op, managementClient.getControllerClient()); op = Util.getWriteAttributeOperation(AUDIT_LOG_LOGGER_ADDR, LOG_READ_ONLY, false); CoreUtils.applyUpdate(op, managementClient.getControllerClient()); }
Example #7
Source File: AbstractSyslogReconnectionTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static SyslogServerIF createAndStartSyslogInstance(SyslogServerConfigIF config, String host, int port, String protocol) { config.setUseStructuredData(true); config.setHost(host); config.setPort(port); config.addEventHandler(new BlockedAllProtocolsSyslogServerEventHandler(protocol)); SyslogServerIF syslogServer = SyslogServer.createInstance(protocol, config); SyslogServer.getThreadedInstance(protocol); return syslogServer; }
Example #8
Source File: Server.java From simple-syslog-server with GNU Lesser General Public License v2.1 | 4 votes |
public static void main(String[] args) throws SyslogRuntimeException, UnknownHostException { // Details for the properties - // http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/JSSERefGuide.html System.setProperty("jsse.enableSNIExtension", "false"); // just in case... System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true"); System.setProperty("sun.security.ssl.allowLegacyHelloMessages", "true"); // clear created server instances (TCP/UDP) SyslogServer.shutdown(); String syslogProtocol = "tls"; System.out.println("Simple syslog server (RFC-5424)"); System.out.println("Usage:"); System.out.println(" java -jar simple-syslog-server.jar [protocol]"); System.out.println(); System.out.println("Possible protocols: udp, tcp, tls"); System.out.println(); if (args.length > 0) { syslogProtocol = args[0]; } else { System.err.println("No protocol provided. Defaulting to " + syslogProtocol); } SyslogServerConfigIF config = getSyslogConfig(syslogProtocol); if (config == null) { System.err.println("Unsupported Syslog protocol: " + syslogProtocol); System.exit(1); } config.setUseStructuredData(true); // config.setHost(InetAddress.getByName(null).getHostAddress()); config.setHost("0.0.0.0"); config.setPort(SYSLOG_PORT); System.out.println("Starting Simple Syslog Server"); System.out.println("Protocol: " + syslogProtocol); System.out.println("Bind address: " + config.getHost()); System.out.println("Port: " + config.getPort()); // start syslog server SyslogServer.createThreadedInstance(syslogProtocol, config); }
Example #9
Source File: AbstractSyslogServer.java From syslog4j with GNU Lesser General Public License v2.1 | 4 votes |
public SyslogServerConfigIF getConfig() { return this.syslogServerConfig; }
Example #10
Source File: SyslogServerSessionTest.java From syslog4j with GNU Lesser General Public License v2.1 | 4 votes |
public void testTCPSession() { SyslogServerConfigIF serverConfig = new TCPNetSyslogServerConfig(9999); TCPSessionHandler handler1 = new TCPSessionHandler("a"); serverConfig.addEventHandler(handler1); TCPSessionHandler handler2 = new TCPSessionHandler("b"); serverConfig.addEventHandler(handler2); SyslogServerIF server = SyslogServer.createThreadedInstance("tcp_session",serverConfig); SyslogUtility.sleep(100); assertTrue(handler1.initialized); assertTrue(handler2.initialized); SyslogConfigIF config = new TCPNetSyslogConfig(); config.setPort(9999); TCPNetSyslogServer tcpServer = (TCPNetSyslogServer) server; SyslogIF syslog1 = Syslog.createInstance("tcp_session_1",config); syslog1.info("1"); syslog1.info("2"); SyslogUtility.sleep(100); assertEquals(1,tcpServer.getSessions().size()); SyslogIF syslog2 = Syslog.createInstance("tcp_session_2",config); syslog2.info("3"); syslog2.info("4"); syslog1.info("5"); syslog1.info("6"); syslog2.info("7"); syslog2.info("8"); SyslogUtility.sleep(100); assertEquals(2,tcpServer.getSessions().size()); syslog1.shutdown(); syslog2.shutdown(); SyslogServer.destroyInstance("tcp_session"); try { SyslogServer.getInstance("tcp_session"); fail(); } catch (SyslogRuntimeException sre) { // } assertEquals(4,handler1.eventCount[0]); assertEquals(0,handler1.eventCount[1]); assertEquals(4,handler1.eventCount[2]); assertEquals(0,handler1.eventCount[3]); assertEquals(0,handler2.eventCount[0]); assertEquals(4,handler2.eventCount[1]); assertEquals(0,handler2.eventCount[2]); assertEquals(4,handler2.eventCount[3]); assertEquals(1,handler1.closeCount[0]); assertEquals(0,handler1.closeCount[1]); assertEquals(1,handler1.closeCount[2]); assertEquals(0,handler1.closeCount[3]); assertEquals(0,handler2.closeCount[0]); assertEquals(1,handler2.closeCount[1]); assertEquals(0,handler2.closeCount[2]); assertEquals(1,handler2.closeCount[3]); SyslogUtility.sleep(100); assertTrue(handler1.destroyed); assertTrue(handler2.destroyed); }
Example #11
Source File: AuditLogToUDPSyslogSetup.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected SyslogServerConfigIF getSyslogConfig() { return new UDPSyslogServerConfig(); }
Example #12
Source File: AuditLogToTCPSyslogTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected SyslogServerConfigIF getSyslogConfig() { return new TCPSyslogServerConfig(); }
Example #13
Source File: TLSAuditLogToTCPSyslogTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override protected SyslogServerConfigIF getSyslogConfig() { return new TCPSyslogServerConfig(); }
Example #14
Source File: SyslogServerSessionTest.java From syslog4j with GNU Lesser General Public License v2.1 | 2 votes |
public void testUDPSession() { SyslogServerConfigIF serverConfig = new UDPNetSyslogServerConfig(9999); UDPSessionHandler handler1 = new UDPSessionHandler("a"); serverConfig.addEventHandler(handler1); UDPSessionHandler handler2 = new UDPSessionHandler("b"); serverConfig.addEventHandler(handler2); SyslogServer.createThreadedInstance("udp_session",serverConfig); SyslogUtility.sleep(100); assertTrue(handler1.initialized); assertTrue(handler2.initialized); SyslogConfigIF config = new UDPNetSyslogConfig(); config.setPort(9999); SyslogIF syslog1 = Syslog.createInstance("udp_session_1",config); syslog1.info("1"); syslog1.info("2"); SyslogIF syslog2 = Syslog.createInstance("udp_session_2",config); syslog2.info("3"); syslog2.info("4"); SyslogUtility.sleep(100); syslog1.shutdown(); syslog2.shutdown(); SyslogServer.destroyInstance("udp_session"); try { SyslogServer.getInstance("udp_session"); fail(); } catch (SyslogRuntimeException sre) { // } assertTrue(handler1.okay); assertTrue(handler2.okay); SyslogUtility.sleep(250); assertTrue(handler1.destroyed); assertTrue(handler2.destroyed); }
Example #15
Source File: AuditLogToSyslogSetup.java From wildfly-core with GNU Lesser General Public License v2.1 | 2 votes |
/** * Returns a new instance of {@link org.productivity.java.syslog4j.server.SyslogServerConfigIF}. It's not necessary to specify host or port, these attributes are * configured in {@link ServerSetupTask#setup(org.wildfly.core.testrunner.ManagementClient)} method. * * @return */ protected abstract SyslogServerConfigIF getSyslogConfig();