public abstract class AbstractClientSession extends AbstractSession implements ClientSession
ClientSession related methodsAbstractCloseable.StateClientSession.ClientSessionEventSessionHeartbeatController.HeartbeatTypeAttributeRepository.AttributeKey<T>| Modifier and Type | Field and Description |
|---|---|
protected boolean |
sendImmediateClientIdentification |
protected boolean |
sendImmediateKexInit |
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, unmodServerProposalauthStart, idleStart, sessionLockcloseFuture, futureLock, statelogREMOTE_COMMAND_WAIT_EVENTSDEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTHEMPTYNONE| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClientSession(ClientFactoryManager factoryManager,
IoSession ioSession) |
addChannelListener, addPortForwardingEventListener, addSessionListener, aeadOutgoingBuffer, appendOutgoingMac, attachSession, calculatePadLength, 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, handleServiceAccept, handleServiceRequest, handleServiceRequest, isRekeyBlocksCountExceeded, isRekeyDataSizeExceeded, isRekeyPacketCountsExceeded, isRekeyRequired, isRekeyTimeIntervalExceeded, messageReceived, negotiate, notImplemented, preClose, prepareBuffer, preProcessEncodeBuffer, 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, getBoundLocalPortForwards, getBoundRemotePortForward, getChannelStreamWriterResolver, getIdleTimeout, getIdleTimeoutStart, getIoSession, getLocalForwardsBindings, getParentPropertyResolver, getProperties, getRemoteForwardsBindings, getReservedSessionMessagesHandler, getSessionDisconnectHandler, getStartedLocalPortForwards, getStartedRemotePortForwards, getTimeoutStatus, getUnknownChannelReferenceHandler, getUsername, handleDebug, handleDisconnect, handleDisconnect, handleIgnore, handleUnimplemented, invokeSessionSignaller, isAuthenticated, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPort, isServerSession, mergeProposals, removeAttribute, resetAuthTimeout, resetIdleTimeout, resizeKey, resolveChannelStreamWriterResolver, resolveIdentificationString, resolvePeerAddress, resolveReservedSessionMessagesHandler, resolveUnknownChannelReferenceHandler, sendDebugMessage, sendIdentification, sendIgnoreMessage, sendNotImplemented, setAttribute, setAuthenticated, setChannelStreamWriterResolver, setReservedSessionMessagesHandler, setSessionDisconnectHandler, setUnknownChannelReferenceHandler, setUsername, signalDisconnect, signalDisconnect, signalExceptionCaught, signalExceptionCaught, signalNegotiationEnd, signalNegotiationEnd, signalNegotiationOptionsCreated, signalNegotiationOptionsCreated, signalNegotiationStart, signalNegotiationStart, signalPeerIdentificationReceived, signalPeerIdentificationReceived, signalReadPeerIdentificationLine, signalReadPeerIdentificationLine, signalSendIdentification, signalSendIdentification, signalSessionClosed, signalSessionClosed, signalSessionCreated, signalSessionCreated, signalSessionEstablished, signalSessionEstablished, signalSessionEvent, signalSessionEvent, toString, writePacketgetCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactoriesdoCloseGracefully, doCloseImmediatelyaddCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenerdebug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitauth, createDynamicPortForwardingTracker, createExecChannel, createLocalPortForwardingTracker, createLocalPortForwardingTracker, createRemotePortForwardingTracker, createShellChannel, executeRemoteCommand, executeRemoteCommand, executeRemoteCommand, getMetadataMap, getSessionState, passwordIteratorOf, providerOf, waitFor, waitForcreateBuffer, 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, 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, getStringProperty, isEmpty, isEmptyclearAttributes, 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, resolveSignatureFactories, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNamesgetSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNamesgetKexExtensionHandler, setKexExtensionHandleraddSessionListener, getSessionListenerProxy, removeSessionListenergetReservedSessionMessagesHandler, setReservedSessionMessagesHandlergetSessionDisconnectHandler, setSessionDisconnectHandleraddChannelListener, getChannelListenerProxy, removeChannelListenergetChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolveraddPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListenergetUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandlersetUserAuthFactoriesNamesgetUserAuthFactoriesNameList, getUserAuthFactoriesNames, setUserAuthFactoriesNameList, setUserAuthFactoriesNamesstartLocalPortForwardinggetBoundLocalPortForwards, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPortprotected final boolean sendImmediateClientIdentification
protected final boolean sendImmediateKexInit
protected AbstractClientSession(ClientFactoryManager factoryManager, IoSession ioSession)
public AttributeRepository getConnectionContext()
getConnectionContext in interface ClientSessionnull if none.public ClientFactoryManager getFactoryManager()
getFactoryManager in interface ClientSessiongetFactoryManager in interface FactoryManagerHoldergetFactoryManager in class SessionHelperFactoryManagerpublic SocketAddress getConnectAddress()
ClientSessionSession.getIoSession() report of the remote peergetConnectAddress in interface ClientSessionpublic void setConnectAddress(SocketAddress connectAddress)
public PublicKey getServerKey()
ClientSessiongetServerKey in interface ClientSessionPublicKey - null if KEX not started or not completedpublic void setServerKey(PublicKey serverKey)
public ServerKeyVerifier getServerKeyVerifier()
ClientAuthenticationManagergetServerKeyVerifier in interface ClientAuthenticationManagerServerKeyVerifier to use - never nullpublic void setServerKeyVerifier(ServerKeyVerifier serverKeyVerifier)
setServerKeyVerifier in interface ClientAuthenticationManagerpublic UserInteraction getUserInteraction()
getUserInteraction in interface ClientAuthenticationManagerUserInteraction object to communicate with the user (may be null to indicate that no
such communication is allowed)public void setUserInteraction(UserInteraction userInteraction)
setUserInteraction in interface ClientAuthenticationManagerpublic PasswordAuthenticationReporter getPasswordAuthenticationReporter()
getPasswordAuthenticationReporter in interface ClientAuthenticationManagerpublic void setPasswordAuthenticationReporter(PasswordAuthenticationReporter reporter)
setPasswordAuthenticationReporter in interface ClientAuthenticationManagerpublic List<UserAuthFactory> getUserAuthFactories()
getUserAuthFactories in interface UserAuthFactoriesManager<ClientSession,UserAuth,UserAuthFactory>public void setUserAuthFactories(List<UserAuthFactory> userAuthFactories)
setUserAuthFactories in interface UserAuthFactoriesManager<ClientSession,UserAuth,UserAuthFactory>public AuthenticationIdentitiesProvider getRegisteredIdentities()
getRegisteredIdentities in interface ClientAuthenticationManagerAuthenticationIdentitiesProvider to be used for attempting password or public key
authenticationpublic PasswordIdentityProvider getPasswordIdentityProvider()
ClientAuthenticationManagerPasswordIdentityProvider used to provide password candidatesgetPasswordIdentityProvider in interface ClientAuthenticationManagerPasswordIdentityProvider instance - ignored if null (i.e., no passwords available).ClientAuthenticationManager.addPasswordIdentity(String)public void setPasswordIdentityProvider(PasswordIdentityProvider provider)
setPasswordIdentityProvider in interface ClientAuthenticationManagerpublic KeyIdentityProvider getKeyIdentityProvider()
getKeyIdentityProvider in interface KeyIdentityProviderHolderpublic void setKeyIdentityProvider(KeyIdentityProvider keyIdentityProvider)
setKeyIdentityProvider in interface KeyIdentityProviderHolderpublic PublicKeyAuthenticationReporter getPublicKeyAuthenticationReporter()
getPublicKeyAuthenticationReporter in interface ClientAuthenticationManagerpublic void setPublicKeyAuthenticationReporter(PublicKeyAuthenticationReporter reporter)
setPublicKeyAuthenticationReporter in interface ClientAuthenticationManagerpublic HostBasedAuthenticationReporter getHostBasedAuthenticationReporter()
getHostBasedAuthenticationReporter in interface ClientAuthenticationManagerpublic void setHostBasedAuthenticationReporter(HostBasedAuthenticationReporter reporter)
setHostBasedAuthenticationReporter in interface ClientAuthenticationManagerpublic ClientProxyConnector getClientProxyConnector()
getClientProxyConnector in interface ClientProxyConnectorHolderpublic void setClientProxyConnector(ClientProxyConnector proxyConnector)
setClientProxyConnector in interface ClientProxyConnectorHolderpublic void addPasswordIdentity(String password)
addPasswordIdentity in interface ClientAuthenticationManagerpassword - Password to be added - may not be null/empty. Note: this password is in
addition to whatever passwords are available via the PasswordIdentityProvider (if
any)public String removePasswordIdentity(String password)
removePasswordIdentity in interface ClientAuthenticationManagerpassword - The password to remove - ignored if null/emptyClientAuthenticationManager.addPasswordIdentity(String) - or
null if no match foundpublic void addPublicKeyIdentity(KeyPair kp)
addPublicKeyIdentity in interface ClientAuthenticationManagerkp - The KeyPair to add - may not be null Note: this key is in addition to
whatever keys are available via the KeyIdentityProvider (if
any)public KeyPair removePublicKeyIdentity(KeyPair kp)
removePublicKeyIdentity in interface ClientAuthenticationManagerkp - The KeyPair to remove - ignored if nullKeyPair - same one that was added via ClientAuthenticationManager.addPublicKeyIdentity(KeyPair) - or
null if no match foundprotected void initializeKeyExchangePhase()
throws Exception
Exceptionprotected void initializeProxyConnector()
throws Exception
Exceptionprotected IoWriteFuture sendClientIdentification() throws Exception
Exceptionpublic ClientChannel createChannel(String type) throws IOException
ClientSessioncreateChannel(type, null).createChannel in interface ClientSessiontype - The channel typeClientChannelIOException - If failed to create the requested channelpublic ClientChannel createChannel(String type, String subType) throws IOException
ClientSessioncreateChannel in interface ClientSessiontype - The channel typesubType - The channel sub-typeClientChannelIOException - If failed to create the requested channelpublic ChannelExec createExecChannel(String command, PtyChannelConfigurationHolder ptyConfig, Map<String,?> env) throws IOException
ClientSessioncreateExecChannel in interface ClientSessioncommand - The command to executeptyConfig - The PTY configuration to use - if null then internal defaults are usedenv - Extra environment configuration to be transmitted to the server - ignored if
null/empty.ChannelExecIOException - If failed to create the requested channelpublic ChannelSubsystem createSubsystemChannel(String subsystem) throws IOException
ClientSessioncreateSubsystemChannel in interface ClientSessionsubsystem - The subsystem nameChannelSubsystemIOException - If failed to create the requested channelpublic ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
ClientSessioncreateDirectTcpipChannel in interface ClientSessionlocal - The local addressremote - The remote addressChannelDirectTcpipIOException - If failed to create the requested channelprotected ClientUserAuthService getUserAuthService()
protected ConnectionService getConnectionService()
getConnectionService in class SessionHelperpublic SshdSocketAddress startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
PortForwardingManagerstartLocalPortForwarding in interface PortForwardingManagerlocal - The local addressremote - The remote addressSshdSocketAddressIOException - If failed to create the requested bindingpublic void stopLocalPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManagerstopLocalPortForwarding in interface PortForwardingManagerlocal - The local addressIOException - If failed to cancel the requested bindingpublic SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException
PortForwardingManagerStart forwarding tcpip from the given address on the server to the given address on the client.
The remote host name is the address to bind to on the server:startRemotePortForwarding in interface PortForwardingManagerremote - The remote addresslocal - The local addressSshdSocketAddressIOException - If failed to create the requested bindingpublic void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException
PortForwardingManagerstopRemotePortForwarding in interface PortForwardingManagerremote - The remote addressIOException - If failed to cancel the requested bindingpublic SshdSocketAddress startDynamicPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManagerstartDynamicPortForwarding in interface PortForwardingManagerlocal - The local addressSshdSocketAddressIOException - If failed to create the requested bindingpublic void stopDynamicPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManagerstopDynamicPortForwarding in interface PortForwardingManagerlocal - The local addressIOException - If failed to cancel the requested bindingprotected Forwarder getForwarder()
getForwarder in class SessionHelperprotected String resolveAvailableSignaturesProposal(FactoryManager manager)
resolveAvailableSignaturesProposal in class AbstractSessionmanager - The FactoryManagernull/empty if no proposalpublic void startService(String name, Buffer buffer) throws Exception
startService in interface Sessionname - Service namebuffer - Extra information provided when the service start request was receivedException - If failed to start itpublic ChannelShell createShellChannel(PtyChannelConfigurationHolder ptyConfig, Map<String,?> env) throws IOException
ClientSessioncreateShellChannel in interface ClientSessionptyConfig - The PTY configuration to use - if null then internal defaults are usedenv - Extra environment configuration to be transmitted to the server - ignored if
null/empty.ChannelShellIOException - If failed to create the requested channelprotected boolean readIdentification(Buffer buffer) throws 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 neededException - if an error occurs such as a bad protocol version or unsuccessful KEX was involvedprotected void signalExtraServerVersionInfo(String version, List<String> lines) throws Exception
Exceptionprotected byte[] sendKexInit(Map<KexProposalOption,String> proposal) throws Exception
AbstractSessionsendKexInit in class AbstractSessionproposal - our proposal for key exchange negotiationException - 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 byte[] receiveKexInit(Buffer buffer) throws Exception
receiveKexInit in class AbstractSessionExceptionprotected void receiveKexInit(Map<KexProposalOption,String> proposal, byte[] seed) throws IOException
receiveKexInit in class AbstractSessionIOExceptionprotected void checkKeys()
throws IOException
AbstractSessioncheckKeys in class AbstractSessionIOException - If validation failedpublic KeyExchangeFuture switchToNoneCipher() throws IOException
ClientSessionSwitch to a none cipher for performance.
This should be done after the authentication phase has been performed. After such a switch, interactive channels are not allowed anymore. Both client and server must have been configured to support the none cipher. If that's not the case, the returned future will be set with an exception.
switchToNoneCipher in interface ClientSessionKeyExchangeFuture that can be used to wait for the exchange to be finishedIOException - if a key exchange is already runningCopyright © 2008–2021 The Apache Software Foundation. All rights reserved.