Package org.apache.sshd.client.session
Class AbstractClientSession
- 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.client.session.AbstractClientSession
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,ClientAuthenticationManager
,ClientProxyConnectorHolder
,ClientSession
,AttributeRepository
,AttributeStore
,MutableUserHolder
,UserAuthFactoriesManager<ClientSession,UserAuth,UserAuthFactory>
,UsernameHolder
,ChannelListenerManager
,ChannelStreamWriterResolver
,ChannelStreamWriterResolverManager
,Closeable
,FactoryManagerHolder
,PortForwardingEventListenerManager
,PortForwardingInformationProvider
,PortForwardingManager
,KexExtensionHandlerManager
,KexFactoryManager
,KeyIdentityProviderHolder
,PropertyResolver
,ReservedSessionMessagesManager
,Session
,SessionContext
,SessionDisconnectHandlerManager
,SessionHeartbeatController
,SessionListenerManager
,UnknownChannelReferenceHandlerManager
,SignatureFactoriesHolder
,SignatureFactoriesManager
,ConnectionEndpointsIndicator
- Direct Known Subclasses:
ClientSessionImpl
public abstract class AbstractClientSession extends AbstractSession implements ClientSession
Provides default implementations ofClientSession
related methods- Author:
- Apache MINA SSHD Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.sshd.common.session.helpers.AbstractSession
AbstractSession.MessageCodingSettings
-
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
AbstractCloseable.State
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T extends Object>
-
Nested classes/interfaces inherited from interface org.apache.sshd.client.session.ClientSession
ClientSession.ClientSessionEvent
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
SessionHeartbeatController.HeartbeatType
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
sendImmediateClientIdentification
protected boolean
sendImmediateKexInit
-
Fields inherited from class org.apache.sshd.common.session.helpers.AbstractSession
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
-
Fields inherited from class org.apache.sshd.common.session.helpers.SessionHelper
authStart, idleStart, initialKexProposal
-
Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, state
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolver
NONE
-
Fields inherited from interface org.apache.sshd.client.session.ClientSession
REMOTE_COMMAND_WAIT_EVENTS
-
Fields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTY
-
Fields inherited from interface org.apache.sshd.common.session.SessionContext
DEFAULT_SSH_VERSION_PREFIX, FALLBACK_SSH_VERSION_PREFIX, MAX_VERSION_LINE_LENGTH
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractClientSession(ClientFactoryManager factoryManager, IoSession ioSession)
-
Method Summary
-
Methods inherited from class org.apache.sshd.common.session.helpers.AbstractSession
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
-
Methods inherited from class org.apache.sshd.common.session.helpers.SessionHelper
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
-
Methods inherited from class org.apache.sshd.common.kex.AbstractKexFactoryManager
getCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactories
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediately
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListener
-
Methods 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, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.AttributeRepository
attributeKeys, getAttribute, getAttributesCount
-
Methods inherited from interface org.apache.sshd.common.AttributeStore
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
-
Methods inherited from interface org.apache.sshd.common.channel.ChannelListenerManager
addChannelListener, getChannelListenerProxy, removeChannelListener
-
Methods inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolverManager
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolver
-
Methods inherited from interface org.apache.sshd.client.ClientAuthenticationManager
setUserAuthFactoriesNames
-
Methods inherited from interface org.apache.sshd.client.session.ClientSession
auth, createDynamicPortForwardingTracker, createExecChannel, createLocalPortForwardingTracker, createLocalPortForwardingTracker, createRemotePortForwardingTracker, createShellChannel, executeRemoteCommand, executeRemoteCommand, executeRemoteCommand, getMetadataMap, getSessionState, waitFor, waitFor
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
Methods inherited from interface org.apache.sshd.common.kex.extension.KexExtensionHandlerManager
getKexExtensionHandler, setKexExtensionHandler
-
Methods inherited from interface org.apache.sshd.common.kex.KexFactoryManager
getCipherFactories, getCipherFactoriesNameList, getCipherFactoriesNames, getCompressionFactories, getCompressionFactoriesNameList, getCompressionFactoriesNames, getKeyExchangeFactories, getMacFactories, getMacFactoriesNameList, getMacFactoriesNames, setCipherFactories, setCipherFactoriesNameList, setCipherFactoriesNames, setCipherFactoriesNames, setCompressionFactories, setCompressionFactoriesNameList, setCompressionFactoriesNames, setCompressionFactoriesNames, setKeyExchangeFactories, setMacFactories, setMacFactoriesNameList, setMacFactoriesNames, setMacFactoriesNames
-
Methods inherited from interface org.apache.sshd.common.auth.MutableUserHolder
setUsername
-
Methods inherited from interface org.apache.sshd.common.forward.PortForwardingEventListenerManager
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListener
-
Methods inherited from interface org.apache.sshd.common.forward.PortForwardingInformationProvider
getBoundLocalPortForwards, getBoundRemotePortForward, getLocalForwardsBindings, getRemoteForwardsBindings, getStartedLocalPortForwards, getStartedRemotePortForwards, isLocalPortForwardingStartedForPort, isRemotePortForwardingStartedForPort
-
Methods inherited from interface org.apache.sshd.common.forward.PortForwardingManager
startLocalPortForwarding
-
Methods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty
-
Methods inherited from interface org.apache.sshd.common.session.ReservedSessionMessagesManager
getReservedSessionMessagesHandler, setReservedSessionMessagesHandler
-
Methods inherited from interface org.apache.sshd.common.session.Session
createBuffer, createBuffer, disconnect, exceptionCaught, getAuthTimeout, getAuthTimeoutStart, getIdleTimeout, getIdleTimeoutStart, getIoSession, getKex, getLocalAddress, getRemoteAddress, getService, getTimeoutStatus, prepareBuffer, reExchangeKeys, request, request, request, request, resetAuthTimeout, resetIdleTimeout, resolveAttribute, sendDebugMessage, sendIgnoreMessage, setAuthenticated, writePacket, writePacket, writePacket, writePacket
-
Methods inherited from interface org.apache.sshd.common.session.SessionContext
getCipherInformation, getClientKexProposals, getClientVersion, getCompressionInformation, getKexNegotiationResult, getKexState, getMacInformation, getNegotiatedKexParameter, getServerKexProposals, getServerVersion, getSessionId, isAuthenticated, isServerSession
-
Methods inherited from interface org.apache.sshd.common.session.SessionDisconnectHandlerManager
getSessionDisconnectHandler, setSessionDisconnectHandler
-
Methods inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeat
-
Methods inherited from interface org.apache.sshd.common.session.SessionListenerManager
addSessionListener, getSessionListenerProxy, removeSessionListener
-
Methods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesHolder
getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames
-
Methods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesManager
setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNames
-
Methods inherited from interface org.apache.sshd.common.session.UnknownChannelReferenceHandlerManager
getUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandler
-
Methods inherited from interface org.apache.sshd.common.auth.UserAuthFactoriesManager
getUserAuthFactoriesNameList, getUserAuthFactoriesNames, setUserAuthFactoriesNameList, setUserAuthFactoriesNames
-
Methods inherited from interface org.apache.sshd.common.auth.UsernameHolder
getUsername
-
-
-
-
Constructor Detail
-
AbstractClientSession
protected AbstractClientSession(ClientFactoryManager factoryManager, IoSession ioSession)
-
-
Method Detail
-
getConnectionContext
public AttributeRepository getConnectionContext()
- Specified by:
getConnectionContext
in interfaceClientSession
- Returns:
- The "context" data provided when session connection was established -
null
if none.
-
getFactoryManager
public ClientFactoryManager getFactoryManager()
- Specified by:
getFactoryManager
in interfaceClientSession
- Specified by:
getFactoryManager
in interfaceFactoryManagerHolder
- Overrides:
getFactoryManager
in classSessionHelper
- Returns:
- The currently associated
FactoryManager
-
getConnectAddress
public SocketAddress getConnectAddress()
Description copied from interface:ClientSession
Returns the original address (after having been translated through host configuration entries if any) that was request to connect. It contains the original host or address string that was used. Note: this may be different than the result of theSession.getIoSession()
report of the remote peer- Specified by:
getConnectAddress
in interfaceClientSession
- Returns:
- The original requested address
-
setConnectAddress
public void setConnectAddress(SocketAddress connectAddress)
-
getServerKey
public PublicKey getServerKey()
Description copied from interface:ClientSession
Retrieves the server's key- Specified by:
getServerKey
in interfaceClientSession
- Returns:
- The server's
PublicKey
-null
if KEX not started or not completed
-
setServerKey
public void setServerKey(PublicKey serverKey)
-
getServerKeyVerifier
public ServerKeyVerifier getServerKeyVerifier()
Description copied from interface:ClientAuthenticationManager
Retrieve the server key verifier to be used to check the key when connecting to an SSH server.- Specified by:
getServerKeyVerifier
in interfaceClientAuthenticationManager
- Returns:
- the
ServerKeyVerifier
to use - nevernull
-
setServerKeyVerifier
public void setServerKeyVerifier(ServerKeyVerifier serverKeyVerifier)
- Specified by:
setServerKeyVerifier
in interfaceClientAuthenticationManager
-
getUserInteraction
public UserInteraction getUserInteraction()
- Specified by:
getUserInteraction
in interfaceClientAuthenticationManager
- Returns:
- A
UserInteraction
object to communicate with the user (may benull
to indicate that no such communication is allowed)
-
setUserInteraction
public void setUserInteraction(UserInteraction userInteraction)
- Specified by:
setUserInteraction
in interfaceClientAuthenticationManager
-
getPasswordAuthenticationReporter
public PasswordAuthenticationReporter getPasswordAuthenticationReporter()
- Specified by:
getPasswordAuthenticationReporter
in interfaceClientAuthenticationManager
-
setPasswordAuthenticationReporter
public void setPasswordAuthenticationReporter(PasswordAuthenticationReporter reporter)
- Specified by:
setPasswordAuthenticationReporter
in interfaceClientAuthenticationManager
-
getUserAuthFactories
public List<UserAuthFactory> getUserAuthFactories()
- Specified by:
getUserAuthFactories
in interfaceUserAuthFactoriesManager<ClientSession,UserAuth,UserAuthFactory>
-
setUserAuthFactories
public void setUserAuthFactories(List<UserAuthFactory> userAuthFactories)
- Specified by:
setUserAuthFactories
in interfaceUserAuthFactoriesManager<ClientSession,UserAuth,UserAuthFactory>
-
getRegisteredIdentities
public AuthenticationIdentitiesProvider getRegisteredIdentities()
- Specified by:
getRegisteredIdentities
in interfaceClientAuthenticationManager
- Returns:
- The
AuthenticationIdentitiesProvider
to be used for attempting password or public key authentication
-
getPasswordIdentityProvider
public PasswordIdentityProvider getPasswordIdentityProvider()
Description copied from interface:ClientAuthenticationManager
RetrievePasswordIdentityProvider
used to provide password candidates- Specified by:
getPasswordIdentityProvider
in interfaceClientAuthenticationManager
- Returns:
- The
PasswordIdentityProvider
instance - ignored ifnull
(i.e., no passwords available). - See Also:
ClientAuthenticationManager.addPasswordIdentity(String)
-
setPasswordIdentityProvider
public void setPasswordIdentityProvider(PasswordIdentityProvider provider)
- Specified by:
setPasswordIdentityProvider
in interfaceClientAuthenticationManager
-
getKeyIdentityProvider
public KeyIdentityProvider getKeyIdentityProvider()
- Specified by:
getKeyIdentityProvider
in interfaceKeyIdentityProviderHolder
-
setKeyIdentityProvider
public void setKeyIdentityProvider(KeyIdentityProvider keyIdentityProvider)
- Specified by:
setKeyIdentityProvider
in interfaceKeyIdentityProviderHolder
-
getPublicKeyAuthenticationReporter
public PublicKeyAuthenticationReporter getPublicKeyAuthenticationReporter()
- Specified by:
getPublicKeyAuthenticationReporter
in interfaceClientAuthenticationManager
-
setPublicKeyAuthenticationReporter
public void setPublicKeyAuthenticationReporter(PublicKeyAuthenticationReporter reporter)
- Specified by:
setPublicKeyAuthenticationReporter
in interfaceClientAuthenticationManager
-
getHostBasedAuthenticationReporter
public HostBasedAuthenticationReporter getHostBasedAuthenticationReporter()
- Specified by:
getHostBasedAuthenticationReporter
in interfaceClientAuthenticationManager
-
setHostBasedAuthenticationReporter
public void setHostBasedAuthenticationReporter(HostBasedAuthenticationReporter reporter)
- Specified by:
setHostBasedAuthenticationReporter
in interfaceClientAuthenticationManager
-
getClientProxyConnector
public ClientProxyConnector getClientProxyConnector()
- Specified by:
getClientProxyConnector
in interfaceClientProxyConnectorHolder
-
setClientProxyConnector
public void setClientProxyConnector(ClientProxyConnector proxyConnector)
- Specified by:
setClientProxyConnector
in interfaceClientProxyConnectorHolder
-
addPasswordIdentity
public void addPasswordIdentity(String password)
- Specified by:
addPasswordIdentity
in interfaceClientAuthenticationManager
- Parameters:
password
- Password to be added - may not benull
/empty. Note: this password is in addition to whatever passwords are available via thePasswordIdentityProvider
(if any)
-
removePasswordIdentity
public String removePasswordIdentity(String password)
- Specified by:
removePasswordIdentity
in interfaceClientAuthenticationManager
- Parameters:
password
- The password to remove - ignored ifnull
/empty- Returns:
- The removed password - same one that was added via
ClientAuthenticationManager.addPasswordIdentity(String)
- ornull
if no match found
-
addPublicKeyIdentity
public void addPublicKeyIdentity(KeyPair kp)
- Specified by:
addPublicKeyIdentity
in interfaceClientAuthenticationManager
- Parameters:
kp
- TheKeyPair
to add - may not benull
Note: this key is in addition to whatever keys are available via theKeyIdentityProvider
(if any)
-
removePublicKeyIdentity
public KeyPair removePublicKeyIdentity(KeyPair kp)
- Specified by:
removePublicKeyIdentity
in interfaceClientAuthenticationManager
- Parameters:
kp
- TheKeyPair
to remove - ignored ifnull
- Returns:
- The removed
KeyPair
- same one that was added viaClientAuthenticationManager.addPublicKeyIdentity(KeyPair)
- ornull
if no match found
-
initializeKeyExchangePhase
protected void initializeKeyExchangePhase() throws Exception
- Throws:
Exception
-
initializeProxyConnector
protected void initializeProxyConnector() throws Exception
- Throws:
Exception
-
sendClientIdentification
protected IoWriteFuture sendClientIdentification() throws Exception
- Throws:
Exception
-
createChannel
public ClientChannel createChannel(String type) throws IOException
Description copied from interface:ClientSession
Create a channel of the given type. Same as callingcreateChannel(type, null)
.- Specified by:
createChannel
in interfaceClientSession
- Parameters:
type
- The channel type- Returns:
- The created
ClientChannel
- Throws:
IOException
- If failed to create the requested channel
-
createChannel
public ClientChannel createChannel(String type, String subType) throws IOException
Description copied from interface:ClientSession
Create a channel of the given type and sub-type.- Specified by:
createChannel
in interfaceClientSession
- Parameters:
type
- The channel typesubType
- The channel sub-type- Returns:
- The created
ClientChannel
- Throws:
IOException
- If failed to create the requested channel
-
createExecChannel
public ChannelExec createExecChannel(String command, PtyChannelConfigurationHolder ptyConfig, Map<String,?> env) throws IOException
Description copied from interface:ClientSession
Create a channel to execute a command using specific PTY settings and/or environment.- Specified by:
createExecChannel
in interfaceClientSession
- Parameters:
command
- The command to executeptyConfig
- The PTY configuration to use - ifnull
then internal defaults are usedenv
- Extra environment configuration to be transmitted to the server - ignored ifnull
/empty.- Returns:
- The created
ChannelExec
- Throws:
IOException
- If failed to create the requested channel
-
createSubsystemChannel
public ChannelSubsystem createSubsystemChannel(String subsystem) throws IOException
Description copied from interface:ClientSession
Create a subsystem channel.- Specified by:
createSubsystemChannel
in interfaceClientSession
- Parameters:
subsystem
- The subsystem name- Returns:
- The created
ChannelSubsystem
- Throws:
IOException
- If failed to create the requested channel
-
createDirectTcpipChannel
public ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
Description copied from interface:ClientSession
Create a direct tcp-ip channel which can be used to stream data to a remote port from the server.- Specified by:
createDirectTcpipChannel
in interfaceClientSession
- Parameters:
local
- The local addressremote
- The remote address- Returns:
- The created
ChannelDirectTcpip
- Throws:
IOException
- If failed to create the requested channel
-
getUserAuthService
protected ClientUserAuthService getUserAuthService()
-
getConnectionService
protected ConnectionService getConnectionService()
- Specified by:
getConnectionService
in classSessionHelper
-
startLocalPortForwarding
public SshdSocketAddress startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
Description copied from interface:PortForwardingManager
Start forwarding the given local address on the client to the given address on the server.- Specified by:
startLocalPortForwarding
in interfacePortForwardingManager
- Parameters:
local
- The local addressremote
- The remote address- Returns:
- The bound
SshdSocketAddress
- Throws:
IOException
- If failed to create the requested binding
-
stopLocalPortForwarding
public void stopLocalPortForwarding(SshdSocketAddress local) throws IOException
Description copied from interface:PortForwardingManager
Stop forwarding the given local address.- Specified by:
stopLocalPortForwarding
in interfacePortForwardingManager
- Parameters:
local
- The local address- Throws:
IOException
- If failed to cancel the requested binding
-
startRemotePortForwarding
public SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException
Description copied from interface: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:- "" means that connections are to be accepted on all protocol families supported by the SSH implementation
- "0.0.0.0" means to listen on all IPv4 addresses
- "::" means to listen on all IPv6 addresses
- "localhost" means to listen on all protocol families supported by the SSH implementation on loopback addresses only, [RFC3330] and RFC3513]
- "127.0.0.1" and "::1" indicate listening on the loopback interfaces for IPv4 and IPv6 respectively
- Specified by:
startRemotePortForwarding
in interfacePortForwardingManager
- Parameters:
remote
- The remote addresslocal
- The local address- Returns:
- The bound
SshdSocketAddress
- Throws:
IOException
- If failed to create the requested binding
-
stopRemotePortForwarding
public void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException
Description copied from interface:PortForwardingManager
Stop forwarding of the given remote address.- Specified by:
stopRemotePortForwarding
in interfacePortForwardingManager
- Parameters:
remote
- The remote address- Throws:
IOException
- If failed to cancel the requested binding
-
startDynamicPortForwarding
public SshdSocketAddress startDynamicPortForwarding(SshdSocketAddress local) throws IOException
Description copied from interface:PortForwardingManager
Start dynamic local port forwarding using a SOCKS proxy.- Specified by:
startDynamicPortForwarding
in interfacePortForwardingManager
- Parameters:
local
- The local address- Returns:
- The bound
SshdSocketAddress
- Throws:
IOException
- If failed to create the requested binding
-
stopDynamicPortForwarding
public void stopDynamicPortForwarding(SshdSocketAddress local) throws IOException
Description copied from interface:PortForwardingManager
Stop a previously started dynamic port forwarding.- Specified by:
stopDynamicPortForwarding
in interfacePortForwardingManager
- Parameters:
local
- The local address- Throws:
IOException
- If failed to cancel the requested binding
-
getForwarder
protected Forwarder getForwarder()
- Overrides:
getForwarder
in classSessionHelper
-
resolveAvailableSignaturesProposal
protected String resolveAvailableSignaturesProposal(FactoryManager manager)
Description copied from class:SessionHelper
Computes the list of available host key signature algorithms supported.- Specified by:
resolveAvailableSignaturesProposal
in classSessionHelper
- Parameters:
manager
- TheFactoryManager
- Returns:
- A comma-separated list of all the signature protocols to be included in the
proposal -
null
/empty if no proposal
-
startService
public void startService(String name, Buffer buffer) throws Exception
- Specified by:
startService
in interfaceSession
- Parameters:
name
- Service namebuffer
- Extra information provided when the service start request was received- Throws:
Exception
- If failed to start it
-
createShellChannel
public ChannelShell createShellChannel(PtyChannelConfigurationHolder ptyConfig, Map<String,?> env) throws IOException
Description copied from interface:ClientSession
Create a channel to start a shell using specific PTY settings and/or environment.- Specified by:
createShellChannel
in interfaceClientSession
- Parameters:
ptyConfig
- The PTY configuration to use - ifnull
then internal defaults are usedenv
- Extra environment configuration to be transmitted to the server - ignored ifnull
/empty.- Returns:
- The created
ChannelShell
- Throws:
IOException
- If failed to create the requested channel
-
readIdentification
protected boolean readIdentification(Buffer buffer) throws Exception
Description copied from class:AbstractSession
Read 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:
readIdentification
in classAbstractSession
- Parameters:
buffer
- TheBuffer
containing the remote identification- Returns:
true
if the identification has been fully read orfalse
if more data is needed- Throws:
Exception
- if an error occurs such as a bad protocol version or unsuccessful KEX was involved
-
signalExtraServerVersionInfo
protected void signalExtraServerVersionInfo(String version, List<String> lines) throws Exception
- Throws:
Exception
-
sendKexInit
protected byte[] sendKexInit(Map<KexProposalOption,String> proposal) throws Exception
Description copied from class:AbstractSession
Send the key exchange initialization packet. This packet contains random data along with our proposal.- Overrides:
sendKexInit
in classAbstractSession
- Parameters:
proposal
- our proposal for key exchange negotiation- Returns:
- the sent packet data which must be kept for later use when deriving the session keys
- Throws:
Exception
- if an error occurred sending the packet
-
setKexSeed
protected void setKexSeed(byte... seed)
- Specified by:
setKexSeed
in classAbstractSession
- Parameters:
seed
- The result of the KEXINIT handshake - required for correct session key establishment
-
receiveKexInit
protected byte[] receiveKexInit(Buffer buffer) throws Exception
- Overrides:
receiveKexInit
in classAbstractSession
- Throws:
Exception
-
receiveKexInit
protected void receiveKexInit(Map<KexProposalOption,String> proposal, byte[] seed) throws IOException
- Specified by:
receiveKexInit
in classAbstractSession
- Throws:
IOException
-
checkKeys
protected void checkKeys() throws IOException
Description copied from class:AbstractSession
Indicates 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:
checkKeys
in classAbstractSession
- Throws:
IOException
- If validation failed
-
switchToNoneCipher
public KeyExchangeFuture switchToNoneCipher() throws IOException
Description copied from interface: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.
- Specified by:
switchToNoneCipher
in interfaceClientSession
- Returns:
- an
KeyExchangeFuture
that can be used to wait for the exchange to be finished - Throws:
IOException
- if a key exchange is already running
-
-