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:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,AttributeRepository,AttributeStore,MutableUserHolder,UsernameHolder,ChannelListenerManager,ChannelStreamWriterResolver,ChannelStreamWriterResolverManager,Closeable,FactoryManagerHolder,PortForwardingEventListenerManager,PortForwardingInformationProvider,KexExtensionHandlerManager,KexFactoryManager,PropertyResolver,ReservedSessionMessagesManager,Session,SessionContext,SessionDisconnectHandlerManager,SessionHeartbeatController,SessionListenerManager,UnknownChannelReferenceHandlerManager,SignatureFactoriesHolder,SignatureFactoriesManager,ConnectionEndpointsIndicator
- Direct Known Subclasses:
AbstractClientSession,AbstractServerSession
public abstract class AbstractSession extends SessionHelper
The AbstractSession handles all the basic SSH protocol such as key exchange, authentication, encoding and decoding. Both server side and client side sessions should inherit from this abstract class. Some basic packet processing methods are defined but the actual call to these methods should be done from the
TODO: if there is any very big packet, decoderBuffer and uncompressBuffer will get quite big and they won't be resized down at any time. Though the packet size is really limited by the channel max packet sizehandleMessage(Buffer)method, which is dependent on the state and side of this session.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractSession.MessageCodingSettingsMessage encoding or decoding settings as determined at the end of a key exchange.-
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
AbstractCloseable.State
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T>
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
SessionHeartbeatController.HeartbeatType
-
-
Field Summary
Fields Modifier and Type Field Description protected ChannelListenerchannelListenerProxyprotected java.util.Collection<ChannelListener>channelListenersChannel events listener containerprivate byte[]clientKexDataprotected java.util.Map<KexProposalOption,java.lang.String>clientProposalprotected java.lang.StringclientVersionprotected ServicecurrentServiceprotected java.lang.ObjectdecodeLockprotected SessionWorkBufferdecoderBufferprotected intdecoderLengthprotected intdecoderStateprotected java.lang.ObjectencodeLockprotected java.lang.BooleanfirstKexPacketFollowsprotected java.util.concurrent.atomic.AtomicLongglobalRequestSeqoprotected intignorePacketDataLengthprotected java.util.concurrent.atomic.AtomicLongignorePacketsCountprotected longignorePacketsFrequencyprotected intignorePacketsVarianceprotected java.util.concurrent.atomic.AtomicLonginBlocksCountprotected java.util.concurrent.atomic.AtomicLonginBytesCountprotected CipherinCipherprotected intinCipherSizeprotected CompressioninCompressionprotected MacinMacprotected byte[]inMacResultprotected intinMacSizeprotected java.util.concurrent.atomic.AtomicLonginPacketsCountprotected AbstractSession.MessageCodingSettingsinSettingsResulting message coding settings at the end of a key exchange for incoming messages.protected KeyExchangekexprotected java.util.concurrent.atomic.AtomicReference<DefaultKeyExchangeFuture>kexFutureHolderprotected DefaultKeyExchangeFuturekexInitializedFutureprotected java.lang.ObjectkexLockprotected java.util.concurrent.atomic.AtomicReference<KexState>kexStateprotected java.util.concurrent.atomic.AtomicReference<java.time.Instant>lastKeyTimeValueprotected java.util.concurrent.atomic.AtomicLongmaxRekeyBlocksprotected longmaxRekeyBytesprotected java.time.DurationmaxRekeyIntervalprotected longmaxRekyPacketsprotected java.util.Map<KexProposalOption,java.lang.String>negotiationResultprotected java.util.concurrent.atomic.AtomicLongoutBlocksCountprotected java.util.concurrent.atomic.AtomicLongoutBytesCountprotected CipheroutCipherprotected intoutCipherSizeprotected CompressionoutCompressionprotected MacoutMacprotected intoutMacSizeprotected java.util.concurrent.atomic.AtomicLongoutPacketsCountprotected AbstractSession.MessageCodingSettingsoutSettingsResulting message coding settings at the end of a key exchange for outgoing messages.protected java.util.concurrent.atomic.AtomicReference<java.lang.String>pendingGlobalRequestprotected java.util.Queue<PendingWriteFuture>pendingPacketsprotected RandomrandomThe pseudo random generatorprotected java.lang.ObjectrequestLockprivate java.util.concurrent.atomic.AtomicReference<java.lang.Object>requestResultUsed to wait for global requests result synchronous waitprotected longseqiInput packet ID.protected longseqoOutput packet ID.private byte[]serverKexDataprotected java.util.Map<KexProposalOption,java.lang.String>serverProposalprotected java.lang.StringserverVersionstatic java.lang.StringSESSIONName of the property where this session is stored in the attributes of the underlying MINA session.protected byte[]sessionIdprotected SessionListenersessionListenerProxyprotected java.util.Collection<SessionListener>sessionListenersSession listeners containerprotected PortForwardingEventListenertunnelListenerProxyprotected java.util.Collection<PortForwardingEventListener>tunnelListenersPort forwarding events listener containerprotected SessionWorkBufferuncompressBufferprotected java.util.Map<KexProposalOption,java.lang.String>unmodClientProposalprotected java.util.Map<KexProposalOption,java.lang.String>unmodNegotiationResultprotected java.util.Map<KexProposalOption,java.lang.String>unmodServerProposal-
Fields inherited from class org.apache.sshd.common.session.helpers.SessionHelper
authStart, idleStart, sessionLock
-
Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, state
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolver
NONE
-
Fields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTY
-
Fields inherited from interface org.apache.sshd.common.session.SessionContext
DEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTH
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSession(boolean serverSession, FactoryManager factoryManager, IoSession ioSession)Create a new session.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddChannelListener(ChannelListener listener)Add a channel listenervoidaddPortForwardingEventListener(PortForwardingEventListener listener)Add a port forwarding listenervoidaddSessionListener(SessionListener listener)Add a session listener.protected voidaeadOutgoingBuffer(Buffer buf, int offset, int len)protected voidappendOutgoingMac(Buffer buf, int offset, int len)static voidattachSession(IoSession ioSession, AbstractSession session)Attach an SSHAbstractSessionto the I/O sessionstatic intcalculatePadLength(int len, int blockSize, boolean etmMode)protected abstract voidcheckKeys()Indicates the the key exchange is completed and the exchanged keys can now be verified - e.g., client can verify the server's keyprotected KeyExchangeFuturecheckRekey()Checks if a re-keying is required and if so initiates itprotected java.util.Map.Entry<java.lang.String,java.lang.String>comparePreferredKexProposalOption(KexProposalOption option)Compares the specifiedKexProposalOptionoption value for client vs.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 voiddecode()Decode the incoming buffer and handle packets as needed.protected longdetermineRekeyBlockLimit(int inCipherBlockSize, int outCipherBlockSize)Compute the number of blocks after which we should re-key again.protected voiddoHandleMessage(Buffer buffer)protected booleandoInvokeUnimplementedMessageHandler(int cmd, Buffer buffer)protected voiddoKexNegotiation()protected IoWriteFuturedoWritePacket(Buffer buffer)protected Bufferencode(Buffer buffer)Encode a buffer into the SSH protocol.protected voidencryptOutgoingBuffer(Buffer buf, int offset, int len)protected PendingWriteFutureenqueuePendingPacket(Buffer buffer)Checks if key-exchange is done - if so, or the packet is related to the key-exchange protocol, then allows the packet to go through, otherwise enqueues it to be sent when key-exchange completedChannelListenergetChannelListenerProxy()CipherInformationgetCipherInformation(boolean incoming)Retrieves current cipher information - Note: may change if key re-exchange executedprotected byte[]getClientKexData()java.util.Map<KexProposalOption,java.lang.String>getClientKexProposals()java.lang.StringgetClientVersion()Retrieve the client version for this session.CompressionInformationgetCompressionInformation(boolean incoming)Retrieves current compression information - Note: may change if key re-exchange executedprotected CloseablegetInnerCloseable()KeyExchangegetKex()java.util.Map<KexProposalOption,java.lang.String>getKexNegotiationResult()KexStategetKexState()MacInformationgetMacInformation(boolean incoming)Retrieves current MAC information - Note: may change if key re-exchange executedjava.lang.StringgetNegotiatedKexParameter(KexProposalOption paramType)Retrieve one of the negotiated values during the KEX stagePortForwardingEventListenergetPortForwardingEventListenerProxy()protected byte[]getServerKexData()java.util.Map<KexProposalOption,java.lang.String>getServerKexProposals()java.lang.StringgetServerVersion()Retrieve the server version for this session.<T extends Service>
TgetService(java.lang.Class<T> clazz)Get the service of the specified type.protected java.util.List<Service>getServices()static AbstractSessiongetSession(IoSession ioSession)Retrieve the SSH session from the I/O session.static AbstractSessiongetSession(IoSession ioSession, boolean allowNull)Retrieve the session SSH from the I/O session.byte[]getSessionId()SessionListenergetSessionListenerProxy()protected booleanhandleFirstKexPacketFollows(int cmd, Buffer buffer, boolean followFlag)protected voidhandleKexExtension(int cmd, Buffer buffer)protected voidhandleKexInit(Buffer buffer)protected voidhandleKexMessage(int cmd, Buffer buffer)protected voidhandleMessage(Buffer buffer)Abstract method for processing incoming decoded packets.protected voidhandleNewCompression(int cmd, Buffer buffer)protected voidhandleNewKeys(int cmd, Buffer buffer)protected voidhandleServiceAccept(java.lang.String serviceName, Buffer buffer)protected voidhandleServiceAccept(Buffer buffer)protected booleanhandleServiceRequest(java.lang.String serviceName, Buffer buffer)protected voidhandleServiceRequest(Buffer buffer)protected booleanisRekeyBlocksCountExceeded()protected booleanisRekeyDataSizeExceeded()protected booleanisRekeyPacketCountsExceeded()protected booleanisRekeyRequired()protected booleanisRekeyTimeIntervalExceeded()voidmessageReceived(Readable buffer)Main input point for the MINA framework.protected java.util.Map<KexProposalOption,java.lang.String>negotiate()Compute the negotiated proposals by merging the client and server proposal.protected IoWriteFuturenotImplemented(int cmd, Buffer buffer)Send aSSH_MSG_UNIMPLEMENTEDpacket.protected voidpreClose()preClose is guaranteed to be called before doCloseGracefully or doCloseImmediately.BufferprepareBuffer(byte cmd, Buffer buffer)Prepare a new "clean" buffer while reserving the needed space (5 bytes) for the packet header.protected voidprepareNewKeys()Prepares the new ciphers, macs and compression algorithms according to the negotiated server and client proposals and stores them ininSettingsandoutSettings.protected BufferpreProcessEncodeBuffer(int cmd, Buffer buffer)Invoked by the session before encoding the buffer in order to make sure that it is at least of sizeSSH_PACKET_HEADER_LEN.protected abstract booleanreadIdentification(Buffer buffer)Read the other side identification.protected abstract voidreceiveKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal, byte[] seed)protected byte[]receiveKexInit(Buffer buffer)protected byte[]receiveKexInit(Buffer buffer, java.util.Map<KexProposalOption,java.lang.String> proposal)Receive the remote key exchange init message.KeyExchangeFuturereExchangeKeys()Initiate a new key exchange.protected voidrefreshConfiguration()Refresh whatever internal configuration is notfinalvoidremoveChannelListener(ChannelListener listener)Remove a channel listenervoidremovePortForwardingEventListener(PortForwardingEventListener listener)Remove a port forwarding listenervoidremoveSessionListener(SessionListener listener)Remove a session listener.Bufferrequest(java.lang.String request, Buffer buffer, long maxWaitMillis)Send a global request and wait for the response.protected voidrequestFailure(Buffer buffer)Indicates the reception of aSSH_MSG_REQUEST_FAILUREmessageprotected KeyExchangeFuturerequestNewKeysExchange()Initiates a new keys exchange if one not already in progressprotected voidrequestSuccess(Buffer buffer)Indicates the reception of aSSH_MSG_REQUEST_SUCCESSmessageprotected java.lang.StringresolveAvailableSignaturesProposal()protected abstract java.lang.StringresolveAvailableSignaturesProposal(FactoryManager manager)protected intresolveIgnoreBufferDataLength()protected BufferresolveOutputPacket(Buffer buffer)protected java.lang.StringresolveSessionKexProposal(java.lang.String hostKeyTypes)protected byte[]sendKexInit()protected byte[]sendKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal)Send the key exchange initialization packet.protected IoWriteFuturesendNewKeys()Send a message to put new keys into use.protected java.util.List<java.util.AbstractMap.SimpleImmutableEntry<PendingWriteFuture,IoWriteFuture>>sendPendingPackets(java.util.Queue<PendingWriteFuture> packetsQueue)protected voidsetClientKexData(byte[] data)protected voidsetInputEncoding()Installs the current preparedinSettingsso that they are effective and will be applied to any future incoming packet.protected abstract voidsetKexSeed(byte... seed)protected java.util.Map<KexProposalOption,java.lang.String>setNegotiationResult(java.util.Map<KexProposalOption,java.lang.String> guess)protected voidsetOutputEncoding()Installs the current preparedoutSettingsso that they are effective and will be applied to any future outgoing packet.protected voidsetServerKexData(byte[] data)protected voidsignalRequestFailure()Marks the current pending global request result as failedprotected voidvalidateIncomingMac(byte[] data, int offset, int len)protected voidvalidateKexState(int cmd, KexState expected)protected <B extends Buffer>
BvalidateTargetBuffer(int cmd, B buffer)Makes sure that the buffer used for output is notnullor one of the session's internal ones used for decoding and uncompressingIoWriteFuturewritePacket(Buffer buffer)Encode and send the given buffer.-
Methods inherited from class org.apache.sshd.common.session.helpers.SessionHelper
attributeKeys, calculateNextIgnorePacketCount, checkAuthenticationTimeout, checkForTimeouts, checkIdleTimeout, clearAttributes, computeAttributeIfAbsent, createProposal, disconnect, doInvokeDebugMessageHandler, doInvokeIgnoreMessageHandler, doReadIdentification, exceptionCaught, getAttribute, getAttributesCount, getAuthTimeout, getAuthTimeoutStart, getBoundLocalPortForwards, getBoundRemotePortForward, getChannelStreamWriterResolver, getConnectionService, getFactoryManager, getForwarder, getIdleTimeout, getIdleTimeoutStart, getIoSession, 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, resizeKey, resolveChannelStreamWriterResolver, resolveIdentificationString, resolvePeerAddress, resolveReservedSessionMessagesHandler, resolveUnknownChannelReferenceHandler, sendDebugMessage, sendIdentification, sendIgnoreMessage, sendNotImplemented, setAttribute, setAuthenticated, setChannelStreamWriterResolver, setReservedSessionMessagesHandler, setSessionDisconnectHandler, setUnknownChannelReferenceHandler, setUsername, signalDisconnect, signalDisconnect, signalExceptionCaught, signalExceptionCaught, signalNegotiationEnd, signalNegotiationEnd, signalNegotiationOptionsCreated, signalNegotiationOptionsCreated, signalNegotiationStart, signalNegotiationStart, signalPeerIdentificationReceived, signalPeerIdentificationReceived, signalReadPeerIdentificationLine, signalReadPeerIdentificationLine, signalSendIdentification, signalSendIdentification, signalSessionClosed, signalSessionClosed, signalSessionCreated, signalSessionCreated, signalSessionEstablished, signalSessionEstablished, signalSessionEvent, signalSessionEvent, toString, writePacket
-
Methods inherited from class org.apache.sshd.common.kex.AbstractKexFactoryManager
getCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactories
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediately
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListener
-
Methods 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, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolverManager
resolveChannelStreamWriter
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
Methods inherited from interface org.apache.sshd.common.kex.extension.KexExtensionHandlerManager
getKexExtensionHandler, setKexExtensionHandler
-
Methods inherited from interface org.apache.sshd.common.kex.KexFactoryManager
getCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNames
-
Methods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getString, getStringProperty, isEmpty
-
Methods inherited from interface org.apache.sshd.common.session.Session
createBuffer, getLocalAddress, getRemoteAddress, request, request, resolveAttribute, startService, writePacket, writePacket
-
Methods inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeat
-
Methods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesHolder
getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames
-
Methods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesManager
setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNames
-
-
-
-
Field Detail
-
SESSION
public static final java.lang.String 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:
- Constant Field Values
-
random
protected final Random random
The pseudo random generator
-
sessionListeners
protected final java.util.Collection<SessionListener> sessionListeners
Session listeners container
-
sessionListenerProxy
protected final SessionListener sessionListenerProxy
-
channelListeners
protected final java.util.Collection<ChannelListener> channelListeners
Channel events listener container
-
channelListenerProxy
protected final ChannelListener channelListenerProxy
-
tunnelListeners
protected final java.util.Collection<PortForwardingEventListener> tunnelListeners
Port forwarding events listener container
-
tunnelListenerProxy
protected final PortForwardingEventListener tunnelListenerProxy
-
sessionId
protected byte[] sessionId
-
serverVersion
protected java.lang.String serverVersion
-
clientVersion
protected java.lang.String clientVersion
-
serverProposal
protected final java.util.Map<KexProposalOption,java.lang.String> serverProposal
-
unmodServerProposal
protected final java.util.Map<KexProposalOption,java.lang.String> unmodServerProposal
-
clientProposal
protected final java.util.Map<KexProposalOption,java.lang.String> clientProposal
-
unmodClientProposal
protected final java.util.Map<KexProposalOption,java.lang.String> unmodClientProposal
-
negotiationResult
protected final java.util.Map<KexProposalOption,java.lang.String> negotiationResult
-
unmodNegotiationResult
protected final java.util.Map<KexProposalOption,java.lang.String> unmodNegotiationResult
-
kex
protected KeyExchange kex
-
firstKexPacketFollows
protected java.lang.Boolean firstKexPacketFollows
-
kexState
protected final java.util.concurrent.atomic.AtomicReference<KexState> kexState
-
kexFutureHolder
protected final java.util.concurrent.atomic.AtomicReference<DefaultKeyExchangeFuture> kexFutureHolder
-
kexInitializedFuture
protected DefaultKeyExchangeFuture kexInitializedFuture
-
outCipher
protected Cipher outCipher
-
inCipher
protected Cipher inCipher
-
outCipherSize
protected int outCipherSize
-
inCipherSize
protected int inCipherSize
-
outMac
protected Mac outMac
-
inMac
protected Mac inMac
-
outMacSize
protected int outMacSize
-
inMacSize
protected int inMacSize
-
inMacResult
protected byte[] inMacResult
-
outCompression
protected Compression outCompression
-
inCompression
protected Compression inCompression
-
seqi
protected long seqi
Input packet ID.
-
seqo
protected long seqo
Output packet ID.
-
uncompressBuffer
protected SessionWorkBuffer uncompressBuffer
-
decoderBuffer
protected final SessionWorkBuffer decoderBuffer
-
decoderState
protected int decoderState
-
decoderLength
protected int decoderLength
-
encodeLock
protected final java.lang.Object encodeLock
-
decodeLock
protected final java.lang.Object decodeLock
-
kexLock
protected final java.lang.Object kexLock
-
requestLock
protected final java.lang.Object requestLock
-
inPacketsCount
protected final java.util.concurrent.atomic.AtomicLong inPacketsCount
-
outPacketsCount
protected final java.util.concurrent.atomic.AtomicLong outPacketsCount
-
inBytesCount
protected final java.util.concurrent.atomic.AtomicLong inBytesCount
-
outBytesCount
protected final java.util.concurrent.atomic.AtomicLong outBytesCount
-
inBlocksCount
protected final java.util.concurrent.atomic.AtomicLong inBlocksCount
-
outBlocksCount
protected final java.util.concurrent.atomic.AtomicLong outBlocksCount
-
lastKeyTimeValue
protected final java.util.concurrent.atomic.AtomicReference<java.time.Instant> lastKeyTimeValue
-
maxRekyPackets
protected long maxRekyPackets
-
maxRekeyBytes
protected long maxRekeyBytes
-
maxRekeyInterval
protected java.time.Duration maxRekeyInterval
-
pendingPackets
protected final java.util.Queue<PendingWriteFuture> pendingPackets
-
inSettings
protected AbstractSession.MessageCodingSettings inSettings
Resulting message coding settings at the end of a key exchange for incoming messages.- See Also:
prepareNewKeys(),setInputEncoding()
-
outSettings
protected AbstractSession.MessageCodingSettings outSettings
Resulting message coding settings at the end of a key exchange for outgoing messages.- See Also:
prepareNewKeys(),setOutputEncoding()
-
currentService
protected Service currentService
-
globalRequestSeqo
protected final java.util.concurrent.atomic.AtomicLong globalRequestSeqo
-
pendingGlobalRequest
protected final java.util.concurrent.atomic.AtomicReference<java.lang.String> pendingGlobalRequest
-
ignorePacketDataLength
protected int ignorePacketDataLength
-
ignorePacketsFrequency
protected long ignorePacketsFrequency
-
ignorePacketsVariance
protected int ignorePacketsVariance
-
maxRekeyBlocks
protected final java.util.concurrent.atomic.AtomicLong maxRekeyBlocks
-
ignorePacketsCount
protected final java.util.concurrent.atomic.AtomicLong ignorePacketsCount
-
requestResult
private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> requestResult
Used to wait for global requests result synchronous wait
-
clientKexData
private byte[] clientKexData
-
serverKexData
private byte[] serverKexData
-
-
Constructor Detail
-
AbstractSession
protected AbstractSession(boolean serverSession, FactoryManager factoryManager, 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 Detail
-
calculatePadLength
public static int calculatePadLength(int len, int blockSize, boolean etmMode)- Parameters:
len- The packet payload sizeblockSize- The cipher block sizeetmMode- Whether using "encrypt-then-MAC" mode- Returns:
- The required padding length
-
getServerVersion
public java.lang.String getServerVersion()
Description copied from interface:SessionContextRetrieve the server version for this session.- Returns:
- the server version - may be
null/empty if versions not yet exchanged
-
getServerKexProposals
public java.util.Map<KexProposalOption,java.lang.String> getServerKexProposals()
- Returns:
- An un-modifiable map of the latest KEX client proposal options. May be empty if KEX not yet completed or re-keying in progress
- See Also:
SessionContext.getKexState()
-
getClientVersion
public java.lang.String getClientVersion()
Description copied from interface:SessionContextRetrieve the client version for this session.- Returns:
- the client version - may be
null/empty if versions not yet exchanged
-
getClientKexProposals
public java.util.Map<KexProposalOption,java.lang.String> getClientKexProposals()
- Returns:
- An un-modifiable map of the latest KEX client proposal options May be empty if KEX not yet completed or re-keying in progress
- See Also:
SessionContext.getKexState()
-
getKex
public KeyExchange getKex()
- Returns:
- The current
KeyExchangein progress -nullif KEX not started or successfully completed
-
getKexState
public KexState getKexState()
-
getSessionId
public byte[] getSessionId()
- Returns:
- A clone of the established session identifier -
nullif not yet established
-
getKexNegotiationResult
public java.util.Map<KexProposalOption,java.lang.String> getKexNegotiationResult()
-
getNegotiatedKexParameter
public java.lang.String getNegotiatedKexParameter(KexProposalOption paramType)
Description copied from interface:SessionContextRetrieve one of the negotiated values during the KEX stage- Parameters:
paramType- The requestKexProposalOptionvalue - ignored ifnull- Returns:
- The negotiated parameter value -
nullif invalid parameter or no negotiated value. - See Also:
SessionContext.getKexState()
-
getCipherInformation
public CipherInformation getCipherInformation(boolean incoming)
Description copied from interface:SessionContextRetrieves current cipher information - Note: may change if key re-exchange executed- Parameters:
incoming- Iftruethen the cipher for the incoming data, otherwise for the outgoing data- Returns:
- The
CipherInformation- ornullif not negotiated yet.
-
getCompressionInformation
public CompressionInformation getCompressionInformation(boolean incoming)
Description copied from interface:SessionContextRetrieves current compression information - Note: may change if key re-exchange executed- Parameters:
incoming- Iftruethen the compression for the incoming data, otherwise for the outgoing data- Returns:
- The
CompressionInformation- ornullif not negotiated yet.
-
getMacInformation
public MacInformation getMacInformation(boolean incoming)
Description copied from interface:SessionContextRetrieves current MAC information - Note: may change if key re-exchange executed- Parameters:
incoming- Iftruethen the MAC for the incoming data, otherwise for the outgoing data- Returns:
- The
MacInformation- ornullif not negotiated yet.
-
messageReceived
public void messageReceived(Readable buffer) throws java.lang.Exception
Main input point for the MINA framework.
This method will be called each time new data is received on the socket and will append it to the input buffer before calling the
decode()method.- Parameters:
buffer- the new buffer received- Throws:
java.lang.Exception- if an error occurs while decoding or handling the data
-
refreshConfiguration
protected void refreshConfiguration()
Refresh whatever internal configuration is notfinal
-
handleMessage
protected void handleMessage(Buffer buffer) throws java.lang.Exception
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:
java.lang.Exception- if an exception occurs while handling this packet.- See Also:
doHandleMessage(Buffer)
-
doHandleMessage
protected void doHandleMessage(Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
handleFirstKexPacketFollows
protected boolean handleFirstKexPacketFollows(int cmd, Buffer buffer, boolean followFlag)
-
comparePreferredKexProposalOption
protected java.util.Map.Entry<java.lang.String,java.lang.String> comparePreferredKexProposalOption(KexProposalOption option)
Compares the specifiedKexProposalOptionoption value for client vs. server- Parameters:
option- The option to check- Returns:
nullif option is equal, otherwise a key/value pair where key=client option value and value=the server-side one
-
sendNewKeys
protected IoWriteFuture sendNewKeys() throws java.lang.Exception
Send a message to put new keys into use.- Returns:
- An
IoWriteFuturethat can be used to wait and check the result of sending the packet - Throws:
java.lang.Exception- if an error occurs sending the message
-
handleKexMessage
protected void handleKexMessage(int cmd, Buffer buffer) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleKexExtension
protected void handleKexExtension(int cmd, Buffer buffer) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleNewCompression
protected void handleNewCompression(int cmd, Buffer buffer) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleServiceRequest
protected void handleServiceRequest(Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
handleServiceRequest
protected boolean handleServiceRequest(java.lang.String serviceName, Buffer buffer) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleServiceAccept
protected void handleServiceAccept(Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
handleServiceAccept
protected void handleServiceAccept(java.lang.String serviceName, Buffer buffer) throws java.lang.Exception- Throws:
java.lang.Exception
-
handleKexInit
protected void handleKexInit(Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
doKexNegotiation
protected void doKexNegotiation() throws java.lang.Exception- Throws:
java.lang.Exception
-
handleNewKeys
protected void handleNewKeys(int cmd, Buffer buffer) throws java.lang.Exception- Throws:
java.lang.Exception
-
sendPendingPackets
protected java.util.List<java.util.AbstractMap.SimpleImmutableEntry<PendingWriteFuture,IoWriteFuture>> sendPendingPackets(java.util.Queue<PendingWriteFuture> packetsQueue) throws java.io.IOException
- Throws:
java.io.IOException
-
validateKexState
protected void validateKexState(int cmd, KexState expected)
-
getInnerCloseable
protected Closeable getInnerCloseable()
- Specified by:
getInnerCloseablein classAbstractInnerCloseable
-
preClose
protected void preClose()
Description copied from class:AbstractCloseablepreClose is guaranteed to be called before doCloseGracefully or doCloseImmediately. When preClose() is called, isClosing() == true- Overrides:
preClosein classAbstractCloseable
-
getServices
protected java.util.List<Service> getServices()
-
getService
public <T extends Service> T getService(java.lang.Class<T> clazz)
Description copied from interface:SessionGet the service of the specified type. If the service is not of the specified class, an IllegalStateException will be thrown.- Type Parameters:
T- The genericServicetype- Parameters:
clazz- The service class- Returns:
- The service instance
-
preProcessEncodeBuffer
protected Buffer preProcessEncodeBuffer(int cmd, Buffer buffer) throws java.io.IOException
Description copied from class:SessionHelperInvoked by the session before encoding the buffer in order to make sure that it is at least of sizeSSH_PACKET_HEADER_LEN. This is required in order to efficiently handle the encoding. If necessary, it re-allocates a new buffer and returns it instead.- Overrides:
preProcessEncodeBufferin classSessionHelper- Parameters:
cmd- The command stored in the bufferbuffer- The originalBuffer- assumed to be properly formatted and be of at least the required minimum length.- Returns:
- The adjusted
Buffer. Note: users may use this method to totally alter the contents of the buffer being sent but it is highly discouraged as it may have unexpected results. - Throws:
java.io.IOException- If failed to process the buffer
-
writePacket
public IoWriteFuture writePacket(Buffer buffer) throws java.io.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:
java.io.IOException- if an error occurred when encoding sending the packet
-
enqueuePendingPacket
protected PendingWriteFuture enqueuePendingPacket(Buffer buffer)
Checks if key-exchange is done - if so, or the packet is related to the key-exchange protocol, then allows the packet to go through, otherwise enqueues it to be sent when key-exchange completed- Parameters:
buffer- TheBuffercontaining the packet to be sent- Returns:
- A
PendingWriteFutureif enqueued,nullif packet can go through.
-
resolveOutputPacket
protected Buffer resolveOutputPacket(Buffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
doWritePacket
protected IoWriteFuture doWritePacket(Buffer buffer) throws java.io.IOException
- Throws:
java.io.IOException
-
resolveIgnoreBufferDataLength
protected int resolveIgnoreBufferDataLength()
-
request
public Buffer request(java.lang.String request, Buffer buffer, long maxWaitMillis) throws java.io.IOException
Description copied from interface:SessionSend a global request and wait for the response. This must only be used when sending aSSH_MSG_GLOBAL_REQUESTwith a result expected, else it will time out- Parameters:
request- the request name - used mainly for logging and debuggingbuffer- the buffer containing the global requestmaxWaitMillis- Max. time to wait for response (millis) - must be positive- Returns:
- the return buffer if the request was successful,
nullotherwise. - Throws:
java.io.IOException- if an error occurred when encoding or sending the packetjava.net.SocketTimeoutException- If no response received within specified timeout
-
doInvokeUnimplementedMessageHandler
protected boolean doInvokeUnimplementedMessageHandler(int cmd, Buffer buffer) throws java.lang.Exception- Overrides:
doInvokeUnimplementedMessageHandlerin classSessionHelper- Parameters:
cmd- The unimplemented commandbuffer- The inputBuffer- Returns:
- Result of invoking
handleUnimplementedMessage - Throws:
java.lang.Exception- if failed to handle the message
-
createBuffer
public 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:
Session.prepareBuffer(byte, Buffer)
-
prepareBuffer
public Buffer prepareBuffer(byte cmd, 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 Buffer> B validateTargetBuffer(int cmd, B buffer)
Makes sure that the buffer used for output is notnullor one of the session's internal ones used for decoding and uncompressing- 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:
java.lang.IllegalArgumentException- if any of the conditions is violated
-
encode
protected Buffer encode(Buffer buffer) throws java.io.IOException
Encode a buffer into the SSH protocol. Note: This method must be called inside asynchronizedblock usingencodeLock.- Parameters:
buffer- the buffer to encode- Returns:
- The encoded buffer - may be different than original if input buffer does not have enough room
for
SshConstants.SSH_PACKET_HEADER_LEN, in which case a substitute buffer will be created and used. - Throws:
java.io.IOException- if an exception occurs during the encoding process
-
aeadOutgoingBuffer
protected void aeadOutgoingBuffer(Buffer buf, int offset, int len) throws java.lang.Exception
- Throws:
java.lang.Exception
-
appendOutgoingMac
protected void appendOutgoingMac(Buffer buf, int offset, int len) throws java.lang.Exception
- Throws:
java.lang.Exception
-
encryptOutgoingBuffer
protected void encryptOutgoingBuffer(Buffer buf, int offset, int len) throws java.lang.Exception
- Throws:
java.lang.Exception
-
decode
protected void decode() throws java.lang.ExceptionDecode the incoming buffer and handle packets as needed.- Throws:
java.lang.Exception- If failed to decode
-
validateIncomingMac
protected void validateIncomingMac(byte[] data, int offset, int len) throws java.lang.Exception- Throws:
java.lang.Exception
-
readIdentification
protected abstract boolean readIdentification(Buffer buffer) throws java.lang.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:
java.lang.Exception- if an error occurs such as a bad protocol version or unsuccessful KEX was involved
-
sendKexInit
protected byte[] sendKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal) throws java.lang.Exception
Send the key exchange initialization packet. This packet contains random data along with our proposal.- Parameters:
proposal- our proposal for key exchange negotiation- Returns:
- the sent packet data which must be kept for later use when deriving the session keys
- Throws:
java.lang.Exception- if an error occurred sending the packet
-
receiveKexInit
protected byte[] receiveKexInit(Buffer buffer, java.util.Map<KexProposalOption,java.lang.String> proposal) throws java.lang.Exception
Receive the remote key exchange init message. The packet data is returned for later use.- Parameters:
buffer- theBuffercontaining the key exchange init packetproposal- the remote proposal to fill- Returns:
- the packet data
- Throws:
java.lang.Exception- If failed to handle the message
-
prepareNewKeys
protected void prepareNewKeys() throws java.lang.ExceptionPrepares the new ciphers, macs and compression algorithms according to the negotiated server and client proposals and stores them ininSettingsandoutSettings. The new settings do not take effect yet; usesetInputEncoding()orsetOutputEncoding()for that.- Throws:
java.lang.Exception- if an error occurs
-
setOutputEncoding
protected void setOutputEncoding() throws java.lang.ExceptionInstalls the current preparedoutSettingsso that they are effective and will be applied to any future outgoing packet. ClearsoutSettings.- Throws:
java.lang.Exception- on errors
-
setInputEncoding
protected void setInputEncoding() throws java.lang.ExceptionInstalls the current preparedinSettingsso that they are effective and will be applied to any future incoming packet. ClearsinSettings.- Throws:
java.lang.Exception- on errors
-
determineRekeyBlockLimit
protected long determineRekeyBlockLimit(int inCipherBlockSize, int outCipherBlockSize)Compute the number of blocks after which we should re-key again. See RFC 4344.- Parameters:
inCipherBlockSize- block size of the input cipheroutCipherBlockSize- block size of the output cipher- Returns:
- the number of block after which re-keying occur at the latest
- See Also:
- RFC 4344, section 3.2
-
notImplemented
protected IoWriteFuture notImplemented(int cmd, Buffer buffer) throws java.lang.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:
java.lang.Exception- if an error occurred while handling the packet.- See Also:
SessionHelper.sendNotImplemented(long)
-
negotiate
protected java.util.Map<KexProposalOption,java.lang.String> negotiate() throws java.lang.Exception
Compute the negotiated proposals by merging the client and server proposal. The negotiated proposal will also be stored in thenegotiationResultproperty.- Returns:
- The negotiated options
Map - Throws:
java.lang.Exception- If negotiation failed
-
setNegotiationResult
protected java.util.Map<KexProposalOption,java.lang.String> setNegotiationResult(java.util.Map<KexProposalOption,java.lang.String> guess)
-
requestSuccess
protected void requestSuccess(Buffer buffer) throws java.lang.Exception
Indicates the reception of aSSH_MSG_REQUEST_SUCCESSmessage- Parameters:
buffer- TheBuffercontaining the message data- Throws:
java.lang.Exception- If failed to handle the message
-
requestFailure
protected void requestFailure(Buffer buffer) throws java.lang.Exception
Indicates the reception of aSSH_MSG_REQUEST_FAILUREmessage- Parameters:
buffer- TheBuffercontaining the message data- Throws:
java.lang.Exception- If failed to handle the message
-
signalRequestFailure
protected void signalRequestFailure()
Marks the current pending global request result as failed
-
addSessionListener
public void addSessionListener(SessionListener listener)
Description copied from interface:SessionListenerManagerAdd a session listener.- Parameters:
listener- TheSessionListenerto add - notnull
-
removeSessionListener
public void removeSessionListener(SessionListener listener)
Description copied from interface:SessionListenerManagerRemove a session listener.- Parameters:
listener- TheSessionListenerto remove
-
getSessionListenerProxy
public SessionListener 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
public void addChannelListener(ChannelListener listener)
Description copied from interface:ChannelListenerManagerAdd a channel listener- Parameters:
listener- TheChannelListenerto add - notnull
-
removeChannelListener
public void removeChannelListener(ChannelListener listener)
Description copied from interface:ChannelListenerManagerRemove a channel listener- Parameters:
listener- TheChannelListenerto remove
-
getChannelListenerProxy
public ChannelListener 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
public PortForwardingEventListener getPortForwardingEventListenerProxy()
- Returns:
- A proxy listener representing all the currently registered listener through this manager
-
addPortForwardingEventListener
public void addPortForwardingEventListener(PortForwardingEventListener listener)
Description copied from interface:PortForwardingEventListenerManagerAdd a port forwarding listener- Parameters:
listener- ThePortForwardingEventListenerto add - nevernull
-
removePortForwardingEventListener
public void removePortForwardingEventListener(PortForwardingEventListener listener)
Description copied from interface:PortForwardingEventListenerManagerRemove a port forwarding listener- Parameters:
listener- ThePortForwardingEventListenerto remove - ignored ifnull
-
reExchangeKeys
public KeyExchangeFuture reExchangeKeys() throws java.io.IOException
Description copied from interface:SessionInitiate a new key exchange.- Returns:
- A
KeyExchangeFuturefor awaiting the completion of the exchange - Throws:
java.io.IOException- If failed to request keys re-negotiation
-
checkRekey
protected KeyExchangeFuture checkRekey() throws java.lang.Exception
Checks if a re-keying is required and if so initiates it- Returns:
- A
KeyExchangeFutureto wait for the initiated exchange ornullif no need to re-key or an exchange is already in progress - Throws:
java.lang.Exception- If failed load/generate the keys or send the request- See Also:
isRekeyRequired(),requestNewKeysExchange()
-
requestNewKeysExchange
protected KeyExchangeFuture requestNewKeysExchange() throws java.lang.Exception
Initiates a new keys exchange if one not already in progress- Returns:
- A
KeyExchangeFutureto wait for the initiated exchange ornullif an exchange is already in progress - Throws:
java.lang.Exception- If failed to load/generate the keys or send the request
-
isRekeyRequired
protected boolean isRekeyRequired()
-
isRekeyTimeIntervalExceeded
protected boolean isRekeyTimeIntervalExceeded()
-
isRekeyPacketCountsExceeded
protected boolean isRekeyPacketCountsExceeded()
-
isRekeyDataSizeExceeded
protected boolean isRekeyDataSizeExceeded()
-
isRekeyBlocksCountExceeded
protected boolean isRekeyBlocksCountExceeded()
-
resolveSessionKexProposal
protected java.lang.String resolveSessionKexProposal(java.lang.String hostKeyTypes) throws java.io.IOException- Overrides:
resolveSessionKexProposalin classSessionHelper- Throws:
java.io.IOException
-
sendKexInit
protected byte[] sendKexInit() throws java.lang.Exception- Throws:
java.lang.Exception
-
getClientKexData
protected byte[] getClientKexData()
-
setClientKexData
protected void setClientKexData(byte[] data)
-
getServerKexData
protected byte[] getServerKexData()
-
setServerKexData
protected void setServerKexData(byte[] data)
-
setKexSeed
protected abstract void setKexSeed(byte... seed)
- Parameters:
seed- The result of the KEXINIT handshake - required for correct session key establishment
-
resolveAvailableSignaturesProposal
protected java.lang.String resolveAvailableSignaturesProposal() throws java.io.IOException, java.security.GeneralSecurityException- Returns:
- A comma-separated list of all the signature protocols to be included in the
proposal -
null/empty if no proposal - Throws:
java.io.IOException- If failed to read/parse the keys datajava.security.GeneralSecurityException- If failed to generate the keys- See Also:
SessionHelper.getFactoryManager(),resolveAvailableSignaturesProposal(FactoryManager)
-
resolveAvailableSignaturesProposal
protected abstract java.lang.String resolveAvailableSignaturesProposal(FactoryManager manager) throws java.io.IOException, java.security.GeneralSecurityException
- Parameters:
manager- TheFactoryManager- Returns:
- A comma-separated list of all the signature protocols to be included in the
proposal -
null/empty if no proposal - Throws:
java.io.IOException- If failed to read/parse the keys datajava.security.GeneralSecurityException- If failed to generate the keys
-
checkKeys
protected abstract void checkKeys() throws java.io.IOExceptionIndicates the the key exchange is completed and the exchanged keys can now be verified - e.g., client can verify the server's key- Throws:
java.io.IOException- If validation failed
-
receiveKexInit
protected byte[] receiveKexInit(Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
receiveKexInit
protected abstract void receiveKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal, byte[] seed) throws java.io.IOException
- Throws:
java.io.IOException
-
getSession
public static AbstractSession getSession(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:
getSession(IoSession, boolean)
-
attachSession
public static void attachSession(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(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
-
-