public interface Session extends KexFactoryManager, SessionListenerManager, ChannelListenerManager, PropertyResolver, Closeable, MutableUserHolder
null
/empty if the session is not yet authenticatedModifier and Type | Interface and Description |
---|---|
static class |
Session.AttributeKey<T>
Type safe key for storage within the user attributes of
AbstractSession . |
static class |
Session.TimeoutStatus
Timeout status.
|
SignatureFactoriesManager.Utils
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_SSH_VERSION_PREFIX
Default prefix expected for the client / server identification string
|
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,
String msg)
Send a disconnect packet with the given reason and message.
|
void |
exceptionCaught(Throwable t)
Handle any exceptions that occurred on this session.
|
<T> T |
getAttribute(Session.AttributeKey<T> key)
Returns the value of the user-defined attribute of this session.
|
long |
getAuthTimeout() |
CipherInformation |
getCipherInformation(boolean incoming)
Retrieves current cipher information - Note: may change if
key re-exchange executed
|
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
|
FactoryManager |
getFactoryManager() |
long |
getIdleTimeout() |
IoSession |
getIoSession() |
KeyExchange |
getKex() |
MacInformation |
getMacInformation(boolean incoming)
Retrieves current MAC information - Note: may change if
key re-exchange executed
|
String |
getNegotiatedKexParameter(KexProposalOption paramType)
Retrieve one of the negotiated values during the KEX stage
|
String |
getServerVersion()
Retrieve the server version for this session.
|
<T extends Service> |
getService(Class<T> clazz)
Get the service of the specified type.
|
byte[] |
getSessionId() |
Session.TimeoutStatus |
getTimeoutStatus()
Check if timeout has occurred.
|
boolean |
isAuthenticated() |
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(Buffer buffer,
long timeout,
TimeUnit unit)
Send a global request and wait for the response.
|
void |
resetIdleTimeout() |
<T,E extends T> |
setAttribute(Session.AttributeKey<T> key,
E value)
Sets a user-defined attribute.
|
void |
setAuthenticated() |
void |
startService(String name) |
IoWriteFuture |
writePacket(Buffer buffer)
Encode and send the given buffer.
|
IoWriteFuture |
writePacket(Buffer buffer,
long timeout,
TimeUnit unit)
Encode and send the given buffer with the specified timeout.
|
getCipherFactories, getCompressionFactories, getKeyExchangeFactories, getMacFactories, setCipherFactories, setCompressionFactories, setKeyExchangeFactories, setMacFactories
getKeyPairProvider, setKeyPairProvider
getSignatureFactories, setSignatureFactories
addSessionListener, getSessionListenerProxy, removeSessionListener
addChannelListener, getChannelListenerProxy, removeChannelListener
getParentPropertyResolver, getProperties
setUsername
getUsername
static final String DEFAULT_SSH_VERSION_PREFIX
<T> T getAttribute(Session.AttributeKey<T> key)
T
- The generic attribute typekey
- The key of the attribute; must not be null
.<T,E extends T> T setAttribute(Session.AttributeKey<T> key, E value)
T
- The generic attribute typeE
- The generic value typekey
- The key of the attribute; must not be null
.value
- The value of the attribute; must not be null
.null
if it is new.String getClientVersion()
String getServerVersion()
FactoryManager getFactoryManager()
FactoryManager
that has created this session, can not be null
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 writePacket(Buffer buffer) throws IOException
buffer
- the buffer to encode and sendIOException
- if an error occurred when encoding sending the packetIoWriteFuture writePacket(Buffer buffer, long timeout, TimeUnit unit) throws 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 parameterIOException
- if an error occurred when encoding sending the packetBuffer request(Buffer buffer, long timeout, TimeUnit unit) throws IOException
SSH_MSG_GLOBAL_REQUEST
with a result expected, else it will time outbuffer
- the buffer containing the global requesttimeout
- The number of time units to wait - must be positiveunit
- The TimeUnit
to wait for the responsenull
otherwise.IOException
- if an error occurred when encoding sending the packetvoid exceptionCaught(Throwable t)
SshException
.t
- the exception to processKeyExchangeFuture reExchangeKeys() throws IOException
KeyExchangeFuture
for awaiting the completion of the exchangeIOException
- If failed to request keys re-negotiation<T extends Service> T getService(Class<T> clazz)
T
- The generic Service
typeclazz
- The service classIllegalStateException
- If failed to find a matching servicevoid resetIdleTimeout()
Session.TimeoutStatus getTimeoutStatus()
null
long getAuthTimeout()
long getIdleTimeout()
boolean isAuthenticated()
void setAuthenticated() throws IOException
IOException
byte[] getSessionId()
KeyExchange getKex()
void disconnect(int reason, String msg) throws IOException
reason
- the reason code for this disconnectmsg
- the text messageIOException
- if an error occurred sending the packetCopyright © 2008–2016 The Apache Software Foundation. All rights reserved.