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, 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:
AbstractSession
Contains split code in order to make
AbstractSession class smaller-
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 Instantprotected InstantStores 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, 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
ConstructorsModifierConstructorDescriptionprotectedSessionHelper(boolean serverSession, FactoryManager factoryManager, org.apache.sshd.common.io.IoSession ioSession) Create a new session. -
Method Summary
Modifier and TypeMethodDescriptionCollection<org.apache.sshd.common.AttributeRepository.AttributeKey<?>> protected org.apache.sshd.common.session.helpers.TimeoutIndicatorcheckAuthenticationTimeout(Instant now, Duration authTimeout) Checks if authentication timeout expiredprotected org.apache.sshd.common.session.helpers.TimeoutIndicatorChecks whether the session has timed out (both authentication and idle timeouts are checked).protected org.apache.sshd.common.session.helpers.TimeoutIndicatorcheckIdleTimeout(Instant now, Duration idleTimeout) Checks if idle timeout expiredvoid<T> TcomputeAttributeIfAbsent(org.apache.sshd.common.AttributeRepository.AttributeKey<T> key, Function<? super org.apache.sshd.common.AttributeRepository.AttributeKey<T>, ? extends T> resolver) createProposal(String hostKeyTypes) Create our proposal for SSH negotiationvoiddisconnect(int reason, String msg) Send a disconnect packet with the given reason and message.protected voiddoInvokeDebugMessageHandler(org.apache.sshd.common.util.buffer.Buffer buffer) Invoked byhandleDebug(Buffer)after validating that the buffer structure seems well-formed and also resetting the idle timeout.protected voiddoInvokeIgnoreMessageHandler(org.apache.sshd.common.util.buffer.Buffer buffer) Invoked byhandleDebug(Buffer)after validating that the buffer structure seems well-formed and also resetting the idle timeout.protected booleandoInvokeUnimplementedMessageHandler(int cmd, org.apache.sshd.common.util.buffer.Buffer buffer) doReadIdentification(org.apache.sshd.common.util.buffer.Buffer buffer, boolean server) Read the remote identification from this buffer.voidHandle any exceptions that occurred on this session.<T> TgetAttribute(org.apache.sshd.common.AttributeRepository.AttributeKey<T> key) intList<org.apache.sshd.common.util.net.SshdSocketAddress> getBoundLocalPortForwards(int port) org.apache.sshd.common.util.net.SshdSocketAddressgetBoundRemotePortForward(int port) protected abstract ConnectionServiceprotected Forwarderorg.apache.sshd.common.io.IoSessionRetrieves this side's initial proposal for KEX negotiation.List<Map.Entry<org.apache.sshd.common.util.net.SshdSocketAddress, org.apache.sshd.common.util.net.SshdSocketAddress>> org.apache.sshd.common.PropertyResolverList<org.apache.sshd.common.util.net.SshdSocketAddress> org.apache.sshd.common.session.helpers.TimeoutIndicatorCheck if timeout has occurred.protected voidhandleDebug(org.apache.sshd.common.util.buffer.Buffer buffer) protected voidhandleDisconnect(int code, String msg, String lang, org.apache.sshd.common.util.buffer.Buffer buffer) protected voidhandleDisconnect(org.apache.sshd.common.util.buffer.Buffer buffer) protected voidhandleIgnore(org.apache.sshd.common.util.buffer.Buffer buffer) protected voidhandleUnimplemented(org.apache.sshd.common.util.buffer.Buffer buffer) protected voidinvokeSessionSignaller(Consumer<SessionListener> listener) booleanbooleanisLocalPortForwardingStartedForPort(int port) Test if local port forwarding is startedbooleanisRemotePortForwardingStartedForPort(int port) Test if remote port forwarding is startedbooleanmergeProposals(Map<org.apache.sshd.common.kex.KexProposalOption, String> current, Map<org.apache.sshd.common.kex.KexProposalOption, String> proposal) <T> TremoveAttribute(org.apache.sshd.common.AttributeRepository.AttributeKey<T> key) Re-start the authentication timeout timerRe-start idle timeout timerprotected StringComputes the list of available host key signature algorithms supported.protected abstract StringComputes the list of available host key signature algorithms supported.protected StringresolveIdentificationString(String configPropName) Resolves the identification to send to the peer session by consulting the associatedFactoryManager.protected SocketAddressresolvePeerAddress(SocketAddress knownAddress) protected ReservedSessionMessagesHandlerprotected StringresolveSessionKexProposal(String hostKeyTypes) Check if current manager has a specific handler set for it - if not, try and resolve one from the "parent" container (if any)org.apache.sshd.common.io.IoWriteFuturesendDebugMessage(boolean display, Object msg, String lang) Sends anSSH_MSG_DEBUGto the peer sessionorg.apache.sshd.common.io.IoWriteFuturesendIgnoreMessage(byte... data) Sends anSSH_MSG_IGNOREto the peer sessionprotected org.apache.sshd.common.io.IoWriteFuturesendNotImplemented(long seqNoValue) Sends aSSH_MSG_UNIMPLEMENTEDmessage<T> TsetAttribute(org.apache.sshd.common.AttributeRepository.AttributeKey<T> key, T value) voidvoidvoidvoidsetSessionDisconnectHandler(SessionDisconnectHandler sessionDisconnectHandler) voidsetUnknownChannelReferenceHandler(UnknownChannelReferenceHandler unknownChannelReferenceHandler) voidsetUsername(String username) protected voidsignalDisconnect(int code, String msg, String lang, boolean initiator) protected voidprotected voidsignalNegotiationEnd(Map<org.apache.sshd.common.kex.KexProposalOption, String> c2sOptions, Map<org.apache.sshd.common.kex.KexProposalOption, String> s2cOptions, Map<org.apache.sshd.common.kex.KexProposalOption, String> negotiatedGuess, Throwable reason) protected voidsignalNegotiationOptionsCreated(Map<org.apache.sshd.common.kex.KexProposalOption, String> proposal) protected voidsignalNegotiationStart(Map<org.apache.sshd.common.kex.KexProposalOption, String> c2sOptions, Map<org.apache.sshd.common.kex.KexProposalOption, String> s2cOptions) protected voidsignalPeerIdentificationReceived(String version, List<String> extraLines) protected voidsignalReadPeerIdentificationLine(String version, List<String> extraLines) protected voidsignalSendIdentification(String version, List<String> extraLines) protected voidprotected voidsignalSessionCreated(org.apache.sshd.common.io.IoSession ioSession) protected voidSends a session event to all currently registered session listenersprotected voidtoString()Methods 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, doCloseImmediately, getInnerCloseableMethods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, preClose, 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 ChannelListenerManager
addChannelListener, getChannelListenerProxy, removeChannelListenerMethods 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 PortForwardingEventListenerManager
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListenerMethods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getString, getStringProperty, isEmptyMethods inherited from interface Session
createBuffer, createBuffer, getFilterChain, getLocalAddress, getRemoteAddress, getService, prepareBuffer, reExchangeKeys, request, request, request, request, resolveAttribute, startService, writePacket, writePacket, writePacket, writePacketMethods inherited from interface org.apache.sshd.common.session.SessionContext
getCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionIdMethods inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeatMethods inherited from interface SessionListenerManager
addSessionListener, getSessionListenerProxy, removeSessionListenerMethods 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
-
authStart
-
idleStart
-
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 Details
-
SessionHelper
protected SessionHelper(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
-
getIoSession
public org.apache.sshd.common.io.IoSession getIoSession()- Specified by:
getIoSessionin interfaceSession- Returns:
- The
IoSessionassociated to this session
-
isServerSession
public boolean isServerSession()- Specified by:
isServerSessionin interfaceorg.apache.sshd.common.session.SessionContext
-
getFactoryManager
- Specified by:
getFactoryManagerin interfaceFactoryManagerHolder- Returns:
- The currently associated
FactoryManager
-
getParentPropertyResolver
public org.apache.sshd.common.PropertyResolver getParentPropertyResolver()- Specified by:
getParentPropertyResolverin interfaceorg.apache.sshd.common.PropertyResolver
-
getProperties
-
getAttributesCount
public int getAttributesCount()- Specified by:
getAttributesCountin interfaceorg.apache.sshd.common.AttributeRepository
-
getAttribute
public <T> T getAttribute(org.apache.sshd.common.AttributeRepository.AttributeKey<T> key) - Specified by:
getAttributein interfaceorg.apache.sshd.common.AttributeRepository
-
attributeKeys
- Specified by:
attributeKeysin interfaceorg.apache.sshd.common.AttributeRepository
-
computeAttributeIfAbsent
public <T> T computeAttributeIfAbsent(org.apache.sshd.common.AttributeRepository.AttributeKey<T> key, Function<? super org.apache.sshd.common.AttributeRepository.AttributeKey<T>, ? extends T> resolver) - Specified by:
computeAttributeIfAbsentin interfaceorg.apache.sshd.common.AttributeStore
-
setAttribute
public <T> T setAttribute(org.apache.sshd.common.AttributeRepository.AttributeKey<T> key, T value) - Specified by:
setAttributein interfaceorg.apache.sshd.common.AttributeStore
-
removeAttribute
public <T> T removeAttribute(org.apache.sshd.common.AttributeRepository.AttributeKey<T> key) - Specified by:
removeAttributein interfaceorg.apache.sshd.common.AttributeStore
-
clearAttributes
public void clearAttributes()- Specified by:
clearAttributesin interfaceorg.apache.sshd.common.AttributeStore
-
getUsername
- Specified by:
getUsernamein interfaceorg.apache.sshd.common.auth.UsernameHolder
-
setUsername
- Specified by:
setUsernamein interfaceorg.apache.sshd.common.auth.MutableUserHolder
-
isAuthenticated
public boolean isAuthenticated()- Specified by:
isAuthenticatedin interfaceorg.apache.sshd.common.session.SessionContext
-
setAuthenticated
- Specified by:
setAuthenticatedin interfaceSession- Throws:
IOException
-
checkForTimeouts
protected org.apache.sshd.common.session.helpers.TimeoutIndicator checkForTimeouts() throws IOExceptionChecks 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:
-
getAuthTimeoutStart
- Specified by:
getAuthTimeoutStartin interfaceSession- Returns:
- The timestamp value (milliseconds since EPOCH) when timer was started
-
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:
-
checkAuthenticationTimeout
protected org.apache.sshd.common.session.helpers.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:
-
getIdleTimeoutStart
- Specified by:
getIdleTimeoutStartin interfaceSession- Returns:
- The timestamp value (milliseconds since EPOCH) when timer was started
-
checkIdleTimeout
protected org.apache.sshd.common.session.helpers.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:
-
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:
-
getTimeoutStatus
public org.apache.sshd.common.session.helpers.TimeoutIndicator getTimeoutStatus()Description copied from interface:SessionCheck if timeout has occurred.- Specified by:
getTimeoutStatusin interfaceSession- Returns:
- the timeout status - never
null
-
getReservedSessionMessagesHandler
- Specified by:
getReservedSessionMessagesHandlerin interfaceReservedSessionMessagesManager- Returns:
- The currently registered
ReservedSessionMessagesHandler- may benull
-
setReservedSessionMessagesHandler
- Specified by:
setReservedSessionMessagesHandlerin interfaceReservedSessionMessagesManager- Parameters:
handler- TheReservedSessionMessagesHandlerto use - may benull
-
getSessionDisconnectHandler
- Specified by:
getSessionDisconnectHandlerin interfaceSessionDisconnectHandlerManager
-
setSessionDisconnectHandler
- Specified by:
setSessionDisconnectHandlerin interfaceSessionDisconnectHandlerManager
-
handleIgnore
-
doInvokeIgnoreMessageHandler
protected void doInvokeIgnoreMessageHandler(org.apache.sshd.common.util.buffer.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.- Parameters:
buffer- The inputBuffer- Throws:
Exception- if failed to handle the message
-
sendNotImplemented
protected org.apache.sshd.common.io.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
-
doInvokeUnimplementedMessageHandler
protected boolean doInvokeUnimplementedMessageHandler(int cmd, org.apache.sshd.common.util.buffer.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 org.apache.sshd.common.io.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:
-
handleDebug
-
doInvokeDebugMessageHandler
protected void doInvokeDebugMessageHandler(org.apache.sshd.common.util.buffer.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.- Parameters:
buffer- The inputBuffer- Throws:
Exception- if failed to handle the message
-
resolveReservedSessionMessagesHandler
-
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
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
- Specified by:
getChannelStreamWriterResolverin interfaceChannelStreamWriterResolverManager
-
setChannelStreamWriterResolver
- Specified by:
setChannelStreamWriterResolverin interfaceChannelStreamWriterResolverManager
-
resolveChannelStreamWriterResolver
- Specified by:
resolveChannelStreamWriterResolverin interfaceChannelStreamWriterResolverManager
-
sendIgnoreMessage
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:
-
signalSessionCreated
-
signalSessionStarting
-
signalSendIdentification
-
signalReadPeerIdentificationLine
-
signalPeerIdentificationReceived
-
signalNegotiationOptionsCreated
-
signalNegotiationStart
-
signalNegotiationEnd
-
signalSessionEvent
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.
-
signalDisconnect
-
signalExceptionCaught
-
signalSessionClosed
protected void signalSessionClosed() -
invokeSessionSignaller
- Throws:
Throwable
-
resolvePeerAddress
- 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
-
resolveIdentificationString
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
-
doReadIdentification
protected List<String> doReadIdentification(org.apache.sshd.common.util.buffer.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
- Throws:
IOException
-
resolveAvailableSignaturesProposal
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:
-
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<org.apache.sshd.common.kex.KexProposalOption, String> getKexProposal() throws ExceptionRetrieves 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<org.apache.sshd.common.kex.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
-
disconnect
Description 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
-
handleDisconnect
-
exceptionCaught
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
-
getConnectionService
-
getForwarder
-
getLocalForwardsBindings
public List<Map.Entry<org.apache.sshd.common.util.net.SshdSocketAddress, org.apache.sshd.common.util.net.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:
-
getStartedLocalPortForwards
- Specified by:
getStartedLocalPortForwardsin interfacePortForwardingInformationProvider- Returns:
- A
Listsnapshot of the currently started local port forward bindings
-
getBoundLocalPortForwards
- Specified by:
getBoundLocalPortForwardsin interfacePortForwardingInformationProvider- Parameters:
port- The port number- Returns:
- The local bound
SshdSocketAddress-es for the port - See Also:
-
getRemoteForwardsBindings
public List<Map.Entry<Integer, org.apache.sshd.common.util.net.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:
-
getStartedRemotePortForwards
- Specified by:
getStartedRemotePortForwardsin interfacePortForwardingInformationProvider- Returns:
- A
NavigableSetsnapshot of the currently started remote port forwards
-
getBoundRemotePortForward
public org.apache.sshd.common.util.net.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:
-
getAuthTimeout
- Specified by:
getAuthTimeoutin interfaceSession- Returns:
- Timeout value in milliseconds for authentication stage
-
getIdleTimeout
- Specified by:
getIdleTimeoutin interfaceSession- Returns:
- Timeout value in milliseconds for communication
-
toString
-