|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread jhomenet.server.console.Session
public abstract class Session
A session represents a single connection to the TINI system shell. When someone attempts to login, a server object spins off a session (an implementation of this class) to handle the communication. The session allows you to log into the system, then processes all system requests. Sessions are designed to be multi-threaded, allowing multiple simultaneous connections. Id: $Id: $
Nested Class Summary | |
---|---|
protected class |
Session.Login
Encapsulates all of the information needed to log a user into the system. |
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected AuthManager |
authManager
Reference to the authentication manager. |
protected java.lang.String[] |
commandHistory
A list of the last few commands issued in this session. |
protected ConsoleService |
consoleService
Reference to the console service. |
static java.lang.String |
CURRENT_COMMAND
The key used to index the current command in system environments. |
static java.lang.String |
CURRENT_DIRECTORY
The key used to index the current directory in system environments. |
protected int |
currentCommand
Marks the beginning of the commandHistory buffer. |
protected java.util.Map<java.lang.String,java.lang.Object> |
environment
The environment properties associated with this session. |
protected SystemPrintStream |
err
The error stream of the remote connection. |
protected boolean |
inCommand
Specifies that a command is currently being processed by this session. |
protected SystemInputStream |
inputStream
The input stream of the remote connection. |
protected int |
lastCommand
Marks the end of the commandHistory buffer. |
protected java.util.Vector<Session.Login> |
loginStack
The list of users that are currently logged into this session. |
protected static java.lang.String |
loginSuccessMessage
The login success message. |
protected java.lang.Object |
myThreadID
The thread ID of this session. |
protected SystemPrintStream |
outputStream
The output stream of the remote connection. |
protected java.lang.Object[] |
paramsArray
Used as temporary storage when parsing the parameters for a command. |
protected java.util.Vector |
paramsVector
Used as temporary storage when parsing the parameters for a command. |
protected java.lang.String |
password
The password for the user that is currently logged in. |
protected byte[] |
prompt
The text used as the command line prompt for this session. |
static java.lang.String |
PROMPT
The basic prompt displayed at the command line. |
protected java.lang.Object[] |
retArray
Used as temporary storage when parsing the parameters for a command. |
protected boolean |
shutdown
Specifies that the session should attempt to close the connection after it has finished processing the current request. |
protected AuthManager.UserStatus |
user
Reference to the user object. |
protected java.lang.String |
userName
The user that is currently logged in with this session. |
protected static java.lang.String |
version
Session version information. |
static java.lang.String |
welcomeMessage
The message shown to all users when they login to this session. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
protected |
Session(java.lang.String desc,
AuthManager authManager,
SystemInputStream in,
SystemPrintStream out,
SystemPrintStream err,
ConsoleService consoleService)
Intializes the session. |
Method Summary | |
---|---|
void |
addToHistory(java.lang.String str)
Adds a new command to the history buffer. |
protected abstract void |
currentCommandFinished()
Notifies this session that the current command has completed. |
void |
endSession()
Cleans up the resources used by this session. |
protected abstract void |
exceptionThrown(java.lang.Exception ex)
Notifies this session that exception was thrown when executing a command. |
void |
execute(java.lang.String commandStr)
Executes the given command in the current shell. |
void |
forceEndSession()
Notifies the server this session is ending and forces the session to terminate. |
void |
forceEndSession(java.util.concurrent.CountDownLatch sessionEndingLatch)
Notifies the server this session is ending and forces the session to terminate. |
java.util.Map |
getEnvironment()
Gets a reference to the current properties. |
java.io.PrintStream |
getErrStream()
Gets the stream this session uses for error notification and critical messages. |
java.lang.String |
getFromEnvironment(java.lang.String key)
Gets the value of the key from the current properties. |
java.lang.String |
getHistoryNumber(int number)
Gets the command at the given index of the command history. |
java.lang.String |
getNextCommand()
Gets the next command from this session's input stream. |
java.io.PrintStream |
getOutputStream()
Gets the stream this session uses for output. |
static java.lang.Object[] |
getParams(java.lang.String str)
Parses the command line into individual elements. |
java.lang.String |
getUserName()
Returns the user location associated with this session. |
boolean |
inCommand()
Indicates whether this session is executing a shell command. |
protected abstract void |
login()
Logs a user into the system. |
protected void |
parseLogin()
Parses and executes the ".login" file for the current user. |
void |
printHistory(java.io.PrintStream out)
Prints the list of commands stored in the history buffer of this session. |
void |
run()
Starts the communication loop of the session. |
protected abstract void |
sessionEnding()
Notify session implementations that the session is ending. |
java.lang.String |
stepDownHistory()
Moves the current position in the history buffer down one and returns the command at that position. |
java.lang.String |
stepUpHistory()
Moves the current position in the history buffer up one and returns the command at that position. |
boolean |
su(java.lang.String userName,
java.lang.String password)
Allows the current user to login as another user. |
void |
updatePrompt(java.lang.String withThis)
Notifies this session of a directory change. |
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 |
Field Detail |
---|
protected SystemInputStream inputStream
protected SystemPrintStream outputStream
protected SystemPrintStream err
protected boolean inCommand
protected java.util.Map<java.lang.String,java.lang.Object> environment
protected boolean shutdown
protected java.lang.String[] commandHistory
protected int lastCommand
protected int currentCommand
protected byte[] prompt
protected final AuthManager authManager
protected final ConsoleService consoleService
protected AuthManager.UserStatus user
protected java.lang.String userName
protected java.lang.String password
protected java.util.Vector<Session.Login> loginStack
protected java.lang.Object myThreadID
protected java.util.Vector paramsVector
protected java.lang.Object[] paramsArray
protected java.lang.Object[] retArray
public static java.lang.String CURRENT_DIRECTORY
public static java.lang.String CURRENT_COMMAND
public static java.lang.String PROMPT
public static java.lang.String welcomeMessage
protected static final java.lang.String version
protected static final java.lang.String loginSuccessMessage
Constructor Detail |
---|
protected Session(java.lang.String desc, AuthManager authManager, SystemInputStream in, SystemPrintStream out, SystemPrintStream err, ConsoleService consoleService)
desc
- session descriptionloginService
- Reference to the login servicein
- stream this session should use to get data from userout
- stream this session should use to output to usererr
- stream this session should use to output errors to userconsoleService
- reference to the console serviceMethod Detail |
---|
public java.lang.String getUserName()
protected abstract void login() throws java.io.IOException
java.io.IOException
public final void run()
login()
method
is called. If the user is sucessfully logged into the system, commands are accepted
and processed until the session is terminated.
run
in interface java.lang.Runnable
run
in class java.lang.Thread
Thread.run()
public java.lang.String getNextCommand() throws java.io.IOException
java.io.IOException
public final void execute(java.lang.String commandStr)
commandStr
parameter can contain any number of elements. These elements will be separated
into String[]
for the command interpreter.
commandStr
- full command line to executepublic java.io.PrintStream getErrStream()
public java.io.PrintStream getOutputStream()
public final void forceEndSession()
public final void forceEndSession(java.util.concurrent.CountDownLatch sessionEndingLatch)
sessionEndingLatch
- public final void endSession()
public boolean su(java.lang.String userName, java.lang.String password)
userName
- new user's locationpassword
- new user's password
true
if login was successful, false
otherwiseprotected abstract void currentCommandFinished()
protected abstract void sessionEnding()
protected abstract void exceptionThrown(java.lang.Exception ex)
ex
- the exception thrownpublic static java.lang.Object[] getParams(java.lang.String str)
str
- complete command line
String
command in the first element, and a String[]
of
the arguments to that command in the second elementpublic java.util.Map getEnvironment()
Hashtable
public java.lang.String getFromEnvironment(java.lang.String key)
key
- location of desired properties variable
null
if that key does not exist in the propertiespublic void addToHistory(java.lang.String str)
str
- command to add to the historypublic java.lang.String stepUpHistory()
public java.lang.String stepDownHistory()
public java.lang.String getHistoryNumber(int number)
number
- index into the history cache.
public void printHistory(java.io.PrintStream out)
out
- stream used to print the historypublic boolean inCommand()
true
if the session is executing a shell commandpublic void updatePrompt(java.lang.String withThis)
withThis
- the new directory locationprotected void parseLogin()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |