handleMessage(Buffer)
method, which is dependent on the state and side of this session.
Todo
if there is any very big packet, decoderBuffer and uncompressBuffer will get quite big and they won't be resized down at any time. Though the packet size is really limited by the channel max packet size
| Modifier and Type | Class and Description |
|---|---|
| private static enum | |
| protected static class | AbstractSession.
Message encoding or decoding settings as determined at the end of a key exchange. |
| Modifier and Type | Field and Description |
|---|---|
| protected final ChannelListener | |
| protected final Collection | channelListeners
Channel events listener container |
| private byte[] | |
| protected final Map | |
| protected String | |
| protected final CurrentService | |
| protected final Object | |
| protected final SessionWorkBuffer | |
| protected int | |
| protected int | |
| protected SshException | |
| protected final Object | |
| protected Boolean | |
| private final Map | |
| protected int | |
| protected final AtomicLong | |
| protected long | |
| protected int | |
| protected final AtomicLong | |
| protected final AtomicLong | |
| protected Cipher | |
| protected int | |
| protected Compression | |
| protected boolean | |
| protected long | |
| protected Mac | |
| protected byte[] | |
| protected int | |
| protected final AtomicLong | |
| protected AbstractSession. | inSettings
Resulting message coding settings at the end of a key exchange for incoming messages. |
| protected KeyExchange | |
| protected final AtomicReference | |
| protected final KeyExchangeMessageHandler | kexHandler
The |
| protected DefaultKeyExchangeFuture | |
| protected final AtomicReference | kexState
Holds the current key exchange state. |
| protected final AtomicReference | |
| protected final AtomicLong | |
| protected long | |
| protected Duration | |
| protected long | |
| protected final Map | |
| protected final AtomicLong | |
| protected final AtomicLong | |
| protected Cipher | |
| protected int | |
| protected Compression | |
| protected Mac | |
| protected int | |
| protected final AtomicLong | |
| protected AbstractSession. | outSettings
Resulting message coding settings at the end of a key exchange for outgoing messages. |
| private final Deque | pendingGlobalRequests
Used to wait for results of global requests sent with |
| protected final Random | random
The pseudo random generator |
| protected final Object | |
| protected long | seqi
Input packet sequence number. |
| protected long | seqo
Output packet sequence number. |
| private byte[] | |
| protected final Map | |
| protected String | |
| public static final String | SESSION
Name of the property where this session is stored in the attributes of the underlying MINA session. |
| protected byte[] | |
| protected final SessionListener | |
| protected final Collection | sessionListeners
Session listeners container |
| protected boolean | strictKex
"Strict KEX" is a mitigation for the "Terrapin attack". |
| protected final PortForwardingEventListener | |
| protected final Collection | tunnelListeners
Port forwarding events listener container |
| protected SessionWorkBuffer | |
| protected final Map | |
| protected final Map | |
| protected final Map |
| Access | Constructor and Description |
|---|---|
| protected | AbstractSession(boolean
true if this is a server session, false if client onethe factory manager factoryManager, IoSession the underlying I/O session ioSession)Create a new session. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addChannelListener(ChannelListener
The listener)ChannelListener to add - not nullImplements org. Add a channel listener |
| public void | addPortForwardingEventListener(PortForwardingEventListener
The listener)PortForwardingEventListener to add - never nullImplements org. Add a port forwarding listener |
| public void | addSessionListener(SessionListener
The listener)SessionListener to add - not nullImplements org. Add a session listener. |
| protected void | |
| protected void | |
| public static void | attachSession(IoSession
The ioSession, AbstractSession IoSessionThe SSH session to attach session)Attach an SSH |
| public static int | Returns: The required padding lengthThe packet payload size len, int The cipher block size blockSize, boolean Whether using "encrypt-then-MAC" mode etmMode)
|
| protected abstract void | checkKeys()
Indicates the the key exchange is completed and the exchanged keys can now be verified - e.g., client can verify the server's key |
| protected KeyExchangeFuture | Returns: AKeyExchangeFuture to wait for the initiated exchange or null if no need to
re-key or an exchange is already in progressChecks if a re-keying is required and if so initiates it |
| protected Map. | Returns: null if option is equal, otherwise a key/value pair where key=client option value and
value=the server-side oneThe option to check option)Compares the specified |
| public Buffer | createBuffer(byte
The SSH command to initialize the buffer with cmd, int Estimated number of bytes the buffer will hold, 0 if unknown. len)Implements org. Create a new buffer for the specified SSH packet and reserve the needed space (5 bytes) for the packet header. |
| protected void | |
| protected long | Returns: the number of block after which re-keying occur at the latestblock size of the input cipher inCipherBlockSize, int block size of the output cipher outCipherBlockSize)Compute the number of blocks after which we should re-key again. |
| protected void | |
| protected boolean | doInvokeUnimplementedMessageHandler(int
The unimplemented command cmd, Buffer The input buffer)BufferOverrides org.
|
| protected void | |
| protected Map | |
| protected IoWriteFuture | |
| protected Buffer | Returns: The encoded buffer - may be different than original if input buffer does not have enough room forSshConstants#SSH_PACKET_HEADER_LEN, in which case a substitute buffer will be
created and used.the buffer to encode buffer)Encode a buffer into the SSH protocol Note This method must be called inside a |
| protected void | |
| protected void | |
| public ChannelListener | |
| public CipherInformation | getCipherInformation(boolean
If incoming)true then the cipher for the incoming data, otherwise for the outgoing dataImplements org. Retrieves current cipher information - Note: may change if key re-exchange executed |
| protected byte[] | |
| public Map | |
| public String | getClientVersion()
Implements org. Retrieve the client version for this session. |
| public CompressionInformation | getCompressionInformation(boolean
If incoming)true then the compression for the incoming data, otherwise for the outgoing dataImplements org. Retrieves current compression information - Note: may change if key re-exchange executed |
| protected Closeable | |
| public KeyExchange | |
| public Map | |
| public KexState | |
| public MacInformation | getMacInformation(boolean
If incoming)true then the MAC for the incoming data, otherwise for the outgoing dataImplements org. Retrieves current MAC information - Note: may change if key re-exchange executed |
| public String | getNegotiatedKexParameter(KexProposalOption
The request paramType)KexProposalOption value - ignored if nullImplements org. Retrieve one of the negotiated values during the KEX stage |
| public PortForwardingEventListener | |
| protected byte[] | |
| public Map | |
| public String | getServerVersion()
Implements org. Retrieve the server version for this session. |
| public <T extends Service> T | getService(Class<T>
The service class clazz)Implements org. Get the service of the specified type. |
| protected List | |
| public static AbstractSession | Returns: The SSH session attached to the I/O sessionThe ioSession)IoSessionRetrieve the SSH session from the I/O session. |
| public static AbstractSession | Returns: the session attached to the I/O session ornullThe ioSession, boolean IoSessionIf allowNull)true, a null value may be returned if no session
is attachedRetrieve the session SSH from the I/O session. |
| public byte[] | |
| public SessionListener | |
| protected boolean | |
| protected void | |
| protected void | |
| protected void | |
| protected void | handleMessage(Buffer
The buffer)Buffer containing the packet - it may be re-used to generate the response once
request has been decodedAbstract method for processing incoming decoded packets. |
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| protected boolean | |
| protected CurrentService | Returns: a newCurrentService instance for the sessionCreates a new |
| protected KeyExchangeMessageHandler | Returns: a newKeyExchangeMessageHandler instance for the sessionCreates a new |
| protected boolean | |
| protected boolean | |
| protected boolean | |
| protected boolean | |
| protected boolean | |
| public void | |
| protected Map | |
| protected IoWriteFuture | Returns: AnIoWriteFuture that can be used to wait for packet write completion - null if
the registered ReservedSessionMessagesHandler decided to handle the command internallyThe un-implemented command value cmd, Buffer The buffer)Buffer that contains the commandNote the buffer's read position is just beyond the command. Send a |
| protected void | |
| protected void | preClose()
Overrides org. preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately. |
| public Buffer | prepareBuffer(byte
The SSH command to initialize the buffer with cmd, Buffer The buffer)Buffer instance to initializeImplements org. Prepare a new "clean" buffer while reserving the needed space (5 bytes) for the packet header. |
| protected void | prepareNewKeys()
Prepares the new ciphers, macs and compression algorithms according to the negotiated server and client proposals
and stores them in |
| protected Buffer | preProcessEncodeBuffer(int
The command stored in the buffer cmd, Buffer The original buffer)Buffer - assumed to be properly formatted and be of at least the
required minimum length.Overrides org. Invoked by the session before encoding the buffer in order to make sure that it is at least of size
|
| protected abstract boolean | Returns: true if the identification has been fully read or false if more data
is neededThe buffer)Buffer containing the remote identificationRead the other side identification. |
| protected byte[] | Returns: the packet datathe buffer, Map<KexProposalOption, String> Buffer containing the key exchange init packetthe remote proposal to fill proposal)Receive the remote key exchange init message. |
| protected byte[] | |
| protected abstract void | |
| public KeyExchangeFuture | reExchangeKeys()
Implements org. Initiate a new key exchange. |
| protected void | |
| public void | removeChannelListener(ChannelListener
The listener)ChannelListener to removeImplements org. Remove a channel listener |
| public void | removePortForwardingEventListener(PortForwardingEventListener
The listener)PortForwardingEventListener to remove - ignored if nullImplements org. Remove a port forwarding listener |
| public void | removeSessionListener(SessionListener
The listener)SessionListener to removeImplements org. Remove a session listener. |
| protected boolean | Returns: true if the option contained the value (and it was removed); false otherwiseMap holding the Kex proposalKexProposalOption to modifyvalue to remove toRemove)Given a KEX proposal and a |
| public Buffer | request(String
the request name - used mainly for logging and debugging request, Buffer the buffer containing the global request buffer, long maximum time in milliseconds to wait for the request to finish - must be
positive maxWaitMillis)Implements org. Send a global request and wait for the response, if the request is sent with |
| public GlobalRequestFuture | request(Buffer
the buffer, String Buffer containing the global request, with the want-reply flag set as
appropriatethe request name request, GlobalRequestFuture.ReplyHandler for handling the reply; may be nullImplements org. Send a global request and handle the reply asynchronously. |
| protected void | requestFailure(Buffer
The buffer)Buffer containing the message dataIndicates the reception of a |
| protected KeyExchangeFuture | Returns: AKeyExchangeFuture to wait for the initiated exchange or null if an exchange
is already in progressInitiates a new keys exchange if one not already in progress |
| protected void | requestSuccess(Buffer
The buffer)Buffer containing the message dataIndicates the reception of a |
| protected int | |
| protected Buffer | |
| protected String | |
| protected byte[] | Returns: the sent packet data which must be kept for later use when deriving the session keysour proposal for key exchange negotiation proposal)Send the key exchange initialization packet. |
| protected byte[] | |
| protected IoWriteFuture | Returns: AnIoWriteFuture that can be used to wait and check the result of sending the packetSend a message to put new keys into use. |
| protected void | |
| protected void | setInputEncoding()
Installs the current prepared |
| protected abstract void | setKexSeed(byte...
The result of the KEXINIT handshake - required for correct session key establishment seed)
|
| protected Map | |
| protected void | setOutputEncoding()
Installs the current prepared |
| protected void | |
| protected void | |
| protected void | |
| protected boolean | |
| protected < The B extends Buffer> BBuffer type being validated | Returns: The validated target instance - default same as inputThe most likely command this buffer refers to (not guaranteed to be correct) cmd, B The buffer to be examined buffer)Makes sure that the buffer used for output is not |
| private boolean | |
| public IoWriteFuture | writePacket(Buffer
the buffer to encode and send buffer)Implements org. Encode and send the given buffer. |
| public IoWriteFuture | writePacket(Buffer
the buffer to encode and spend buffer, long the timeout timeout, TimeUnit the time unit of the timeout parameter unit)Implements org. Encode and send the given buffer with the specified timeout. |