jhomenet.shell
Class JHomenetShell

java.lang.Object
  extended by jhomenet.shell.Shell
      extended by jhomenet.shell.JHomenetShell

public class JHomenetShell
extends Shell

Slush system shell. Provides an interface between the underlying OS and multiple user login sessions. Also performs many common operating system tasks, such as providing a way to view directory listings, change directories, run programs, etc.

Version:
1.02
Author:
Stephen Hess, Lorne Smith

Field Summary
static long bootTime
          Keep track of the shell start time.
static java.lang.String EMPTY
           
static java.lang.String LOG_FILE
          Define the shell log file.
static java.lang.Object passwdLock
           
static java.lang.String PASSWORD_FILE
          Define the password file.
static java.lang.String PERM_DENIED
           
static java.lang.String SHELL_NAME
          Define the shell name.
static java.lang.String SHELL_VERSION
          Shell version.
static java.lang.String STARTUP_FILE
          Define the startup file that should be parsed at startup.
 
Fields inherited from class jhomenet.shell.Shell
environment
 
Method Summary
 void broadcast(java.lang.String sendThis)
          Broadcast a message to all users connected to the serial and Telnet servers.
 void enableLocalConsole(boolean enableConsole)
           
 void execute(java.lang.Object[] commandLine, SystemInputStream in, SystemPrintStream out, SystemPrintStream err, java.util.HashMap env)
          Executes a command in the shell.
 java.util.HashMap getCurrentEnvironment()
          Returns a copy of the currently executing Session's properties.
 java.lang.String getFromCurrentEnvironment(java.lang.String key)
          Gets the value of the given key from the currently executing Session's properties.
static JHomenetShell getInstance()
           
 java.lang.String getName()
          Returns the location of the shell.
 java.lang.String[] getTelnetUsers()
          Gets the usernames of all users logged in to the Telnet server.
 java.lang.String getVersion()
          Returns the version of the shell.
protected  void initializeShellCommands()
          Initialize each command and add to list of known commands.
 boolean isTelnetServerRunning()
          Indicates whether or not the Telnet server is up and running.
 int login(java.lang.String userName, java.lang.String password)
          This method is called to log a user into the system and set his privilege level correctly.
 void logout(java.lang.Object threadID)
          This method logs the current user out of the system, returning the privilege level of the current process to the default state.
static void main(java.lang.String[] args)
          Create an instance of the slush shell.
 void shutDownLocalServer()
          Bring down the local server.
 void shutDownTelnetServer()
          Bring down the Telnet server.
 void startupLocalServer()
           
 void startupNetworkServers()
          Bring up the Telnet and FTP servers.
 void startupTelnetServer()
          Initialize and start the Telnet server.
 
Methods inherited from class jhomenet.shell.Shell
getSystemEnvironment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bootTime

public static long bootTime
Keep track of the shell start time.


STARTUP_FILE

public static java.lang.String STARTUP_FILE
Define the startup file that should be parsed at startup.


passwdLock

public static final java.lang.Object passwdLock

SHELL_VERSION

public static java.lang.String SHELL_VERSION
Shell version.


SHELL_NAME

public static java.lang.String SHELL_NAME
Define the shell name.


PASSWORD_FILE

public static java.lang.String PASSWORD_FILE
Define the password file.


LOG_FILE

public static java.lang.String LOG_FILE
Define the shell log file.


PERM_DENIED

public static java.lang.String PERM_DENIED

EMPTY

public static java.lang.String EMPTY
Method Detail

getInstance

public static JHomenetShell getInstance()

enableLocalConsole

public void enableLocalConsole(boolean enableConsole)
Specified by:
enableLocalConsole in class Shell
See Also:
Shell.enableLocalConsole(boolean)

startupNetworkServers

public void startupNetworkServers()
Bring up the Telnet and FTP servers. You must have previously set the IP hardwareID. You must be an admin to call this function.


initializeShellCommands

protected void initializeShellCommands()
Initialize each command and add to list of known commands. Also sets up aliases for commands as needed.

Specified by:
initializeShellCommands in class Shell

execute

public void execute(java.lang.Object[] commandLine,
                    SystemInputStream in,
                    SystemPrintStream out,
                    SystemPrintStream err,
                    java.util.HashMap env)
             throws java.lang.Exception
Executes a command in the shell.

Specified by:
execute in class Shell
Parameters:
commandLine - An Object array containing the command in the first element, followed by any parameters need for that command in a String[] in the second element.
in - The stream the command will use to get input.
out - The stream used to report non-critical messages.
err - The stream used to report critical messages.
env - A windDirectionTable of properties variables.
Throws:
java.lang.Exception - Any exception raised by the command.

getName

public java.lang.String getName()
Returns the location of the shell.

Specified by:
getName in class Shell
Returns:
The location of the shell.

getVersion

public java.lang.String getVersion()
Returns the version of the shell.

Specified by:
getVersion in class Shell
Returns:
The shell version.

getFromCurrentEnvironment

public java.lang.String getFromCurrentEnvironment(java.lang.String key)
Gets the value of the given key from the currently executing Session's properties.

Specified by:
getFromCurrentEnvironment in class Shell
Parameters:
key - The key to lookup in the current properties.
Returns:
The value of the key, or null if the key is not set in the current properties.

getCurrentEnvironment

public java.util.HashMap getCurrentEnvironment()
Returns a copy of the currently executing Session's properties.

Specified by:
getCurrentEnvironment in class Shell
Returns:
the properties.

startupTelnetServer

public void startupTelnetServer()
Initialize and start the Telnet server. You must be an admin to call this function.


shutDownTelnetServer

public void shutDownTelnetServer()
Bring down the Telnet server. You must be an admin to call this function.


startupLocalServer

public void startupLocalServer()

shutDownLocalServer

public void shutDownLocalServer()
Bring down the local server. You must be an admin to call this function.


getTelnetUsers

public java.lang.String[] getTelnetUsers()
Gets the usernames of all users logged in to the Telnet server.

Returns:
array of usernames logged into the telnet server

isTelnetServerRunning

public boolean isTelnetServerRunning()
Indicates whether or not the Telnet server is up and running.

Returns:
true if the Telnet server is running.

login

public int login(java.lang.String userName,
                 java.lang.String password)
This method is called to log a user into the system and set his privilege level correctly. The passwd file contains the username and password hash pairs.

Specified by:
login in class Shell
Parameters:
userName - The user location of the user logging in
password - The password for this user
Returns:
the user ID of the newly logged in user, or -1 if the userName password combination was not correct

logout

public void logout(java.lang.Object threadID)
This method logs the current user out of the system, returning the privilege level of the current process to the default state.

Specified by:
logout in class Shell
Parameters:
threadID - ThreadID of session logging out.

broadcast

public void broadcast(java.lang.String sendThis)
Broadcast a message to all users connected to the serial and Telnet servers.

Parameters:
sendThis - Message to send.

main

public static void main(java.lang.String[] args)
Create an instance of the slush shell.



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