Class SshThread
- All Implemented Interfaces:
Runnable
Enables the J2SSH application framework to execute threads in the context of a given session.
- Since:
- 0.2.0
- Version:
- $Revision: 1.25 $
- Author:
- Lee David Painter
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]
The raw session id generating during the first key exchange.protected String
A string representation of the session id.protected String
The thread ownerFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncloneThread
(Runnable target, String name) Create's a cloned copy of this thread with the given target and name.boolean
containsProperty
(String name) Determine if this thread contains the given property.static String
Returns the session id of the current thread context.static SshThread
Returns the currentSshThread
.static String
Call to determine the username of the current thread context.getProperty
(String name) Gets a property from this thread.Returns the session id string for this thread.Gets the username for this thread.static boolean
void
setProperty
(String name, Object value) Sets a property in the thread.void
setSessionId
(byte[] sessionId) Sets the session id for this thread.void
setUsername
(String username) Set the username for this thread.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
sessionId
protected byte[] sessionIdThe raw session id generating during the first key exchange. -
sessionIdString
A string representation of the session id. -
username
The thread owner
-
-
Constructor Details
-
SshThread
Constructs an SshThread.
- Parameters:
target
- The target to executename
- The name of the threaddaemon
- run as a daemon thread?- Since:
- 0.2.0
-
SshThread
-
-
Method Details
-
setSessionId
public void setSessionId(byte[] sessionId) Sets the session id for this thread.
- Parameters:
sessionId
- the session id created during the first key exchange.- Since:
- 0.2.0
-
getSessionIdString
Returns the session id string for this thread.
- Returns:
- a string representation of the session id
- Since:
- 0.2.0
-
setUsername
Set the username for this thread.
- Parameters:
username
- the thread owner- Since:
- 0.2.0
-
getUsername
Gets the username for this thread.
- Returns:
- the thread owner
- Since:
- 0.2.0
-
cloneThread
Create's a cloned copy of this thread with the given target and name.
- Parameters:
target
- the target to executename
- the thread name- Returns:
- the cloned thread
- Since:
- 0.2.0
-
setProperty
Sets a property in the thread.
- Parameters:
name
- the name of the propertyvalue
- the property value- Since:
- 0.2.0
-
getProperty
Gets a property from this thread.
- Parameters:
name
- the name of the property- Returns:
- the property value
- Since:
- 0.2.0
-
containsProperty
Determine if this thread contains the given property.
- Parameters:
name
- the name of the property- Returns:
- true if the property exists, otherwise false
- Since:
- 0.2.0
-
getCurrentThreadUser
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.- Returns:
- the owner of the current thread
- Throws:
SshRuntimeException
- if the current thread is not anSshThread
- Since:
- 0.2.0
-
hasUserContext
public static boolean hasUserContext() -
getCurrentSessionId
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.- Returns:
- the session id of the current thread
- Throws:
SshRuntimeException
- if the current thread is not anSshThread
- Since:
- 0.2.0
-
getCurrentThread
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.- Returns:
- the current
SshThread
- Throws:
SshRuntimeException
- if the current thread is not anSshThread
- Since:
- 0.2.0
-