public class SessionChannel extends AbstractDirectChannel implements Session, Session.Command, Session.Shell, Session.Subsystem
Session implementation.Session.Command, Session.Shell, Session.SubsystemChannel.Direct, Channel.ForwardedErrorNotifiable.UtilcloseEvent, conn, log, lwin, openEvent, rwin, trans| Constructor and Description |
|---|
SessionChannel(Connection conn) |
| Modifier and Type | Method and Description |
|---|---|
void |
allocateDefaultPTY()
Allocates a default PTY.
|
void |
allocatePTY(java.lang.String term,
int cols,
int rows,
int width,
int height,
java.util.Map<PTYMode,java.lang.Integer> modes)
Allocate a psuedo-terminal for this session.
|
java.lang.Boolean |
canDoFlowControl()
Whether the client can do local flow control using
control-S and control-Q. |
void |
changeWindowDimensions(int cols,
int rows,
int width,
int height)
Sends a window dimension change message.
|
protected void |
closeAllStreams()
Called when all I/O streams should be closed.
|
protected void |
eofInputStreams()
Called when EOF has been received.
|
Session.Command |
exec(java.lang.String command)
Execute a remote command.
|
java.io.InputStream |
getErrorStream()
Returns the command's
stderr stream. |
java.lang.String |
getExitErrorMessage()
If the command exit violently
with a signal, an error message would have been
received and can be retrieved via this method. |
Signal |
getExitSignal()
Returns the
signal if the command exit violently, or null if this information was not
received. |
java.lang.Integer |
getExitStatus()
Returns the exit status of the command if it was received, or
null if this information was not
received. |
java.lang.Boolean |
getExitWasCoreDumped()
If the command exit violently
with a signal, information about whether a core dump
took place would have been received and can be retrieved via this method. |
protected void |
gotExtendedData(SSHPacket buf) |
void |
handleRequest(java.lang.String req,
SSHPacket buf) |
void |
notifyError(SSHException error)
Notifies this object of an
error. |
void |
reqX11Forwarding(java.lang.String authProto,
java.lang.String authCookie,
int screen)
Request X11 forwarding.
|
void |
setEnvVar(java.lang.String name,
java.lang.String value)
Set an enviornment variable.
|
void |
signal(Signal sig)
Send a signal to the remote command.
|
Session.Shell |
startShell()
Request a shell.
|
Session.Subsystem |
startSubsystem(java.lang.String name)
Request a subsystem.
|
buildOpenReq, gotUnknown, openclose, finishOff, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getOutputStream, getRecipient, getRemoteMaxPacketSize, getRemoteWinSize, getType, handle, init, isOpen, join, join, newBuffer, receiveInto, sendChannelRequest, sendClose, setAutoExpand, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitclose, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getOutputStream, getRecipient, getRemoteMaxPacketSize, getRemoteWinSize, getType, isOpen, join, join, setAutoExpandhandlepublic SessionChannel(Connection conn)
public void allocateDefaultPTY()
throws ConnectionException,
TransportException
Session"vt100" with the echo modes disabled.allocateDefaultPTY in interface SessionConnectionExceptionTransportExceptionpublic void allocatePTY(java.lang.String term,
int cols,
int rows,
int width,
int height,
java.util.Map<PTYMode,java.lang.Integer> modes)
throws ConnectionException,
TransportException
Session0 dimension parameters will be ignored by the server.allocatePTY in interface Sessionterm - TERM environment variable value (e.g., vt100)cols - terminal width, cols (e.g., 80)rows - terminal height, rows (e.g., 24)width - terminal width, pixels (e.g., 640)height - terminal height, pixels (e.g., 480)ConnectionExceptionTransportExceptionpublic java.lang.Boolean canDoFlowControl()
Session.Shellcontrol-S and control-Q.canDoFlowControl in interface Session.Shellnull if no such information was
receivedpublic void changeWindowDimensions(int cols,
int rows,
int width,
int height)
throws TransportException
Session.ShellchangeWindowDimensions in interface Session.Shellcols - terminal width, columnsrows - terminal height, rowswidth - terminal width, pixelsheight - terminal height, pixelsTransportExceptionpublic Session.Command exec(java.lang.String command) throws ConnectionException, TransportException
Sessionexec in interface SessionSession.Command instance which should now be usedConnectionException - if the request to execute the command failedTransportException - if there is an error sending the requestpublic java.io.InputStream getErrorStream()
Session.Commandstderr stream.getErrorStream in interface Session.CommandgetErrorStream in interface Session.Shellpublic java.lang.String getExitErrorMessage()
Session.Commandwith a signal, an error message would have been
received and can be retrieved via this method. Otherwise, this method will return null.getExitErrorMessage in interface Session.Commandpublic Signal getExitSignal()
Session.Commandsignal if the command exit violently, or null if this information was not
received.getExitSignal in interface Session.Commandpublic java.lang.Integer getExitStatus()
Session.Commandnull if this information was not
received.getExitStatus in interface Session.CommandgetExitStatus in interface Session.Subsystempublic void handleRequest(java.lang.String req,
SSHPacket buf)
throws ConnectionException,
TransportException
handleRequest in class AbstractChannelConnectionExceptionTransportExceptionpublic void reqX11Forwarding(java.lang.String authProto,
java.lang.String authCookie,
int screen)
throws ConnectionException,
TransportException
SessionreqX11Forwarding in interface SessionauthProto - X11 authentication protocol nameauthCookie - X11 authentication cookiescreen - X11 screen numberConnectionException - if the request failedTransportException - if there was an error sending the requestpublic void setEnvVar(java.lang.String name,
java.lang.String value)
throws ConnectionException,
TransportException
SessionsetEnvVar in interface Sessionname - name of the variablevalue - value to setConnectionException - if the request failedTransportException - if there was an error sending the requestpublic void signal(Signal sig) throws TransportException
Session.Commandsignal in interface Session.Commandsignal in interface Session.Shellsig - the signalTransportException - if error sending the signalpublic Session.Shell startShell() throws ConnectionException, TransportException
SessionstartShell in interface SessionSession.Shell instance which should now be usedConnectionException - if the request failedTransportException - if there was an error sending the requestpublic Session.Subsystem startSubsystem(java.lang.String name) throws ConnectionException, TransportException
SessionstartSubsystem in interface Sessionname - subsystem nameSession.Subsystem instance which should now be usedConnectionException - if the request failedTransportException - if there was an error sending the requestpublic java.lang.Boolean getExitWasCoreDumped()
Session.Commandwith a signal, information about whether a core dump
took place would have been received and can be retrieved via this method. Otherwise, this method will return
null.getExitWasCoreDumped in interface Session.Commandprotected void closeAllStreams()
AbstractChannelcloseAllStreams in class AbstractChannelprotected void eofInputStreams()
AbstractChanneleofInputStreams in class AbstractChannelprotected void gotExtendedData(SSHPacket buf) throws ConnectionException, TransportException
gotExtendedData in class AbstractChannelConnectionExceptionTransportExceptionpublic void notifyError(SSHException error)
ErrorNotifiableerror.notifyError in interface ErrorNotifiablenotifyError in class AbstractChannel