public class ChannelSession extends AbstractServerChannel
| Modifier and Type | Class and Description |
|---|---|
class |
ChannelSession.CommandCloseable |
AbstractChannel.GracefulChannelCloseable, AbstractChannel.GracefulStateAbstractCloseable.StateAttributeRepository.AttributeKey<T>| Modifier and Type | Field and Description |
|---|---|
protected ChannelAsyncOutputStream |
asyncErr |
protected ChannelAsyncOutputStream |
asyncOut |
protected CloseFuture |
commandExitFuture |
protected Command |
commandInstance |
protected AtomicBoolean |
commandStarted |
static List<ChannelRequestHandler> |
DEFAULT_HANDLERS |
protected StandardEnvironment |
env |
protected OutputStream |
err |
protected Buffer |
extendedDataBuffer |
protected ChannelDataReceiver |
extendedDataWriter |
protected OutputStream |
out |
protected ChannelDataReceiver |
receiver |
protected Buffer |
receiverBuffer |
protected String |
type |
exitStatusSentchannelListenerProxy, channelListeners, closeSignaled, eofReceived, eofSent, gracefulFuture, gracefulState, initialized, RESPONSE_BUFFER_GROWTH_FACTOR, service, unregisterSignaledcloseFuture, futureLock, statelogCHANNEL_EXEC, CHANNEL_SHELL, CHANNEL_SUBSYSTEMEMPTYNONE| Constructor and Description |
|---|
ChannelSession() |
ChannelSession(Collection<? extends RequestHandler<Channel>> handlers) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addEnvVariable(String name,
String value) |
protected void |
closeImmediately0() |
protected void |
closeShell(int exitValue,
boolean closeImmediately) |
protected void |
doWriteData(byte[] data,
int off,
long len) |
protected void |
doWriteExtendedData(byte[] data,
int off,
long len) |
StandardEnvironment |
getEnvironment() |
protected Closeable |
getInnerCloseable() |
protected int |
getPtyModeValue(PtyMode mode) |
ServerSession |
getSession() |
protected RequestHandler.Result |
handleAgentForwarding(String requestType,
Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleAgentForwardingParsed(String requestType) |
protected RequestHandler.Result |
handleBreak(Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleBreakParsed(long breakLength) |
protected RequestHandler.Result |
handleEnv(Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleEnvParsed(String name,
String value) |
void |
handleEof()
Invoked when
SSH_MSG_CHANNEL_EOF received |
protected RequestHandler.Result |
handleExec(String request,
Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleExecParsed(String request,
String commandLine) |
protected RequestHandler.Result |
handleInternalRequest(String requestType,
boolean wantReply,
Buffer buffer)
Called by
AbstractChannel.handleUnknownChannelRequest(String, boolean, Buffer) in order to allow channel request
handling if none of the registered handlers processed the request - last chance. |
protected RequestHandler.Result |
handlePtyReq(Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handlePtyReqParsed(String term,
int tColumns,
int tRows,
int tWidth,
int tHeight,
Map<PtyMode,Integer> ptyModes) |
protected RequestHandler.Result |
handleShell(String request,
Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleShellParsed(String request) |
protected RequestHandler.Result |
handleSignal(Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleSignalParsed(String name) |
protected RequestHandler.Result |
handleSubsystem(String request,
Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleSubsystemParsed(String request,
String subsystem) |
void |
handleWindowAdjust(Buffer buffer)
Invoked when
SSH_MSG_CHANNEL_WINDOW_ADJUST received |
protected RequestHandler.Result |
handleWindowChange(Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleWindowChangeParsed(int tColumns,
int tRows,
int tWidth,
int tHeight) |
protected RequestHandler.Result |
handleX11Forwarding(String requestType,
Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleX11ForwardingParsed(String requestType,
ServerSession session,
boolean singleConnection,
String authProtocol,
String authCookie,
int screenId) |
protected boolean |
isSendChunkIfRemoteWindowIsSmallerThanPacketSize(byte cmd)
Chance for specializations to vary chunking behaviour depending on the SFTP client version.
|
protected RequestHandler.Result |
prepareChannelCommand(String request,
Command cmd) |
protected Command |
prepareCommand(String requestType,
Command command)
Called by
prepareChannelCommand(String, Command) in order to set up the command's streams, session,
file-system, exit callback, etc.. |
protected IoWriteFuture |
sendResponse(Buffer buffer,
String req,
RequestHandler.Result result,
boolean wantReply) |
void |
setDataReceiver(ChannelDataReceiver receiver)
For
Command to install ChannelDataReceiver. |
void |
setExtendedDataWriter(ChannelDataReceiver extendedDataWriter)
A special
ChannelDataReceiver that can be used to receive data sent as "extended" - usually
STDERR. |
doInit, handleOpenFailure, handleOpenSuccess, open, sendExitStatusaddChannelListener, addPendingRequest, addRequestHandler, attributeKeys, clearAttributes, computeAttributeIfAbsent, configureWindow, getAttribute, getAttributesCount, getChannelListenerProxy, getChannelStreamWriterResolver, getExecutorService, getId, getLocalWindow, getParentPropertyResolver, getProperties, getRecipient, getRemoteWindow, getRequestHandlers, handleChannelRegistrationResult, handleChannelRequest, handleChannelUnregistration, handleClose, handleData, handleExtendedData, handleFailure, handleRequest, handleSuccess, handleUnknownChannelRequest, init, invokeChannelSignaller, isEofSent, isEofSignalled, isInitialized, notifyStateChanged, notifyStateChanged, preClose, removeAttribute, removeChannelListener, removePendingRequest, removeRequestHandler, resolveChannelStreamWriterResolver, sendEof, sendWindowAdjust, setAttribute, setChannelStreamWriterResolver, setRecipient, signalChannelClosed, signalChannelClosed, signalChannelInitialized, signalChannelInitialized, signalChannelOpenFailure, signalChannelOpenFailure, signalChannelOpenSuccess, signalChannelOpenSuccess, toString, validateIncomingDataSize, writePacketdoCloseGracefully, doCloseImmediatelyaddCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenerdebug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetServerSessionaddRequestHandler, addRequestHandlers, getId, getLocalWindow, getRecipient, getRemoteWindow, getRequestHandlers, handleChannelRegistrationResult, handleChannelUnregistration, handleClose, handleData, handleExtendedData, handleFailure, handleRequest, handleSuccess, init, isEofSignalled, isInitialized, removeRequestHandler, removeRequestHandlers, resolveAttribute, resolveAttribute, writePacketgetSessionContextaddChannelListener, getChannelListenerProxy, removeChannelListenergetBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty, isEmptyclearAttributes, computeAttributeIfAbsent, removeAttribute, setAttributeattributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePairgetChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolveraddCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListenerpublic static final List<ChannelRequestHandler> DEFAULT_HANDLERS
protected String type
protected ChannelAsyncOutputStream asyncOut
protected ChannelAsyncOutputStream asyncErr
protected OutputStream out
protected OutputStream err
protected Command commandInstance
protected ChannelDataReceiver receiver
protected ChannelDataReceiver extendedDataWriter
protected Buffer receiverBuffer
protected Buffer extendedDataBuffer
protected final AtomicBoolean commandStarted
protected final StandardEnvironment env
protected final CloseFuture commandExitFuture
public ChannelSession()
public ChannelSession(Collection<? extends RequestHandler<Channel>> handlers)
public ServerSession getSession()
getSession in interface SessionHolder<Session>getSession in class AbstractChannelpublic void handleWindowAdjust(Buffer buffer) throws IOException
ChannelSSH_MSG_CHANNEL_WINDOW_ADJUST receivedhandleWindowAdjust in class AbstractChannelbuffer - The rest of the message data Buffer after decoding the channel identifiersIOException - If failed to handle the messageprotected Closeable getInnerCloseable()
getInnerCloseable in class AbstractChannelprotected void closeImmediately0()
public void handleEof()
throws IOException
ChannelSSH_MSG_CHANNEL_EOF receivedhandleEof in class AbstractChannelIOException - If failed to handle the messageprotected void doWriteData(byte[] data,
int off,
long len)
throws IOException
doWriteData in class AbstractChannelIOExceptionprotected void doWriteExtendedData(byte[] data,
int off,
long len)
throws IOException
doWriteExtendedData in class AbstractChannelIOExceptionprotected RequestHandler.Result handleInternalRequest(String requestType, boolean wantReply, Buffer buffer) throws IOException
AbstractChannelAbstractChannel.handleUnknownChannelRequest(String, boolean, Buffer) in order to allow channel request
handling if none of the registered handlers processed the request - last chance.handleInternalRequest in class AbstractChannelrequestType - The request typewantReply - Whether reply is requestedbuffer - The Buffer containing extra request-specific datanull or Unsupported and reply is required then a
failure message will be sentIOException - If failed to process the request internallyprotected IoWriteFuture sendResponse(Buffer buffer, String req, RequestHandler.Result result, boolean wantReply) throws IOException
sendResponse in class AbstractChannelIOExceptionprotected RequestHandler.Result handleEnv(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleEnvParsed(String name, String value) throws IOException
IOExceptionprotected RequestHandler.Result handlePtyReq(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handlePtyReqParsed(String term, int tColumns, int tRows, int tWidth, int tHeight, Map<PtyMode,Integer> ptyModes) throws IOException
IOExceptionprotected RequestHandler.Result handleWindowChange(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleWindowChangeParsed(int tColumns, int tRows, int tWidth, int tHeight) throws IOException
IOExceptionprotected RequestHandler.Result handleSignal(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleSignalParsed(String name) throws IOException
IOExceptionprotected RequestHandler.Result handleBreak(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleBreakParsed(long breakLength) throws IOException
IOExceptionprotected RequestHandler.Result handleShell(String request, Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleShellParsed(String request) throws IOException
IOExceptionprotected RequestHandler.Result handleExec(String request, Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleExecParsed(String request, String commandLine) throws IOException
IOExceptionprotected RequestHandler.Result handleSubsystem(String request, Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleSubsystemParsed(String request, String subsystem) throws IOException
IOExceptionprotected RequestHandler.Result prepareChannelCommand(String request, Command cmd) throws IOException
IOExceptionpublic void setDataReceiver(ChannelDataReceiver receiver)
Command to install ChannelDataReceiver. When you do this,
CommandDirectInputStreamAware.setInputStream(java.io.InputStream) or
AsyncCommandInputStreamAware.setIoInputStream(org.apache.sshd.common.io.IoInputStream)
will no longer be invoked. If you call this method from Command#start(ChannelSession, Environment), the
input stream you received in CommandDirectInputStreamAware.setInputStream(java.io.InputStream) will not read any data.receiver - The ChannelDataReceiver instancepublic void setExtendedDataWriter(ChannelDataReceiver extendedDataWriter)
ChannelDataReceiver that can be used to receive data sent as "extended" - usually
STDERR. Note: by default any such data sent to the channel session causes an exception, but specific
implementations may choose to register such a receiver (e.g., for custom usage of the STDERR stream). A good
place in the code to register such a writer would be in commands that also implement ChannelSessionAware.extendedDataWriter - The ChannelDataReceiver.protected Command prepareCommand(String requestType, Command command) throws IOException
prepareChannelCommand(String, Command) in order to set up the command's streams, session,
file-system, exit callback, etc..requestType - The request that caused the command to be createdcommand - The created Command - may be nullnull then the request that initially caused the
creation of the command is failed and the original command (if any) destroyed (eventually).
Note: if a different command instance than the input one is returned, then it is up to
the implementor to take care of the wrapping or destruction of the original command instance.IOException - If failed to prepare the commandprotected int getPtyModeValue(PtyMode mode)
protected RequestHandler.Result handleAgentForwarding(String requestType, Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleAgentForwardingParsed(String requestType) throws IOException
IOExceptionprotected RequestHandler.Result handleX11Forwarding(String requestType, Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleX11ForwardingParsed(String requestType, ServerSession session, boolean singleConnection, String authProtocol, String authCookie, int screenId) throws IOException
IOExceptionpublic StandardEnvironment getEnvironment()
protected void closeShell(int exitValue,
boolean closeImmediately)
throws IOException
IOExceptionprotected boolean isSendChunkIfRemoteWindowIsSmallerThanPacketSize(byte cmd)
cmd - Either SSH_MSG_CHANNEL_DATA or
SSH_MSG_CHANNEL_EXTENDED_DATA indicating the output stream typetrue if should chunk data sent via ChannelAsyncOutputStream
when reported remote window size is less than its packet sizeUnsupportedOperationException - if the command is neither of the supported onesChannelAsyncOutputStream(Channel, byte, boolean)Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.