Package org.apache.sshd.common.channel
Interface Channel
-
- All Superinterfaces:
AttributeRepository
,AttributeStore
,java.lang.AutoCloseable
,java.nio.channels.Channel
,ChannelListenerManager
,ChannelStreamPacketWriterResolver
,ChannelStreamPacketWriterResolverManager
,java.io.Closeable
,Closeable
,PacketWriter
,PropertyResolver
,SessionContextHolder
,SessionHolder<Session>
- All Known Subinterfaces:
ClientChannel
,ServerChannel
- All Known Implementing Classes:
AbstractChannel
,AbstractClientChannel
,AbstractServerChannel
,AgentForwardedChannel
,ChannelAgentForwarding
,ChannelDirectTcpip
,ChannelExec
,ChannelForwardedX11
,ChannelSession
,ChannelSession
,ChannelShell
,ChannelSubsystem
,PtyCapableChannelSession
,TcpipClientChannel
,TcpipServerChannel
public interface Channel extends SessionHolder<Session>, ChannelListenerManager, PropertyResolver, AttributeStore, PacketWriter, ChannelStreamPacketWriterResolverManager, Closeable
Represents a channel opened over an SSH session - holds information that is common both to server and client channels.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T>
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CHANNEL_EXEC
static java.lang.String
CHANNEL_SHELL
static java.lang.String
CHANNEL_SUBSYSTEM
-
Fields inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamPacketWriterResolver
NONE
-
Fields inherited from interface org.apache.sshd.common.Closeable
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
-
Fields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTY
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addRequestHandler(RequestHandler<Channel> handler)
default void
addRequestHandlers(java.util.Collection<? extends RequestHandler<Channel>> handlers)
int
getId()
Window
getLocalWindow()
int
getRecipient()
Window
getRemoteWindow()
java.util.List<RequestHandler<Channel>>
getRequestHandlers()
void
handleClose()
Invoked whenSSH_MSG_CHANNEL_CLOSE
receivedvoid
handleData(Buffer buffer)
Invoked whenSSH_MSG_CHANNEL_DATA
receivedvoid
handleEof()
Invoked whenSSH_MSG_CHANNEL_EOF
receivedvoid
handleExtendedData(Buffer buffer)
Invoked whenSSH_MSG_CHANNEL_EXTENDED_DATA
receivedvoid
handleFailure()
Invoked whenSSH_MSG_CHANNEL_FAILURE
receivedvoid
handleOpenFailure(Buffer buffer)
For a client channel, this method will be called internally by the session when the server has rejected this channel opening.void
handleOpenSuccess(int recipient, long rwSize, long packetSize, Buffer buffer)
For a client channel, this method will be called internally by the session when the confirmation has been received.void
handleRequest(Buffer buffer)
Invoked whenSSH_MSG_CHANNEL_REQUEST
receivedvoid
handleSuccess()
Invoked whenSSH_MSG_CHANNEL_SUCCESS
receivedvoid
handleWindowAdjust(Buffer buffer)
Invoked whenSSH_MSG_CHANNEL_WINDOW_ADJUST
receivedvoid
init(ConnectionService service, Session session, int id)
Invoked when the local channel is initial createdboolean
isEofSignalled()
boolean
isInitialized()
OpenFuture
open(int recipient, long rwSize, long packetSize, Buffer buffer)
For a server channel, this method will actually open the channelvoid
removeRequestHandler(RequestHandler<Channel> handler)
default void
removeRequestHandlers(java.util.Collection<? extends RequestHandler<Channel>> handlers)
default <T> T
resolveAttribute(AttributeRepository.AttributeKey<T> key)
Attempts to resolve the associated value by going up the store's hierarchy (if any)static <T> T
resolveAttribute(Channel channel, AttributeRepository.AttributeKey<T> key)
Attempts to use the channel attribute, if not found then tries the session-
Methods inherited from interface org.apache.sshd.common.AttributeRepository
attributeKeys, getAttribute, getAttributesCount
-
Methods inherited from interface org.apache.sshd.common.AttributeStore
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
-
Methods inherited from interface org.apache.sshd.common.channel.ChannelListenerManager
addChannelListener, getChannelListenerProxy, removeChannelListener
-
Methods inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamPacketWriterResolverManager
getChannelStreamPacketWriterResolver, resolveChannelStreamPacketWriter, resolveChannelStreamPacketWriterResolver, setChannelStreamPacketWriterResolver
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
Methods inherited from interface org.apache.sshd.common.io.PacketWriter
writePacket
-
Methods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty
-
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSession, getSessionContext
-
-
-
-
Field Detail
-
CHANNEL_EXEC
static final java.lang.String CHANNEL_EXEC
- See Also:
- Constant Field Values
-
CHANNEL_SHELL
static final java.lang.String CHANNEL_SHELL
- See Also:
- Constant Field Values
-
CHANNEL_SUBSYSTEM
static final java.lang.String CHANNEL_SUBSYSTEM
- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
int getId()
- Returns:
- Local channel identifier
-
getRecipient
int getRecipient()
- Returns:
- Remote channel identifier
-
getLocalWindow
Window getLocalWindow()
-
getRemoteWindow
Window getRemoteWindow()
-
getRequestHandlers
java.util.List<RequestHandler<Channel>> getRequestHandlers()
-
addRequestHandler
void addRequestHandler(RequestHandler<Channel> handler)
-
addRequestHandlers
default void addRequestHandlers(java.util.Collection<? extends RequestHandler<Channel>> handlers)
-
removeRequestHandler
void removeRequestHandler(RequestHandler<Channel> handler)
-
removeRequestHandlers
default void removeRequestHandlers(java.util.Collection<? extends RequestHandler<Channel>> handlers)
-
handleClose
void handleClose() throws java.io.IOException
Invoked whenSSH_MSG_CHANNEL_CLOSE
received- Throws:
java.io.IOException
- If failed to handle the message
-
handleWindowAdjust
void handleWindowAdjust(Buffer buffer) throws java.io.IOException
Invoked whenSSH_MSG_CHANNEL_WINDOW_ADJUST
received- Parameters:
buffer
- The rest of the message dataBuffer
after decoding the channel identifiers- Throws:
java.io.IOException
- If failed to handle the message
-
handleRequest
void handleRequest(Buffer buffer) throws java.io.IOException
Invoked whenSSH_MSG_CHANNEL_REQUEST
received- Parameters:
buffer
- The rest of the message dataBuffer
after decoding the channel identifiers- Throws:
java.io.IOException
- If failed to handle the message
-
handleData
void handleData(Buffer buffer) throws java.io.IOException
Invoked whenSSH_MSG_CHANNEL_DATA
received- Parameters:
buffer
- The rest of the message dataBuffer
after decoding the channel identifiers- Throws:
java.io.IOException
- If failed to handle the message
-
handleExtendedData
void handleExtendedData(Buffer buffer) throws java.io.IOException
Invoked whenSSH_MSG_CHANNEL_EXTENDED_DATA
received- Parameters:
buffer
- The rest of the message dataBuffer
after decoding the channel identifiers- Throws:
java.io.IOException
- If failed to handle the message
-
handleEof
void handleEof() throws java.io.IOException
Invoked whenSSH_MSG_CHANNEL_EOF
received- Throws:
java.io.IOException
- If failed to handle the message
-
handleSuccess
void handleSuccess() throws java.io.IOException
Invoked whenSSH_MSG_CHANNEL_SUCCESS
received- Throws:
java.io.IOException
- If failed to handle the message
-
handleFailure
void handleFailure() throws java.io.IOException
Invoked whenSSH_MSG_CHANNEL_FAILURE
received- Throws:
java.io.IOException
- If failed to handle the message
-
init
void init(ConnectionService service, Session session, int id) throws java.io.IOException
Invoked when the local channel is initial created- Parameters:
service
- TheConnectionService
through which the channel is initializedsession
- TheSession
associated with the channelid
- The locally assigned channel identifier- Throws:
java.io.IOException
- If failed to process the initialization
-
isInitialized
boolean isInitialized()
- Returns:
true
if call toinit(ConnectionService, Session, int)
was successfully completed
-
isEofSignalled
boolean isEofSignalled()
- Returns:
true
if the peer signaled that it will not send any more data- See Also:
- RFC 4254 - section 5.3 - SSH_MSG_CHANNEL_EOF
-
open
OpenFuture open(int recipient, long rwSize, long packetSize, Buffer buffer)
For a server channel, this method will actually open the channel- Parameters:
recipient
- Recipient identifierrwSize
- Read/Write window size (uint32
)packetSize
- Preferred maximum packet size (uint32
)buffer
- IncomingBuffer
that triggered the call. Note: the buffer's read position is exactly after the information that read to this call was decoded- Returns:
- An
OpenFuture
for the channel open request
-
handleOpenSuccess
void handleOpenSuccess(int recipient, long rwSize, long packetSize, Buffer buffer) throws java.io.IOException
For a client channel, this method will be called internally by the session when the confirmation has been received.- Parameters:
recipient
- Recipient identifierrwSize
- Read/Write window size (uint32
)packetSize
- Preferred maximum packet size (uint32
)buffer
- IncomingBuffer
that triggered the call. Note: the buffer's read position is exactly after the information that read to this call was decoded- Throws:
java.io.IOException
- If failed to handle the success
-
handleOpenFailure
void handleOpenFailure(Buffer buffer) throws java.io.IOException
For a client channel, this method will be called internally by the session when the server has rejected this channel opening.- Parameters:
buffer
- IncomingBuffer
that triggered the call. Note: the buffer's read position is exactly after the information that read to this call was decoded- Throws:
java.io.IOException
- If failed to handle the success
-
resolveAttribute
default <T> T resolveAttribute(AttributeRepository.AttributeKey<T> key)
Description copied from interface:AttributeRepository
Attempts to resolve the associated value by going up the store's hierarchy (if any)- Specified by:
resolveAttribute
in interfaceAttributeRepository
- Type Parameters:
T
- The generic attribute type- Parameters:
key
- The key of the attribute; must not benull
.- Returns:
null
if there is no value associated with the specified key either in this repository or any of its ancestors (if any available)
-
resolveAttribute
static <T> T resolveAttribute(Channel channel, AttributeRepository.AttributeKey<T> key)
Attempts to use the channel attribute, if not found then tries the session- Type Parameters:
T
- The generic attribute type- Parameters:
channel
- TheChannel
- ignored ifnull
key
- The attribute key - nevernull
- Returns:
- Associated value -
null
if not found - See Also:
SessionHolder.getSession()
,Session.resolveAttribute(Session, AttributeRepository.AttributeKey)
-
-