public class SessionChannel extends AbstractDirectChannel implements Session, Session.Command, Session.Shell, Session.Subsystem
Session
implementation.Session.Command, Session.Shell, Session.Subsystem
Channel.Direct, Channel.Forwarded
ErrorNotifiable.Util
closeEvent, 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, open
close, finishOff, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getOutputStream, getRecipient, getRemoteMaxPacketSize, getRemoteWinSize, getType, handle, init, isOpen, join, join, newBuffer, receiveInto, sendChannelRequest, sendClose, setAutoExpand, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getOutputStream, getRecipient, getRemoteMaxPacketSize, getRemoteWinSize, getType, isOpen, join, join, setAutoExpand
handle
public SessionChannel(Connection conn)
public void allocateDefaultPTY() throws ConnectionException, TransportException
Session
"vt100"
with the echo modes disabled.allocateDefaultPTY
in interface Session
ConnectionException
TransportException
public 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
Session
0
dimension parameters will be ignored by the server.allocatePTY
in interface Session
term
- 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)ConnectionException
TransportException
public java.lang.Boolean canDoFlowControl()
Session.Shell
control-S
and control-Q
.canDoFlowControl
in interface Session.Shell
null
if no such information was
receivedpublic void changeWindowDimensions(int cols, int rows, int width, int height) throws TransportException
Session.Shell
changeWindowDimensions
in interface Session.Shell
cols
- terminal width, columnsrows
- terminal height, rowswidth
- terminal width, pixelsheight
- terminal height, pixelsTransportException
public Session.Command exec(java.lang.String command) throws ConnectionException, TransportException
Session
exec
in interface Session
Session.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.Command
stderr
stream.getErrorStream
in interface Session.Command
getErrorStream
in interface Session.Shell
public java.lang.String getExitErrorMessage()
Session.Command
with 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.Command
public Signal getExitSignal()
Session.Command
signal
if the command exit violently, or null
if this information was not
received.getExitSignal
in interface Session.Command
public java.lang.Integer getExitStatus()
Session.Command
null
if this information was not
received.getExitStatus
in interface Session.Command
getExitStatus
in interface Session.Subsystem
public void handleRequest(java.lang.String req, SSHPacket buf) throws ConnectionException, TransportException
handleRequest
in class AbstractChannel
ConnectionException
TransportException
public void reqX11Forwarding(java.lang.String authProto, java.lang.String authCookie, int screen) throws ConnectionException, TransportException
Session
reqX11Forwarding
in interface Session
authProto
- 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
Session
setEnvVar
in interface Session
name
- 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.Command
signal
in interface Session.Command
signal
in interface Session.Shell
sig
- the signalTransportException
- if error sending the signalpublic Session.Shell startShell() throws ConnectionException, TransportException
Session
startShell
in interface Session
Session.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
Session
startSubsystem
in interface Session
name
- 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.Command
with 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.Command
protected void closeAllStreams()
AbstractChannel
closeAllStreams
in class AbstractChannel
protected void eofInputStreams()
AbstractChannel
eofInputStreams
in class AbstractChannel
protected void gotExtendedData(SSHPacket buf) throws ConnectionException, TransportException
gotExtendedData
in class AbstractChannel
ConnectionException
TransportException
public void notifyError(SSHException error)
ErrorNotifiable
error
.notifyError
in interface ErrorNotifiable
notifyError
in class AbstractChannel