jhomenet.shell.server.telnet
Class TelnetServer

java.lang.Object
  extended by java.lang.Thread
      extended by jhomenet.shell.server.Server
          extended by jhomenet.shell.server.telnet.TelnetServer
All Implemented Interfaces:
java.lang.Runnable

public class TelnetServer
extends Server

A simple server that uses the Telnet protocol as described in RFC 854. This server uses a ServerSocket to listen on the specified port (defaults to port 23) for Telnet connection requests. For each connection made, a Telnet session is created. All command processing is handled by the Telnet session, not this server.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class jhomenet.shell.server.Server
pauseServer, sessions, shutdown
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TelnetServer(SystemInterface systemInterface)
          Prepares the Telnet server to listen on the well known Telnet port (23).
TelnetServer(SystemInterface systemInterface, int port)
          Prepares the Telnet server to listen on an arbitrary port.
 
Method Summary
protected  Session acceptNewSession()
          Waits for a connection request.
protected  void closeAllPorts()
          Closes the ServerSocket used to listen for connections.
static java.lang.String getWelcomeFile()
          Gets the location of the file to be displayed when after a user logs in to this server.
static boolean isRootAllowed()
          Indicates whether root access is allowed to this Telnet server.
 
Methods inherited from class jhomenet.shell.server.Server
broadcast, checkForNewSessions, getConnectedUsers, getSystemInterface, pauseServer, resumeServer, run, sessionEnded, shutDown
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TelnetServer

public TelnetServer(SystemInterface systemInterface)
             throws java.io.IOException
Prepares the Telnet server to listen on the well known Telnet port (23). The server will not be started and no connections will be accepted until its run() method is executed.

Throws:
java.io.IOException

TelnetServer

public TelnetServer(SystemInterface systemInterface,
                    int port)
             throws java.io.IOException
Prepares the Telnet server to listen on an arbitrary port. The server will not be started and no connections will be accepted until its run() method is executed.

Throws:
java.io.IOException
Method Detail

getWelcomeFile

public static java.lang.String getWelcomeFile()
Gets the location of the file to be displayed when after a user logs in to this server. This file is specified by setting the "TELNET_WELCOME" properties variable equal to the location of the file. This method will always return the value the variable had when the server was constructed. Changing the value of properties variable after creating the server will have no effect.

Returns:
the location of the welcome file to display, or null if no welcome file was specified

isRootAllowed

public static boolean isRootAllowed()
Indicates whether root access is allowed to this Telnet server. This is specified with the properties variable "TELNET_ROOT_ALLOWED". Set the variable to "false" to disallow root login. All other values will be interpreted as true and root logins will be accepted. This method will always return the value the variable had when the server was constructed. Changing the value of properties variable after creating the server will have no effect.

Returns:
true if root is allowed to login

acceptNewSession

protected Session acceptNewSession()
Description copied from class: Server
Waits for a connection request. This method should block until a request is received. When a request is made, it should create, initialize, and return a new Session to handle that connection.

Specified by:
acceptNewSession in class Server
Returns:
a new Session

closeAllPorts

protected void closeAllPorts()
                      throws java.io.IOException
Closes the ServerSocket used to listen for connections.

Specified by:
closeAllPorts in class Server
Throws:
java.io.IOException


Copyright © 2004-2005 David Irwin. All Rights Reserved.