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 |
static int |
DEFAULT_MAX_EXTDATA_BUFSIZE
Default value of "channel-session-max-extdata-bufsize"
|
protected StandardEnvironment |
env |
protected OutputStream |
err |
protected Buffer |
extendedDataBuffer |
protected ChannelDataReceiver |
extendedDataWriter |
static String |
MAX_EXTDATA_BUFSIZE
Maximum amount of extended (a.k.a.
|
protected OutputStream |
out |
protected ChannelDataReceiver |
receiver |
protected Buffer |
receiverBuffer |
protected String |
type |
exitStatusSentchannelListenerProxy, channelListeners, eofReceived, eofSent, gracefulFuture, gracefulState, initialized, RESPONSE_BUFFER_GROWTH_FACTOR, servicecloseFuture, futureLock, statelogCHANNEL_EXEC, CHANNEL_SHELL, CHANNEL_SUBSYSTEMEMPTYNONECLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT| 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) |
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 |
handleBreak(Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleEnv(Buffer buffer,
boolean wantReply) |
void |
handleEof()
Invoked when
SSH_MSG_CHANNEL_EOF received |
protected RequestHandler.Result |
handleExec(String request,
Buffer buffer,
boolean wantReply) |
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 |
handleShell(String request,
Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleSignal(Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleSubsystem(String request,
Buffer buffer,
boolean wantReply) |
void |
handleWindowAdjust(Buffer buffer)
Invoked when
SSH_MSG_CHANNEL_WINDOW_ADJUST received |
protected RequestHandler.Result |
handleWindowChange(Buffer buffer,
boolean wantReply) |
protected RequestHandler.Result |
handleX11Forwarding(String requestType,
Buffer buffer,
boolean wantReply) |
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, getChannelStreamPacketWriterResolver, getExecutorService, getId, getLocalWindow, getParentPropertyResolver, getProperties, getRecipient, getRemoteWindow, getRequestHandlers, handleChannelRequest, handleClose, handleData, handleExtendedData, handleFailure, handleRequest, handleSuccess, handleUnknownChannelRequest, init, invokeChannelSignaller, isEofSent, isEofSignalled, isInitialized, notifyStateChanged, notifyStateChanged, preClose, removeAttribute, removeChannelListener, removePendingRequest, removeRequestHandler, resolveChannelStreamPacketWriterResolver, sendEof, sendWindowAdjust, setAttribute, setChannelStreamPacketWriterResolver, setRecipient, signalChannelClosed, signalChannelClosed, signalChannelInitialized, signalChannelInitialized, signalChannelOpenFailure, signalChannelOpenFailure, signalChannelOpenSuccess, signalChannelOpenSuccess, toString, validateIncomingDataSize, writePacketdoCloseGracefully, doCloseImmediatelyaddCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenergetSimplifiedLoggerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetServerSessionaddRequestHandler, addRequestHandlers, getId, getLocalWindow, getRecipient, getRemoteWindow, getRequestHandlers, handleClose, handleData, handleExtendedData, handleFailure, handleRequest, handleSuccess, init, isEofSignalled, isInitialized, removeRequestHandler, removeRequestHandlers, resolveAttribute, resolveAttributegetSessionContextaddChannelListener, getChannelListenerProxy, removeChannelListenergetBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringPropertyclearAttributes, computeAttributeIfAbsent, removeAttribute, setAttributeattributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePaircalculatePadLength, writePacketgetChannelStreamPacketWriterResolver, resolveChannelStreamPacketWriter, resolveChannelStreamPacketWriterResolver, setChannelStreamPacketWriterResolveraddCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListenerpublic static final List<ChannelRequestHandler> DEFAULT_HANDLERS
public static final String MAX_EXTDATA_BUFSIZE
ChannelDataReceiver for the data is registeredpublic static final int DEFAULT_MAX_EXTDATA_BUFSIZE
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 handlePtyReq(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleWindowChange(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleSignal(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleBreak(Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleShell(String request, Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleExec(String request, Buffer buffer, boolean wantReply) throws IOException
IOExceptionprotected RequestHandler.Result handleSubsystem(String request, Buffer buffer, boolean wantReply) 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, Command.setInputStream(java.io.InputStream) or
AsyncCommand.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 Command.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 handleX11Forwarding(String requestType, Buffer buffer, boolean wantReply) throws IOException
IOExceptionpublic StandardEnvironment getEnvironment()
protected void closeShell(int exitValue)
throws IOException
IOExceptionCopyright © 2008–2020 The Apache Software Foundation. All rights reserved.