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.TransportRunnableNested classes/interfaces inherited from interface net.schmizz.sshj.connection.channel.Channel
Channel.Direct, Channel.ForwardedNested classes/interfaces inherited from interface net.schmizz.sshj.common.ErrorNotifiable
ErrorNotifiable.UtilNested classes/interfaces inherited from interface net.schmizz.sshj.connection.channel.direct.Session
Session.Command, Session.Shell, Session.Subsystem -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Booleanprivate final ChannelInputStreamprivate Stringprivate Signalprivate Integerprivate booleanprivate BooleanFields 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 TypeMethodDescriptionvoidAllocates a default PTY.voidallocatePTY(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-Sandcontrol-Q.voidchangeWindowDimensions(int cols, int rows, int width, int height) Sends a window dimension change message.private voidprotected voidCalled when all I/O streams should be closed.protected voidCalled when EOF has been received.Execute a remote command.Returns the command'sstderrstream.If the command exit violentlywith a signal, an error message would have been received and can be retrieved via this method.Returns thesignalif the command exit violently, ornullif this information was not received.Returns the exit status of the command if it was received, ornullif 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 voidgotExtendedData(SSHPacket buf) voidhandleRequest(String req, SSHPacket buf) voidnotifyError(SSHException error) Notifies this object of anerror.voidreqX11Forwarding(String authProto, String authCookie, int screen) Request X11 forwarding.voidSet an environment variable.voidSend 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, openMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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, setAutoExpandMethods 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:SessionAllocates a default PTY. The default PTY is"vt100"with the echo modes disabled.- Specified by:
allocateDefaultPTYin interfaceSession- Throws:
ConnectionExceptionTransportException
-
allocatePTY
public void allocatePTY(String term, int cols, int rows, int width, int height, Map<PTYMode, Integer> modes) throws ConnectionException, TransportExceptionDescription copied from interface:SessionAllocate a psuedo-terminal for this session.0dimension parameters will be ignored by the server.- Specified by:
allocatePTYin interfaceSession- Parameters:
term-TERMenvironment 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:
ConnectionExceptionTransportException
-
canDoFlowControl
Description copied from interface:Session.ShellWhether the client can do local flow control usingcontrol-Sandcontrol-Q.- Specified by:
canDoFlowControlin interfaceSession.Shell- Returns:
- boolean value indicating whether 'client can do', or
nullif no such information was received
-
changeWindowDimensions
public void changeWindowDimensions(int cols, int rows, int width, int height) throws TransportException Description copied from interface:Session.ShellSends a window dimension change message.- Specified by:
changeWindowDimensionsin interfaceSession.Shell- Parameters:
cols- terminal width, columnsrows- terminal height, rowswidth- terminal width, pixelsheight- terminal height, pixels- Throws:
TransportException
-
exec
Description copied from interface:SessionExecute a remote command.- Specified by:
execin interfaceSession- Parameters:
command-- Returns:
Session.Commandinstance 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.CommandReturns the command'sstderrstream.- Specified by:
getErrorStreamin interfaceSession.Command- Specified by:
getErrorStreamin interfaceSession.Shell
-
getExitErrorMessage
Description copied from interface:Session.CommandIf 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:
getExitErrorMessagein interfaceSession.Command
-
getExitSignal
Description copied from interface:Session.CommandReturns thesignalif the command exit violently, ornullif this information was not received. NOTE: Always callChannel.close()first before inspecting the exit signal.- Specified by:
getExitSignalin interfaceSession.Command
-
getExitStatus
Description copied from interface:Session.CommandReturns the exit status of the command if it was received, ornullif this information was not received. NOTE: Always callChannel.close()first before inspecting the exit status.- Specified by:
getExitStatusin interfaceSession.Command- Specified by:
getExitStatusin interfaceSession.Subsystem
-
handleRequest
- Overrides:
handleRequestin classAbstractChannel- Throws:
ConnectionExceptionTransportException
-
reqX11Forwarding
public void reqX11Forwarding(String authProto, String authCookie, int screen) throws ConnectionException, TransportException Description copied from interface:SessionRequest X11 forwarding.- Specified by:
reqX11Forwardingin 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:SessionSet an environment variable.- Specified by:
setEnvVarin 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.CommandSend a signal to the remote command.- Specified by:
signalin interfaceSession.Command- Specified by:
signalin interfaceSession.Shell- Parameters:
sig- the signal- Throws:
TransportException- if error sending the signal
-
startShell
Description copied from interface:SessionRequest a shell.- Specified by:
startShellin interfaceSession- Returns:
Session.Shellinstance which should now be used- Throws:
ConnectionException- if the request failedTransportException- if there was an error sending the request
-
startSubsystem
Description copied from interface:SessionRequest a subsystem.- Specified by:
startSubsystemin interfaceSession- Parameters:
name- subsystem name- Returns:
Session.Subsysteminstance 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.CommandIf 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:
getExitWasCoreDumpedin interfaceSession.Command
-
closeAllStreams
protected void closeAllStreams()Description copied from class:AbstractChannelCalled when all I/O streams should be closed. Subclasses can override but must call super.- Overrides:
closeAllStreamsin classAbstractChannel
-
eofInputStreams
protected void eofInputStreams()Description copied from class:AbstractChannelCalled when EOF has been received. Subclasses can override but must call super.- Overrides:
eofInputStreamsin classAbstractChannel
-
gotExtendedData
- Overrides:
gotExtendedDatain classAbstractChannel- Throws:
SSHException
-
notifyError
Description copied from interface:ErrorNotifiableNotifies this object of anerror.- Specified by:
notifyErrorin interfaceErrorNotifiable- Overrides:
notifyErrorin classAbstractChannel
-
checkReuse
private void checkReuse()
-