ecologylab.services.distributed.server
Class DoubleThreadedAuthNIOServer<A extends AuthenticationListEntry>
java.lang.Object
ecologylab.generic.Debug
ecologylab.services.distributed.impl.NIOServerBase
ecologylab.services.distributed.server.DoubleThreadedNIOServer
ecologylab.services.distributed.server.DoubleThreadedAuthNIOServer<A>
- All Implemented Interfaces:
- StartAndStoppable, Authenticatable<A>, AuthLogging, AuthMessages, AuthServerRegistryObjects, NetworkingConstants, ServerConstants, SessionObjects, Shutdownable, NIOServerFrontend, java.lang.Runnable
public class DoubleThreadedAuthNIOServer<A extends AuthenticationListEntry>
- extends DoubleThreadedNIOServer
- implements AuthServerRegistryObjects, AuthMessages, AuthLogging, Authenticatable<A>
An authenticating server that uses NIO and two threads (one for handling IO,
the other for handling interfacing with messages).
Any clients attempting to communicate with this server must either first
provide a Login request, or otherwise have previously been logged in;
otherwise, no requests are processed from the client.
- Author:
- Zachary O. Toups (toupsz@cs.tamu.edu)
|
Method Summary |
void |
addAuthenticationListener(AuthenticationListener authListener)
|
void |
addLoggingListener(Logging log)
|
void |
fireLoggingEvent(AuthenticationOp op)
|
protected void |
fireLoginEvent(java.lang.String username,
java.lang.String sessionId)
|
protected void |
fireLogoutEvent(java.lang.String username,
java.lang.String sessionId)
|
protected AbstractClientManager |
generateContextManager(java.lang.Object sessionId,
java.nio.channels.SelectionKey sk,
TranslationSpace translationSpace,
Scope registry)
Hook method to allow changing the ContextManager to enable specific extra
functionality. |
static DoubleThreadedAuthNIOServer |
getInstance(int portNumber,
java.net.InetAddress[] inetAddress,
TranslationSpace requestTranslationSpace,
Scope objectRegistry,
int idleConnectionTimeout,
int maxPacketSize,
AuthenticationList authList)
This is the actual way to create an instance of this. |
static DoubleThreadedAuthNIOServer |
getInstance(int portNumber,
java.net.InetAddress[] inetAddress,
TranslationSpace requestTranslationSpace,
Scope objectRegistry,
int idleConnectionTimeout,
int maxPacketSize,
java.lang.String authListFilename)
This is the actual way to create an instance of this. |
AbstractClientManager |
invalidate(java.lang.Object sessionId,
boolean permanent)
Ensure that the user associated with sc has been logged out of the
authenticator, then call super.invalidate(). |
boolean |
isLoggedIn(java.lang.String username)
Indicates whether or not the supplied username is currently logged-in to the system. |
boolean |
login(A entry,
java.lang.String sessionId)
Determines whether a user can log in (based on the content of entry and its originating IP address (address)). |
boolean |
logout(A entry,
java.lang.String sessionId)
Logs the user out of the system (based on the content of entry and its originating IP address (address)). |
| Methods inherited from class ecologylab.generic.Debug |
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
authenticator
protected Authenticator<A extends AuthenticationListEntry> authenticator
DoubleThreadedAuthNIOServer
protected DoubleThreadedAuthNIOServer(int portNumber,
java.net.InetAddress[] inetAddress,
TranslationSpace requestTranslationSpace,
Scope objectRegistry,
int idleConnectionTimeout,
int maxPacketSize,
AuthenticationList authList)
throws java.io.IOException,
java.net.BindException
- Parameters:
portNumber - inetAddress - translationSpace - objectRegistry -
- Throws:
java.io.IOException
java.net.BindException
getInstance
public static DoubleThreadedAuthNIOServer getInstance(int portNumber,
java.net.InetAddress[] inetAddress,
TranslationSpace requestTranslationSpace,
Scope objectRegistry,
int idleConnectionTimeout,
int maxPacketSize,
java.lang.String authListFilename)
- This is the actual way to create an instance of this.
- Parameters:
portNumber - translationSpace - objectRegistry - authListFilename - -
a file name indicating the location of the authentication list;
this should be an XML file of an AuthenticationList object.
- Returns:
- A server instance, or null if it was not possible to open a
ServerSocket on the port on this machine.
getInstance
public static DoubleThreadedAuthNIOServer getInstance(int portNumber,
java.net.InetAddress[] inetAddress,
TranslationSpace requestTranslationSpace,
Scope objectRegistry,
int idleConnectionTimeout,
int maxPacketSize,
AuthenticationList authList)
- This is the actual way to create an instance of this.
- Parameters:
portNumber - translationSpace - objectRegistry - authList - -
the AuthorizationList object to be used to determine possible
users.
- Returns:
- A server instance, or null if it was not possible to open a
ServerSocket on the port on this machine.
generateContextManager
protected AbstractClientManager generateContextManager(java.lang.Object sessionId,
java.nio.channels.SelectionKey sk,
TranslationSpace translationSpace,
Scope registry)
- Description copied from class:
DoubleThreadedNIOServer
- Hook method to allow changing the ContextManager to enable specific extra
functionality.
- Overrides:
generateContextManager in class DoubleThreadedNIOServer
- Parameters:
sessionId - translationSpace - registry -
- Returns:
addLoggingListener
public void addLoggingListener(Logging log)
- Specified by:
addLoggingListener in interface AuthLogging
- See Also:
AuthLogging.addLoggingListener(ecologylab.services.logging.Logging)
addAuthenticationListener
public void addAuthenticationListener(AuthenticationListener authListener)
fireLogoutEvent
protected void fireLogoutEvent(java.lang.String username,
java.lang.String sessionId)
fireLoginEvent
protected void fireLoginEvent(java.lang.String username,
java.lang.String sessionId)
fireLoggingEvent
public void fireLoggingEvent(AuthenticationOp op)
- Specified by:
fireLoggingEvent in interface AuthLogging
logout
public boolean logout(A entry,
java.lang.String sessionId)
- Description copied from interface:
Authenticatable
- Logs the user out of the system (based on the content of entry and its originating IP address (address)). Handles
necessary bookkeeping (such as a list of authenticated clients).
- Specified by:
logout in interface Authenticatable<A extends AuthenticationListEntry>
- Parameters:
entry - the information about the user attempting to log out (username / password, etc.).
- Returns:
- true if the user successfully logged out, false otherwise. This method may return false if the user was
never logged in, or if the attempt appears to be a spoof.
isLoggedIn
public boolean isLoggedIn(java.lang.String username)
- Description copied from interface:
Authenticatable
- Indicates whether or not the supplied username is currently logged-in to the system.
- Specified by:
isLoggedIn in interface Authenticatable<A extends AuthenticationListEntry>
- Parameters:
username - the username to check.
- Returns:
login
public boolean login(A entry,
java.lang.String sessionId)
- Description copied from interface:
Authenticatable
- Determines whether a user can log in (based on the content of entry and its originating IP address (address)).
Handles any necessary bookkeeping (such as a list of authenticated clients).
- Specified by:
login in interface Authenticatable<A extends AuthenticationListEntry>
- Parameters:
entry - the information about the user attempting to log in (username / password, etc.).sessionId - the session id for the connected socket.
- Returns:
- true if the user successfully logged in, false otherwise.
invalidate
public AbstractClientManager invalidate(java.lang.Object sessionId,
boolean permanent)
- Ensure that the user associated with sc has been logged out of the
authenticator, then call super.invalidate().
- Specified by:
invalidate in interface NIOServerFrontend- Overrides:
invalidate in class DoubleThreadedNIOServer
permanent - -
indicates whether the NIOServerFrontend should destroy the context manager object associated with the
given connection.
- Returns:
- the ContextManager object associated with sc that has been removed from the system.
- See Also:
ecologylab.services.distributed.server.DoubleThreadedNIOServer#invalidate(java.lang.Object,
ecologylab.services.distributed.impl.NIOServerBackend,
java.nio.channels.SocketChannel)