public class

ConnectionImpl

extends AbstractService
implements Connection
java.lang.Object
   ↳ net.schmizz.sshj.AbstractService
     ↳ net.schmizz.sshj.connection.ConnectionImpl

Class Overview

Connection implementation.

Summary

Fields
private final Map<Integer, Channel> channels
private final Queue<Promise<SSHPacketConnectionException>> globalReqPromises
private final Object internalSynchronizer
private int maxPacketSize
private final AtomicInteger nextID
private final Map<String, ForwardedChannelOpener> openers
private long windowSize
[Expand]
Inherited Fields
From class net.schmizz.sshj.AbstractService
Public Constructors
ConnectionImpl(Transport trans)
Create with an associated Transport.
Public Methods
void attach(Channel chan)
Attach a Channel to this connection.
void attach(ForwardedChannelOpener opener)
Attach a ForwardedChannelOpener to this connection, which will be delegated opening of any CHANNEL_OPEN packets for which it is responsible.
void forget(ForwardedChannelOpener opener)
Forget an attached ForwardedChannelOpener.
void forget(Channel chan)
Forget an attached Channel.
Channel get(int id)
ForwardedChannelOpener get(String chanType)
int getMaxPacketSize()
Transport getTransport()
long getWindowSize()
void handle(Message msg, SSHPacket buf)
Delegate handling of some SSH packet to this object.
void join()
Wait for the situation that no channels are attached (e.g., got closed).
int nextID()
void notifyError(SSHException error)
Notifies this object of an error.
Promise<SSHPacketConnectionException> sendGlobalRequest(String name, boolean wantReply, byte[] specifics)
Send an SSH global request.
void sendOpenFailure(int recipient, OpenFailException.Reason reason, String message)
Send a SSH_MSG_OPEN_FAILURE for specified Reason and message.
void setMaxPacketSize(int maxPacketSize)
Set the maximum packet size for the local window this connection recommends to any Channel's that ask for it.
void setWindowSize(long windowSize)
Set the size for the local window this connection recommends to any Channel's that ask for it.
[Expand]
Inherited Methods
From class net.schmizz.sshj.AbstractService
From class java.lang.Object
From interface net.schmizz.sshj.Service
From interface net.schmizz.sshj.common.ErrorNotifiable
From interface net.schmizz.sshj.common.SSHPacketHandler
From interface net.schmizz.sshj.connection.Connection

Fields

private final Map<Integer, Channel> channels

private final Queue<Promise<SSHPacketConnectionException>> globalReqPromises

private final Object internalSynchronizer

private int maxPacketSize

private final AtomicInteger nextID

private final Map<String, ForwardedChannelOpener> openers

private long windowSize

Public Constructors

public ConnectionImpl (Transport trans)

Create with an associated Transport.

Parameters
trans Transport layer

Public Methods

public void attach (Channel chan)

Attach a Channel to this connection. A channel must be attached to the connection if it is to receive any channel-specific data that is received.

Parameters
chan The channel

public void attach (ForwardedChannelOpener opener)

Attach a ForwardedChannelOpener to this connection, which will be delegated opening of any CHANNEL_OPEN packets for which it is responsible.

Parameters
opener An opener for forwarded channels

public void forget (ForwardedChannelOpener opener)

Forget an attached ForwardedChannelOpener.

Parameters
opener The opener to forget

public void forget (Channel chan)

Forget an attached Channel.

Parameters
chan The channel

public Channel get (int id)

Parameters
id

public ForwardedChannelOpener get (String chanType)

Parameters
chanType

public int getMaxPacketSize ()

public Transport getTransport ()

public long getWindowSize ()

public void handle (Message msg, SSHPacket buf)

Delegate handling of some SSH packet to this object.

Parameters
msg The SSH message identifier
buf SSHPacket containing rest of the request
Throws
SSHException

public void join ()

Wait for the situation that no channels are attached (e.g., got closed).

Throws
InterruptedException

public int nextID ()

public void notifyError (SSHException error)

Notifies this object of an error.

Parameters
error

public Promise<SSHPacketConnectionException> sendGlobalRequest (String name, boolean wantReply, byte[] specifics)

Send an SSH global request.

Parameters
name Request name
wantReply Whether a reply is requested
specifics SSHPacket containing fields specific to the request
Returns
  • a Promise for the reply data (in case wantReply is true) which allows waiting on the reply, or null if a reply is not requested.

public void sendOpenFailure (int recipient, OpenFailException.Reason reason, String message)

Send a SSH_MSG_OPEN_FAILURE for specified Reason and message.

Parameters
recipient Number of the recipient channel
reason A reason for the failure
message An explanatory message

public void setMaxPacketSize (int maxPacketSize)

Set the maximum packet size for the local window this connection recommends to any Channel's that ask for it.

Parameters
maxPacketSize Maximum packet size in bytes

public void setWindowSize (long windowSize)

Set the size for the local window this connection recommends to any Channel's that ask for it.

Parameters
windowSize Window size in bytes