Class AbstractSession
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.common.util.closeable.IoBaseCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.util.closeable.AbstractInnerCloseable
org.apache.sshd.common.kex.AbstractKexFactoryManager
org.apache.sshd.common.session.helpers.SessionHelper
org.apache.sshd.common.session.helpers.AbstractSession
- All Implemented Interfaces:
Closeable, AutoCloseable, Channel, org.apache.sshd.common.AttributeRepository, org.apache.sshd.common.AttributeStore, org.apache.sshd.common.auth.MutableUserHolder, org.apache.sshd.common.auth.UsernameHolder, ChannelListenerManager, ChannelStreamWriterResolver, ChannelStreamWriterResolverManager, org.apache.sshd.common.Closeable, FactoryManagerHolder, PortForwardingEventListenerManager, PortForwardingInformationProvider, KexExtensionHandlerManager, KexFactoryManager, org.apache.sshd.common.PropertyResolver, ReservedSessionMessagesManager, Session, org.apache.sshd.common.session.SessionContext, SessionDisconnectHandlerManager, org.apache.sshd.common.session.SessionHeartbeatController, SessionListenerManager, UnknownChannelReferenceHandlerManager, org.apache.sshd.common.signature.SignatureFactoriesHolder, org.apache.sshd.common.signature.SignatureFactoriesManager, org.apache.sshd.common.util.net.ConnectionEndpointsIndicator
- Direct Known Subclasses:
AbstractClientSession, AbstractServerSession
Encapsulates common behavior for both client and server sessions. In particular, holds the
FilterChain
implementing the SSH transport protocol, and provides convenience methods to write SSH packets or make Channel global
requests.- Author:
- Apache MINA SSHD Project
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable.StateNested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
org.apache.sshd.common.AttributeRepository.AttributeKey<T>Nested classes/interfaces inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
org.apache.sshd.common.session.SessionHeartbeatController.HeartbeatType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ChannelListenerprotected final Collection<ChannelListener> Channel events listener containerprotected Stringprotected final CurrentServiceprotected final org.apache.sshd.common.random.RandomThe pseudo random generatorprotected Stringstatic final StringName of the property where this session is stored in the attributes of the underlying MINA session.protected final SessionListenerprotected final Collection<SessionListener> Session listeners containerprotected final PortForwardingEventListenerprotected final Collection<PortForwardingEventListener> Port forwarding events listener containerFields inherited from class SessionHelper
authStart, idleStart, initialKexProposalFields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, stateFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
logFields inherited from interface ChannelStreamWriterResolver
NONEFields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTYFields inherited from interface org.apache.sshd.common.session.SessionContext
DEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractSession(boolean serverSession, FactoryManager factoryManager, org.apache.sshd.common.io.IoSession ioSession) Create a new session. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChannelListener(ChannelListener listener) Add a channel listenervoidaddKexListener(KexListener listener) voidAdd a port forwarding listenervoidaddSessionListener(SessionListener listener) Add a session listener.static voidattachSession(org.apache.sshd.common.io.IoSession ioSession, AbstractSession session) Attach an SSHAbstractSessionto the I/O sessionprotected abstract voidIndicates the the key exchange is completed and the exchanged keys can now be verified - e.g., client can verify the server's keyorg.apache.sshd.common.util.buffer.BuffercreateBuffer(byte cmd, int len) Create a new buffer for the specified SSH packet and reserve the needed space (5 bytes) for the packet header.protected booleandoInvokeUnimplementedMessageHandler(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) org.apache.sshd.common.cipher.CipherInformationgetCipherInformation(boolean incoming) org.apache.sshd.common.compression.CompressionInformationgetCompressionInformation(boolean incoming) protected <T> TgetCurrentService(Class<? extends T> type) Retrieves theFilterChainof the session.protected org.apache.sshd.common.Closeableorg.apache.sshd.common.kex.KexStateorg.apache.sshd.common.mac.MacInformationgetMacInformation(boolean incoming) getNegotiatedKexParameter(org.apache.sshd.common.kex.KexProposalOption paramType) <T extends Service>
TgetService(Class<T> clazz) Get the service of the specified type.static AbstractSessiongetSession(org.apache.sshd.common.io.IoSession ioSession) Retrieve the SSH session from the I/O session.static AbstractSessiongetSession(org.apache.sshd.common.io.IoSession ioSession, boolean allowNull) Retrieve the session SSH from the I/O session.byte[]protected SshTransportFilterprotected voidhandleKexExtension(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) protected voidhandleMessage(org.apache.sshd.common.util.buffer.Buffer buffer) Abstract method for processing incoming decoded packets.protected voidhandleNewCompression(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) protected voidhandleServiceAccept(String serviceName, org.apache.sshd.common.util.buffer.Buffer buffer) protected voidhandleServiceAccept(org.apache.sshd.common.util.buffer.Buffer buffer) protected booleanhandleServiceRequest(String serviceName, org.apache.sshd.common.util.buffer.Buffer buffer) protected voidhandleServiceRequest(org.apache.sshd.common.util.buffer.Buffer buffer) protected CurrentServiceCreates a newCurrentServiceinstance managing this session's current SSH service.protected voidprotected booleanprotected booleanprotected org.apache.sshd.common.io.IoWriteFuturenotImplemented(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) Send aSSH_MSG_UNIMPLEMENTEDpacket.protected voidpreClose()org.apache.sshd.common.util.buffer.BufferprepareBuffer(byte cmd, org.apache.sshd.common.util.buffer.Buffer buffer) Prepare a new "clean" buffer while reserving the needed space (5 bytes) for the packet header.protected abstract booleanreadIdentification(org.apache.sshd.common.util.buffer.Buffer buffer) Read the other side identification.Initiate a new key exchange.voidremoveChannelListener(ChannelListener listener) Remove a channel listenervoidremoveKexListener(KexListener listener) voidRemove a port forwarding listenervoidremoveSessionListener(SessionListener listener) Remove a session listener.org.apache.sshd.common.util.buffer.BufferSend a global request and wait for the response, if the request is sent withwant-reply = true.request(org.apache.sshd.common.util.buffer.Buffer buffer, String request, GlobalRequestFuture.ReplyHandler replyHandler) Send a global request and handle the reply asynchronously.protected StringresolveSessionKexProposal(String hostKeyTypes) protected voidprotected voidstart()Starts the SSH protocol.protected <B extends org.apache.sshd.common.util.buffer.Buffer>
BvalidateTargetBuffer(int cmd, B buffer) Makes sure that the buffer used for output is notnull.org.apache.sshd.common.io.IoWriteFuturewritePacket(org.apache.sshd.common.util.buffer.Buffer buffer) Encode and send the given buffer.org.apache.sshd.common.io.IoWriteFuturewritePacket(org.apache.sshd.common.util.buffer.Buffer buffer, long timeout, TimeUnit unit) Encode and send the given buffer with the specified timeout.Methods inherited from class SessionHelper
attributeKeys, checkAuthenticationTimeout, checkForTimeouts, checkIdleTimeout, clearAttributes, computeAttributeIfAbsent, createProposal, disconnect, doInvokeDebugMessageHandler, doInvokeIgnoreMessageHandler, doReadIdentification, exceptionCaught, getAttribute, getAttributesCount, getAuthTimeout, getAuthTimeoutStart, getBoundLocalPortForwards, getBoundRemotePortForward, getChannelStreamWriterResolver, getConnectionService, getFactoryManager, getForwarder, getIdleTimeout, getIdleTimeoutStart, getIoSession, getKexProposal, getLocalForwardsBindings, getParentPropertyResolver, getProperties, getRemoteForwardsBindings, getReservedSessionMessagesHandler, getSessionDisconnectHandler, getStartedLocalPortForwards, getStartedRemotePortForwards, getTimeoutStatus, getUnknownChannelReferenceHandler, getUsername, handleDebug, handleDisconnect, handleDisconnect, handleIgnore, handleUnimplemented, invokeSessionSignaller, isAuthenticated, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPort, isServerSession, mergeProposals, removeAttribute, resetAuthTimeout, resetIdleTimeout, resolveAvailableSignaturesProposal, resolveAvailableSignaturesProposal, resolveChannelStreamWriterResolver, resolveIdentificationString, resolvePeerAddress, resolveReservedSessionMessagesHandler, resolveUnknownChannelReferenceHandler, sendDebugMessage, sendIgnoreMessage, sendNotImplemented, setAttribute, setAuthenticated, setChannelStreamWriterResolver, setReservedSessionMessagesHandler, setSessionDisconnectHandler, setUnknownChannelReferenceHandler, setUsername, signalDisconnect, signalExceptionCaught, signalNegotiationEnd, signalNegotiationOptionsCreated, signalNegotiationStart, signalPeerIdentificationReceived, signalReadPeerIdentificationLine, signalSendIdentification, signalSessionClosed, signalSessionCreated, signalSessionEvent, signalSessionStarting, toStringMethods inherited from class AbstractKexFactoryManager
getCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactoriesMethods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediatelyMethods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenerMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ChannelStreamWriterResolverManager
resolveChannelStreamWriterMethods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListenerMethods inherited from interface KexExtensionHandlerManager
getKexExtensionHandler, setKexExtensionHandlerMethods inherited from interface KexFactoryManager
getCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNamesMethods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getString, getStringProperty, isEmptyMethods inherited from interface Session
createBuffer, getLocalAddress, getRemoteAddress, request, request, resolveAttribute, startService, writePacket, writePacketMethods inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeatMethods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesHolder
getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNamesMethods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesManager
setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNames
-
Field Details
-
SESSION
Name of the property where this session is stored in the attributes of the underlying MINA session. SeegetSession(IoSession, boolean)andattachSession(IoSession, AbstractSession).- See Also:
-
random
protected final org.apache.sshd.common.random.Random randomThe pseudo random generator -
sessionListeners
Session listeners container -
sessionListenerProxy
-
channelListeners
Channel events listener container -
channelListenerProxy
-
tunnelListeners
Port forwarding events listener container -
tunnelListenerProxy
-
currentService
-
serverVersion
-
clientVersion
-
-
Constructor Details
-
AbstractSession
protected AbstractSession(boolean serverSession, FactoryManager factoryManager, org.apache.sshd.common.io.IoSession ioSession) Create a new session.- Parameters:
serverSession-trueif this is a server session,falseif client onefactoryManager- the factory managerioSession- the underlying I/O session
-
-
Method Details
-
start
Starts the SSH protocol. Invoked by the framework after the session object was fully created, and afterSessionListener.sessionCreated(org.apache.sshd.common.session.Session)has been invoked.- Throws:
Exception- on errors
-
setupFilterChain
protected void setupFilterChain() -
getFilterChain
Description copied from interface:SessionRetrieves theFilterChainof the session.- Returns:
- the
FilterChain; nevernull
-
getTransport
-
isConnectionSecure
protected boolean isConnectionSecure() -
addKexListener
-
removeKexListener
-
initializeKeyExchangePhase
-
isStrictKex
protected boolean isStrictKex() -
initializeCurrentService
Creates a newCurrentServiceinstance managing this session's current SSH service.This initialization method is invoked once from the
AbstractSessionconstructor. Do not rely on subclass fields being initialized.- Returns:
- a new
CurrentServiceinstance for the session
-
getServerVersion
-
getServerKexProposals
-
getClientVersion
-
getClientKexProposals
-
getKexState
public org.apache.sshd.common.kex.KexState getKexState() -
getSessionId
public byte[] getSessionId() -
getKexNegotiationResult
-
getNegotiatedKexParameter
-
getCipherInformation
public org.apache.sshd.common.cipher.CipherInformation getCipherInformation(boolean incoming) -
getCompressionInformation
public org.apache.sshd.common.compression.CompressionInformation getCompressionInformation(boolean incoming) -
getMacInformation
public org.apache.sshd.common.mac.MacInformation getMacInformation(boolean incoming) -
handleMessage
Abstract method for processing incoming decoded packets. The given buffer will hold the decoded packet, starting from the command byte at the read position.- Parameters:
buffer- TheBuffercontaining the packet - it may be re-used to generate the response once request has been decoded- Throws:
Exception- if an exception occurs while handling this packet.
-
handleKexExtension
-
handleNewCompression
-
handleServiceRequest
-
handleServiceRequest
-
handleServiceAccept
-
handleServiceAccept
-
getInnerCloseable
protected org.apache.sshd.common.Closeable getInnerCloseable()- Specified by:
getInnerCloseablein classorg.apache.sshd.common.util.closeable.AbstractInnerCloseable
-
preClose
protected void preClose()- Overrides:
preClosein classorg.apache.sshd.common.util.closeable.AbstractCloseable
-
getServices
-
getService
-
writePacket
public org.apache.sshd.common.io.IoWriteFuture writePacket(org.apache.sshd.common.util.buffer.Buffer buffer) throws IOException Description copied from interface:SessionEncode and send the given buffer. The buffer has to have 5 bytes free at the beginning to allow the encoding to take place. Also, the write position of the buffer has to be set to the position of the last byte to write.- Parameters:
buffer- the buffer to encode and send- Returns:
- An
IoWriteFuturethat can be used to check when the packet has actually been sent - Throws:
IOException- if an error occurred when encoding sending the packet
-
writePacket
public org.apache.sshd.common.io.IoWriteFuture writePacket(org.apache.sshd.common.util.buffer.Buffer buffer, long timeout, TimeUnit unit) throws IOException Description copied from interface:SessionEncode and send the given buffer with the specified timeout. If the buffer could not be written before the timeout elapses, the returnedIoWriteFuturewill be set with aTimeoutExceptionexception to indicate a timeout.- Parameters:
buffer- the buffer to encode and spendtimeout- the timeoutunit- the time unit of the timeout parameter- Returns:
- a future that can be used to check when the packet has actually been sent
- Throws:
IOException- if an error occurred when encoding or sending the packet
-
request
public org.apache.sshd.common.util.buffer.Buffer request(String request, org.apache.sshd.common.util.buffer.Buffer buffer, long maxWaitMillis) throws IOException Description copied from interface:SessionSend a global request and wait for the response, if the request is sent withwant-reply = true.- Parameters:
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 positive- Returns:
- the return buffer if the request was successful,
nullotherwise. - Throws:
IOException- if an error occurred when encoding or sending the packet
-
request
public GlobalRequestFuture request(org.apache.sshd.common.util.buffer.Buffer buffer, String request, GlobalRequestFuture.ReplyHandler replyHandler) throws IOException Description copied from interface:SessionSend a global request and handle the reply asynchronously. Ifwant-reply = true, pass the receivedBufferto the givenGlobalRequestFuture.ReplyHandler, which may execute in a different thread.- want-reply == true && replyHandler != null
- The returned future is fulfilled with
nullwhen the request was sent, or with an exception if the request could not be sent. ThereplyHandleris invoked once the reply is received, with the SSH reply code and the data received. - want-reply == true && replyHandler == null
- The returned future is fulfilled with an exception if the request could not be sent, or a failure reply was received. If a success reply was received, the future is fulfilled with the received data buffer.
- want-reply == false
- The returned future is fulfilled with an empty
Bufferwhen 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.
- Parameters:
buffer- theBuffercontaining the global request, with thewant-replyflag set as appropriaterequest- the request namereplyHandler-GlobalRequestFuture.ReplyHandlerfor handling the reply; may benull- Returns:
- Created
GlobalRequestFuture - Throws:
IOException- if an error occurred while encoding or sending the packet
-
doInvokeUnimplementedMessageHandler
protected boolean doInvokeUnimplementedMessageHandler(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception - Overrides:
doInvokeUnimplementedMessageHandlerin classSessionHelper- Parameters:
cmd- The unimplemented commandbuffer- The inputBuffer- Returns:
- Result of invoking
handleUnimplementedMessage - Throws:
Exception- if failed to handle the message
-
createBuffer
public org.apache.sshd.common.util.buffer.Buffer createBuffer(byte cmd, int len) Description copied from interface:SessionCreate a new buffer for the specified SSH packet and reserve the needed space (5 bytes) for the packet header.- Parameters:
cmd- The SSH command to initialize the buffer withlen- Estimated number of bytes the buffer will hold, 0 if unknown.- Returns:
- a new buffer ready for write
- See Also:
-
prepareBuffer
public org.apache.sshd.common.util.buffer.Buffer prepareBuffer(byte cmd, org.apache.sshd.common.util.buffer.Buffer buffer) Description copied from interface:SessionPrepare a new "clean" buffer while reserving the needed space (5 bytes) for the packet header.- Parameters:
cmd- The SSH command to initialize the buffer withbuffer- TheBufferinstance to initialize- Returns:
- The initialized buffer
-
validateTargetBuffer
protected <B extends org.apache.sshd.common.util.buffer.Buffer> B validateTargetBuffer(int cmd, B buffer) Makes sure that the buffer used for output is notnull.- Type Parameters:
B- TheBuffertype being validated- Parameters:
cmd- The most likely command this buffer refers to (not guaranteed to be correct)buffer- The buffer to be examined- Returns:
- The validated target instance - default same as input
- Throws:
IllegalArgumentException- if any of the conditions is violated
-
readIdentification
protected abstract boolean readIdentification(org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception Read the other side identification. This method is specific to the client or server side, but both should callSessionHelper.doReadIdentification(Buffer, boolean)and store the result in the needed property.- Parameters:
buffer- TheBuffercontaining the remote identification- Returns:
trueif the identification has been fully read orfalseif more data is needed- Throws:
Exception- if an error occurs such as a bad protocol version or unsuccessful KEX was involved
-
notImplemented
protected org.apache.sshd.common.io.IoWriteFuture notImplemented(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception Send aSSH_MSG_UNIMPLEMENTEDpacket. This packet should contain the sequence id of the unsupported packet: this number is assumed to be the last packet received.- Parameters:
cmd- The un-implemented command valuebuffer- TheBufferthat contains the command. Note: the buffer's read position is just beyond the command.- Returns:
- An
IoWriteFuturethat can be used to wait for packet write completion -nullif the registeredReservedSessionMessagesHandlerdecided to handle the command internally - Throws:
Exception- if an error occurred while handling the packet.- See Also:
-
addSessionListener
Description copied from interface:SessionListenerManagerAdd a session listener.- Parameters:
listener- TheSessionListenerto add - notnull
-
removeSessionListener
Description copied from interface:SessionListenerManagerRemove a session listener.- Parameters:
listener- TheSessionListenerto remove
-
getSessionListenerProxy
- Returns:
- A (never
nullproxySessionListenerthat represents all the currently registered listeners. Any method invocation on the proxy is replicated to the currently registered listeners
-
addChannelListener
Description copied from interface:ChannelListenerManagerAdd a channel listener- Parameters:
listener- TheChannelListenerto add - notnull
-
removeChannelListener
Description copied from interface:ChannelListenerManagerRemove a channel listener- Parameters:
listener- TheChannelListenerto remove
-
getChannelListenerProxy
- Returns:
- A (never
nullproxyChannelListenerthat represents all the currently registered listeners. Any method invocation on the proxy is replicated to the currently registered listeners
-
getPortForwardingEventListenerProxy
- Returns:
- A proxy listener representing all the currently registered listeners in this manager
-
addPortForwardingEventListener
Description copied from interface:PortForwardingEventListenerManagerAdd a port forwarding listener- Parameters:
listener- ThePortForwardingEventListenerto add - nevernull
-
removePortForwardingEventListener
Description copied from interface:PortForwardingEventListenerManagerRemove a port forwarding listener- Parameters:
listener- ThePortForwardingEventListenerto remove - ignored ifnull
-
reExchangeKeys
Description copied from interface:SessionInitiate a new key exchange.- Returns:
- A
KeyExchangeFuturefor awaiting the completion of the exchange - Throws:
IOException- If failed to request keys re-negotiation
-
resolveSessionKexProposal
- Overrides:
resolveSessionKexProposalin classSessionHelper- Throws:
IOException
-
getCurrentService
-
checkKeys
Indicates the the key exchange is completed and the exchanged keys can now be verified - e.g., client can verify the server's key- Throws:
IOException- If validation failed
-
getSession
public static AbstractSession getSession(org.apache.sshd.common.io.IoSession ioSession) throws MissingAttachedSessionException Retrieve the SSH session from the I/O session. If the session has not been attached, an exception will be thrown- Parameters:
ioSession- TheIoSession- Returns:
- The SSH session attached to the I/O session
- Throws:
MissingAttachedSessionException- if no attached SSH session- See Also:
-
attachSession
public static void attachSession(org.apache.sshd.common.io.IoSession ioSession, AbstractSession session) throws MultipleAttachedSessionException Attach an SSHAbstractSessionto the I/O session- Parameters:
ioSession- TheIoSessionsession- The SSH session to attach- Throws:
MultipleAttachedSessionException- If a previous session already attached
-
getSession
public static AbstractSession getSession(org.apache.sshd.common.io.IoSession ioSession, boolean allowNull) throws MissingAttachedSessionException Retrieve the session SSH from the I/O session. If the session has not been attached and allowNull isfalse, an exception will be thrown, otherwise anullwill be returned.- Parameters:
ioSession- TheIoSessionallowNull- Iftrue, anullvalue may be returned if no session is attached- Returns:
- the session attached to the I/O session or
null - Throws:
MissingAttachedSessionException- if no attached session and allowNull=false
-