org.openuat.authentication
Class HostServerSocket
java.lang.Object
org.openuat.authentication.AuthenticationEventSender
org.openuat.authentication.HostServerSocket
- All Implemented Interfaces:
- java.lang.Runnable
public class HostServerSocket
- extends AuthenticationEventSender
- implements java.lang.Runnable
This class represents a listener on a TCP port which responds to incoming authentication requests by delegating any incoming
connection to the HostProtocolHandler class. More specifically, for each incoming TCP connection, the
HostProtocolHandler.startIncomingAuthenticationThread is invoked with the connected TCP socket.
Listening is done in a background thread using blocking accept() calls. After constructing a HostServerSocket object for
a specific port, startListening() needs to be called to start accepting incoming connection.
- Version:
- 1.0
- Author:
- Rene Mayrhofer
|
Constructor Summary |
HostServerSocket(int port,
boolean keepSocketConnected,
boolean useJSSE)
Initialized the listener socket by binding it to the specified port. |
|
Method Summary |
void |
run()
Does the actual listening for incoming connections by calling the blocking accept() on the listening socket in a loop. |
void |
startListening()
Starts a background thread (using the run() method of this class) that will listen for incoming connections. |
void |
stopListening()
Signals the background listening thread to stop and waits for it. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HostServerSocket
public HostServerSocket(int port,
boolean keepSocketConnected,
boolean useJSSE)
throws java.io.IOException
- Initialized the listener socket by binding it to the specified port.
- Parameters:
useJSSE - If set to true, the JSSE API with the default JCE provider of the JVM will be used
for cryptographic operations. If set to false, an internal copy of the Bouncycastle
Lightweight API classes will be used.
- Throws:
java.io.IOException- See Also:
If set to true, the socket to the client will be kept connected after the
registered HostProtocolHandler has finished. This allows the socket to be
reused for additional communication after the first authentication
protocol has been completed.
startListening
public void startListening()
- Starts a background thread (using the run() method of this class) that will listen for incoming connections.
stopListening
public void stopListening()
throws InternalApplicationException
- Signals the background listening thread to stop and waits for it. This method will not return until the listening
thread has terminated.
- Throws:
InternalApplicationException
run
public void run()
- Does the actual listening for incoming connections by calling the blocking accept() on the listening socket in a loop.
For each incoming connection, a new HostProtocolHandler object is created and its startIncomingAuthenticationThread is
used to start a thread that handles the new connection.
- Specified by:
run in interface java.lang.Runnable
2005-2006, Rene Mayrhofer.