Class NetAcctServer

java.lang.Object
  extended byjava.lang.Thread
      extended byNetAcctServer
All Implemented Interfaces:
Runnable

public class NetAcctServer
extends Thread

This class provides a multithreaded, network interface to the drink accounting system. The server opens a port either on the default port, or the port specified by the -p option on the command line, if present. As connections to the port are made, new NetAcctServerSession's are spawned to handle the requests. This class is the server portion of NetAcctMgr, which was originally written by Michael J. Douglas. TODO: Better ConfigMgr usage. TODO: Get rid of command line argument processing. TODO: Unify config variable names. TODO: Generic DrinkLoggerSpec stuff, eg NetDrinkLogger, LocalDrinkLogger. TODO: Use configfile stuff. Keep syntax same with BasicDrinkLogger. TODO: Put the hostacl stuff in the configfile. TODO: Check for hostacl file existance at startup.

Version:
$Revision: #20 $
Author:
Kevin Thompson [antiduh@csh.rit.edu], Michael Douglas [nodata@csh.rit.edu]
See Also:
Networked Account Manager Protocol

Nested Class Summary
(package private)  class NetAcctServer.NetAcctServerSession
          Handles processing and IO for individual client sessions.
 
Field Summary
private  AcctMgrSpec acct
          The underlying Account Manager implementation that we actually use.
private  ConfigMgr config
          Where we get our config data from.
static String configFile
          The file we read our config data out of.
static int DEFAULT_PORT
          The port that the account manager runs on when no "-p port" command line option is specified.
private  ServerSocket listen
          The socket that the clients connect on.
private  DrinkLoggerSpec log
          The class to use for logging.
private  int port
          The port that we are listening on.
static String VERSION_TAG
          The version of the software/protocol implementation.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
NetAcctServer(DrinkLoggerSpec inLog, AcctMgrSpec inAcct, int inPort)
          Instantiates a new NetAcctServer to listen for and handle incoming connections by threading-off the new connections.
 
Method Summary
private  boolean authenticate(String user, String pass, String host)
           
private  boolean isHostIPAllowed(String host)
          Determines whether or not the specified host is allowed to connect and communicate with the account server.
static void main(String[] args)
          Start the server.
 void run()
          Accepts connects forever and launches new NetAcctServerThread's to handle the incoming connections.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION_TAG

public static final String VERSION_TAG
The version of the software/protocol implementation.

See Also:
Constant Field Values

configFile

public static final String configFile
The file we read our config data out of.

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
The port that the account manager runs on when no "-p port" command line option is specified.

See Also:
Constant Field Values

acct

private AcctMgrSpec acct
The underlying Account Manager implementation that we actually use.


log

private DrinkLoggerSpec log
The class to use for logging.


port

private int port
The port that we are listening on.


listen

private ServerSocket listen
The socket that the clients connect on.


config

private ConfigMgr config
Where we get our config data from.

Constructor Detail

NetAcctServer

public NetAcctServer(DrinkLoggerSpec inLog,
                     AcctMgrSpec inAcct,
                     int inPort)
Instantiates a new NetAcctServer to listen for and handle incoming connections by threading-off the new connections.

Parameters:
inLog - The DrinkLoggerSpec to write log messages to.
inAcct - The underlying AcctMgrSpec to work with.
inPort - The port number to listen on.
Method Detail

main

public static void main(String[] args)
Start the server. The server accepts nothing on the command line. All runtime configuration data is read from the configfile using the ConfigMgr class. This will set up the ConfigMgr, DrinkLoggerSpec, AcctMgrSpec, read in the cofiguratino data, then instantiate a new NetAcctServer to manage and thread-off new incoming connections. Configfile options used: so_acctsrvlog so_acctsrvimpl

Parameters:
args - The command line arguments, which are ignored.

run

public void run()
Accepts connects forever and launches new NetAcctServerThread's to handle the incoming connections.


isHostIPAllowed

private boolean isHostIPAllowed(String host)
Determines whether or not the specified host is allowed to connect and communicate with the account server.

Parameters:
host - The host to verify
Returns:
True if the host is allowed to access the server, false otherwise.

authenticate

private boolean authenticate(String user,
                             String pass,
                             String host)