public interface Session extends SessionContext, MutableUserHolder, KexFactoryManager, SessionListenerManager, ReservedSessionMessagesManager, SessionDisconnectHandlerManager, ChannelListenerManager, ChannelStreamPacketWriterResolverManager, PortForwardingEventListenerManager, UnknownChannelReferenceHandlerManager, FactoryManagerHolder, PortForwardingInformationProvider, PacketWriter
null/empty if the
session is not yet authenticatedSessionHeartbeatController.HeartbeatTypeAttributeRepository.AttributeKey<T>DEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTHDEFAULT_CONNECTION_HEARTBEAT_INTERVAL, SESSION_HEARTBEAT_INTERVAL, SESSION_HEARTBEAT_TYPEEMPTYCLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUTNONE| Modifier and Type | Method and Description |
|---|---|
default 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() |
long |
getAuthTimeoutStart() |
long |
getIdleTimeout() |
long |
getIdleTimeoutStart() |
IoSession |
getIoSession() |
KeyExchange |
getKex() |
default java.net.SocketAddress |
getLocalAddress() |
default java.net.SocketAddress |
getRemoteAddress() |
<T extends Service> |
getService(java.lang.Class<T> clazz)
Get the service of the specified type.
|
TimeoutIndicator |
getTimeoutStatus()
Check if timeout has occurred.
|
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.
|
default Buffer |
request(java.lang.String request,
Buffer buffer,
java.time.Duration timeout)
Send a global request and wait for the response.
|
Buffer |
request(java.lang.String request,
Buffer buffer,
long maxWaitMillis)
Send a global request and wait for the response.
|
default Buffer |
request(java.lang.String request,
Buffer buffer,
long timeout,
java.util.concurrent.TimeUnit unit)
Send a global request and wait for the response.
|
long |
resetAuthTimeout()
Re-start the authentication timeout timer
|
long |
resetIdleTimeout()
Re-start idle timeout timer
|
default <T> T |
resolveAttribute(AttributeRepository.AttributeKey<T> key)
Attempts to resolve the associated value by going up the store's hierarchy (if any)
|
static <T> T |
resolveAttribute(Session session,
AttributeRepository.AttributeKey<T> key)
Attempts to use the session's attribute, if not found then tries the factory manager
|
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,
Buffer buffer) |
default IoWriteFuture |
writePacket(Buffer buffer,
java.time.Duration timeout)
Encode and send the given buffer with the specified timeout.
|
default IoWriteFuture |
writePacket(Buffer buffer,
long maxWaitMillis)
Encode and send the given buffer with the specified timeout.
|
IoWriteFuture |
writePacket(Buffer buffer,
long timeout,
java.util.concurrent.TimeUnit unit)
Encode and send the given buffer with the specified timeout.
|
getCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionId, isAuthenticated, isDataIntegrityTransport, isSecureSessionTransport, isServerSession, isValidVersionPrefixdisableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeatgetBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringPropertyclearAttributes, computeAttributeIfAbsent, removeAttribute, setAttributeattributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePairaddCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListenersetUsernamegetUsernamegetCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNamesgetSignatureFactories, getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames, resolveSignatureFactories, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNamesgetKexExtensionHandler, setKexExtensionHandleraddSessionListener, getSessionListenerProxy, removeSessionListenergetReservedSessionMessagesHandler, setReservedSessionMessagesHandlergetSessionDisconnectHandler, setSessionDisconnectHandleraddChannelListener, getChannelListenerProxy, removeChannelListenergetChannelStreamPacketWriterResolver, resolveChannelStreamPacketWriter, resolveChannelStreamPacketWriterResolver, setChannelStreamPacketWriterResolveraddPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListenergetUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandlergetFactoryManagergetBoundLocalPortForward, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPortcalculatePadLength, writePacketdefault Buffer createBuffer(byte cmd)
cmd - the SSH commandcreateBuffer(byte, int)Buffer 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 packetdefault IoWriteFuture writePacket(Buffer buffer, java.time.Duration timeout) throws java.io.IOException
IoWriteFuture will be set with a
TimeoutException exception to indicate a timeout.buffer - the buffer to encode and spendtimeout - the (never null) timeout value - its milliseconds value
will be usedjava.io.IOException - if an error occurred when encoding sending the packetwritePacket(Buffer, long)default IoWriteFuture writePacket(Buffer buffer, long maxWaitMillis) throws java.io.IOException
IoWriteFuture will be set with a
TimeoutException exception to indicate a timeout.buffer - the buffer to encode and spendmaxWaitMillis - the timeout in millisecondsjava.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 packetdefault Buffer 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 packetjava.net.SocketTimeoutException - If no response received within specified timeoutdefault Buffer request(java.lang.String request, Buffer buffer, java.time.Duration timeout) 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 (never null) timeout to wait - its milliseconds value is usednull otherwise.java.io.IOException - if an error occurred when encoding sending the packetjava.net.SocketTimeoutException - If no response received within specified timeoutBuffer request(java.lang.String request, Buffer buffer, long maxWaitMillis) 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 requestmaxWaitMillis - Max. time to wait for response (millis) - must be positivenull otherwise.java.io.IOException - if an error occurred when encoding sending the packetjava.net.SocketTimeoutException - If no response received within specified timeoutvoid 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 servicedefault java.net.SocketAddress getLocalAddress()
getLocalAddress in interface ConnectionEndpointsIndicatordefault java.net.SocketAddress getRemoteAddress()
getRemoteAddress in interface ConnectionEndpointsIndicatorTimeoutIndicator getTimeoutStatus()
nulllong getIdleTimeout()
long getIdleTimeoutStart()
long resetIdleTimeout()
getIdleTimeoutStart()long getAuthTimeout()
long getAuthTimeoutStart()
long resetAuthTimeout()
getAuthTimeoutStart()void setAuthenticated()
throws java.io.IOException
java.io.IOExceptionKeyExchange 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,
Buffer buffer)
throws java.lang.Exception
name - Service namebuffer - Extra information provided when the service start request was receivedjava.lang.Exception - If failed to start itdefault <T> T resolveAttribute(AttributeRepository.AttributeKey<T> key)
AttributeRepositoryresolveAttribute in interface AttributeRepositoryT - The generic attribute typekey - The key of the attribute; must not be null.null if there is no value associated with the specified key either in this repository or any
of its ancestors (if any available)static <T> T resolveAttribute(Session session, AttributeRepository.AttributeKey<T> key)
T - The generic attribute typesession - The Session - ignored if nullkey - The attribute key - never nullnull if not foundFactoryManagerHolder.getFactoryManager(),
FactoryManager.resolveAttribute(FactoryManager, AttributeRepository.AttributeKey)