Package org.apache.sshd.server.shell
Class ProcessShell
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.server.shell.ProcessShell
- All Implemented Interfaces:
SessionContextHolder,SessionHolder<ServerSession>,ServerChannelSessionHolder,CommandLifecycle,ServerSessionAware,ServerSessionHolder,InvertedShell
Bridges the I/O streams between the SSH command and the process that executes it
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ChannelSessionprivate Stringprivate TtyFilterInputStreamprivate TtyFilterOutputStreamprivate TtyFilterInputStreamprivate Processprivate ServerSessionFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy(ChannelSession channel) This method is called by the SSH server to destroy the command because the client has disconnected somehow.intRetrieve the exit value of the shell.Returns the output stream used to feed the shell.booleanisAlive()Check if the underlying shell is still aliveresolveShellTtyOptions(Map<PtyMode, Integer> modes) voidsetSession(ServerSession session) voidstart(ChannelSession channel, Environment env) Starts the command execution.toString()Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.server.shell.InvertedShell
getSessionMethods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
Field Details
-
command
-
cmdValue
-
session
-
channelSession
-
process
-
in
-
out
-
err
-
-
Constructor Details
-
ProcessShell
- Parameters:
command- The command components which when joined (with space separator) create the full command to be executed by the shell
-
ProcessShell
-
-
Method Details
-
getServerSession
- Specified by:
getServerSessionin interfaceServerSessionHolder- Returns:
- The underlying
ServerSessionused
-
setSession
- Specified by:
setSessionin interfaceServerSessionAware- Parameters:
session- TheServerSessionin which this shell will be executed.
-
getServerChannelSession
- Specified by:
getServerChannelSessionin interfaceServerChannelSessionHolder
-
start
Description copied from interface:CommandLifecycleStarts the command execution. All streams must have been set before calling this method. The command should implementRunnable, and this method should spawn a new thread like:Thread(this).start();- Specified by:
startin interfaceCommandLifecycle- Parameters:
channel- TheChannelSessionthrough which the command has been receivedenv- TheEnvironment- Throws:
IOException- If failed to start
-
resolveShellEnvironment
-
resolveShellTtyOptions
-
getInputStream
Description copied from interface:InvertedShellReturns the output stream used to feed the shell. This method is called after the shell has been started.- Specified by:
getInputStreamin interfaceInvertedShell- Returns:
- The
OutputStreamused to feed the shell
-
getOutputStream
- Specified by:
getOutputStreamin interfaceInvertedShell- Returns:
- The
InputStreamrepresenting the output stream of the shell
-
getErrorStream
- Specified by:
getErrorStreamin interfaceInvertedShell- Returns:
- The
InputStreamrepresenting the error stream of the shell
-
isAlive
public boolean isAlive()Description copied from interface:InvertedShellCheck if the underlying shell is still alive- Specified by:
isAlivein interfaceInvertedShell- Returns:
trueif alive
-
exitValue
public int exitValue()Description copied from interface:InvertedShellRetrieve the exit value of the shell. This method must only be called when the shell is not alive anymore.- Specified by:
exitValuein interfaceInvertedShell- Returns:
- the exit value of the shell
-
destroy
Description copied from interface:CommandLifecycleThis method is called by the SSH server to destroy the command because the client has disconnected somehow.- Specified by:
destroyin interfaceCommandLifecycle- Parameters:
channel- TheChannelSessionthrough which the command has been received
-
toString
-