public interface Session extends KexFactoryManager, SessionListenerManager, ReservedSessionMessagesManager, ChannelListenerManager, ChannelStreamPacketWriterResolverManager, PortForwardingEventListenerManager, UnknownChannelReferenceHandlerManager, FactoryManagerHolder, PropertyResolver, AttributeStore, Closeable, MutableUserHolder, PacketWriter
null
/empty if the session is not yet authenticatedModifier and Type | Interface and Description |
---|---|
static class |
Session.TimeoutStatus
Timeout status.
|
AttributeStore.AttributeKey<T>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_SSH_VERSION_PREFIX
Default prefix expected for the client / server identification string
|
static java.lang.String |
FALLBACK_SSH_VERSION_PREFIX
Backward compatible special prefix
|
static int |
MAX_VERSION_LINE_LENGTH
Maximum number of characters for any single line sent as part
of the initial handshake - according to
RFC 4253 - section 4.2:
|
NONE
EMPTY
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
Modifier and Type | Method and Description |
---|---|
Buffer |
createBuffer(byte cmd)
Create a new buffer for the specified SSH packet and reserve the needed space
(5 bytes) for the packet header.
|
Buffer |
createBuffer(byte cmd,
int estimatedSize)
Create a new buffer for the specified SSH packet and reserve the needed space
(5 bytes) for the packet header.
|
void |
disconnect(int reason,
java.lang.String msg)
Send a disconnect packet with the given reason and message.
|
void |
exceptionCaught(java.lang.Throwable t)
Handle any exceptions that occurred on this session.
|
long |
getAuthTimeout() |
CipherInformation |
getCipherInformation(boolean incoming)
Retrieves current cipher information - Note: may change if
key re-exchange executed
|
java.lang.String |
getClientVersion()
Retrieve the client version for this session.
|
CompressionInformation |
getCompressionInformation(boolean incoming)
Retrieves current compression information - Note: may change if
key re-exchange executed
|
long |
getIdleTimeout() |
IoSession |
getIoSession() |
KeyExchange |
getKex() |
MacInformation |
getMacInformation(boolean incoming)
Retrieves current MAC information - Note: may change if
key re-exchange executed
|
java.lang.String |
getNegotiatedKexParameter(KexProposalOption paramType)
Retrieve one of the negotiated values during the KEX stage
|
java.lang.String |
getServerVersion()
Retrieve the server version for this session.
|
<T extends Service> |
getService(java.lang.Class<T> clazz)
Get the service of the specified type.
|
byte[] |
getSessionId() |
Session.TimeoutStatus |
getTimeoutStatus()
Check if timeout has occurred.
|
boolean |
isAuthenticated() |
static boolean |
isValidVersionPrefix(java.lang.String version) |
Buffer |
prepareBuffer(byte cmd,
Buffer buffer)
Prepare a new "clean" buffer while reserving the needed space
(5 bytes) for the packet header.
|
KeyExchangeFuture |
reExchangeKeys()
Initiate a new key exchange.
|
Buffer |
request(java.lang.String request,
Buffer buffer,
long timeout,
java.util.concurrent.TimeUnit unit)
Send a global request and wait for the response.
|
void |
resetIdleTimeout()
Re-start idle timeout timer
|
IoWriteFuture |
sendDebugMessage(boolean display,
java.lang.Object msg,
java.lang.String lang)
Sends an
SSH_MSG_DEBUG to the peer session |
IoWriteFuture |
sendIgnoreMessage(byte... data)
Sends an
SSH_MSG_IGNORE to the peer session |
void |
setAuthenticated() |
void |
startService(java.lang.String name) |
IoWriteFuture |
writePacket(Buffer buffer,
long timeout,
java.util.concurrent.TimeUnit unit)
Encode and send the given buffer with the specified timeout.
|
getCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNames
getKeyPairProvider, setKeyPairProvider
getSignatureFactories, getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames, resolveSignatureFactories, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNames
addSessionListener, getSessionListenerProxy, removeSessionListener
getReservedSessionMessagesHandler, setReservedSessionMessagesHandler
addChannelListener, getChannelListenerProxy, removeChannelListener
getChannelStreamPacketWriterResolver, resolveChannelStreamPacketWriter, resolveChannelStreamPacketWriterResolver, setChannelStreamPacketWriterResolver
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListener
getUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandler
getFactoryManager
getBoolean, getBooleanProperty, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty
getAttribute, removeAttribute, resolveAttribute, resolveAttribute, resolveAttribute, resolveAttribute, setAttribute
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
setUsername
getUsername
writePacket
static final java.lang.String DEFAULT_SSH_VERSION_PREFIX
static final java.lang.String FALLBACK_SSH_VERSION_PREFIX
static final int MAX_VERSION_LINE_LENGTH
The maximum length of the string is 255 characters,
including the Carriage Return and Line Feed.
java.lang.String getClientVersion()
java.lang.String getServerVersion()
java.lang.String getNegotiatedKexParameter(KexProposalOption paramType)
paramType
- The request KexProposalOption
value - ignored
if null
null
if invalid
parameter or no negotiated valueCipherInformation getCipherInformation(boolean incoming)
incoming
- If true
then the cipher for the incoming data,
otherwise for the outgoing dataCipherInformation
- or null
if not negotiated yet.CompressionInformation getCompressionInformation(boolean incoming)
incoming
- If true
then the compression for the incoming data,
otherwise for the outgoing dataCompressionInformation
- or null
if not negotiated yet.MacInformation getMacInformation(boolean incoming)
incoming
- If true
then the MAC for the incoming data,
otherwise for the outgoing dataMacInformation
- or null
if not negotiated yet.Buffer createBuffer(byte cmd)
cmd
- the SSH commandBuffer createBuffer(byte cmd, int estimatedSize)
cmd
- The SSH command to initialize the buffer withestimatedSize
- Estimated number of bytes the buffer will hold, 0 if unknown.prepareBuffer(byte, Buffer)
Buffer prepareBuffer(byte cmd, Buffer buffer)
cmd
- The SSH command to initialize the buffer withbuffer
- The Buffer
instance to initializeIoWriteFuture sendDebugMessage(boolean display, java.lang.Object msg, java.lang.String lang) throws java.io.IOException
SSH_MSG_DEBUG
to the peer sessiondisplay
- true
if OK to display the message at the peer as-ismsg
- The message object whose toString()
value to be used - if
null
then the "null" string is sentlang
- The language - null
/empty if some pre-agreed default is usedIoWriteFuture
that can be used to check when the packet has actually been sentjava.io.IOException
- if an error occurred when encoding sending the packetIoWriteFuture sendIgnoreMessage(byte... data) throws java.io.IOException
SSH_MSG_IGNORE
to the peer sessiondata
- The message dataIoWriteFuture
that can be used to check when the packet has actually been sentjava.io.IOException
- if an error occurred when encoding sending the packetIoWriteFuture writePacket(Buffer buffer, long timeout, java.util.concurrent.TimeUnit unit) throws java.io.IOException
IoWriteFuture
will be set with a
TimeoutException
exception to indicate a timeout.buffer
- the buffer to encode and spendtimeout
- the timeoutunit
- the time unit of the timeout parameterjava.io.IOException
- if an error occurred when encoding sending the packetBuffer request(java.lang.String request, Buffer buffer, long timeout, java.util.concurrent.TimeUnit unit) throws java.io.IOException
SSH_MSG_GLOBAL_REQUEST
with a result expected, else it will time outrequest
- the request name - used mainly for logging and debuggingbuffer
- the buffer containing the global requesttimeout
- The number of time units to wait - must be positiveunit
- The TimeUnit
to wait for the responsenull
otherwise.java.io.IOException
- if an error occurred when encoding sending the packetvoid exceptionCaught(java.lang.Throwable t)
SshException
with a positive error codet
- the exception to processKeyExchangeFuture reExchangeKeys() throws java.io.IOException
KeyExchangeFuture
for awaiting the completion of the exchangejava.io.IOException
- If failed to request keys re-negotiation<T extends Service> T getService(java.lang.Class<T> clazz)
T
- The generic Service
typeclazz
- The service classjava.lang.IllegalStateException
- If failed to find a matching servicevoid resetIdleTimeout()
Session.TimeoutStatus getTimeoutStatus()
null
long getAuthTimeout()
long getIdleTimeout()
boolean isAuthenticated()
void setAuthenticated() throws java.io.IOException
java.io.IOException
byte[] getSessionId()
null
if
not yet establishedKeyExchange getKex()
void disconnect(int reason, java.lang.String msg) throws java.io.IOException
reason
- the reason code for this disconnectmsg
- the text messagejava.io.IOException
- if an error occurred sending the packetvoid startService(java.lang.String name) throws java.lang.Exception
name
- Service namejava.lang.Exception
- If failed to start itstatic boolean isValidVersionPrefix(java.lang.String version)
version
- The reported client/server versiontrue
if version not empty and starts with either
"SSH-2.0-" or "SSH-1.99-"