Class SessionHelper
- 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
-
- All Implemented Interfaces:
Closeable,AutoCloseable,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:
AbstractSession
public abstract class SessionHelper extends AbstractKexFactoryManager implements Session
Contains split code in order to makeAbstractSessionclass smaller
-
-
Nested Class Summary
-
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 extends Object>
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
SessionHeartbeatController.HeartbeatType
-
-
Field Summary
Fields Modifier and Type Field Description protected InstantauthStartprotected InstantidleStartprotected Map<KexProposalOption,String>initialKexProposalStores the initial KEX proposal after it has been run through the hooks allowing client code to modify it; seegetKexProposal().-
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 protectedSessionHelper(boolean serverSession, FactoryManager factoryManager, IoSession ioSession)Create a new session.
-
Method Summary
-
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, getInnerCloseable
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, preClose, 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.ChannelListenerManager
addChannelListener, getChannelListenerProxy, removeChannelListener
-
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.forward.PortForwardingEventListenerManager
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListener
-
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, createBuffer, getKex, getLocalAddress, getRemoteAddress, getService, prepareBuffer, reExchangeKeys, request, request, request, request, resolveAttribute, startService, writePacket, writePacket, writePacket, writePacket
-
Methods inherited from interface org.apache.sshd.common.session.SessionContext
getCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionId
-
Methods inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeat
-
Methods inherited from interface org.apache.sshd.common.session.SessionListenerManager
addSessionListener, getSessionListenerProxy, removeSessionListener
-
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
-
authStart
protected Instant authStart
-
idleStart
protected Instant idleStart
-
initialKexProposal
protected Map<KexProposalOption,String> initialKexProposal
Stores the initial KEX proposal after it has been run through the hooks allowing client code to modify it; seegetKexProposal(). The same proposal is then used for the initial KEX and for any re-KEX.
-
-
Constructor Detail
-
SessionHelper
protected SessionHelper(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
-
getIoSession
public IoSession getIoSession()
- Specified by:
getIoSessionin interfaceSession- Returns:
- The
IoSessionassociated to this session
-
isServerSession
public boolean isServerSession()
- Specified by:
isServerSessionin interfaceSessionContext
-
getFactoryManager
public FactoryManager getFactoryManager()
- Specified by:
getFactoryManagerin interfaceFactoryManagerHolder- Returns:
- The currently associated
FactoryManager
-
getParentPropertyResolver
public PropertyResolver getParentPropertyResolver()
- Specified by:
getParentPropertyResolverin interfacePropertyResolver
-
getProperties
public Map<String,Object> getProperties()
- Specified by:
getPropertiesin interfacePropertyResolver
-
getAttributesCount
public int getAttributesCount()
- Specified by:
getAttributesCountin interfaceAttributeRepository
-
getAttribute
public <T> T getAttribute(AttributeRepository.AttributeKey<T> key)
- Specified by:
getAttributein interfaceAttributeRepository
-
attributeKeys
public Collection<AttributeRepository.AttributeKey<?>> attributeKeys()
- Specified by:
attributeKeysin interfaceAttributeRepository
-
computeAttributeIfAbsent
public <T> T computeAttributeIfAbsent(AttributeRepository.AttributeKey<T> key, Function<? super AttributeRepository.AttributeKey<T>,? extends T> resolver)
- Specified by:
computeAttributeIfAbsentin interfaceAttributeStore
-
setAttribute
public <T> T setAttribute(AttributeRepository.AttributeKey<T> key, T value)
- Specified by:
setAttributein interfaceAttributeStore
-
removeAttribute
public <T> T removeAttribute(AttributeRepository.AttributeKey<T> key)
- Specified by:
removeAttributein interfaceAttributeStore
-
clearAttributes
public void clearAttributes()
- Specified by:
clearAttributesin interfaceAttributeStore
-
getUsername
public String getUsername()
- Specified by:
getUsernamein interfaceUsernameHolder
-
setUsername
public void setUsername(String username)
- Specified by:
setUsernamein interfaceMutableUserHolder
-
isAuthenticated
public boolean isAuthenticated()
- Specified by:
isAuthenticatedin interfaceSessionContext
-
setAuthenticated
public void setAuthenticated() throws IOException- Specified by:
setAuthenticatedin interfaceSession- Throws:
IOException
-
checkForTimeouts
protected TimeoutIndicator checkForTimeouts() throws IOException
Checks whether the session has timed out (both authentication and idle timeouts are checked). If the session has timed out, a DISCONNECT message will be sent.- Returns:
- An indication whether timeout has been detected
- Throws:
IOException- If failed to check- See Also:
checkAuthenticationTimeout(Instant, Duration),checkIdleTimeout(Instant, Duration)
-
getAuthTimeoutStart
public Instant getAuthTimeoutStart()
- Specified by:
getAuthTimeoutStartin interfaceSession- Returns:
- The timestamp value (milliseconds since EPOCH) when timer was started
-
resetAuthTimeout
public Instant resetAuthTimeout()
Description copied from interface:SessionRe-start the authentication timeout timer- Specified by:
resetAuthTimeoutin interfaceSession- Returns:
- The timestamp value (milliseconds since EPOCH) when timer was started
- See Also:
Session.getAuthTimeoutStart()
-
checkAuthenticationTimeout
protected TimeoutIndicator checkAuthenticationTimeout(Instant now, Duration authTimeout)
Checks if authentication timeout expired- Parameters:
now- The current time in millisauthTimeout- The configured timeout - if non-positive then no timeout- Returns:
- A
TimeoutIndicatorspecifying the timeout status and disconnect reason message if timeout expired,nullorNoTimeoutif no timeout occurred - See Also:
getAuthTimeout()
-
getIdleTimeoutStart
public Instant getIdleTimeoutStart()
- Specified by:
getIdleTimeoutStartin interfaceSession- Returns:
- The timestamp value (milliseconds since EPOCH) when timer was started
-
checkIdleTimeout
protected TimeoutIndicator checkIdleTimeout(Instant now, Duration idleTimeout)
Checks if idle timeout expired- Parameters:
now- The current time in millisidleTimeout- The configured timeout - if non-positive then no timeout- Returns:
- A
TimeoutIndicatorspecifying the timeout status and disconnect reason message if timeout expired,nullorNoTimeoutif no timeout occurred - See Also:
getIdleTimeout()
-
resetIdleTimeout
public Instant resetIdleTimeout()
Description copied from interface:SessionRe-start idle timeout timer- Specified by:
resetIdleTimeoutin interfaceSession- Returns:
- The timestamp value (milliseconds since EPOCH) when timer was started
- See Also:
Session.getIdleTimeoutStart()
-
getTimeoutStatus
public TimeoutIndicator getTimeoutStatus()
Description copied from interface:SessionCheck if timeout has occurred.- Specified by:
getTimeoutStatusin interfaceSession- Returns:
- the timeout status - never
null
-
getReservedSessionMessagesHandler
public ReservedSessionMessagesHandler getReservedSessionMessagesHandler()
- Specified by:
getReservedSessionMessagesHandlerin interfaceReservedSessionMessagesManager- Returns:
- The currently registered
ReservedSessionMessagesHandler- may benull
-
setReservedSessionMessagesHandler
public void setReservedSessionMessagesHandler(ReservedSessionMessagesHandler handler)
- Specified by:
setReservedSessionMessagesHandlerin interfaceReservedSessionMessagesManager- Parameters:
handler- TheReservedSessionMessagesHandlerto use - may benull
-
getSessionDisconnectHandler
public SessionDisconnectHandler getSessionDisconnectHandler()
- Specified by:
getSessionDisconnectHandlerin interfaceSessionDisconnectHandlerManager
-
setSessionDisconnectHandler
public void setSessionDisconnectHandler(SessionDisconnectHandler sessionDisconnectHandler)
- Specified by:
setSessionDisconnectHandlerin interfaceSessionDisconnectHandlerManager
-
doInvokeIgnoreMessageHandler
protected void doInvokeIgnoreMessageHandler(Buffer buffer) throws Exception
Invoked byhandleDebug(Buffer)after validating that the buffer structure seems well-formed and also resetting the idle timeout. By default, retrieves theReservedSessionMessagesHandlerand invokes itshandleIgnoreMessagemethod.
-
sendNotImplemented
protected IoWriteFuture sendNotImplemented(long seqNoValue) throws IOException
Sends aSSH_MSG_UNIMPLEMENTEDmessage- Parameters:
seqNoValue- The referenced sequence number- Returns:
- An
IoWriteFuturethat can be used to wait for packet write completion - Throws:
IOException- if an error occurred sending the packet
-
handleUnimplemented
protected void handleUnimplemented(Buffer buffer) throws Exception
- Throws:
Exception
-
doInvokeUnimplementedMessageHandler
protected boolean doInvokeUnimplementedMessageHandler(int cmd, Buffer buffer) throws Exception- Parameters:
cmd- The unimplemented commandbuffer- The inputBuffer- Returns:
- Result of invoking
handleUnimplementedMessage - Throws:
Exception- if failed to handle the message
-
sendDebugMessage
public IoWriteFuture sendDebugMessage(boolean display, Object msg, String lang) throws IOException
Description copied from interface:SessionSends anSSH_MSG_DEBUGto the peer session- Specified by:
sendDebugMessagein interfaceSession- Parameters:
display-trueif OK to display the message at the peer as-ismsg- The message object whosetoString()value to be used - ifnullthen the "null" string is sentlang- The language -null/empty if some pre-agreed default is used- Returns:
- An
IoWriteFuturethat can be used to check when the packet has actually been sent - Throws:
IOException- if an error occurred when encoding or sending the packet- See Also:
- RFC 4253 - section 11.3
-
doInvokeDebugMessageHandler
protected void doInvokeDebugMessageHandler(Buffer buffer) throws Exception
Invoked byhandleDebug(Buffer)after validating that the buffer structure seems well-formed and also resetting the idle timeout. By default, retrieves theReservedSessionMessagesHandlerand invokes itshandleDebugMessagemethod.
-
resolveReservedSessionMessagesHandler
protected ReservedSessionMessagesHandler resolveReservedSessionMessagesHandler()
-
getUnknownChannelReferenceHandler
public UnknownChannelReferenceHandler getUnknownChannelReferenceHandler()
- Specified by:
getUnknownChannelReferenceHandlerin interfaceUnknownChannelReferenceHandlerManager- Returns:
- The
UnknownChannelReferenceHandlerManagerto use - ifnullthen any reference to unknown channel causes anSshChannelNotFoundException
-
setUnknownChannelReferenceHandler
public void setUnknownChannelReferenceHandler(UnknownChannelReferenceHandler unknownChannelReferenceHandler)
- Specified by:
setUnknownChannelReferenceHandlerin interfaceUnknownChannelReferenceHandlerManager- Parameters:
unknownChannelReferenceHandler- TheUnknownChannelReferenceHandlerManagerto use - ifnullthen any reference to unknown channel causes anSshChannelNotFoundException
-
resolveUnknownChannelReferenceHandler
public UnknownChannelReferenceHandler resolveUnknownChannelReferenceHandler()
Description copied from interface:UnknownChannelReferenceHandlerManagerCheck if current manager has a specific handler set for it - if not, try and resolve one from the "parent" container (if any)- Specified by:
resolveUnknownChannelReferenceHandlerin interfaceUnknownChannelReferenceHandlerManager- Returns:
- The resolved handler instance
-
getChannelStreamWriterResolver
public ChannelStreamWriterResolver getChannelStreamWriterResolver()
- Specified by:
getChannelStreamWriterResolverin interfaceChannelStreamWriterResolverManager
-
setChannelStreamWriterResolver
public void setChannelStreamWriterResolver(ChannelStreamWriterResolver resolver)
- Specified by:
setChannelStreamWriterResolverin interfaceChannelStreamWriterResolverManager
-
resolveChannelStreamWriterResolver
public ChannelStreamWriterResolver resolveChannelStreamWriterResolver()
- Specified by:
resolveChannelStreamWriterResolverin interfaceChannelStreamWriterResolverManager
-
sendIgnoreMessage
public IoWriteFuture sendIgnoreMessage(byte... data) throws IOException
Description copied from interface:SessionSends anSSH_MSG_IGNOREto the peer session- Specified by:
sendIgnoreMessagein interfaceSession- Parameters:
data- The message data- Returns:
- An
IoWriteFuturethat can be used to check when the packet has actually been sent - Throws:
IOException- if an error occurred when encoding or sending the packet- See Also:
- RFC 4253 - section 11.2
-
signalSessionEstablished
protected void signalSessionEstablished(IoSession ioSession) throws Exception
- Throws:
Exception
-
signalSessionEstablished
protected void signalSessionEstablished(SessionListener listener)
-
signalSessionCreated
protected void signalSessionCreated(IoSession ioSession) throws Exception
- Throws:
Exception
-
signalSessionCreated
protected void signalSessionCreated(SessionListener listener)
-
signalSendIdentification
protected void signalSendIdentification(String version, List<String> extraLines) throws Exception
- Throws:
Exception
-
signalSendIdentification
protected void signalSendIdentification(SessionListener listener, String version, List<String> extraLines)
-
signalReadPeerIdentificationLine
protected void signalReadPeerIdentificationLine(String line, List<String> extraLines) throws Exception
- Throws:
Exception
-
signalReadPeerIdentificationLine
protected void signalReadPeerIdentificationLine(SessionListener listener, String version, List<String> extraLines)
-
signalPeerIdentificationReceived
protected void signalPeerIdentificationReceived(String version, List<String> extraLines) throws Exception
- Throws:
Exception
-
signalPeerIdentificationReceived
protected void signalPeerIdentificationReceived(SessionListener listener, String version, List<String> extraLines)
-
signalSessionEvent
protected void signalSessionEvent(SessionListener.Event event) throws Exception
Sends a session event to all currently registered session listeners- Parameters:
event- The event to send- Throws:
Exception- If any of the registered listeners threw an exception.
-
signalSessionEvent
protected void signalSessionEvent(SessionListener listener, SessionListener.Event event) throws IOException
- Throws:
IOException
-
invokeSessionSignaller
protected void invokeSessionSignaller(Invoker<SessionListener,Void> invoker) throws Throwable
- Throws:
Throwable
-
resizeKey
protected byte[] resizeKey(byte[] e, int kdfSize, Digest hash, byte[] k, byte[] h) throws ExceptionMethod used while putting new keys into use that will resize the key used to initialize the cipher to the needed length.- Parameters:
e- the key to resizekdfSize- the cipher key-derivation-factor (in bytes)hash- the hash algorithmk- the key exchange k parameterh- the key exchange h parameter- Returns:
- the resized key
- Throws:
Exception- if a problem occur while resizing the key
-
resolvePeerAddress
protected SocketAddress resolvePeerAddress(SocketAddress knownAddress)
- Parameters:
knownAddress- Any externally set peer address - e.g., due to some proxy mechanism meta-data- Returns:
- The external address if not
nullotherwise, theIoSessionpeer address
-
calculateNextIgnorePacketCount
protected long calculateNextIgnorePacketCount(Random r, long freq, int variance)
-
resolveIdentificationString
protected String resolveIdentificationString(String configPropName)
Resolves the identification to send to the peer session by consulting the associatedFactoryManager. If a value is set, then it is appended to the standardSessionContext.DEFAULT_SSH_VERSION_PREFIX. Otherwise a default value is returned consisting of the prefix and the core artifact name + version in uppercase - e.g.,' "SSH-2.0-APACHE-SSHD-1.2.3.4"- Parameters:
configPropName- The property used to query the factory manager- Returns:
- The resolved identification value
-
sendIdentification
protected IoWriteFuture sendIdentification(String version, List<String> extraLines) throws Exception
Send our identification.- Parameters:
version- our identification to sendextraLines- Extra lines to send - used only by server sessions- Returns:
IoWriteFuturethat can be used to wait for notification that identification has been send- Throws:
Exception- If failed to send the packet
-
doReadIdentification
protected List<String> doReadIdentification(Buffer buffer, boolean server) throws Exception
Read the remote identification from this buffer. If more data is needed, the buffer will be reset to its original state and anullvalue will be returned. Else the identification string will be returned and the data read will be consumed from the buffer.- Parameters:
buffer- the buffer containing the identification stringserver-trueif it is called by the server session,falseif by the client session- Returns:
- A
Listof all received remote identification lines until the version line was read ornullif more data is needed. The identification line is the last one in the list - Throws:
Exception- if malformed identification found
-
resolveSessionKexProposal
protected String resolveSessionKexProposal(String hostKeyTypes) throws IOException
- Throws:
IOException
-
resolveAvailableSignaturesProposal
protected String resolveAvailableSignaturesProposal() throws IOException, GeneralSecurityException
Computes the list of available host key signature algorithms supported.- Returns:
- A comma-separated list of all the signature protocols to be included in the
proposal -
null/empty if no proposal - Throws:
IOException- If failed to read/parse the keys dataGeneralSecurityException- If failed to generate the keys- See Also:
getFactoryManager(),resolveAvailableSignaturesProposal(FactoryManager)
-
resolveAvailableSignaturesProposal
protected abstract String resolveAvailableSignaturesProposal(FactoryManager manager) throws IOException, GeneralSecurityException
Computes the list of available host key signature algorithms supported.- 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:
IOException- If failed to read/parse the keys dataGeneralSecurityException- If failed to generate the keys
-
getKexProposal
protected Map<KexProposalOption,String> getKexProposal() throws Exception
Retrieves this side's initial proposal for KEX negotiation. If no proposal exists yet, one is created and passed though theKexExtensionHandlerand theSessionListenerfor customization, otherwise the previously created proposal for the session is returned.
-
createProposal
protected Map<KexProposalOption,String> createProposal(String hostKeyTypes) throws IOException
Create our proposal for SSH negotiation- Parameters:
hostKeyTypes- The comma-separated list of supported host key types- Returns:
- The proposal
Map - Throws:
IOException- If internal problem - e.g., KEX extensions negotiation issue
-
mergeProposals
protected Map<KexProposalOption,String> mergeProposals(Map<KexProposalOption,String> current, Map<KexProposalOption,String> proposal)
-
signalNegotiationOptionsCreated
protected void signalNegotiationOptionsCreated(Map<KexProposalOption,String> proposal)
-
signalNegotiationOptionsCreated
protected void signalNegotiationOptionsCreated(SessionListener listener, Map<KexProposalOption,String> proposal)
-
signalNegotiationStart
protected void signalNegotiationStart(Map<KexProposalOption,String> c2sOptions, Map<KexProposalOption,String> s2cOptions)
-
signalNegotiationStart
protected void signalNegotiationStart(SessionListener listener, Map<KexProposalOption,String> c2sOptions, Map<KexProposalOption,String> s2cOptions)
-
signalNegotiationEnd
protected void signalNegotiationEnd(Map<KexProposalOption,String> c2sOptions, Map<KexProposalOption,String> s2cOptions, Map<KexProposalOption,String> negotiatedGuess, Throwable reason)
-
signalNegotiationEnd
protected void signalNegotiationEnd(SessionListener listener, Map<KexProposalOption,String> c2sOptions, Map<KexProposalOption,String> s2cOptions, Map<KexProposalOption,String> negotiatedGuess, Throwable reason)
-
preProcessEncodeBuffer
protected Buffer preProcessEncodeBuffer(int cmd, Buffer buffer) throws IOException
Invoked 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.- 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:
IOException- If failed to process the buffer
-
disconnect
public void disconnect(int reason, String msg) throws IOExceptionDescription copied from interface:SessionSend a disconnect packet with the given reason and message. Once the packet has been sent, the session will be closed asynchronously.- Specified by:
disconnectin interfaceSession- Parameters:
reason- the reason code for this disconnectmsg- the text message- Throws:
IOException- if an error occurred sending the packet
-
handleDisconnect
protected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception- Throws:
Exception
-
signalDisconnect
protected void signalDisconnect(int code, String msg, String lang, boolean initiator)
-
signalDisconnect
protected void signalDisconnect(SessionListener listener, int code, String msg, String lang, boolean initiator)
-
exceptionCaught
public void exceptionCaught(Throwable t)
Handle any exceptions that occurred on this session. The session will be closed and a disconnect packet will be sent before if the given exception is anSshException.- Specified by:
exceptionCaughtin interfaceSession- Parameters:
t- the exception to process
-
signalExceptionCaught
protected void signalExceptionCaught(Throwable t)
-
signalExceptionCaught
protected void signalExceptionCaught(SessionListener listener, Throwable t)
-
signalSessionClosed
protected void signalSessionClosed()
-
signalSessionClosed
protected void signalSessionClosed(SessionListener listener)
-
getConnectionService
protected abstract ConnectionService getConnectionService()
-
getForwarder
protected Forwarder getForwarder()
-
getLocalForwardsBindings
public List<Map.Entry<SshdSocketAddress,SshdSocketAddress>> getLocalForwardsBindings()
- Specified by:
getLocalForwardsBindingsin interfacePortForwardingInformationProvider- Returns:
- A snapshot of the currently bound forwarded local ports as "pairs" of local/remote
SshdSocketAddress-es
-
isLocalPortForwardingStartedForPort
public boolean isLocalPortForwardingStartedForPort(int port)
Description copied from interface:PortForwardingInformationProviderTest if local port forwarding is started- Specified by:
isLocalPortForwardingStartedForPortin interfacePortForwardingInformationProvider- Parameters:
port- The local port- Returns:
trueif local port forwarding is started- See Also:
getBoundLocalPortForwards
-
getStartedLocalPortForwards
public List<SshdSocketAddress> getStartedLocalPortForwards()
- Specified by:
getStartedLocalPortForwardsin interfacePortForwardingInformationProvider- Returns:
- A
Listsnapshot of the currently started local port forward bindings
-
getBoundLocalPortForwards
public List<SshdSocketAddress> getBoundLocalPortForwards(int port)
- Specified by:
getBoundLocalPortForwardsin interfacePortForwardingInformationProvider- Parameters:
port- The port number- Returns:
- The local bound
SshdSocketAddress-es for the port - See Also:
isLocalPortForwardingStartedForPort,PortForwardingInformationProvider.getStartedLocalPortForwards()
-
getRemoteForwardsBindings
public List<Map.Entry<Integer,SshdSocketAddress>> getRemoteForwardsBindings()
- Specified by:
getRemoteForwardsBindingsin interfacePortForwardingInformationProvider- Returns:
- A snapshot of the currently bound forwarded remote ports as "pairs" of port + bound
SshdSocketAddress
-
isRemotePortForwardingStartedForPort
public boolean isRemotePortForwardingStartedForPort(int port)
Description copied from interface:PortForwardingInformationProviderTest if remote port forwarding is started- Specified by:
isRemotePortForwardingStartedForPortin interfacePortForwardingInformationProvider- Parameters:
port- The remote port- Returns:
trueif remote port forwarding is started- See Also:
getBoundRemotePortForward
-
getStartedRemotePortForwards
public NavigableSet<Integer> getStartedRemotePortForwards()
- Specified by:
getStartedRemotePortForwardsin interfacePortForwardingInformationProvider- Returns:
- A
NavigableSetsnapshot of the currently started remote port forwards
-
getBoundRemotePortForward
public SshdSocketAddress getBoundRemotePortForward(int port)
- Specified by:
getBoundRemotePortForwardin interfacePortForwardingInformationProvider- Parameters:
port- The port number- Returns:
- The remote bound
SshdSocketAddressfor the port -nullif none bound - See Also:
isRemotePortForwardingStartedForPort,PortForwardingInformationProvider.getStartedRemotePortForwards()
-
getAuthTimeout
public Duration getAuthTimeout()
- Specified by:
getAuthTimeoutin interfaceSession- Returns:
- Timeout value in milliseconds for authentication stage
-
getIdleTimeout
public Duration getIdleTimeout()
- Specified by:
getIdleTimeoutin interfaceSession- Returns:
- Timeout value in milliseconds for communication
-
-