public class ChannelSession extends AbstractServerChannel
Modifier and Type | Class and Description |
---|---|
class |
ChannelSession.CommandCloseable |
AbstractChannel.GracefulChannelCloseable, AbstractChannel.GracefulState
AbstractCloseable.State
AttributeRepository.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 OutputStream |
out |
protected ChannelDataReceiver |
receiver |
protected Buffer |
tempBuffer |
protected String |
type |
exitStatusSent
channelListenerProxy, channelListeners, eofReceived, eofSent, gracefulFuture, gracefulState, initialized, RESPONSE_BUFFER_GROWTH_FACTOR, service
closeFuture, lock, state
log
CHANNEL_EXEC, CHANNEL_SHELL, CHANNEL_SUBSYSTEM
EMPTY
NONE
CLOSE_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,
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 |
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 . |
doInit, getServerSession, handleOpenFailure, handleOpenSuccess, open, sendExitStatus
addChannelListener, 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, writePacket
doCloseGracefully, doCloseImmediately
addCloseFutureListener, builder, close, isClosed, isClosing, removeCloseFutureListener
getSimplifiedLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addRequestHandler, addRequestHandlers, getId, getLocalWindow, getRecipient, getRemoteWindow, getRequestHandlers, handleClose, handleData, handleExtendedData, handleFailure, handleRequest, handleSuccess, init, isEofSignalled, isInitialized, removeRequestHandler, removeRequestHandlers, resolveAttribute, resolveAttribute
addChannelListener, getChannelListenerProxy, removeChannelListener
getBoolean, getBooleanProperty, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
attributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePair
writePacket
getChannelStreamPacketWriterResolver, resolveChannelStreamPacketWriter, resolveChannelStreamPacketWriterResolver, setChannelStreamPacketWriterResolver
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
public 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 Buffer tempBuffer
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 class AbstractChannel
Session
public void handleWindowAdjust(Buffer buffer) throws IOException
Channel
SSH_MSG_CHANNEL_WINDOW_ADJUST
receivedhandleWindowAdjust
in class AbstractChannel
buffer
- The rest of the message data Buffer
after
decoding the channel identifiersIOException
- If failed to handle the messageprotected Closeable getInnerCloseable()
getInnerCloseable
in class AbstractChannel
protected void closeImmediately0()
public void handleEof() throws IOException
Channel
SSH_MSG_CHANNEL_EOF
receivedhandleEof
in class AbstractChannel
IOException
- If failed to handle the messageprotected void doWriteData(byte[] data, int off, long len) throws IOException
doWriteData
in class AbstractChannel
IOException
protected void doWriteExtendedData(byte[] data, int off, long len) throws IOException
doWriteExtendedData
in class AbstractChannel
IOException
protected RequestHandler.Result handleInternalRequest(String requestType, boolean wantReply, Buffer buffer) throws IOException
AbstractChannel
AbstractChannel.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 AbstractChannel
requestType
- 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 AbstractChannel
IOException
protected RequestHandler.Result handleEnv(Buffer buffer, boolean wantReply) throws IOException
IOException
protected RequestHandler.Result handlePtyReq(Buffer buffer, boolean wantReply) throws IOException
IOException
protected RequestHandler.Result handleWindowChange(Buffer buffer, boolean wantReply) throws IOException
IOException
protected RequestHandler.Result handleSignal(Buffer buffer, boolean wantReply) throws IOException
IOException
protected RequestHandler.Result handleBreak(Buffer buffer, boolean wantReply) throws IOException
IOException
protected RequestHandler.Result handleShell(String request, Buffer buffer, boolean wantReply) throws IOException
IOException
protected RequestHandler.Result handleExec(String request, Buffer buffer, boolean wantReply) throws IOException
IOException
protected RequestHandler.Result handleSubsystem(String request, Buffer buffer, boolean wantReply) throws IOException
IOException
protected RequestHandler.Result prepareChannelCommand(String request, Command cmd) throws IOException
IOException
public 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 CommandLifecycle.start(Environment)
,
the input stream you received in Command.setInputStream(java.io.InputStream)
will
not read any data.receiver
- The ChannelDataReceiver
instanceprotected 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 null
null
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
IOException
protected RequestHandler.Result handleX11Forwarding(String requestType, Buffer buffer, boolean wantReply) throws IOException
IOException
public StandardEnvironment getEnvironment()
protected void closeShell(int exitValue, boolean closeImmediately) throws IOException
IOException
Copyright © 2008–2022 The Apache Software Foundation. All rights reserved.