public abstract class AbstractClientSession extends AbstractSession implements ClientSession
ClientSession
related methodsAbstractSession.MessageCodingSettings
AbstractCloseable.State
ClientSession.ClientSessionEvent
SessionHeartbeatController.HeartbeatType
AttributeRepository.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, ignorePacketDataLength, ignorePacketsCount, ignorePacketsFrequency, ignorePacketsVariance, inBlocksCount, inBytesCount, inCipher, inCipherSize, inCompression, initialKexDone, inMac, inMacResult, inMacSize, inPacketsCount, inSettings, kex, kexFutureHolder, kexHandler, kexInitializedFuture, kexState, lastKeyTimeValue, maxRekeyBlocks, maxRekeyBytes, maxRekeyInterval, maxRekyPackets, negotiationResult, outBlocksCount, outBytesCount, outCipher, outCipherSize, outCompression, outMac, outMacSize, outPacketsCount, outSettings, random, requestLock, seqi, seqo, serverProposal, serverVersion, SESSION, sessionId, sessionListenerProxy, sessionListeners, tunnelListenerProxy, tunnelListeners, uncompressBuffer, unmodClientProposal, unmodNegotiationResult, unmodServerProposal
authStart, idleStart, initialKexProposal
closeFuture, futureLock, state
log
REMOTE_COMMAND_WAIT_EVENTS
DEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTH
EMPTY
NONE
Modifier | Constructor and Description |
---|---|
protected |
AbstractClientSession(ClientFactoryManager factoryManager,
IoSession ioSession) |
addChannelListener, addPortForwardingEventListener, addSessionListener, aeadOutgoingBuffer, appendOutgoingMac, attachSession, calculatePadLength, checkRekey, comparePreferredKexProposalOption, createBuffer, decode, determineRekeyBlockLimit, doHandleMessage, doInvokeUnimplementedMessageHandler, doKexNegotiation, doWritePacket, encode, encryptOutgoingBuffer, 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, initializeCurrentService, initializeKeyExchangeMessageHandler, isRekeyBlocksCountExceeded, isRekeyDataSizeExceeded, isRekeyPacketCountsExceeded, isRekeyRequired, isRekeyTimeIntervalExceeded, messageReceived, negotiate, notImplemented, preClose, prepareBuffer, prepareNewKeys, preProcessEncodeBuffer, receiveKexInit, reExchangeKeys, refreshConfiguration, removeChannelListener, removePortForwardingEventListener, removeSessionListener, request, request, requestFailure, requestNewKeysExchange, requestSuccess, resolveIgnoreBufferDataLength, resolveOutputPacket, resolveSessionKexProposal, sendKexInit, sendNewKeys, setClientKexData, setInputEncoding, setNegotiationResult, setOutputEncoding, setServerKexData, validateIncomingMac, validateKexState, validateServiceKexState, validateTargetBuffer, writePacket, writePacket
attributeKeys, calculateNextIgnorePacketCount, checkAuthenticationTimeout, checkForTimeouts, checkIdleTimeout, clearAttributes, computeAttributeIfAbsent, createProposal, disconnect, doInvokeDebugMessageHandler, doInvokeIgnoreMessageHandler, doReadIdentification, exceptionCaught, getAttribute, getAttributesCount, getAuthTimeout, getAuthTimeoutStart, getBoundLocalPortForwards, getBoundRemotePortForward, getChannelStreamWriterResolver, 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, resizeKey, resolveAvailableSignaturesProposal, 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
getCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactories
doCloseGracefully, doCloseImmediately
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListener
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
auth, createDynamicPortForwardingTracker, createExecChannel, createLocalPortForwardingTracker, createLocalPortForwardingTracker, createRemotePortForwardingTracker, createShellChannel, executeRemoteCommand, executeRemoteCommand, executeRemoteCommand, getMetadataMap, getSessionState, passwordIteratorOf, providerOf, waitFor, waitFor
createBuffer, createBuffer, disconnect, exceptionCaught, getAuthTimeout, getAuthTimeoutStart, getIdleTimeout, getIdleTimeoutStart, getIoSession, getKex, getLocalAddress, getRemoteAddress, getService, getTimeoutStatus, prepareBuffer, reExchangeKeys, request, request, request, request, resetAuthTimeout, resetIdleTimeout, resolveAttribute, resolveAttribute, sendDebugMessage, sendIgnoreMessage, setAuthenticated, writePacket, writePacket, writePacket, writePacket
getCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionId, isAuthenticated, isDataIntegrityTransport, isSecureSessionTransport, isServerSession, isValidSessionPayloadSize, isValidVersionPrefix, validateSessionPayloadSize
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeat
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty, isEmpty
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
attributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePair
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
setUsername
getUsername
getCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNames
getSignatureFactories, resolveSignatureFactories, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNames
getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames
getKexExtensionHandler, setKexExtensionHandler
addSessionListener, getSessionListenerProxy, removeSessionListener
getReservedSessionMessagesHandler, setReservedSessionMessagesHandler
getSessionDisconnectHandler, setSessionDisconnectHandler
addChannelListener, getChannelListenerProxy, removeChannelListener
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolver
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListener
getUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandler
setUserAuthFactoriesNames
getUserAuthFactoriesNameList, getUserAuthFactoriesNames, setUserAuthFactoriesNameList, setUserAuthFactoriesNames
startLocalPortForwarding
getBoundLocalPortForwards, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPort
protected final boolean sendImmediateClientIdentification
protected final boolean sendImmediateKexInit
protected AbstractClientSession(ClientFactoryManager factoryManager, IoSession ioSession)
public AttributeRepository getConnectionContext()
getConnectionContext
in interface ClientSession
null
if none.public ClientFactoryManager getFactoryManager()
getFactoryManager
in interface ClientSession
getFactoryManager
in interface FactoryManagerHolder
getFactoryManager
in class SessionHelper
FactoryManager
public SocketAddress getConnectAddress()
ClientSession
Session.getIoSession()
report of the remote peergetConnectAddress
in interface ClientSession
public void setConnectAddress(SocketAddress connectAddress)
public PublicKey getServerKey()
ClientSession
getServerKey
in interface ClientSession
PublicKey
- null
if KEX not started or not completedpublic void setServerKey(PublicKey serverKey)
public ServerKeyVerifier getServerKeyVerifier()
ClientAuthenticationManager
getServerKeyVerifier
in interface ClientAuthenticationManager
ServerKeyVerifier
to use - never null
public void setServerKeyVerifier(ServerKeyVerifier serverKeyVerifier)
setServerKeyVerifier
in interface ClientAuthenticationManager
public UserInteraction getUserInteraction()
getUserInteraction
in interface ClientAuthenticationManager
UserInteraction
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 ClientAuthenticationManager
public PasswordAuthenticationReporter getPasswordAuthenticationReporter()
getPasswordAuthenticationReporter
in interface ClientAuthenticationManager
public void setPasswordAuthenticationReporter(PasswordAuthenticationReporter reporter)
setPasswordAuthenticationReporter
in interface ClientAuthenticationManager
public List<UserAuthFactory> getUserAuthFactories()
UserAuthFactoriesManager
UserAuth
objects.getUserAuthFactories
in interface UserAuthFactoriesManager<ClientSession,UserAuth,UserAuthFactory>
UserAuth
factories, never null
/emptypublic void setUserAuthFactories(List<UserAuthFactory> userAuthFactories)
setUserAuthFactories
in interface UserAuthFactoriesManager<ClientSession,UserAuth,UserAuthFactory>
public AuthenticationIdentitiesProvider getRegisteredIdentities()
getRegisteredIdentities
in interface ClientAuthenticationManager
AuthenticationIdentitiesProvider
to be used for attempting password or public key
authenticationpublic PasswordIdentityProvider getPasswordIdentityProvider()
ClientAuthenticationManager
PasswordIdentityProvider
used to provide password candidatesgetPasswordIdentityProvider
in interface ClientAuthenticationManager
PasswordIdentityProvider
instance - ignored if null
(i.e., no passwords available).ClientAuthenticationManager.addPasswordIdentity(String)
public void setPasswordIdentityProvider(PasswordIdentityProvider provider)
setPasswordIdentityProvider
in interface ClientAuthenticationManager
public KeyIdentityProvider getKeyIdentityProvider()
getKeyIdentityProvider
in interface KeyIdentityProviderHolder
KeyIdentityProvider
used to provide key-pair(s) for public key authenticationpublic void setKeyIdentityProvider(KeyIdentityProvider keyIdentityProvider)
setKeyIdentityProvider
in interface KeyIdentityProviderHolder
public PublicKeyAuthenticationReporter getPublicKeyAuthenticationReporter()
getPublicKeyAuthenticationReporter
in interface ClientAuthenticationManager
public void setPublicKeyAuthenticationReporter(PublicKeyAuthenticationReporter reporter)
setPublicKeyAuthenticationReporter
in interface ClientAuthenticationManager
public HostBasedAuthenticationReporter getHostBasedAuthenticationReporter()
getHostBasedAuthenticationReporter
in interface ClientAuthenticationManager
public void setHostBasedAuthenticationReporter(HostBasedAuthenticationReporter reporter)
setHostBasedAuthenticationReporter
in interface ClientAuthenticationManager
public ClientProxyConnector getClientProxyConnector()
getClientProxyConnector
in interface ClientProxyConnectorHolder
public void setClientProxyConnector(ClientProxyConnector proxyConnector)
setClientProxyConnector
in interface ClientProxyConnectorHolder
public void addPasswordIdentity(String password)
addPasswordIdentity
in interface ClientAuthenticationManager
password
- 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 ClientAuthenticationManager
password
- The password to remove - ignored if null
/emptyClientAuthenticationManager.addPasswordIdentity(String)
- or
null
if no match foundpublic void addPublicKeyIdentity(KeyPair kp)
addPublicKeyIdentity
in interface ClientAuthenticationManager
kp
- 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 ClientAuthenticationManager
kp
- The KeyPair
to remove - ignored if null
KeyPair
- same one that was added via ClientAuthenticationManager.addPublicKeyIdentity(KeyPair)
- or
null
if no match foundprotected void initializeKeyExchangePhase() throws Exception
Exception
protected void initializeProxyConnector() throws Exception
Exception
protected IoWriteFuture sendClientIdentification() throws Exception
Exception
public ClientChannel createChannel(String type) throws IOException
ClientSession
createChannel(type, null)
.createChannel
in interface ClientSession
type
- The channel typeClientChannel
IOException
- If failed to create the requested channelpublic ClientChannel createChannel(String type, String subType) throws IOException
ClientSession
createChannel
in interface ClientSession
type
- The channel typesubType
- The channel sub-typeClientChannel
IOException
- If failed to create the requested channelpublic ChannelExec createExecChannel(String command, PtyChannelConfigurationHolder ptyConfig, Map<String,?> env) throws IOException
ClientSession
createExecChannel
in interface ClientSession
command
- 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.ChannelExec
IOException
- If failed to create the requested channelpublic ChannelSubsystem createSubsystemChannel(String subsystem) throws IOException
ClientSession
createSubsystemChannel
in interface ClientSession
subsystem
- The subsystem nameChannelSubsystem
IOException
- If failed to create the requested channelpublic ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
ClientSession
createDirectTcpipChannel
in interface ClientSession
local
- The local addressremote
- The remote addressChannelDirectTcpip
IOException
- If failed to create the requested channelprotected ClientUserAuthService getUserAuthService()
protected ConnectionService getConnectionService()
getConnectionService
in class SessionHelper
public SshdSocketAddress startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
PortForwardingManager
startLocalPortForwarding
in interface PortForwardingManager
local
- The local addressremote
- The remote addressSshdSocketAddress
IOException
- If failed to create the requested bindingpublic void stopLocalPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManager
stopLocalPortForwarding
in interface PortForwardingManager
local
- The local addressIOException
- If failed to cancel the requested bindingpublic SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException
PortForwardingManager
Start 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 PortForwardingManager
remote
- The remote addresslocal
- The local addressSshdSocketAddress
IOException
- If failed to create the requested bindingpublic void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException
PortForwardingManager
stopRemotePortForwarding
in interface PortForwardingManager
remote
- The remote addressIOException
- If failed to cancel the requested bindingpublic SshdSocketAddress startDynamicPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManager
startDynamicPortForwarding
in interface PortForwardingManager
local
- The local addressSshdSocketAddress
IOException
- If failed to create the requested bindingpublic void stopDynamicPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManager
stopDynamicPortForwarding
in interface PortForwardingManager
local
- The local addressIOException
- If failed to cancel the requested bindingprotected Forwarder getForwarder()
getForwarder
in class SessionHelper
protected String resolveAvailableSignaturesProposal(FactoryManager manager)
SessionHelper
resolveAvailableSignaturesProposal
in class SessionHelper
manager
- The FactoryManager
null
/empty if no proposalpublic void startService(String name, Buffer buffer) throws Exception
startService
in interface Session
name
- 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
ClientSession
createShellChannel
in interface ClientSession
ptyConfig
- 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.ChannelShell
IOException
- If failed to create the requested channelprotected boolean readIdentification(Buffer buffer) throws Exception
AbstractSession
SessionHelper.doReadIdentification(Buffer, boolean)
and store the result in the needed property.readIdentification
in class AbstractSession
buffer
- 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
Exception
protected byte[] sendKexInit(Map<KexProposalOption,String> proposal) throws Exception
AbstractSession
sendKexInit
in class AbstractSession
proposal
- our proposal for key exchange negotiationException
- if an error occurred sending the packetprotected void setKexSeed(byte... seed)
setKexSeed
in class AbstractSession
seed
- The result of the KEXINIT handshake - required for correct session key establishmentprotected byte[] receiveKexInit(Buffer buffer) throws Exception
receiveKexInit
in class AbstractSession
Exception
protected void receiveKexInit(Map<KexProposalOption,String> proposal, byte[] seed) throws IOException
receiveKexInit
in class AbstractSession
IOException
protected void checkKeys() throws IOException
AbstractSession
checkKeys
in class AbstractSession
IOException
- If validation failedpublic KeyExchangeFuture switchToNoneCipher() throws IOException
ClientSession
Switch 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 ClientSession
KeyExchangeFuture
that can be used to wait for the exchange to be finishedIOException
- if a key exchange is already runningCopyright © 2008–2024 The Apache Software Foundation. All rights reserved.