public interface Session extends Closeable
| Modifier 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.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(SessionListener listener)
Add a session |listener|.
|
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 occured on this session.
|
<T> T |
getAttribute(Session.AttributeKey<T> key)
Returns the value of the user-defined attribute of this session.
|
long |
getAuthTimeout() |
String |
getClientVersion()
Retrieve the client version for this session.
|
FactoryManager |
getFactoryManager() |
long |
getIdleTimeout() |
int |
getIntProperty(String name,
int defaultValue)
Retrieve a configuration property as an integer
|
IoSession |
getIoSession() |
KeyExchange |
getKex() |
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.
|
String |
getUsername()
Retrieve the name of the user authenticated on this session
or null if the session has not been authenticated yet.
|
boolean |
isAuthenticated() |
SshFuture |
reExchangeKeys()
Initiate a new key exchange.
|
void |
removeListener(SessionListener listener)
Remove a session |listener|.
|
Buffer |
request(Buffer buffer)
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 |
setUsername(String username) |
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.
|
<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 getUsername()
void setUsername(String username)
String getClientVersion()
String getServerVersion()
FactoryManager getFactoryManager()
FactoryManager that has created this session, can not be nullString getNegotiatedKexParameter(KexProposalOption paramType)
paramType - The request KexProposalOption value - ignored
if nullnull if invalid
parameter or no negotiated valueint getIntProperty(String name, int defaultValue)
name - the name of the propertydefaultValue - the default valueBuffer createBuffer(byte cmd)
cmd - the SSH commandBuffer createBuffer(byte cmd, int estimatedSize)
cmd - the SSH commandestimatedSize - estimated number of bytes the buffer will hold, 0 if unknown.IoWriteFuture 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) throws IOException
buffer - the buffer containing the global requestnull otherwise.IOException - if an error occurred when encoding sending the packetvoid exceptionCaught(Throwable t)
SshException.t - the exception to processvoid addListener(SessionListener listener)
listener - the session listener to addvoid removeListener(SessionListener listener)
listener - the session listener to removeSshFuture reExchangeKeys() throws IOException
SshFuture for awaiting the completion of the exchangeIOException - If failed to negotiate keys<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()
nulllong getAuthTimeout()
long getIdleTimeout()
boolean isAuthenticated()
void setAuthenticated()
throws IOException
IOExceptionbyte[] 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–2015 The Apache Software Foundation. All rights reserved.