Package org.apache.sshd.client.channel
Interface ClientChannel
-
- All Superinterfaces:
AttributeRepository
,AttributeStore
,AutoCloseable
,Channel
,Channel
,ChannelIdentifier
,ChannelListenerManager
,ChannelStreamWriterResolver
,ChannelStreamWriterResolverManager
,ClientSessionHolder
,Closeable
,Closeable
,PropertyResolver
,SessionContextHolder
,SessionHolder<Session>
,StreamingChannel
- All Known Implementing Classes:
AbstractClientChannel
,AgentForwardedChannel
,AgentForwardedChannel
,ChannelDirectTcpip
,ChannelExec
,ChannelForwardedX11
,ChannelSession
,ChannelShell
,ChannelSubsystem
,PtyCapableChannelSession
,TcpipClientChannel
public interface ClientChannel extends Channel, StreamingChannel, ClientSessionHolder
A client channel used to communicate with the SSH server. Client channels can be shells, simple commands or subsystems. Note: client channels may be associated with a server session if they are opened by the server - e.g., for agent proxy, port forwarding, etc..- Author:
- Apache MINA SSHD Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T extends Object>
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.channel.StreamingChannel
StreamingChannel.Streaming
-
-
Field Summary
-
Fields inherited from interface org.apache.sshd.common.channel.Channel
CHANNEL_EXEC, CHANNEL_SHELL, CHANNEL_SUBSYSTEM
-
Fields inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolver
NONE
-
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 IoInputStream
getAsyncErr()
IoOutputStream
getAsyncIn()
IoInputStream
getAsyncOut()
Set<ClientChannelEvent>
getChannelState()
String
getChannelType()
default ClientSession
getClientSession()
String
getExitSignal()
Integer
getExitStatus()
InputStream
getInvertedErr()
OutputStream
getInvertedIn()
Access to an output stream to send data directly to the remote channel.InputStream
getInvertedOut()
OpenFuture
open()
void
setErr(OutputStream err)
void
setIn(InputStream in)
Set an input stream that will be read by this channel and forwarded to the remote channel.void
setOut(OutputStream out)
void
setRedirectErrorStream(boolean redirectErrorStream)
static void
validateCommandExitStatusCode(String command, Integer exitStatus)
Makes sure remote command exit status has been provided and it is zeroSet<ClientChannelEvent>
waitFor(Collection<ClientChannelEvent> mask, long timeout)
Waits until any of the specified events in the mask is signaleddefault Set<ClientChannelEvent>
waitFor(Collection<ClientChannelEvent> mask, Duration timeout)
Waits until any of the specified events in the mask is signaled-
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.Channel
addRequestHandler, addRequestHandlers, getLocalWindow, getRecipient, getRemoteWindow, getRequestHandlers, handleChannelRegistrationResult, handleChannelUnregistration, handleClose, handleData, handleEof, handleExtendedData, handleFailure, handleOpenFailure, handleOpenSuccess, handleRequest, handleSuccess, handleWindowAdjust, init, isEofSignalled, isInitialized, open, removeRequestHandler, removeRequestHandlers, resolveAttribute, writePacket
-
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
-
Methods inherited from interface org.apache.sshd.common.channel.StreamingChannel
getStreaming, setStreaming
-
-
-
-
Method Detail
-
getClientSession
default ClientSession getClientSession()
- Specified by:
getClientSession
in interfaceClientSessionHolder
- Returns:
- The underlying
ClientSession
used
-
getChannelType
String getChannelType()
- Returns:
- The type of channel reported when it was created
-
getAsyncIn
IoOutputStream getAsyncIn()
-
getAsyncOut
IoInputStream getAsyncOut()
-
getAsyncErr
IoInputStream getAsyncErr()
-
getInvertedIn
OutputStream getInvertedIn()
Access to an output stream to send data directly to the remote channel. This can be used instead of usingsetIn(java.io.InputStream)
method and having the channel polling for data in that stream.- Returns:
- an OutputStream to be used to send data
-
getInvertedOut
InputStream getInvertedOut()
-
getInvertedErr
InputStream getInvertedErr()
-
setIn
void setIn(InputStream in)
Set an input stream that will be read by this channel and forwarded to the remote channel. Note that using such a stream will create an additional thread for pumping the stream which will only be able to end when that stream is actually closed or some data is read. It is recommended to use thegetInvertedIn()
method instead and write data directly.- Parameters:
in
- an InputStream to be polled and forwarded
-
setOut
void setOut(OutputStream out)
-
setErr
void setErr(OutputStream err)
-
setRedirectErrorStream
void setRedirectErrorStream(boolean redirectErrorStream)
- Parameters:
redirectErrorStream
- Iftrue
then STDERR stream is set to be the same as STDOUT unlesssetErr(OutputStream)
was called. Note: the call must occur before channel is opened. Calling it afterwards has no effect - i.e., the last state before opening the stream determines the channel's behavior.
-
open
OpenFuture open() throws IOException
- Throws:
IOException
-
getChannelState
Set<ClientChannelEvent> getChannelState()
- Returns:
- A snapshot of the current channel state
- See Also:
waitFor(Collection, long)
-
waitFor
Set<ClientChannelEvent> waitFor(Collection<ClientChannelEvent> mask, long timeout)
Waits until any of the specified events in the mask is signaled- Parameters:
mask
- TheClientChannelEvent
s masktimeout
- The timeout to wait (msec.) - if non-positive then forever- Returns:
- The actual signaled event - includes
ClientChannelEvent.TIMEOUT
if timeout expired before the expected event was signaled
-
waitFor
default Set<ClientChannelEvent> waitFor(Collection<ClientChannelEvent> mask, Duration timeout)
Waits until any of the specified events in the mask is signaled- Parameters:
mask
- TheClientChannelEvent
s masktimeout
- The timeout to wait - if null then forever- Returns:
- The actual signaled event - includes
ClientChannelEvent.TIMEOUT
if timeout expired before the expected event was signaled
-
getExitStatus
Integer getExitStatus()
- Returns:
- The signaled exit status via "exit-status" request -
null
if not signaled
-
getExitSignal
String getExitSignal()
- Returns:
- The signaled exit signal via "exit-signal" -
null
if not signaled
-
validateCommandExitStatusCode
static void validateCommandExitStatusCode(String command, Integer exitStatus) throws RemoteException
Makes sure remote command exit status has been provided and it is zero- Parameters:
command
- The command string - used only for exception textexitStatus
- The exit status value- Throws:
RemoteException
- If exitStatus isnull
or non-zero
-
-