public interface Session extends SessionContext, MutableUserHolder, KexFactoryManager, SessionListenerManager, ReservedSessionMessagesManager, SessionDisconnectHandlerManager, ChannelListenerManager, ChannelStreamWriterResolverManager, PortForwardingEventListenerManager, UnknownChannelReferenceHandlerManager, FactoryManagerHolder, PortForwardingInformationProvider
null
/empty if the
session is not yet authenticatedSessionHeartbeatController.HeartbeatType
AttributeRepository.AttributeKey<T>
DEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTH
EMPTY
NONE
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,
String msg)
Send a disconnect packet with the given reason and message.
|
void |
exceptionCaught(Throwable t)
Handle any exceptions that occurred on this session.
|
Duration |
getAuthTimeout() |
Instant |
getAuthTimeoutStart() |
Duration |
getIdleTimeout() |
Instant |
getIdleTimeoutStart() |
IoSession |
getIoSession() |
KeyExchange |
getKex() |
default SocketAddress |
getLocalAddress() |
default SocketAddress |
getRemoteAddress() |
<T extends Service> |
getService(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.
|
GlobalRequestFuture |
request(Buffer buffer,
String request,
GlobalRequestFuture.ReplyHandler replyHandler)
Send a global request and handle the reply asynchronously.
|
default Buffer |
request(String request,
Buffer buffer,
Duration timeout)
Send a global request and wait for the response, if the request is sent with
want-reply = true . |
Buffer |
request(String request,
Buffer buffer,
long maxWaitMillis)
Send a global request and wait for the response, if the request is sent with
want-reply = true . |
default Buffer |
request(String request,
Buffer buffer,
long timeout,
TimeUnit unit)
Send a global request and wait for the response, if the request is sent with
want-reply = true . |
Instant |
resetAuthTimeout()
Re-start the authentication timeout timer
|
Instant |
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,
Object msg,
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(String name,
Buffer buffer) |
IoWriteFuture |
writePacket(Buffer buffer)
Encode and send the given buffer.
|
default IoWriteFuture |
writePacket(Buffer buffer,
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,
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, isValidSessionPayloadSize, isValidVersionPrefix, validateSessionPayloadSize
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeat
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty, isEmpty
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
attributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePair
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
setUsername
getUsername
getCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNames
getSignatureFactories, resolveSignatureFactories, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNames
getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames
getKexExtensionHandler, setKexExtensionHandler
addSessionListener, getSessionListenerProxy, removeSessionListener
getReservedSessionMessagesHandler, setReservedSessionMessagesHandler
getSessionDisconnectHandler, setSessionDisconnectHandler
addChannelListener, getChannelListenerProxy, removeChannelListener
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolver
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListener
getUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandler
getFactoryManager
getBoundLocalPortForwards, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPort
default 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, Object msg, String lang) throws 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 sentIOException
- if an error occurred when encoding or sending the packetIoWriteFuture sendIgnoreMessage(byte... data) throws IOException
SSH_MSG_IGNORE
to the peer sessiondata
- The message dataIoWriteFuture
that can be used to check when the packet has actually been sentIOException
- if an error occurred when encoding or sending the packetIoWriteFuture writePacket(Buffer buffer) throws IOException
buffer
- the buffer to encode and sendIoWriteFuture
that can be used to check when the packet has actually been sentIOException
- if an error occurred when encoding sending the packetdefault IoWriteFuture writePacket(Buffer buffer, Duration timeout) throws 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 usedIOException
- if an error occurred when encoding or sending the packetwritePacket(Buffer, long)
default IoWriteFuture writePacket(Buffer buffer, long maxWaitMillis) throws IOException
IoWriteFuture
will be set with a
TimeoutException
exception to indicate a timeout.buffer
- the buffer to encode and spendmaxWaitMillis
- the timeout in millisecondsIOException
- if an error occurred when encoding or 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 or sending the packetdefault Buffer request(String request, Buffer buffer, long timeout, TimeUnit unit) throws IOException
want-reply = true
.request
- 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.IOException
- if an error occurred when encoding or sending the packetSocketTimeoutException
- If no response received within specified timeoutdefault Buffer request(String request, Buffer buffer, Duration timeout) throws IOException
want-reply = true
.request
- 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.IOException
- if an error occurred when encoding or sending the packetSocketTimeoutException
- If no response received within specified timeoutBuffer request(String request, Buffer buffer, long maxWaitMillis) throws IOException
want-reply = true
.request
- the request name - used mainly for logging and debuggingbuffer
- the buffer containing the global requestmaxWaitMillis
- maximum time in milliseconds to wait for the request to finish - must be
positivenull
otherwise.IOException
- if an error occurred when encoding or sending the packetSocketTimeoutException
- If no response received within specified timeoutGlobalRequestFuture request(Buffer buffer, String request, GlobalRequestFuture.ReplyHandler replyHandler) throws IOException
want-reply = true
, pass the received
Buffer
to the given GlobalRequestFuture.ReplyHandler
, which may execute in a different thread.
null
when the request was sent, or with an exception if the
request could not be sent. The replyHandler
is invoked once the reply is received, with the SSH reply
code and the data received.Buffer
when the request was sent, or with an exception
if the request could not be sent. If a reply handler is given, it is invoked with that empty buffer. The handler
is not invoked if sending the request failed.buffer
- the Buffer
containing the global request, with the want-reply
flag set as
appropriaterequest
- the request namereplyHandler
- GlobalRequestFuture.ReplyHandler
for handling the reply; may be null
IOException
- if an error occurred while encoding or sending the packetvoid exceptionCaught(Throwable t)
SshException
with a positive error codet
- 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 servicedefault SocketAddress getLocalAddress()
getLocalAddress
in interface ConnectionEndpointsIndicator
default SocketAddress getRemoteAddress()
getRemoteAddress
in interface ConnectionEndpointsIndicator
TimeoutIndicator getTimeoutStatus()
null
Duration getIdleTimeout()
Instant getIdleTimeoutStart()
Instant resetIdleTimeout()
getIdleTimeoutStart()
Duration getAuthTimeout()
Instant getAuthTimeoutStart()
Instant resetAuthTimeout()
getAuthTimeoutStart()
void setAuthenticated() throws IOException
IOException
KeyExchange getKex()
KeyExchange
in progress - null
if KEX not started or successfully completedvoid disconnect(int reason, String msg) throws IOException
reason
- the reason code for this disconnectmsg
- the text messageIOException
- if an error occurred sending the packetvoid startService(String name, Buffer buffer) throws Exception
name
- Service namebuffer
- Extra information provided when the service start request was receivedException
- If failed to start itdefault <T> T resolveAttribute(AttributeRepository.AttributeKey<T> key)
AttributeRepository
resolveAttribute
in interface AttributeRepository
T
- 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 null
key
- The attribute key - never null
null
if not foundFactoryManagerHolder.getFactoryManager()
,
FactoryManager.resolveAttribute(FactoryManager, AttributeRepository.AttributeKey)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.