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 void
destroy(ChannelSession channel)
This method is called by the SSH server to destroy the command because the client has disconnected somehow.int
exitValue()
Retrieve the exit value of the shell.InputStream
getErrorStream()
OutputStream
getInputStream()
Returns the output stream used to feed the shell.InputStream
getOutputStream()
ChannelSession
getServerChannelSession()
ServerSession
getServerSession()
boolean
isAlive()
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)
void
setSession(ServerSession session)
void
start(ChannelSession channel, Environment env)
Starts the command execution.String
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, 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:
getServerSession
in interfaceServerSessionHolder
- Returns:
- The underlying
ServerSession
used
-
setSession
public void setSession(ServerSession session)
- Specified by:
setSession
in interfaceServerSessionAware
- Parameters:
session
- TheServerSession
in which this shell will be executed.
-
getServerChannelSession
public ChannelSession getServerChannelSession()
- Specified by:
getServerChannelSession
in interfaceServerChannelSessionHolder
-
start
public void start(ChannelSession channel, Environment env) throws IOException
Description copied from interface:CommandLifecycle
Starts 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:
start
in interfaceCommandLifecycle
- Parameters:
channel
- TheChannelSession
through 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:InvertedShell
Returns the output stream used to feed the shell. This method is called after the shell has been started.- Specified by:
getInputStream
in interfaceInvertedShell
- Returns:
- The
OutputStream
used to feed the shell
-
getOutputStream
public InputStream getOutputStream()
- Specified by:
getOutputStream
in interfaceInvertedShell
- Returns:
- The
InputStream
representing the output stream of the shell
-
getErrorStream
public InputStream getErrorStream()
- Specified by:
getErrorStream
in interfaceInvertedShell
- Returns:
- The
InputStream
representing the error stream of the shell
-
isAlive
public boolean isAlive()
Description copied from interface:InvertedShell
Check if the underlying shell is still alive- Specified by:
isAlive
in interfaceInvertedShell
- Returns:
true
if alive
-
exitValue
public int exitValue()
Description copied from interface:InvertedShell
Retrieve the exit value of the shell. This method must only be called when the shell is not alive anymore.- Specified by:
exitValue
in interfaceInvertedShell
- Returns:
- the exit value of the shell
-
destroy
public void destroy(ChannelSession channel)
Description copied from interface:CommandLifecycle
This method is called by the SSH server to destroy the command because the client has disconnected somehow.- Specified by:
destroy
in interfaceCommandLifecycle
- Parameters:
channel
- TheChannelSession
through which the command has been received
-
-