public class SshThread
extends java.lang.Thread
Enables the J2SSH application framework to execute threads in the context of a given session.
Modifier and Type | Field and Description |
---|---|
protected byte[] |
sessionId
The raw session id generating during the first key exchange.
|
protected java.lang.String |
sessionIdString
A string representation of the session id.
|
protected java.lang.String |
username
The thread owner
|
Constructor and Description |
---|
SshThread(java.lang.Runnable target,
java.lang.String name,
boolean daemon)
Constructs an SshThread.
|
SshThread(java.lang.String name,
boolean daemon) |
Modifier and Type | Method and Description |
---|---|
SshThread |
cloneThread(java.lang.Runnable target,
java.lang.String name)
Create's a cloned copy of this thread with the given target and name.
|
boolean |
containsProperty(java.lang.String name)
Determine if this thread contains the given property.
|
static java.lang.String |
getCurrentSessionId()
Returns the session id of the current thread context.
|
static SshThread |
getCurrentThread()
Returns the current
SshThread . |
static java.lang.String |
getCurrentThreadUser()
Call to determine the username of the current thread context.
|
java.lang.Object |
getProperty(java.lang.String name)
Gets a property from this thread.
|
java.lang.String |
getSessionIdString()
Returns the session id string for this thread.
|
java.lang.String |
getUsername()
Gets the username for this thread.
|
static boolean |
hasUserContext() |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a property in the thread.
|
void |
setSessionId(byte[] sessionId)
Sets the session id for this thread.
|
void |
setUsername(java.lang.String username)
Set the username for this thread.
|
activeCount, checkAccess, clone, 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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected byte[] sessionId
protected java.lang.String sessionIdString
protected java.lang.String username
public SshThread(java.lang.Runnable target, java.lang.String name, boolean daemon)
Constructs an SshThread.
target
- The target to executename
- The name of the threaddaemon
- run as a daemon thread?public SshThread(java.lang.String name, boolean daemon)
public void setSessionId(byte[] sessionId)
Sets the session id for this thread.
sessionId
- the session id created during the first key exchange.public java.lang.String getSessionIdString()
Returns the session id string for this thread.
public void setUsername(java.lang.String username)
Set the username for this thread.
username
- the thread ownerpublic java.lang.String getUsername()
Gets the username for this thread.
public SshThread cloneThread(java.lang.Runnable target, java.lang.String name)
Create's a cloned copy of this thread with the given target and name.
target
- the target to executename
- the thread namepublic void setProperty(java.lang.String name, java.lang.Object value)
Sets a property in the thread.
name
- the name of the propertyvalue
- the property valuepublic java.lang.Object getProperty(java.lang.String name)
Gets a property from this thread.
name
- the name of the propertypublic boolean containsProperty(java.lang.String name)
Determine if this thread contains the given property.
name
- the name of the propertypublic static java.lang.String getCurrentThreadUser() throws SshRuntimeException
Call to determine the username of the current thread context.
This should be called when the caller is certain that the current thread
is running in an SshThread
context. If not a runtime
exception is thrown.
SshRuntimeException
- if the current thread is not an
SshThread
public static boolean hasUserContext()
public static java.lang.String getCurrentSessionId() throws SshRuntimeException
Returns the session id of the current thread context.
This should be called when the caller is certain that the current thread
is running in an SshThread
context. If not a Runtime
exception is thrown.
SshRuntimeException
- if the current thread is not an
SshThread
public static SshThread getCurrentThread() throws SshRuntimeException
Returns the current SshThread
.
This should be called when the caller is certain that the current thread
is running in an SshThread
context. If not a Runtime
exception is thrown.
SshThread
SshRuntimeException
- if the current thread is not an
SshThread
Copyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.