Dallas Semiconductor TINI 1.02 Release: Class TINIShell

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.dalsemi.shell
Class TINIShell

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

Direct Known Subclasses:
  DefaultTINIShell

public abstract class TINIShell
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 environment 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
`static byte` | `adminUID` Standard administrator UID.
`protected java.util.Hashtable` | `environment` Contains the current environment variables for the process.

Constructor Summary
`TINIShell()` Creates the initial environment for a shell.

Method Summary
`abstract void` | `execute(java.lang.Object[] commandLine, SystemInputStream in, SystemPrintStream out, SystemPrintStream err, java.util.Hashtable env)` Executes a command in the shell.
`abstract java.util.Hashtable` | `getCurrentEnvironment()` Returns a copy of the current environment.
`abstract byte` | `getCurrentUID()` Returns the user ID of the current user.
`abstract java.lang.String` | `getCurrentUserName()` Returns the name of the current user logged in.
`abstract java.lang.String` | `getFromCurrentEnvironment(java.lang.String key)` Gets the value of the given key from the current environment.
`abstract java.lang.String` | `getName()` Returns the name of the shell.
`java.util.Hashtable` | `getSystemEnvironment()` Returns the system environment (the environment that all processes see when they start up).
`abstract int` | `getUIDByUserName(java.lang.String username)` Returns the ID of the user with the given user name.
`abstract java.lang.String` | `getUserNameByUID(byte uid)` Returns the user name of the user with the given user ID.
`abstract java.lang.String` | `getVersion()` Returns the version of the shell.
`boolean` | `isAdmin(byte uid)` Determines if the given user ID has administrative rights.
`boolean` | `isCurrentUserAdmin()` Indicates whether or not the current user has admin privileges.
`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

### adminUID

    public static final byte adminUID

  Standard administrator UID. Also used as mask to determine if other UIDs are administrators.

### environment

    protected java.util.Hashtable environment

  Contains the current environment variables for the process.

Constructor Detail

### TINIShell

    public TINIShell()

  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

### 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 name of the user logging in
    `password` - the password for this user

### 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 name of the shell.
  Returns:
    the name of the shell

### getVersion

    public abstract java.lang.String getVersion()

  Returns the version of the shell.
  Returns:
    the shell version

### isCurrentUserAdmin

    public boolean isCurrentUserAdmin()

  Indicates whether or not the current user has admin privileges.
  Returns:
    `true` if the user has admin rights, `false` otherwise

### getCurrentUID

    public abstract byte getCurrentUID()

  Returns the user ID of the current user.
  Returns:
    the current user's ID

### isAdmin

    public boolean isAdmin(byte uid)

  Determines if the given user ID has administrative rights.
  Parameters:
    `uid` - the user ID
  Returns:
    `true` if the user is an administrator, `false` otherwise

### getUserNameByUID

    public abstract java.lang.String getUserNameByUID(byte uid)

  Returns the user name of the user with the given user ID.
  Parameters:
    `uid` - the uid to check
  Returns:
    the user name of the user with the given user ID, or null if that ID is not valid

### getUIDByUserName

    public abstract int getUIDByUserName(java.lang.String username)

  Returns the ID of the user with the given user name.
  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

### getCurrentUserName

    public abstract java.lang.String getCurrentUserName()

  Returns the name of the current user logged in.
  Returns:
    the name of the current user

### getSystemEnvironment

    public java.util.Hashtable getSystemEnvironment()

  Returns the system environment (the environment 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 environment

### getCurrentEnvironment

    public abstract java.util.Hashtable getCurrentEnvironment()

  Returns a copy of the current environment.
  Returns:
    the environment

### getFromCurrentEnvironment

    public abstract 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 `null` if the key is not set in the current environment

### execute

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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD