org.jwall.web.audit.net
Class NetworkEventServer

java.lang.Object
  extended by java.lang.Thread
      extended by org.jwall.web.audit.net.NetworkEventServer
All Implemented Interfaces:
Runnable, EventListener<AuditEvent>, AuditEventListener

public class NetworkEventServer
extends Thread
implements AuditEventListener

This class implements a small event-server thread. It will listen on a socket and wait for a NetworkAuditEventSource to connect and push all events to the connected event-sources. This class is not well-tested!

Author:
Christian Bockermann <chris@jwall.org>

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int CLIENT_POLL_TIME
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NetworkEventServer(int port, Authenticator auth)
           
NetworkEventServer(String s, Authenticator auth)
           
NetworkEventServer(String serv, int port, Authenticator auth)
           
 
Method Summary
static NetworkEventServer createSSLEventServer(File keyFile, String pass, int port, Authenticator auth)
           
static NetworkEventServer createSSLEventServer(InputStream keyIn, int port, Authenticator auth)
           
static NetworkEventServer createSSLEventServer(InputStream keyStream, String pass, int port, Authenticator auth)
          This method creates a new NetworkEventServer that is based on an SSL-enabled server socket.
 void eventArrived(AuditEvent e)
          This method is called when a new event arrives at the listener.
 void eventsArrived(Collection<AuditEvent> events)
          This method is called for notifying the listener of arrival of several events in a block.
 void run()
           
 void start()
           
 void unregisterClient(NetworkClientWorkerThread t)
          This method is used to unregister one of the client thread from the dispatcher.
 
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, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLIENT_POLL_TIME

public static final int CLIENT_POLL_TIME
See Also:
Constant Field Values
Constructor Detail

NetworkEventServer

public NetworkEventServer(String s,
                          Authenticator auth)
                   throws Exception
Throws:
Exception

NetworkEventServer

public NetworkEventServer(String serv,
                          int port,
                          Authenticator auth)
                   throws Exception
Throws:
Exception

NetworkEventServer

public NetworkEventServer(int port,
                          Authenticator auth)
                   throws Exception
Throws:
Exception
Method Detail

start

public void start()
Overrides:
start in class Thread

createSSLEventServer

public static NetworkEventServer createSSLEventServer(File keyFile,
                                                      String pass,
                                                      int port,
                                                      Authenticator auth)
                                               throws Exception
Throws:
Exception

createSSLEventServer

public static NetworkEventServer createSSLEventServer(InputStream keyIn,
                                                      int port,
                                                      Authenticator auth)
                                               throws Exception
Throws:
Exception

createSSLEventServer

public static NetworkEventServer createSSLEventServer(InputStream keyStream,
                                                      String pass,
                                                      int port,
                                                      Authenticator auth)
                                               throws Exception
This method creates a new NetworkEventServer that is based on an SSL-enabled server socket. Compared to the non-SSL case, the additional parameters are the keyStream and the pass, which refer to the stream that is used to read the private/public key pair from. The password is used to decrypt the private key from the keyStream.

Parameters:
keyStream - The stream to read the public/private key pair from.
pass - The password to decrypt the key information.
port - The port on which this server will accept connections.
auth - This map contains a set of login/password pairs used to authenticate users.
Returns:
The SSL-enabled server instance.
Throws:
Exception - In case the server socket could not be created or something went wrong with the key decryption.

run

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

eventArrived

public void eventArrived(AuditEvent e)
Description copied from interface: AuditEventListener
This method is called when a new event arrives at the listener. The Listener should be threaded and response-time to this method should be as small as possible.

After the dispatcher calls this method each listener gets a call to #notify(), thus a listener might wait for packets to arrive.

Specified by:
eventArrived in interface EventListener<AuditEvent>
Specified by:
eventArrived in interface AuditEventListener
Parameters:
e - The event which arrived.
See Also:
AuditEventListener.eventArrived(org.jwall.web.audit.AuditEvent)

eventsArrived

public void eventsArrived(Collection<AuditEvent> events)
Description copied from interface: AuditEventListener
This method is called for notifying the listener of arrival of several events in a block. Usually, this method is implemented by calling AuditEventListener.eventArrived(AuditEvent) for each of the given events, but may be handled in a more efficient way by implementations capable of processing blocks of events.

Specified by:
eventsArrived in interface AuditEventListener
Parameters:
events - The block of events arrived.

unregisterClient

public void unregisterClient(NetworkClientWorkerThread t)
This method is used to unregister one of the client thread from the dispatcher. The call is simply delegated to the dispatcher itself.

Parameters:
t - The client thread to unregister.


Copyright © 2012 jwall.org. All Rights Reserved.