public abstract class AbstractServerSession extends AbstractSession implements ServerSession
ServerSession related methodsAbstractCloseable.StateSessionHeartbeatController.HeartbeatTypeAttributeRepository.AttributeKey<T>| Modifier and Type | Field and Description |
|---|---|
private java.net.SocketAddress |
clientAddress |
private GSSAuthenticator |
gssAuthenticator |
private HostBasedAuthenticator |
hostBasedAuthenticator |
private HostKeyCertificateProvider |
hostKeyCertificateProvider |
private KeyboardInteractiveAuthenticator |
interactiveAuthenticator |
private KeyPairProvider |
keyPairProvider |
private PasswordAuthenticator |
passwordAuthenticator |
private ServerProxyAcceptor |
proxyAcceptor |
private PublickeyAuthenticator |
publickeyAuthenticator |
private java.util.List<UserAuthFactory> |
userAuthFactories |
channelListenerProxy, channelListeners, clientProposal, clientVersion, currentService, decodeLock, decoderBuffer, decoderLength, decoderState, encodeLock, firstKexPacketFollows, globalRequestSeqo, ignorePacketDataLength, ignorePacketsCount, ignorePacketsFrequency, ignorePacketsVariance, inBlocksCount, inBytesCount, inCipher, inCipherSize, inCompression, inMac, inMacResult, inMacSize, inPacketsCount, kex, kexFutureHolder, kexState, lastKeyTimeValue, maxRekeyBlocks, maxRekeyBytes, maxRekeyInterval, maxRekyPackets, negotiationResult, outBlocksCount, outBytesCount, outCipher, outCipherSize, outCompression, outMac, outMacSize, outPacketsCount, pendingGlobalRequest, pendingPackets, random, requestLock, seqi, seqo, serverProposal, serverVersion, SESSION, sessionId, sessionListenerProxy, sessionListeners, tunnelListenerProxy, tunnelListeners, uncompressBuffer, unmodClientProposal, unmodNegotiationResult, unmodServerProposalauthNanoStart, idleNanoStart, sessionLockcloseFuture, futureLock, statelogDEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTHDEFAULT_CONNECTION_HEARTBEAT_INTERVAL, SESSION_HEARTBEAT_INTERVAL, SESSION_HEARTBEAT_TYPEEMPTYCLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUTNONEAUTH_METHODS, AUTO_WELCOME_BANNER_VALUE, DEFAULT_BANNER_PHASE, DEFAULT_MAX_AUTH_REQUESTS, DEFAULT_USER_AUTH_GSS_FACTORY, DEFAULT_USER_AUTH_KB_INTERACTIVE_FACTORY, DEFAULT_USER_AUTH_PASSWORD_FACTORY, DEFAULT_USER_AUTH_PUBLIC_KEY_FACTORY, DEFAULT_WELCOME_BANNER_LANGUAGE, MAX_AUTH_REQUESTS, WELCOME_BANNER, WELCOME_BANNER_CHARSET, WELCOME_BANNER_LANGUAGE, WELCOME_BANNER_PHASE| Modifier | Constructor and Description |
|---|---|
protected |
AbstractServerSession(ServerFactoryManager factoryManager,
IoSession ioSession) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkKeys()
Indicates the the key exchange is completed and the exchanged keys can now be verified - e.g., client can verify
the server's key
|
int |
getActiveSessionCountForUser(java.lang.String userName)
Retrieve the current number of sessions active for a given username.
|
java.net.SocketAddress |
getClientAddress() |
protected ConnectionService |
getConnectionService() |
ServerFactoryManager |
getFactoryManager() |
GSSAuthenticator |
getGSSAuthenticator()
Retrieve the
GSSAuthenticator to be used by the SSH server. |
HostBasedAuthenticator |
getHostBasedAuthenticator()
Retrieve the
HostBasedAuthenticator to be used by the SSH server. |
java.security.KeyPair |
getHostKey() |
HostKeyCertificateProvider |
getHostKeyCertificateProvider() |
long |
getId() |
KeyboardInteractiveAuthenticator |
getKeyboardInteractiveAuthenticator()
Retrieve the
KeyboardInteractiveAuthenticator to be used by the SSH server. |
KeyPairProvider |
getKeyPairProvider()
Retrieve the
KeyPairProvider that will be used to find the host key to use on the server side or the
user key on the client side. |
PasswordAuthenticator |
getPasswordAuthenticator()
Retrieve the
PasswordAuthenticator to be used by the SSH server. |
PublickeyAuthenticator |
getPublickeyAuthenticator()
Retrieve the
PublickeyAuthenticator to be used by SSH server. |
ServerProxyAcceptor |
getServerProxyAcceptor() |
java.util.List<UserAuthFactory> |
getUserAuthFactories()
Retrieve the list of named factories for
UserAuth objects. |
protected void |
handleServiceAccept(java.lang.String serviceName,
Buffer buffer) |
protected boolean |
handleServiceRequest(java.lang.String serviceName,
Buffer buffer) |
protected boolean |
readIdentification(Buffer buffer)
Read the other side identification.
|
protected void |
receiveKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal,
byte[] seed) |
protected java.lang.String |
resolveAvailableSignaturesProposal(FactoryManager proposedManager) |
protected java.lang.String |
resolveEmptySignaturesProposal(java.lang.Iterable<java.lang.String> supported,
java.lang.Iterable<java.lang.String> provided)
Called by
resolveAvailableSignaturesProposal(FactoryManager) if none of the provided keys is supported -
last chance for the derived implementation to do something |
protected byte[] |
sendKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal)
Send the key exchange initialization packet.
|
protected IoWriteFuture |
sendServerIdentification(java.lang.String... headerLines)
Sends the server identification + any extra header lines
|
void |
setClientAddress(java.net.SocketAddress clientAddress) |
void |
setGSSAuthenticator(GSSAuthenticator gssAuthenticator) |
void |
setHostBasedAuthenticator(HostBasedAuthenticator hostBasedAuthenticator) |
void |
setHostKeyCertificateProvider(HostKeyCertificateProvider hostKeyCertificateProvider) |
protected void |
setKexSeed(byte... seed) |
void |
setKeyboardInteractiveAuthenticator(KeyboardInteractiveAuthenticator interactiveAuthenticator) |
void |
setKeyPairProvider(KeyPairProvider keyPairProvider) |
void |
setPasswordAuthenticator(PasswordAuthenticator passwordAuthenticator) |
void |
setPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator) |
void |
setServerProxyAcceptor(ServerProxyAcceptor proxyAcceptor) |
void |
setUserAuthFactories(java.util.List<UserAuthFactory> userAuthFactories) |
IoWriteFuture |
signalAuthenticationSuccess(java.lang.String username,
java.lang.String authService,
Buffer buffer) |
void |
startService(java.lang.String name,
Buffer buffer) |
addChannelListener, addPortForwardingEventListener, addSessionListener, appendOutgoingMac, attachSession, checkRekey, comparePreferredKexProposalOption, createBuffer, decode, doHandleMessage, doInvokeUnimplementedMessageHandler, doKexNegotiation, doWritePacket, encode, encryptOutgoingBuffer, enqueuePendingPacket, getChannelListenerProxy, getCipherInformation, getClientKexData, getClientKexProposals, getClientVersion, getCompressionInformation, getInnerCloseable, getKex, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getPortForwardingEventListenerProxy, getServerKexData, getServerKexProposals, getServerVersion, getService, getServices, getSession, getSession, getSessionId, getSessionListenerProxy, handleFirstKexPacketFollows, handleKexExtension, handleKexInit, handleKexMessage, handleMessage, handleNewCompression, handleNewKeys, handleServiceAccept, handleServiceRequest, isRekeyBlocksCountExceeded, isRekeyDataSizeExceeded, isRekeyPacketCountsExceeded, isRekeyRequired, isRekeyTimeIntervalExceeded, messageReceived, negotiate, notImplemented, preClose, prepareBuffer, preProcessEncodeBuffer, receiveKexInit, receiveKexInit, receiveNewKeys, reExchangeKeys, refreshConfiguration, removeChannelListener, removePortForwardingEventListener, removeSessionListener, request, requestFailure, requestNewKeysExchange, requestSuccess, resolveAvailableSignaturesProposal, resolveIgnoreBufferDataLength, resolveOutputPacket, resolveSessionKexProposal, sendKexInit, sendNewKeys, sendPendingPackets, setClientKexData, setNegotiationResult, setServerKexData, signalRequestFailure, validateIncomingMac, validateKexState, validateTargetBuffer, writePacketattributeKeys, calculateNextIgnorePacketCount, checkAuthenticationTimeout, checkForTimeouts, checkIdleTimeout, clearAttributes, computeAttributeIfAbsent, createProposal, disconnect, doInvokeDebugMessageHandler, doInvokeIgnoreMessageHandler, doReadIdentification, exceptionCaught, getAttribute, getAttributesCount, getAuthTimeout, getAuthTimeoutStart, getBoundLocalPortForward, getBoundRemotePortForward, getChannelStreamPacketWriterResolver, getForwardingFilter, 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, resolveChannelStreamPacketWriterResolver, resolveIdentificationString, resolvePeerAddress, resolveReservedSessionMessagesHandler, resolveUnknownChannelReferenceHandler, sendDebugMessage, sendIdentification, sendIgnoreMessage, sendNotImplemented, setAttribute, setAuthenticated, setChannelStreamPacketWriterResolver, setReservedSessionMessagesHandler, setSessionDisconnectHandler, setUnknownChannelReferenceHandler, setUsername, signalDisconnect, signalDisconnect, signalExceptionCaught, signalExceptionCaught, signalNegotiationEnd, signalNegotiationEnd, signalNegotiationStart, signalNegotiationStart, signalPeerIdentificationReceived, signalPeerIdentificationReceived, signalSessionClosed, signalSessionClosed, signalSessionCreated, signalSessionCreated, signalSessionEstablished, signalSessionEstablished, signalSessionEvent, signalSessionEvent, toString, writePacketgetCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactoriesdoCloseGracefully, doCloseImmediatelyaddCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenergetSimplifiedLoggerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateBuffer, createBuffer, disconnect, exceptionCaught, getAuthTimeout, getAuthTimeoutStart, getIdleTimeout, getIdleTimeoutStart, getIoSession, getKex, getLocalAddress, getRemoteAddress, getService, getTimeoutStatus, prepareBuffer, reExchangeKeys, request, request, request, resetAuthTimeout, resetIdleTimeout, resolveAttribute, resolveAttribute, sendDebugMessage, sendIgnoreMessage, setAuthenticated, writePacket, writePacket, writePacketgetCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionId, isAuthenticated, isDataIntegrityTransport, isSecureSessionTransport, isServerSession, isValidVersionPrefixdisableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeatgetBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringPropertyclearAttributes, computeAttributeIfAbsent, removeAttribute, setAttributeattributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePairaddCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListenersetUsernamegetUsernamegetCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNamesgetSignatureFactories, getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames, resolveSignatureFactories, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNamesgetKexExtensionHandler, setKexExtensionHandleraddSessionListener, getSessionListenerProxy, removeSessionListenergetReservedSessionMessagesHandler, setReservedSessionMessagesHandlergetSessionDisconnectHandler, setSessionDisconnectHandleraddChannelListener, getChannelListenerProxy, removeChannelListenergetChannelStreamPacketWriterResolver, resolveChannelStreamPacketWriter, resolveChannelStreamPacketWriterResolver, setChannelStreamPacketWriterResolveraddPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListenergetUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandlergetBoundLocalPortForward, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPortcalculatePadLength, writePacketresolveUserAuthFactories, resolveUserAuthFactories, setUserAuthFactoriesNamesgetUserAuthFactoriesNameList, getUserAuthFactoriesNames, setUserAuthFactoriesNameList, setUserAuthFactoriesNamesprivate ServerProxyAcceptor proxyAcceptor
private java.net.SocketAddress clientAddress
private PasswordAuthenticator passwordAuthenticator
private PublickeyAuthenticator publickeyAuthenticator
private KeyboardInteractiveAuthenticator interactiveAuthenticator
private GSSAuthenticator gssAuthenticator
private HostBasedAuthenticator hostBasedAuthenticator
private java.util.List<UserAuthFactory> userAuthFactories
private KeyPairProvider keyPairProvider
private HostKeyCertificateProvider hostKeyCertificateProvider
protected AbstractServerSession(ServerFactoryManager factoryManager, IoSession ioSession)
public ServerFactoryManager getFactoryManager()
getFactoryManager in interface FactoryManagerHoldergetFactoryManager in interface ServerSessiongetFactoryManager in class SessionHelperFactoryManagerpublic ServerProxyAcceptor getServerProxyAcceptor()
getServerProxyAcceptor in interface ServerProxyAcceptorHolderpublic void setServerProxyAcceptor(ServerProxyAcceptor proxyAcceptor)
setServerProxyAcceptor in interface ServerProxyAcceptorHolderpublic java.net.SocketAddress getClientAddress()
getClientAddress in interface ServerSessionSocketAddress of the remote client. If no proxy wrapping was used then this is the same as
the IoSession#getRemoteAddress(). Otherwise, it indicates the real client's address that was
somehow transmitted via the proxy meta-datapublic void setClientAddress(java.net.SocketAddress clientAddress)
public PasswordAuthenticator getPasswordAuthenticator()
ServerAuthenticationManagerPasswordAuthenticator to be used by the SSH server. If no authenticator has been
configured (i.e. this method returns null), then client authentication requests based on passwords will
be rejected.getPasswordAuthenticator in interface ServerAuthenticationManagerPasswordAuthenticator or nullpublic void setPasswordAuthenticator(PasswordAuthenticator passwordAuthenticator)
setPasswordAuthenticator in interface ServerAuthenticationManagerpublic PublickeyAuthenticator getPublickeyAuthenticator()
ServerAuthenticationManagerPublickeyAuthenticator to be used by SSH server. If no authenticator has been
configured (i.e. this method returns null), then client authentication requests based on keys will be
rejected.getPublickeyAuthenticator in interface ServerAuthenticationManagerPublickeyAuthenticator or nullpublic void setPublickeyAuthenticator(PublickeyAuthenticator publickeyAuthenticator)
setPublickeyAuthenticator in interface ServerAuthenticationManagerpublic KeyboardInteractiveAuthenticator getKeyboardInteractiveAuthenticator()
ServerAuthenticationManagerKeyboardInteractiveAuthenticator to be used by the SSH server. If no authenticator has
been configured (i.e. this method returns null), then client authentication requests based on this method
will be rejected.getKeyboardInteractiveAuthenticator in interface ServerAuthenticationManagerKeyboardInteractiveAuthenticator or nullpublic void setKeyboardInteractiveAuthenticator(KeyboardInteractiveAuthenticator interactiveAuthenticator)
setKeyboardInteractiveAuthenticator in interface ServerAuthenticationManagerpublic GSSAuthenticator getGSSAuthenticator()
ServerAuthenticationManagerGSSAuthenticator to be used by the SSH server. If no authenticator has been configured
(i.e. this method returns null), then client authentication requests based on gssapi will be rejected.getGSSAuthenticator in interface ServerAuthenticationManagerGSSAuthenticator or nullpublic void setGSSAuthenticator(GSSAuthenticator gssAuthenticator)
setGSSAuthenticator in interface ServerAuthenticationManagerpublic HostBasedAuthenticator getHostBasedAuthenticator()
ServerAuthenticationManagerHostBasedAuthenticator to be used by the SSH server. If no authenticator has been configured
(i.e. this method returns null), then client authentication requests based on this method will be
rejected.getHostBasedAuthenticator in interface ServerAuthenticationManagerHostBasedAuthenticator or nullpublic void setHostBasedAuthenticator(HostBasedAuthenticator hostBasedAuthenticator)
setHostBasedAuthenticator in interface ServerAuthenticationManagerpublic java.util.List<UserAuthFactory> getUserAuthFactories()
UserAuthFactoriesManagerUserAuth objects.getUserAuthFactories in interface UserAuthFactoriesManager<ServerSession,UserAuth,UserAuthFactory>UserAuth factories, never null/emptypublic void setUserAuthFactories(java.util.List<UserAuthFactory> userAuthFactories)
setUserAuthFactories in interface UserAuthFactoriesManager<ServerSession,UserAuth,UserAuthFactory>public KeyPairProvider getKeyPairProvider()
KeyPairProviderHolderKeyPairProvider that will be used to find the host key to use on the server side or the
user key on the client side.getKeyPairProvider in interface KeyPairProviderHolderKeyPairProvider, never nullpublic HostKeyCertificateProvider getHostKeyCertificateProvider()
getHostKeyCertificateProvider in interface ServerAuthenticationManagerHostKeyCertificateProvider if available, null as defaultpublic void setHostKeyCertificateProvider(HostKeyCertificateProvider hostKeyCertificateProvider)
setHostKeyCertificateProvider in interface ServerAuthenticationManagerpublic void setKeyPairProvider(KeyPairProvider keyPairProvider)
setKeyPairProvider in interface KeyPairProviderHolderprotected IoWriteFuture sendServerIdentification(java.lang.String... headerLines) throws java.io.IOException
headerLines - Extra header lines to be prepended to the actual identification string - ignored if
null/emptyIoWriteFuture that can be used to be notified of identification data being written
successfully or failingjava.io.IOException - If failed to send identificationprotected void checkKeys()
AbstractSessioncheckKeys in class AbstractSessionprotected boolean handleServiceRequest(java.lang.String serviceName,
Buffer buffer)
throws java.lang.Exception
handleServiceRequest in class AbstractSessionjava.lang.Exceptionpublic void startService(java.lang.String name,
Buffer buffer)
throws java.lang.Exception
startService in interface Sessionname - Service namebuffer - Extra information provided when the service start request was receivedjava.lang.Exception - If failed to start itpublic IoWriteFuture signalAuthenticationSuccess(java.lang.String username, java.lang.String authService, Buffer buffer) throws java.lang.Exception
ServerSession
SSH_MSG_USERAUTH_SUCCESS message.signalAuthenticationSuccess in interface ServerSessionusername - The authenticated usernameauthService - The service to startbuffer - Any extra data received to use to start the serviceIoWriteFuture that can be used to wait for the SSH_MSG_USERAUTH_SUCCESS
message send resultjava.lang.Exception - if cannot handle the requestprotected void handleServiceAccept(java.lang.String serviceName,
Buffer buffer)
throws java.lang.Exception
handleServiceAccept in class AbstractSessionjava.lang.Exceptionprotected byte[] sendKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal) throws java.io.IOException
AbstractSessionsendKexInit in class AbstractSessionproposal - our proposal for key exchange negotiationjava.io.IOException - if an error occurred sending the packetprotected void setKexSeed(byte... seed)
setKexSeed in class AbstractSessionseed - The result of the KEXINIT handshake - required for correct session key establishmentprotected java.lang.String resolveAvailableSignaturesProposal(FactoryManager proposedManager) throws java.io.IOException, java.security.GeneralSecurityException
resolveAvailableSignaturesProposal in class AbstractSessionproposedManager - The FactoryManagernull/empty if no proposaljava.io.IOException - If failed to read/parse the keys datajava.security.GeneralSecurityException - If failed to generate the keysprotected java.lang.String resolveEmptySignaturesProposal(java.lang.Iterable<java.lang.String> supported,
java.lang.Iterable<java.lang.String> provided)
resolveAvailableSignaturesProposal(FactoryManager) if none of the provided keys is supported -
last chance for the derived implementation to do somethingsupported - The supported key types - may be null/emptyprovided - The available signature types - may be null/emptynull by defaultprotected boolean readIdentification(Buffer buffer) throws java.lang.Exception
AbstractSessionSessionHelper.doReadIdentification(Buffer, boolean) and store the result in the needed property.readIdentification in class AbstractSessionbuffer - The Buffer containing the remote identificationtrue if the identification has been fully read or false if more data
is neededjava.lang.Exception - if an error occurs such as a bad protocol version or unsuccessful KEX was involvedprotected void receiveKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal, byte[] seed) throws java.io.IOException
receiveKexInit in class AbstractSessionjava.io.IOExceptionpublic java.security.KeyPair getHostKey()
getHostKey in interface ServerSessionKeyPair representing the current session's used keys on KEX - null if not negotiated
yetpublic int getActiveSessionCountForUser(java.lang.String userName)
ServerSessiongetActiveSessionCountForUser in interface ServerSessionuserName - The name of the user - ignored if null/emptySshSession objects associated with the userpublic long getId()
IoSession id.protected ConnectionService getConnectionService()
getConnectionService in class SessionHelper