Class SessionChannel
java.lang.Object
net.schmizz.sshj.connection.channel.AbstractChannel
net.schmizz.sshj.connection.channel.direct.AbstractDirectChannel
net.schmizz.sshj.connection.channel.direct.SessionChannel
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ErrorNotifiable
,SSHPacketHandler
,Channel
,Channel.Direct
,Session
,Session.Command
,Session.Shell
,Session.Subsystem
public class SessionChannel
extends AbstractDirectChannel
implements Session, Session.Command, Session.Shell, Session.Subsystem
Session
implementation.-
Nested Class Summary
Nested classes/interfaces inherited from class net.schmizz.sshj.connection.channel.AbstractChannel
AbstractChannel.TransportRunnable
Nested classes/interfaces inherited from interface net.schmizz.sshj.connection.channel.Channel
Channel.Direct, Channel.Forwarded
Nested classes/interfaces inherited from interface net.schmizz.sshj.common.ErrorNotifiable
ErrorNotifiable.Util
Nested classes/interfaces inherited from interface net.schmizz.sshj.connection.channel.direct.Session
Session.Command, Session.Shell, Session.Subsystem
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Boolean
private final ChannelInputStream
private String
private Signal
private Integer
private boolean
private Boolean
Fields inherited from class net.schmizz.sshj.connection.channel.AbstractChannel
closeEvent, conn, log, loggerFactory, lwin, openEvent, rwin, trans
-
Constructor Summary
ConstructorsConstructorDescriptionSessionChannel
(Connection conn) SessionChannel
(Connection conn, Charset remoteCharset) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Allocates a default PTY.void
allocatePTY
(String term, int cols, int rows, int width, int height, Map<PTYMode, Integer> modes) Allocate a psuedo-terminal for this session.Whether the client can do local flow control usingcontrol-S
andcontrol-Q
.void
changeWindowDimensions
(int cols, int rows, int width, int height) Sends a window dimension change message.private void
protected void
Called when all I/O streams should be closed.protected void
Called when EOF has been received.Execute a remote command.Returns the command'sstderr
stream.If the command exit violentlywith a signal
, an error message would have been received and can be retrieved via this method.Returns thesignal
if the command exit violently, ornull
if this information was not received.Returns the exit status of the command if it was received, ornull
if this information was not received.If the command exit violentlywith 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
(String req, SSHPacket buf) void
notifyError
(SSHException error) Notifies this object of anerror
.void
reqX11Forwarding
(String authProto, String authCookie, int screen) Request X11 forwarding.void
Set an environment variable.void
Send a signal to the remote command.Request a shell.startSubsystem
(String name) Request a subsystem.Methods inherited from class net.schmizz.sshj.connection.channel.direct.AbstractDirectChannel
buildOpenReq, gotUnknown, open
Methods inherited from class net.schmizz.sshj.connection.channel.AbstractChannel
close, finishOff, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getLoggerFactory, getOutputStream, getRecipient, getRemoteCharset, getRemoteMaxPacketSize, getRemoteWinSize, getType, handle, init, isEOF, isOpen, join, join, newBuffer, receiveInto, sendChannelRequest, sendClose, setAutoExpand, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.schmizz.sshj.connection.channel.Channel
close, getAutoExpand, getID, getInputStream, getLocalMaxPacketSize, getLocalWinSize, getLoggerFactory, getOutputStream, getRecipient, getRemoteCharset, getRemoteMaxPacketSize, getRemoteWinSize, getType, isEOF, isOpen, join, join, setAutoExpand
Methods inherited from interface net.schmizz.sshj.common.SSHPacketHandler
handle
-
Field Details
-
err
-
exitStatus
-
exitSignal
-
wasCoreDumped
-
exitErrMsg
-
canDoFlowControl
-
usedUp
private boolean usedUp
-
-
Constructor Details
-
SessionChannel
-
SessionChannel
-
-
Method Details
-
allocateDefaultPTY
Description copied from interface:Session
Allocates a default PTY. The default PTY is"vt100"
with the echo modes disabled.- Specified by:
allocateDefaultPTY
in interfaceSession
- Throws:
ConnectionException
TransportException
-
allocatePTY
public void allocatePTY(String term, int cols, int rows, int width, int height, Map<PTYMode, Integer> modes) throws ConnectionException, TransportExceptionDescription copied from interface:Session
Allocate a psuedo-terminal for this session.0
dimension parameters will be ignored by the server.- Specified by:
allocatePTY
in interfaceSession
- Parameters:
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)modes
-- Throws:
ConnectionException
TransportException
-
canDoFlowControl
Description copied from interface:Session.Shell
Whether the client can do local flow control usingcontrol-S
andcontrol-Q
.- Specified by:
canDoFlowControl
in interfaceSession.Shell
- Returns:
- boolean value indicating whether 'client can do', or
null
if no such information was received
-
changeWindowDimensions
public void changeWindowDimensions(int cols, int rows, int width, int height) throws TransportException Description copied from interface:Session.Shell
Sends a window dimension change message.- Specified by:
changeWindowDimensions
in interfaceSession.Shell
- Parameters:
cols
- terminal width, columnsrows
- terminal height, rowswidth
- terminal width, pixelsheight
- terminal height, pixels- Throws:
TransportException
-
exec
Description copied from interface:Session
Execute a remote command.- Specified by:
exec
in interfaceSession
- Parameters:
command
-- Returns:
Session.Command
instance which should now be used- Throws:
ConnectionException
- if the request to execute the command failedTransportException
- if there is an error sending the request
-
getErrorStream
Description copied from interface:Session.Command
Returns the command'sstderr
stream.- Specified by:
getErrorStream
in interfaceSession.Command
- Specified by:
getErrorStream
in interfaceSession.Shell
-
getExitErrorMessage
Description copied from interface:Session.Command
If the command exit violentlywith a signal
, an error message would have been received and can be retrieved via this method. Otherwise, this method will returnnull
. NOTE: Always callChannel.close()
first before inspecting the exit error message.- Specified by:
getExitErrorMessage
in interfaceSession.Command
-
getExitSignal
Description copied from interface:Session.Command
Returns thesignal
if the command exit violently, ornull
if this information was not received. NOTE: Always callChannel.close()
first before inspecting the exit signal.- Specified by:
getExitSignal
in interfaceSession.Command
-
getExitStatus
Description copied from interface:Session.Command
Returns the exit status of the command if it was received, ornull
if this information was not received. NOTE: Always callChannel.close()
first before inspecting the exit status.- Specified by:
getExitStatus
in interfaceSession.Command
- Specified by:
getExitStatus
in interfaceSession.Subsystem
-
handleRequest
- Overrides:
handleRequest
in classAbstractChannel
- Throws:
ConnectionException
TransportException
-
reqX11Forwarding
public void reqX11Forwarding(String authProto, String authCookie, int screen) throws ConnectionException, TransportException Description copied from interface:Session
Request X11 forwarding.- Specified by:
reqX11Forwarding
in interfaceSession
- Parameters:
authProto
- X11 authentication protocol nameauthCookie
- X11 authentication cookiescreen
- X11 screen number- Throws:
ConnectionException
- if the request failedTransportException
- if there was an error sending the request
-
setEnvVar
Description copied from interface:Session
Set an environment variable.- Specified by:
setEnvVar
in interfaceSession
- Parameters:
name
- name of the variablevalue
- value to set- Throws:
ConnectionException
- if the request failedTransportException
- if there was an error sending the request
-
signal
Description copied from interface:Session.Command
Send a signal to the remote command.- Specified by:
signal
in interfaceSession.Command
- Specified by:
signal
in interfaceSession.Shell
- Parameters:
sig
- the signal- Throws:
TransportException
- if error sending the signal
-
startShell
Description copied from interface:Session
Request a shell.- Specified by:
startShell
in interfaceSession
- Returns:
Session.Shell
instance which should now be used- Throws:
ConnectionException
- if the request failedTransportException
- if there was an error sending the request
-
startSubsystem
Description copied from interface:Session
Request a subsystem.- Specified by:
startSubsystem
in interfaceSession
- Parameters:
name
- subsystem name- Returns:
Session.Subsystem
instance which should now be used- Throws:
ConnectionException
- if the request failedTransportException
- if there was an error sending the request
-
getExitWasCoreDumped
Description copied from interface:Session.Command
If the command exit violentlywith 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 returnnull
.- Specified by:
getExitWasCoreDumped
in interfaceSession.Command
-
closeAllStreams
protected void closeAllStreams()Description copied from class:AbstractChannel
Called when all I/O streams should be closed. Subclasses can override but must call super.- Overrides:
closeAllStreams
in classAbstractChannel
-
eofInputStreams
protected void eofInputStreams()Description copied from class:AbstractChannel
Called when EOF has been received. Subclasses can override but must call super.- Overrides:
eofInputStreams
in classAbstractChannel
-
gotExtendedData
- Overrides:
gotExtendedData
in classAbstractChannel
- Throws:
SSHException
-
notifyError
Description copied from interface:ErrorNotifiable
Notifies this object of anerror
.- Specified by:
notifyError
in interfaceErrorNotifiable
- Overrides:
notifyError
in classAbstractChannel
-
checkReuse
private void checkReuse()
-