Package org.apache.sshd.common.channel
Interface Channel
- All Superinterfaces:
AttributeRepository
,AttributeStore
,AutoCloseable
,Channel
,ChannelIdentifier
,ChannelListenerManager
,ChannelStreamWriterResolver
,ChannelStreamWriterResolverManager
,Closeable
,Closeable
,PropertyResolver
,SessionContextHolder
,SessionHolder<Session>
- All Known Subinterfaces:
ClientChannel
,ServerChannel
- All Known Implementing Classes:
AbstractChannel
,AbstractClientChannel
,AbstractServerChannel
,AgentForwardedChannel
,AgentForwardedChannel
,ChannelAgentForwarding
,ChannelAgentForwarding
,ChannelDirectTcpip
,ChannelExec
,ChannelForwardedX11
,ChannelSession
,ChannelSession
,ChannelShell
,ChannelSubsystem
,PtyCapableChannelSession
,TcpipClientChannel
,TcpipServerChannel
public interface Channel
extends SessionHolder<Session>, ChannelIdentifier, ChannelListenerManager, PropertyResolver, AttributeStore, ChannelStreamWriterResolverManager, Closeable
Represents a channel opened over an SSH session - holds information that is common both to server and client
channels.
- Author:
- Apache MINA SSHD Project
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T extends Object>
-
Field Summary
Fields inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolver
NONE
Fields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTY
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addRequestHandler
(RequestHandler<Channel> handler) default void
addRequestHandlers
(Collection<? extends RequestHandler<Channel>> handlers) long
void
handleChannelRegistrationResult
(ConnectionService service, Session session, long id, boolean registered) Invoked after being successfully registered by the connection service - should throw aRuntimeException
if not registeredvoid
Called by the connection service to inform the channel that it has bee unregistered.void
Invoked whenSSH_MSG_CHANNEL_CLOSE
receivedvoid
handleData
(Buffer buffer) Invoked whenSSH_MSG_CHANNEL_DATA
receivedvoid
Invoked whenSSH_MSG_CHANNEL_EOF
receivedvoid
handleExtendedData
(Buffer buffer) Invoked whenSSH_MSG_CHANNEL_EXTENDED_DATA
receivedvoid
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
(long 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
Invoked whenSSH_MSG_CHANNEL_SUCCESS
receivedvoid
handleWindowAdjust
(Buffer buffer) Invoked whenSSH_MSG_CHANNEL_WINDOW_ADJUST
receivedvoid
init
(ConnectionService service, Session session, long id) Invoked when the local channel is initial createdboolean
boolean
For a server channel, this method will actually open the channelvoid
removeRequestHandler
(RequestHandler<Channel> handler) default void
removeRequestHandlers
(Collection<? extends RequestHandler<Channel>> handlers) default <T> T
static <T> T
resolveAttribute
(Channel channel, AttributeRepository.AttributeKey<T> key) Attempts to use the channel attribute, if not found then tries the sessionwritePacket
(Buffer buffer) Encode and send the given buffer.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.ChannelIdentifier
getChannelId
Methods inherited from interface org.apache.sshd.common.channel.ChannelListenerManager
addChannelListener, getChannelListenerProxy, removeChannelListener
Methods inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolverManager
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolver
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
Methods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty
Methods inherited from interface org.apache.sshd.common.session.SessionHolder
getSession, getSessionContext
-
Field Details
-
CHANNEL_EXEC
- See Also:
-
CHANNEL_SHELL
- See Also:
-
CHANNEL_SUBSYSTEM
- See Also:
-
-
Method Details
-
getRecipient
long getRecipient()- Returns:
- Remote channel UITN32 identifier
-
getLocalWindow
LocalWindow getLocalWindow() -
getRemoteWindow
RemoteWindow getRemoteWindow() -
getRequestHandlers
List<RequestHandler<Channel>> getRequestHandlers() -
addRequestHandler
-
addRequestHandlers
-
removeRequestHandler
-
removeRequestHandlers
-
handleClose
Invoked whenSSH_MSG_CHANNEL_CLOSE
received- Throws:
IOException
- If failed to handle the message
-
handleWindowAdjust
Invoked whenSSH_MSG_CHANNEL_WINDOW_ADJUST
received- Parameters:
buffer
- The rest of the message dataBuffer
after decoding the channel identifiers- Throws:
IOException
- If failed to handle the message
-
handleRequest
Invoked whenSSH_MSG_CHANNEL_REQUEST
received- Parameters:
buffer
- The rest of the message dataBuffer
after decoding the channel identifiers- Throws:
IOException
- If failed to handle the message
-
handleData
Invoked whenSSH_MSG_CHANNEL_DATA
received- Parameters:
buffer
- The rest of the message dataBuffer
after decoding the channel identifiers- Throws:
IOException
- If failed to handle the message
-
handleExtendedData
Invoked whenSSH_MSG_CHANNEL_EXTENDED_DATA
received- Parameters:
buffer
- The rest of the message dataBuffer
after decoding the channel identifiers- Throws:
IOException
- If failed to handle the message
-
handleEof
Invoked whenSSH_MSG_CHANNEL_EOF
received- Throws:
IOException
- If failed to handle the message
-
handleSuccess
Invoked whenSSH_MSG_CHANNEL_SUCCESS
received- Throws:
IOException
- If failed to handle the message
-
handleFailure
Invoked whenSSH_MSG_CHANNEL_FAILURE
received- Throws:
IOException
- If failed to handle the message
-
init
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 (UINT32 represented as along
)- Throws:
IOException
- If failed to process the initialization
-
handleChannelRegistrationResult
void handleChannelRegistrationResult(ConnectionService service, Session session, long id, boolean registered) Invoked after being successfully registered by the connection service - should throw aRuntimeException
if not registered- Parameters:
service
- TheConnectionService
through which the channel is registeredsession
- TheSession
associated with the channelid
- The locally assigned channel identifier (UINT32 represented as along
)registered
- Whether registration was successful or not
-
handleChannelUnregistration
Called by the connection service to inform the channel that it has bee unregistered.- Parameters:
service
- TheConnectionService
through which the channel is unregistered
-
isInitialized
boolean isInitialized()- Returns:
true
if call toinit(ConnectionService, Session, long)
was successfully completed
-
isEofSignalled
boolean isEofSignalled()- Returns:
true
if the peer signaled that it will not send any more data- See Also:
-
open
For a server channel, this method will actually open the channel- Parameters:
recipient
- Recipient identifier (UINT32 represented as along
)rwSize
- 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(long recipient, long rwSize, long packetSize, Buffer buffer) throws IOException For a client channel, this method will be called internally by the session when the confirmation has been received.- Parameters:
recipient
- Recipient identifier (UINT32 represented as along
)rwSize
- 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:
IOException
- If failed to handle the success
-
handleOpenFailure
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:
IOException
- If failed to handle the success
-
resolveAttribute
- Specified by:
resolveAttribute
in interfaceAttributeRepository
-
resolveAttribute
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:
-
writePacket
Encode and send the given buffer. Note: for session packets the buffer has to have 5 bytes free at the beginning to allow the encoding to take place. Also, the write position of the buffer has to be set to the position of the last byte to write.- Parameters:
buffer
- the buffer to encode and send. NOTE: the buffer must not be touched until the returned write future is completed.- Returns:
- An
IoWriteFuture
that can be used to check when the packet has actually been sent - Throws:
IOException
- if an error occurred when encoding or sending the packet
-