org.jwall.web.audit.net
Class NetworkAuditEventSource

java.lang.Object
  extended by java.lang.Thread
      extended by org.jwall.web.audit.net.NetworkAuditEventSource
All Implemented Interfaces:
Runnable, AuditEventSource
Direct Known Subclasses:
SSLNetworkAuditEventSource

public class NetworkAuditEventSource
extends Thread
implements AuditEventSource

This class implements a network client-thread that will connect to a given host and then wait for audit-events to be read from that connection.

Author:
Christian Bockermann <chris@jwall.org>

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NetworkAuditEventSource(String host, int port, boolean ssl)
          This creates a new instance of this class which connects to the given server and port.
 
Method Summary
 void addEventListener(AuditEventListener l)
          This method adds the given listener to the list of listeners to be notified of new events.
 void close()
          This method tries to cleanly unregister from the server and close the tcp connection.
 boolean connect(String login, String pass)
          This method is used to connect this client side source to an audit event server.
 boolean hasNext()
          This method returns true if there is at least one more event pending, so if hasNext returns true, the next call to nextEvent should neither fail nor throw an exception.
 ModSecurityAuditEvent nextEvent()
          Returns the next available AuditEvent.
 void removeEventListener(AuditEventListener l)
          This method removes the given listener.
 void run()
           
 void setFilter(AuditEventFilter f)
          This sets a filter on the source.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NetworkAuditEventSource

public NetworkAuditEventSource(String host,
                               int port,
                               boolean ssl)
                        throws Exception
This creates a new instance of this class which connects to the given server and port. In case ssl is true, the connection will be established using SSL encryption.

Parameters:
host - The server name to which to connect to.
port - The port at which the event server is listening.
ssl - If to connect using ssl.
Throws:
Exception - In case the connection could not be established.
Method Detail

addEventListener

public void addEventListener(AuditEventListener l)
This method adds the given listener to the list of listeners to be notified of new events.

Parameters:
l - The listener to be added.

removeEventListener

public void removeEventListener(AuditEventListener l)
This method removes the given listener.

Parameters:
l - The listener to be removed.

hasNext

public boolean hasNext()
Description copied from interface: AuditEventSource
This method returns true if there is at least one more event pending, so if hasNext returns true, the next call to nextEvent should neither fail nor throw an exception.

Specified by:
hasNext in interface AuditEventSource
Returns:
true iff there is another event available.
See Also:
AuditEventSource.hasNext()

nextEvent

public ModSecurityAuditEvent nextEvent()
Description copied from interface: AuditEventSource
Returns the next available AuditEvent. If no event is available null is returned.

Specified by:
nextEvent in interface AuditEventSource
Returns:
The next event.
See Also:
AuditEventSource.nextEvent()

setFilter

public void setFilter(AuditEventFilter f)
Description copied from interface: AuditEventSource
This sets a filter on the source. A source should only return events that match this filter or all events, if no filter is set. To disable filtering filter can be set to null.

Specified by:
setFilter in interface AuditEventSource
Parameters:
f - The filter that determines the events which are returned.
See Also:
org.jwall.web.audit.io.AuditEventSource#setFilter(org.jwall.web.audit.AuditEventFilter)

connect

public boolean connect(String login,
                       String pass)
                throws Exception
This method is used to connect this client side source to an audit event server. The connection is basically established upon instantiation time. This method basically authenticates the user and registers this source to receive events.

Parameters:
login - The user name used to authenticate.
pass - The password for authentication.
Returns:
true, if the user was successfully authenticated.
Throws:
Exception - In case an IO error occurs.

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

close

public void close()
This method tries to cleanly unregister from the server and close the tcp connection.



Copyright © 2012 jwall.org. All Rights Reserved.