com.dalsemi.shell
Class DefaultTINIShell

java.lang.Object
  |
  +--com.dalsemi.shell.TINIShell
        |
        +--com.dalsemi.shell.DefaultTINIShell

public class DefaultTINIShell
extends TINIShell

The default implementation of a TINIShell. In this shell, all users are assigned the same UID and user name, and all are given adminstrator privileges. This shell has no commands associated with it. For an example of a complete implementation of a TINIShell, see the slush shell that is included with the TINI distribution files.


Fields inherited from class com.dalsemi.shell.TINIShell
adminUID, environment
 
Constructor Summary
DefaultTINIShell()
          Creates the initial environment for a shell.
 
Method Summary
 void execute(java.lang.Object[] commandLine, SystemInputStream in, SystemPrintStream out, SystemPrintStream err, java.util.Hashtable env)
          Executes a command in the shell.
 java.util.Hashtable getCurrentEnvironment()
          Returns a copy of the current environment.
 byte getCurrentUID()
          Returns the user ID of the current user.
 java.lang.String getCurrentUserName()
          Returns the name of the current user logged in.
 java.lang.String getFromCurrentEnvironment(java.lang.String key)
          Gets the value of the given key from the current environment.
 java.lang.String getName()
          Returns the name of the shell.
 int getUIDByUserName(java.lang.String username)
          Returns the ID of the user with the given user name.
 java.lang.String getUserNameByUID(byte uid)
          Returns the user name of the user with the given user ID.
 java.lang.String getVersion()
          Returns the version of the shell.
 int login(java.lang.String userName, java.lang.String password)
          Logs a user into the system and sets that user's privilege level correctly.
 void logout(java.lang.Object info)
          Does nothing in this implementation.
 
Methods inherited from class com.dalsemi.shell.TINIShell
getSystemEnvironment, isAdmin, isCurrentUserAdmin
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTINIShell

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

getName

public java.lang.String getName()
Returns the name of the shell. The name of the default TINI shell is simply "slushLite".
Returns:
the name of the shell
Overrides:
getName in class TINIShell

getVersion

public java.lang.String getVersion()
Returns the version of the shell.
Returns:
the shell version
Overrides:
getVersion in class TINIShell

login

public 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). This shell always returns the default adminstrator UID (0x80).
Parameters:
userName - the user name of the user logging in
password - the password for this user
Overrides:
login in class TINIShell

logout

public void logout(java.lang.Object info)
Does nothing in this implementation.
Parameters:
info - any extra information needed in the logout process
Overrides:
logout in class TINIShell

getCurrentUID

public byte getCurrentUID()
Returns the user ID of the current user. This implementation will always return the default adminstrator UID (0x80).
Returns:
the current user's ID
Overrides:
getCurrentUID in class TINIShell

getUserNameByUID

public java.lang.String getUserNameByUID(byte uid)
Returns the user name of the user with the given user ID. This implementation will always return the default adminstrator name ("root").
Parameters:
uid - The uid to check
Returns:
the user name of the user with the given user ID
Overrides:
getUserNameByUID in class TINIShell

getUIDByUserName

public int getUIDByUserName(java.lang.String username)
Returns the ID of the user with the given user name. This implementation will always return the default adminstrator UID (0x80).
Parameters:
username - the username to check
Returns:
the ID of the user with the given user name, or -1 if that user does not exist
Overrides:
getUIDByUserName in class TINIShell

getCurrentUserName

public java.lang.String getCurrentUserName()
Returns the name of the current user logged in. This implementation will always return the default adminstrator name ("root").
Returns:
the name of the current user
Overrides:
getCurrentUserName in class TINIShell

getCurrentEnvironment

public java.util.Hashtable getCurrentEnvironment()
Returns a copy of the current environment.
Returns:
the environment
Overrides:
getCurrentEnvironment in class TINIShell

getFromCurrentEnvironment

public java.lang.String getFromCurrentEnvironment(java.lang.String key)
Gets the value of the given key from the current environment.
Parameters:
key - the key to lookup in the current environment
Returns:
the value of the key, or an empty String if the key is not set in the current environment
Overrides:
getFromCurrentEnvironment in class TINIShell

execute

public void execute(java.lang.Object[] commandLine,
                    SystemInputStream in,
                    SystemPrintStream out,
                    SystemPrintStream err,
                    java.util.Hashtable env)
             throws java.lang.Exception
Executes a command in the shell. This implementation has no commands. A call to this method will print "Command not found." to the given error stream.
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 table of environment variables
Throws:
java.lang.Exception - any exception raised by the command.
Overrides:
execute in class TINIShell


Используются технологии uCoz