jhomenet.shell
Class Shell

java.lang.Object
  extended by jhomenet.shell.Shell
Direct Known Subclasses:
JHomenetShell, TestShell

public abstract class Shell
extends java.lang.Object

This abstract class encapsulates all of the functionality of a system shell for TINI. It interacts between a process and the system OS, and provides the current properties and the user ID of the current process. Methods are provided for converting to and from the numerical user ID and the text representation and for determining whether a particular user is an administrator. A user will be considered an administrator if the most significant bit of their user ID is set.


Field Summary
protected  java.util.HashMap<java.lang.String,java.lang.String> environment
          Contains the current properties variables for the process.
 
Constructor Summary
Shell()
          Creates the initial properties for a shell.
 
Method Summary
abstract  void enableLocalConsole(boolean enableConsole)
           
abstract  void execute(java.lang.Object[] commandLine, SystemInputStream in, SystemPrintStream out, SystemPrintStream err, java.util.HashMap env)
          Executes a command in the shell.
abstract  java.util.HashMap getCurrentEnvironment()
          Returns a copy of the current properties.
abstract  java.lang.String getFromCurrentEnvironment(java.lang.String key)
          Gets the value of the given key from the current properties.
abstract  java.lang.String getName()
          Returns the location of the shell.
 java.util.HashMap getSystemEnvironment()
          Returns the system properties (the properties that all processes see when they start up).
abstract  java.lang.String getVersion()
          Returns the version of the shell.
protected abstract  void initializeShellCommands()
           
abstract  int login(java.lang.String userName, java.lang.String password)
          Logs a user into the system and sets that user's privilege level correctly.
abstract  void logout(java.lang.Object info)
          Logs the current user out of the system, returning the privilege level of the current process to the default state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

environment

protected java.util.HashMap<java.lang.String,java.lang.String> environment
Contains the current properties variables for the process.

Constructor Detail

Shell

public Shell()
Creates the initial properties for a shell. The properties is initialized to hold the current working directory. This value is stored under the "current directory" key.

Method Detail

initializeShellCommands

protected abstract void initializeShellCommands()

enableLocalConsole

public abstract void enableLocalConsole(boolean enableConsole)

login

public abstract int login(java.lang.String userName,
                          java.lang.String password)
Logs a user into the system and sets that user's privilege level correctly. Most shells will have a list of valid users and their corresponding passwords and user id's to consult when this method is called. (Such as a passwd file.)

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 abstract void logout(java.lang.Object info)
Logs the current user out of the system, returning the privilege level of the current process to the default state.

Parameters:
info - any extra information needed in the logout process

getName

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

Returns:
the location of the shell

getVersion

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

Returns:
the shell version

getSystemEnvironment

public java.util.HashMap getSystemEnvironment()
Returns the system properties (the properties that all processes see when they start up). The Hashtable that is returned is a clone of the original.

Returns:
a copy of the system properties

getCurrentEnvironment

public abstract java.util.HashMap getCurrentEnvironment()
Returns a copy of the current properties.

Returns:
the properties

getFromCurrentEnvironment

public abstract java.lang.String getFromCurrentEnvironment(java.lang.String key)
Gets the value of the given key from the current properties.

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

execute

public abstract 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.

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


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