本文整理汇总了Java中org.productivity.java.syslog4j.SyslogIF类的典型用法代码示例。如果您正苦于以下问题:Java SyslogIF类的具体用法?Java SyslogIF怎么用?Java SyslogIF使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SyslogIF类属于org.productivity.java.syslog4j包,在下文中一共展示了SyslogIF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: modify
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public String modify(SyslogIF syslog, int facility, int level, String 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);
buffer.append(this.config.getPrefix());
buffer.append(macString);
buffer.append(this.config.getSuffix());
return buffer.toString();
}
}
示例2: modify
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public String modify(SyslogIF syslog, int facility, int level, String message) {
synchronized(this.config.getChecksum()) {
StringBuffer messageBuffer = new StringBuffer(message);
byte[] messageBytes = SyslogUtility.getBytes(syslog.getConfig(),message);
if (!this.config.isContinuous()) {
this.config.getChecksum().reset();
}
this.config.getChecksum().update(messageBytes,0,message.length());
messageBuffer.append(this.config.getPrefix());
messageBuffer.append(Long.toHexString(this.config.getChecksum().getValue()).toUpperCase());
messageBuffer.append(this.config.getSuffix());
return messageBuffer.toString();
}
}
示例3: testHashVerify
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public void testHashVerify() {
SyslogIF syslog = Syslog.getInstance("tcp");
HashSyslogMessageModifier modifier = HashSyslogMessageModifier.createMD5();
modifier.getConfig().setSuffix(null);
String message = "md5 hash Test 1212 ABAB";
String modifiedMessage = modifier.modify(syslog,0,0,message);
System.out.println(modifiedMessage);
if (!modifier.verify(message,"fqfK2PYV76Wv9yNQjLoVeg==")) {
fail();
}
if (!modifier.verify(message,Base64.decode("fqfK2PYV76Wv9yNQjLoVeg=="))) {
fail();
}
if (!modifier.verify(modifiedMessage)) {
fail();
}
assertFalse(modifier.verify(null));
}
示例4: testMacVerify
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public void testMacVerify() {
SyslogIF syslog = Syslog.getInstance("udp");
MacSyslogMessageModifier modifier = MacSyslogMessageModifier.createHmacMD5("fb7Jl0VGnzY5ehJCdeff7bSZ5Vk=");
modifier.getConfig().setPrefix(" ");
modifier.getConfig().setSuffix(null);
String message = "hmacmd5 Test 3434 DCDC";
String modifiedMessage = modifier.modify(syslog,0,0,message);
System.out.println(modifiedMessage);
if (!modifier.verify(message,"MfWJ4XhFiMlPwnFEJ401zA==")) {
fail();
}
if (!modifier.verify(message,Base64.decode("MfWJ4XhFiMlPwnFEJ401zA=="))) {
fail();
}
if (!modifier.verify(modifiedMessage)) {
fail();
}
}
示例5: testPCISyslogMessage
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public void testPCISyslogMessage() {
// PREPARE
List events = new ArrayList();
String message = null;
String protocol = getClientProtocol();
SyslogIF syslog = getSyslog(protocol);
message = new PCISyslogMessage("a","b",new Date(),"c","d","e").createMessage();
syslog.info("[TEST] " + message);
events.add("[TEST] " + message);
// VERIFY
SyslogUtility.sleep(pause);
syslog.flush();
verifySendReceive(events,false,false);
}
示例6: testStructuredSyslogMessage
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public void testStructuredSyslogMessage() {
SyslogConfigIF config = new UDPNetSyslogConfig();
config.setUseStructuredData(true);
assertTrue(config.isUseStructuredData());
config.setUseStructuredData(false);
assertFalse(config.isUseStructuredData());
SyslogIF syslog = Syslog.createInstance("testStructuredSyslog",config);
SyslogMessageProcessorIF messageProcessor = new StructuredSyslogMessageProcessor();
syslog.setStructuredMessageProcessor(messageProcessor);
assertEquals(messageProcessor,syslog.getStructuredMessageProcessor());
SyslogMessageIF m1 = new StructuredSyslogMessage("test1",new HashMap(),"test2");
SyslogMessageIF m2 = new StructuredSyslogMessage("test1",new HashMap(),"test2");
SyslogMessageIF m3 = new StructuredSyslogMessage("test3",new HashMap(),"test2");
SyslogMessageIF m4 = new StructuredSyslogMessage("test1",new HashMap(),"test4");
assertFalse(m1.equals(null));
assertFalse(m1.equals("Wrong Class"));
assertTrue(m1.equals(m1));
assertTrue(m2.equals(m2));
assertFalse(m1.equals(m3));
assertFalse(m1.equals(m4));
}
示例7: testCreateAndDestroyByProtocol
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public void testCreateAndDestroyByProtocol() {
UDPNetSyslogConfig config = new UDPNetSyslogConfig();
config.setPort(999);
SyslogIF syslog = Syslog.createInstance("udpToDestroy",config);
assertEquals(SyslogMessageProcessor.getDefault(),syslog.getMessageProcessor());
SyslogMessageProcessorIF messageProcessor = new FakeMessageProcessor();
syslog.setMessageProcessor(messageProcessor);
assertEquals(messageProcessor,syslog.getMessageProcessor());
SyslogIF matchSyslog = Syslog.getInstance("udpToDestroy");
assertEquals(syslog,matchSyslog);
Syslog.destroyInstance("");
Syslog.destroyInstance("udpToDestroy");
try {
Syslog.getInstance("udpToDestroy");
fail("udpToDestroy should not exist");
} catch (SyslogRuntimeException sre) {
//
}
}
示例8: getSyslog
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
protected SyslogIF getSyslog(String protocol) {
if (!Syslog.exists(protocol)) {
fail("Protocol \"" + protocol + "\" does not exist");
}
SyslogIF syslog = Syslog.getInstance(protocol);
if (!(syslog instanceof MultipleSyslog)) {
syslog.getConfig().setIdent(APP_ID);
}
if (!(syslog.getConfig() instanceof MultipleSyslogConfig)) {
syslog.getConfig().setPort(TEST_PORT);
}
return syslog;
}
示例9: assertSyslog
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
protected void assertSyslog(SyslogIF syslog, String[] expectedMessages) {
SplitSyslog splitSyslog = (SplitSyslog) syslog;
List lastMessages = splitSyslog.getLastMessages();
if (lastMessages.size() < 1) {
fail("No messages received");
}
for(int i=0; i<lastMessages.size(); i++) {
String lastMessage = ((String) lastMessages.get(i)).substring(21 + this.localNameLength);
assertEquals(expectedMessages[i],lastMessage);
}
syslog.flush();
}
示例10: testTruncate
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public void testTruncate() {
setMessageLength(10);
SyslogIF syslog = Syslog.getInstance("split");
syslog.getConfig().setTruncateMessage(true);
syslog.info("T");
syslog.info("Test 1234");
syslog.info("Test 12345");
syslog.info("Test 654321");
syslog.info("Test 12345 For now is the time for all good men to come to the aid of their country");
assertSyslog(syslog,new String[] {"T", "Test 1234", "Test 12345", "Test 65432", "Test 12345" } );
syslog.flush();
}
示例11: start
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
@Override
public void start() {
super.start();
synchronized (this) {
try {
Class syslogClass = syslogConfig.getSyslogClass();
syslog = (SyslogIF) syslogClass.newInstance();
syslog.initialize(syslogClass.getSimpleName(), syslogConfig);
} catch (ClassCastException cse) {
throw new SyslogRuntimeException(cse);
} catch (IllegalAccessException iae) {
throw new SyslogRuntimeException(iae);
} catch (InstantiationException ie) {
throw new SyslogRuntimeException(ie);
}
}
}
示例12: modify
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public String modify(SyslogIF syslog, int facility, int level, String message) {
String _message = message;
if (message != null) {
if (this.stringCase == LOWER_CASE) {
_message = _message.toLowerCase();
} else if (this.stringCase == UPPER_CASE) {
_message = _message.toUpperCase();
}
}
return _message;
}
示例13: modify
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public String modify(SyslogIF syslog, int facility, int level, String message) {
if (this.suffix == null || "".equals(this.suffix.trim())) {
return message;
}
return message + this.delimiter + this.suffix;
}
示例14: modify
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public String modify(SyslogIF syslog, int facility, int level, String message) {
if (this.prefix == null || "".equals(this.prefix.trim())) {
return message;
}
return this.prefix + this.delimiter + message;
}
示例15: modify
import org.productivity.java.syslog4j.SyslogIF; //导入依赖的package包/类
public String modify(SyslogIF syslog, int facility, int level, String message) {
StringBuffer buffer = new StringBuffer(message);
buffer.append(this.config.getPrefix());
buffer.append(nextSequence(level));
buffer.append(this.config.getSuffix());
return buffer.toString();
}