Class AbstractServerSession
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
org.apache.sshd.server.session.AbstractServerSession
- 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.UserAuthFactoriesManager<ServerSession, UserAuth, UserAuthFactory>, org.apache.sshd.common.auth.UsernameHolder, ChannelListenerManager, ChannelStreamWriterResolver, ChannelStreamWriterResolverManager, org.apache.sshd.common.Closeable, FactoryManagerHolder, PortForwardingEventListenerManager, PortForwardingInformationProvider, KexExtensionHandlerManager, KexFactoryManager, org.apache.sshd.common.keyprovider.KeyPairProviderHolder, 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, ServerAuthenticationManager, ServerSession
- Direct Known Subclasses:
ServerSessionImpl
Provides default implementations for
ServerSession related methods- Author:
- Apache MINA SSHD Project
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable.StateNested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
org.apache.sshd.common.AttributeRepository.AttributeKey<T>Nested classes/interfaces inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
org.apache.sshd.common.session.SessionHeartbeatController.HeartbeatType -
Field Summary
Fields inherited from class AbstractSession
channelListenerProxy, channelListeners, clientVersion, currentService, random, serverVersion, SESSION, sessionListenerProxy, sessionListeners, tunnelListenerProxy, tunnelListenersFields inherited from class SessionHelper
authStart, idleStart, initialKexProposalFields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, stateFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
logFields inherited from interface ChannelStreamWriterResolver
NONEFields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTYFields inherited from interface ServerAuthenticationManager
DEFAULT_USER_AUTH_GSS_FACTORY, DEFAULT_USER_AUTH_KB_INTERACTIVE_FACTORY, DEFAULT_USER_AUTH_PASSWORD_FACTORY, DEFAULT_USER_AUTH_PUBLIC_KEY_FACTORYFields inherited from interface org.apache.sshd.common.session.SessionContext
DEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractServerSession(ServerFactoryManager factoryManager, org.apache.sshd.common.io.IoSession ioSession) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidIndicates the the key exchange is completed and the exchanged keys can now be verified - e.g., client can verify the server's keyintgetActiveSessionCountForUser(String userName) Retrieve the current number of sessions active for a given username.protected ConnectionServiceRetrieve theGSSAuthenticatorto be used by the SSH server.Retrieve theHostBasedAuthenticatorto be used by the SSH server.org.apache.sshd.common.keyprovider.HostKeyCertificateProviderlonggetId()Retrieve theKeyboardInteractiveAuthenticatorto be used by the SSH server.org.apache.sshd.common.keyprovider.KeyPairProviderRetrieve thePasswordAuthenticatorto be used by the SSH server.Retrieve thePublickeyAuthenticatorto be used by SSH server.protected voidhandleServiceAccept(String serviceName, org.apache.sshd.common.util.buffer.Buffer buffer) protected booleanhandleServiceRequest(String serviceName, org.apache.sshd.common.util.buffer.Buffer buffer) protected booleanreadIdentification(org.apache.sshd.common.util.buffer.Buffer buffer) Read the other side identification.protected StringresolveAvailableSignaturesProposal(FactoryManager proposedManager) Computes the list of available host key signature algorithms supported.protected StringresolveEmptySignaturesProposal(Iterable<String> supported, Iterable<String> provided) Called byresolveAvailableSignaturesProposal(FactoryManager)if none of the provided keys is supported - last chance for the derived implementation to do somethingvoidsetClientAddress(SocketAddress clientAddress) voidsetGSSAuthenticator(GSSAuthenticator gssAuthenticator) voidsetHostBasedAuthenticator(HostBasedAuthenticator hostBasedAuthenticator) voidsetHostKeyCertificateProvider(org.apache.sshd.common.keyprovider.HostKeyCertificateProvider hostKeyCertificateProvider) voidsetKeyboardInteractiveAuthenticator(KeyboardInteractiveAuthenticator interactiveAuthenticator) voidsetKeyPairProvider(org.apache.sshd.common.keyprovider.KeyPairProvider keyPairProvider) voidsetPasswordAuthenticator(PasswordAuthenticator passwordAuthenticator) voidsetPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator) voidsetUserAuthFactories(List<UserAuthFactory> userAuthFactories) org.apache.sshd.common.io.IoWriteFuturesignalAuthenticationSuccess(String username, String authService, org.apache.sshd.common.util.buffer.Buffer buffer) voidstartService(String name, org.apache.sshd.common.util.buffer.Buffer buffer) Methods inherited from class AbstractSession
addChannelListener, addKexListener, addPortForwardingEventListener, addSessionListener, attachSession, createBuffer, doInvokeUnimplementedMessageHandler, getChannelListenerProxy, getCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getCurrentService, getFilterChain, getInnerCloseable, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getPortForwardingEventListenerProxy, getServerKexProposals, getServerVersion, getService, getServices, getSession, getSession, getSessionId, getSessionListenerProxy, getTransport, handleKexExtension, handleMessage, handleNewCompression, handleServiceAccept, handleServiceRequest, initializeCurrentService, initializeKeyExchangePhase, isConnectionSecure, isStrictKex, notImplemented, preClose, prepareBuffer, reExchangeKeys, removeChannelListener, removeKexListener, removePortForwardingEventListener, removeSessionListener, request, request, resolveSessionKexProposal, setupFilterChain, start, validateTargetBuffer, writePacket, writePacketMethods inherited from class SessionHelper
attributeKeys, checkAuthenticationTimeout, checkForTimeouts, checkIdleTimeout, clearAttributes, computeAttributeIfAbsent, createProposal, disconnect, doInvokeDebugMessageHandler, doInvokeIgnoreMessageHandler, doReadIdentification, exceptionCaught, getAttribute, getAttributesCount, getAuthTimeout, getAuthTimeoutStart, getBoundLocalPortForwards, getBoundRemotePortForward, getChannelStreamWriterResolver, getForwarder, getIdleTimeout, getIdleTimeoutStart, getIoSession, getKexProposal, getLocalForwardsBindings, getParentPropertyResolver, getProperties, getRemoteForwardsBindings, getReservedSessionMessagesHandler, getSessionDisconnectHandler, getStartedLocalPortForwards, getStartedRemotePortForwards, getTimeoutStatus, getUnknownChannelReferenceHandler, getUsername, handleDebug, handleDisconnect, handleDisconnect, handleIgnore, handleUnimplemented, invokeSessionSignaller, isAuthenticated, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPort, isServerSession, mergeProposals, removeAttribute, resetAuthTimeout, resetIdleTimeout, resolveAvailableSignaturesProposal, resolveChannelStreamWriterResolver, resolveIdentificationString, resolvePeerAddress, resolveReservedSessionMessagesHandler, resolveUnknownChannelReferenceHandler, sendDebugMessage, sendIgnoreMessage, sendNotImplemented, setAttribute, setAuthenticated, setChannelStreamWriterResolver, setReservedSessionMessagesHandler, setSessionDisconnectHandler, setUnknownChannelReferenceHandler, setUsername, signalDisconnect, signalExceptionCaught, signalNegotiationEnd, signalNegotiationOptionsCreated, signalNegotiationStart, signalPeerIdentificationReceived, signalReadPeerIdentificationLine, signalSendIdentification, signalSessionClosed, signalSessionCreated, signalSessionEvent, signalSessionStarting, toStringMethods inherited from class AbstractKexFactoryManager
getCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactoriesMethods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediatelyMethods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenerMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.AttributeRepository
attributeKeys, getAttribute, getAttributesCountMethods inherited from interface org.apache.sshd.common.AttributeStore
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttributeMethods inherited from interface ChannelListenerManager
addChannelListener, getChannelListenerProxy, removeChannelListenerMethods inherited from interface ChannelStreamWriterResolverManager
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolverMethods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListenerMethods inherited from interface KexExtensionHandlerManager
getKexExtensionHandler, setKexExtensionHandlerMethods inherited from interface KexFactoryManager
getCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNamesMethods inherited from interface org.apache.sshd.common.auth.MutableUserHolder
setUsernameMethods inherited from interface PortForwardingEventListenerManager
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListenerMethods inherited from interface PortForwardingInformationProvider
getBoundLocalPortForwards, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPortMethods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmptyMethods inherited from interface ReservedSessionMessagesManager
getReservedSessionMessagesHandler, setReservedSessionMessagesHandlerMethods inherited from interface ServerAuthenticationManager
setUserAuthFactoriesNamesMethods inherited from interface Session
createBuffer, createBuffer, disconnect, exceptionCaught, getAuthTimeout, getAuthTimeoutStart, getFilterChain, getIdleTimeout, getIdleTimeoutStart, getIoSession, getLocalAddress, getRemoteAddress, getService, getTimeoutStatus, prepareBuffer, reExchangeKeys, request, request, request, request, resetAuthTimeout, resetIdleTimeout, resolveAttribute, sendDebugMessage, sendIgnoreMessage, setAuthenticated, writePacket, writePacket, writePacket, writePacketMethods inherited from interface org.apache.sshd.common.session.SessionContext
getCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionId, isAuthenticated, isServerSessionMethods inherited from interface SessionDisconnectHandlerManager
getSessionDisconnectHandler, setSessionDisconnectHandlerMethods 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, setSignatureFactoriesNamesMethods inherited from interface UnknownChannelReferenceHandlerManager
getUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandlerMethods inherited from interface org.apache.sshd.common.auth.UserAuthFactoriesManager
getUserAuthFactoriesNameList, getUserAuthFactoriesNames, setUserAuthFactoriesNameList, setUserAuthFactoriesNamesMethods inherited from interface org.apache.sshd.common.auth.UsernameHolder
getUsername
-
Constructor Details
-
AbstractServerSession
protected AbstractServerSession(ServerFactoryManager factoryManager, org.apache.sshd.common.io.IoSession ioSession)
-
-
Method Details
-
getFactoryManager
- Specified by:
getFactoryManagerin interfaceFactoryManagerHolder- Specified by:
getFactoryManagerin interfaceServerSession- Overrides:
getFactoryManagerin classSessionHelper- Returns:
- The currently associated
FactoryManager
-
getClientAddress
- Specified by:
getClientAddressin interfaceServerSession- Returns:
- The
SocketAddressof the remote client. If no proxy wrapping was used then this is the same as theIoSession#getRemoteAddress(). Otherwise, it indicates the real client's address that was somehow transmitted via the proxy meta-data
-
setClientAddress
-
getPasswordAuthenticator
Description copied from interface:ServerAuthenticationManagerRetrieve thePasswordAuthenticatorto be used by the SSH server. If no authenticator has been configured (i.e. this method returnsnull), then client authentication requests based on passwords will be rejected.- Specified by:
getPasswordAuthenticatorin interfaceServerAuthenticationManager- Returns:
- the
PasswordAuthenticatorornull
-
setPasswordAuthenticator
- Specified by:
setPasswordAuthenticatorin interfaceServerAuthenticationManager
-
getPublickeyAuthenticator
Description copied from interface:ServerAuthenticationManagerRetrieve thePublickeyAuthenticatorto be used by SSH server. If no authenticator has been configured (i.e. this method returnsnull), then client authentication requests based on keys will be rejected.- Specified by:
getPublickeyAuthenticatorin interfaceServerAuthenticationManager- Returns:
- the
PublickeyAuthenticatorornull
-
setPublickeyAuthenticator
- Specified by:
setPublickeyAuthenticatorin interfaceServerAuthenticationManager
-
getKeyboardInteractiveAuthenticator
Description copied from interface:ServerAuthenticationManagerRetrieve theKeyboardInteractiveAuthenticatorto be used by the SSH server. If no authenticator has been configured (i.e. this method returnsnull), then client authentication requests based on this method will be rejected.- Specified by:
getKeyboardInteractiveAuthenticatorin interfaceServerAuthenticationManager- Returns:
- The
KeyboardInteractiveAuthenticatorornull
-
setKeyboardInteractiveAuthenticator
public void setKeyboardInteractiveAuthenticator(KeyboardInteractiveAuthenticator interactiveAuthenticator) - Specified by:
setKeyboardInteractiveAuthenticatorin interfaceServerAuthenticationManager
-
getGSSAuthenticator
Description copied from interface:ServerAuthenticationManagerRetrieve theGSSAuthenticatorto be used by the SSH server. If no authenticator has been configured (i.e. this method returnsnull), then client authentication requests based on gssapi will be rejected.- Specified by:
getGSSAuthenticatorin interfaceServerAuthenticationManager- Returns:
- the
GSSAuthenticatorornull
-
setGSSAuthenticator
- Specified by:
setGSSAuthenticatorin interfaceServerAuthenticationManager
-
getHostBasedAuthenticator
Description copied from interface:ServerAuthenticationManagerRetrieve theHostBasedAuthenticatorto be used by the SSH server. If no authenticator has been configured (i.e. this method returnsnull), then client authentication requests based on this method will be rejected.- Specified by:
getHostBasedAuthenticatorin interfaceServerAuthenticationManager- Returns:
- the
HostBasedAuthenticatorornull
-
setHostBasedAuthenticator
- Specified by:
setHostBasedAuthenticatorin interfaceServerAuthenticationManager
-
getUserAuthFactories
- Specified by:
getUserAuthFactoriesin interfaceorg.apache.sshd.common.auth.UserAuthFactoriesManager<ServerSession, UserAuth, UserAuthFactory>
-
setUserAuthFactories
- Specified by:
setUserAuthFactoriesin interfaceorg.apache.sshd.common.auth.UserAuthFactoriesManager<ServerSession, UserAuth, UserAuthFactory>
-
getKeyPairProvider
public org.apache.sshd.common.keyprovider.KeyPairProvider getKeyPairProvider()- Specified by:
getKeyPairProviderin interfaceorg.apache.sshd.common.keyprovider.KeyPairProviderHolder
-
getHostKeyCertificateProvider
public org.apache.sshd.common.keyprovider.HostKeyCertificateProvider getHostKeyCertificateProvider()- Specified by:
getHostKeyCertificateProviderin interfaceServerAuthenticationManager- Returns:
- a
HostKeyCertificateProviderif available, null as default
-
setHostKeyCertificateProvider
public void setHostKeyCertificateProvider(org.apache.sshd.common.keyprovider.HostKeyCertificateProvider hostKeyCertificateProvider) - Specified by:
setHostKeyCertificateProviderin interfaceServerAuthenticationManager
-
setKeyPairProvider
public void setKeyPairProvider(org.apache.sshd.common.keyprovider.KeyPairProvider keyPairProvider) - Specified by:
setKeyPairProviderin interfaceorg.apache.sshd.common.keyprovider.KeyPairProviderHolder
-
checkKeys
protected void checkKeys()Description copied from class:AbstractSessionIndicates the the key exchange is completed and the exchanged keys can now be verified - e.g., client can verify the server's key- Specified by:
checkKeysin classAbstractSession
-
handleServiceRequest
protected boolean handleServiceRequest(String serviceName, org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception - Overrides:
handleServiceRequestin classAbstractSession- Throws:
Exception
-
startService
public void startService(String name, org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception - Specified by:
startServicein interfaceSession- Parameters:
name- Service namebuffer- Extra information provided when the service start request was received- Throws:
Exception- If failed to start it
-
signalAuthenticationSuccess
public org.apache.sshd.common.io.IoWriteFuture signalAuthenticationSuccess(String username, String authService, org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception Description copied from interface:ServerSession- Marks the session as authenticated.
- Starts the specified service.
- Sends the
SSH_MSG_USERAUTH_SUCCESSmessage.
- Specified by:
signalAuthenticationSuccessin interfaceServerSession- Parameters:
username- The authenticated usernameauthService- The service to startbuffer- Any extra data received to use to start the service- Returns:
- An
IoWriteFuturethat can be used to wait for theSSH_MSG_USERAUTH_SUCCESSmessage send result - Throws:
Exception- if cannot handle the request
-
handleServiceAccept
protected void handleServiceAccept(String serviceName, org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception - Overrides:
handleServiceAcceptin classAbstractSession- Throws:
Exception
-
resolveAvailableSignaturesProposal
protected String resolveAvailableSignaturesProposal(FactoryManager proposedManager) throws IOException, GeneralSecurityException Description copied from class:SessionHelperComputes the list of available host key signature algorithms supported.- Specified by:
resolveAvailableSignaturesProposalin classSessionHelper- Parameters:
proposedManager- 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
-
resolveEmptySignaturesProposal
protected String resolveEmptySignaturesProposal(Iterable<String> supported, Iterable<String> provided) Called byresolveAvailableSignaturesProposal(FactoryManager)if none of the provided keys is supported - last chance for the derived implementation to do something- Parameters:
supported- The supported key types - may benull/emptyprovided- The available signature types - may benull/empty- Returns:
- The resolved proposal -
nullby default
-
readIdentification
protected boolean readIdentification(org.apache.sshd.common.util.buffer.Buffer buffer) throws Exception Description copied from class:AbstractSessionRead 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.- Specified by:
readIdentificationin classAbstractSession- Parameters:
buffer- TheBuffercontaining the remote identification- Returns:
trueif the identification has been fully read orfalseif more data is needed- Throws:
Exception- if an error occurs such as a bad protocol version or unsuccessful KEX was involved
-
getHostKey
- Specified by:
getHostKeyin interfaceServerSession- Returns:
- The
KeyPairrepresenting the current session's used keys on KEX -nullif not negotiated yet
-
getActiveSessionCountForUser
Description copied from interface:ServerSessionRetrieve the current number of sessions active for a given username.- Specified by:
getActiveSessionCountForUserin interfaceServerSession- Parameters:
userName- The name of the user - ignored ifnull/empty- Returns:
- The current number of live
SshSessionobjects associated with the user
-
getId
public long getId()- Returns:
- The underlying
IoSessionid.
-
getConnectionService
- Specified by:
getConnectionServicein classSessionHelper
-