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
public class ProcessShell extends AbstractLoggingBean implements InvertedShell
Bridges the I/O streams between the SSH command and the process that executes it- Author:
- Apache MINA SSHD Project
-
-
Field Summary
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description ProcessShell(String... command)ProcessShell(Collection<String> command)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy(ChannelSession channel)This method is called by the SSH server to destroy the command because the client has disconnected somehow.intexitValue()Retrieve the exit value of the shell.InputStreamgetErrorStream()OutputStreamgetInputStream()Returns the output stream used to feed the shell.InputStreamgetOutputStream()ChannelSessiongetServerChannelSession()ServerSessiongetServerSession()booleanisAlive()Check if the underlying shell is still aliveprotected Map<String,String>resolveShellEnvironment(Map<String,String> env)protected Map<PtyMode,Integer>resolveShellTtyOptions(Map<PtyMode,Integer> modes)voidsetSession(ServerSession session)voidstart(ChannelSession channel, Environment env)Starts the command execution.StringtoString()-
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, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.server.shell.InvertedShell
getSession
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSessionContext
-
-
-
-
Constructor Detail
-
ProcessShell
public ProcessShell(String... command)
- Parameters:
command- The command components which when joined (with space separator) create the full command to be executed by the shell
-
ProcessShell
public ProcessShell(Collection<String> command)
-
-
Method Detail
-
getServerSession
public ServerSession getServerSession()
- Specified by:
getServerSessionin interfaceServerSessionHolder- Returns:
- The underlying
ServerSessionused
-
setSession
public void setSession(ServerSession session)
- Specified by:
setSessionin interfaceServerSessionAware- Parameters:
session- TheServerSessionin which this shell will be executed.
-
getServerChannelSession
public ChannelSession getServerChannelSession()
- Specified by:
getServerChannelSessionin interfaceServerChannelSessionHolder
-
start
public void start(ChannelSession channel, Environment env) throws IOException
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
protected Map<String,String> resolveShellEnvironment(Map<String,String> env)
-
resolveShellTtyOptions
protected Map<PtyMode,Integer> resolveShellTtyOptions(Map<PtyMode,Integer> modes)
-
getInputStream
public OutputStream 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
public InputStream getOutputStream()
- Specified by:
getOutputStreamin interfaceInvertedShell- Returns:
- The
InputStreamrepresenting the output stream of the shell
-
getErrorStream
public InputStream 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
public void destroy(ChannelSession channel)
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
-
-