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:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.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
-
-
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>
-
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 private java.net.SocketAddress
connectAddress
private AttributeRepository
connectionContext
private HostBasedAuthenticationReporter
hostBasedAuthenticationReporter
private java.util.List<java.lang.Object>
identities
private AuthenticationIdentitiesProvider
identitiesProvider
private KeyIdentityProvider
keyIdentityProvider
private PasswordAuthenticationReporter
passwordAuthenticationReporter
private PasswordIdentityProvider
passwordIdentityProvider
private ClientProxyConnector
proxyConnector
private PublicKeyAuthenticationReporter
publicKeyAuthenticationReporter
protected boolean
sendImmediateClientIdentification
protected boolean
sendImmediateKexInit
private java.security.PublicKey
serverKey
private ServerKeyVerifier
serverKeyVerifier
private java.util.List<UserAuthFactory>
userAuthFactories
private UserInteraction
userInteraction
-
Fields inherited from class org.apache.sshd.common.session.helpers.AbstractSession
channelListenerProxy, channelListeners, clientProposal, clientVersion, currentService, decodeLock, decoderBuffer, decoderLength, decoderState, discarding, encodeLock, firstKexPacketFollows, ignorePacketDataLength, ignorePacketsCount, ignorePacketsFrequency, ignorePacketsVariance, inBlocksCount, inBytesCount, inCipher, inCipherSize, inCompression, initialKexDone, initialKexInitSequenceNumber, 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, strictKex, 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPasswordIdentity(java.lang.String password)
void
addPublicKeyIdentity(java.security.KeyPair kp)
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 keyClientChannel
createChannel(java.lang.String type)
Create a channel of the given type.ClientChannel
createChannel(java.lang.String type, java.lang.String subType)
Create a channel of the given type and sub-type.ChannelDirectTcpip
createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote)
Create a direct tcp-ip channel which can be used to stream data to a remote port from the server.ChannelExec
createExecChannel(byte[] command, PtyChannelConfigurationHolder ptyConfig, java.util.Map<java.lang.String,?> env)
Create a channel to execute a command using specific PTY settings and/or environment.ChannelExec
createExecChannel(java.lang.String command, java.nio.charset.Charset charset, PtyChannelConfigurationHolder ptyConfig, java.util.Map<java.lang.String,?> env)
Create a channel to execute a command using specific PTY settings and/or environment.ChannelShell
createShellChannel(PtyChannelConfigurationHolder ptyConfig, java.util.Map<java.lang.String,?> env)
Create a channel to start a shell using specific PTY settings and/or environment.ChannelSubsystem
createSubsystemChannel(java.lang.String subsystem)
Create a subsystem channel.ClientProxyConnector
getClientProxyConnector()
java.net.SocketAddress
getConnectAddress()
Returns the original address (after having been translated through host configuration entries if any) that was request to connect.AttributeRepository
getConnectionContext()
protected ConnectionService
getConnectionService()
ClientFactoryManager
getFactoryManager()
protected Forwarder
getForwarder()
HostBasedAuthenticationReporter
getHostBasedAuthenticationReporter()
KeyIdentityProvider
getKeyIdentityProvider()
PasswordAuthenticationReporter
getPasswordAuthenticationReporter()
PasswordIdentityProvider
getPasswordIdentityProvider()
RetrievePasswordIdentityProvider
used to provide password candidatesPublicKeyAuthenticationReporter
getPublicKeyAuthenticationReporter()
AuthenticationIdentitiesProvider
getRegisteredIdentities()
java.security.PublicKey
getServerKey()
Retrieves the server's keyServerKeyVerifier
getServerKeyVerifier()
Retrieve the server key verifier to be used to check the key when connecting to an SSH server.java.util.List<UserAuthFactory>
getUserAuthFactories()
Retrieve the list of named factories forUserAuth
objects.protected ClientUserAuthService
getUserAuthService()
UserInteraction
getUserInteraction()
protected void
initializeKeyExchangePhase()
protected void
initializeProxyConnector()
protected boolean
readIdentification(Buffer buffer)
Read the other side identification.protected void
receiveKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal, byte[] seed)
protected byte[]
receiveKexInit(Buffer buffer)
java.lang.String
removePasswordIdentity(java.lang.String password)
java.security.KeyPair
removePublicKeyIdentity(java.security.KeyPair kp)
protected java.lang.String
resolveAvailableSignaturesProposal(FactoryManager manager)
Computes the list of available host key signature algorithms supported.protected IoWriteFuture
sendClientIdentification()
protected byte[]
sendKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal)
Send the key exchange initialization packet.void
setClientProxyConnector(ClientProxyConnector proxyConnector)
void
setConnectAddress(java.net.SocketAddress connectAddress)
void
setHostBasedAuthenticationReporter(HostBasedAuthenticationReporter reporter)
protected void
setKexSeed(byte... seed)
void
setKeyIdentityProvider(KeyIdentityProvider keyIdentityProvider)
void
setPasswordAuthenticationReporter(PasswordAuthenticationReporter reporter)
void
setPasswordIdentityProvider(PasswordIdentityProvider provider)
void
setPublicKeyAuthenticationReporter(PublicKeyAuthenticationReporter reporter)
void
setServerKey(java.security.PublicKey serverKey)
void
setServerKeyVerifier(ServerKeyVerifier serverKeyVerifier)
void
setUserAuthFactories(java.util.List<UserAuthFactory> userAuthFactories)
void
setUserInteraction(UserInteraction userInteraction)
protected void
signalExtraServerVersionInfo(java.lang.String version, java.util.List<java.lang.String> lines)
SshdSocketAddress
startDynamicPortForwarding(SshdSocketAddress local)
Start dynamic local port forwarding using a SOCKS proxy.SshdSocketAddress
startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote)
Start forwarding the given local address on the client to the given address on the server.SshdSocketAddress
startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local)
Start forwarding tcpip from the given address on the server to the given address on the client.void
startService(java.lang.String name, Buffer buffer)
void
stopDynamicPortForwarding(SshdSocketAddress local)
Stop a previously started dynamic port forwarding.void
stopLocalPortForwarding(SshdSocketAddress local)
Stop forwarding the given local address.void
stopRemotePortForwarding(SshdSocketAddress remote)
Stop forwarding of the given remote address.KeyExchangeFuture
switchToNoneCipher()
Switch to a none cipher for performance.-
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, doStrictKexProposal, doWritePacket, encode, encryptOutgoingBuffer, failStrictKex, 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, performKexNegotiation, preClose, prepareBuffer, prepareNewKeys, preProcessEncodeBuffer, receiveKexInit, reExchangeKeys, refreshConfiguration, removeChannelListener, removePortForwardingEventListener, removeSessionListener, removeValue, 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, 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
-
-
-
-
Field Detail
-
sendImmediateClientIdentification
protected final boolean sendImmediateClientIdentification
-
sendImmediateKexInit
protected final boolean sendImmediateKexInit
-
identities
private final java.util.List<java.lang.Object> identities
-
identitiesProvider
private final AuthenticationIdentitiesProvider identitiesProvider
-
connectionContext
private final AttributeRepository connectionContext
-
serverKey
private java.security.PublicKey serverKey
-
serverKeyVerifier
private ServerKeyVerifier serverKeyVerifier
-
userInteraction
private UserInteraction userInteraction
-
passwordIdentityProvider
private PasswordIdentityProvider passwordIdentityProvider
-
passwordAuthenticationReporter
private PasswordAuthenticationReporter passwordAuthenticationReporter
-
keyIdentityProvider
private KeyIdentityProvider keyIdentityProvider
-
publicKeyAuthenticationReporter
private PublicKeyAuthenticationReporter publicKeyAuthenticationReporter
-
hostBasedAuthenticationReporter
private HostBasedAuthenticationReporter hostBasedAuthenticationReporter
-
userAuthFactories
private java.util.List<UserAuthFactory> userAuthFactories
-
connectAddress
private java.net.SocketAddress connectAddress
-
proxyConnector
private ClientProxyConnector proxyConnector
-
-
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 java.net.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(java.net.SocketAddress connectAddress)
-
getServerKey
public java.security.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(java.security.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 java.util.List<UserAuthFactory> getUserAuthFactories()
Description copied from interface:UserAuthFactoriesManager
Retrieve the list of named factories forUserAuth
objects.- Specified by:
getUserAuthFactories
in interfaceUserAuthFactoriesManager<ClientSession,UserAuth,UserAuthFactory>
- Returns:
- a list of named
UserAuth
factories, nevernull
/empty
-
setUserAuthFactories
public void setUserAuthFactories(java.util.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
- Returns:
- The
KeyIdentityProvider
used to provide key-pair(s) for public key authentication
-
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(java.lang.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 java.lang.String removePasswordIdentity(java.lang.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(java.security.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 java.security.KeyPair removePublicKeyIdentity(java.security.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 java.lang.Exception
- Throws:
java.lang.Exception
-
initializeProxyConnector
protected void initializeProxyConnector() throws java.lang.Exception
- Throws:
java.lang.Exception
-
sendClientIdentification
protected IoWriteFuture sendClientIdentification() throws java.lang.Exception
- Throws:
java.lang.Exception
-
createChannel
public ClientChannel createChannel(java.lang.String type) throws java.io.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:
java.io.IOException
- If failed to create the requested channel
-
createChannel
public ClientChannel createChannel(java.lang.String type, java.lang.String subType) throws java.io.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:
java.io.IOException
- If failed to create the requested channel
-
createExecChannel
public ChannelExec createExecChannel(java.lang.String command, java.nio.charset.Charset charset, PtyChannelConfigurationHolder ptyConfig, java.util.Map<java.lang.String,?> env) throws java.io.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 executecharset
- TheCharset
to use for sending the command stringptyConfig
- 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:
java.io.IOException
- If failed to create the requested channel
-
createExecChannel
public ChannelExec createExecChannel(byte[] command, PtyChannelConfigurationHolder ptyConfig, java.util.Map<java.lang.String,?> env) throws java.io.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:
java.io.IOException
- If failed to create the requested channel
-
createSubsystemChannel
public ChannelSubsystem createSubsystemChannel(java.lang.String subsystem) throws java.io.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:
java.io.IOException
- If failed to create the requested channel
-
createDirectTcpipChannel
public ChannelDirectTcpip createDirectTcpipChannel(SshdSocketAddress local, SshdSocketAddress remote) throws java.io.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:
java.io.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 java.io.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:
java.io.IOException
- If failed to create the requested binding
-
stopLocalPortForwarding
public void stopLocalPortForwarding(SshdSocketAddress local) throws java.io.IOException
Description copied from interface:PortForwardingManager
Stop forwarding the given local address.- Specified by:
stopLocalPortForwarding
in interfacePortForwardingManager
- Parameters:
local
- The local address- Throws:
java.io.IOException
- If failed to cancel the requested binding
-
startRemotePortForwarding
public SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws java.io.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:
java.io.IOException
- If failed to create the requested binding
-
stopRemotePortForwarding
public void stopRemotePortForwarding(SshdSocketAddress remote) throws java.io.IOException
Description copied from interface:PortForwardingManager
Stop forwarding of the given remote address.- Specified by:
stopRemotePortForwarding
in interfacePortForwardingManager
- Parameters:
remote
- The remote address- Throws:
java.io.IOException
- If failed to cancel the requested binding
-
startDynamicPortForwarding
public SshdSocketAddress startDynamicPortForwarding(SshdSocketAddress local) throws java.io.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:
java.io.IOException
- If failed to create the requested binding
-
stopDynamicPortForwarding
public void stopDynamicPortForwarding(SshdSocketAddress local) throws java.io.IOException
Description copied from interface:PortForwardingManager
Stop a previously started dynamic port forwarding.- Specified by:
stopDynamicPortForwarding
in interfacePortForwardingManager
- Parameters:
local
- The local address- Throws:
java.io.IOException
- If failed to cancel the requested binding
-
getForwarder
protected Forwarder getForwarder()
- Overrides:
getForwarder
in classSessionHelper
-
resolveAvailableSignaturesProposal
protected java.lang.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(java.lang.String name, Buffer buffer) throws java.lang.Exception
- Specified by:
startService
in interfaceSession
- Parameters:
name
- Service namebuffer
- Extra information provided when the service start request was received- Throws:
java.lang.Exception
- If failed to start it
-
createShellChannel
public ChannelShell createShellChannel(PtyChannelConfigurationHolder ptyConfig, java.util.Map<java.lang.String,?> env) throws java.io.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:
java.io.IOException
- If failed to create the requested channel
-
readIdentification
protected boolean readIdentification(Buffer buffer) throws java.lang.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:
java.lang.Exception
- if an error occurs such as a bad protocol version or unsuccessful KEX was involved
-
signalExtraServerVersionInfo
protected void signalExtraServerVersionInfo(java.lang.String version, java.util.List<java.lang.String> lines) throws java.lang.Exception
- Throws:
java.lang.Exception
-
sendKexInit
protected byte[] sendKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal) throws java.lang.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:
java.lang.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 java.lang.Exception
- Overrides:
receiveKexInit
in classAbstractSession
- Throws:
java.lang.Exception
-
receiveKexInit
protected void receiveKexInit(java.util.Map<KexProposalOption,java.lang.String> proposal, byte[] seed) throws java.io.IOException
- Specified by:
receiveKexInit
in classAbstractSession
- Throws:
java.io.IOException
-
checkKeys
protected void checkKeys() throws java.io.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:
java.io.IOException
- If validation failed
-
switchToNoneCipher
public KeyExchangeFuture switchToNoneCipher() throws java.io.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:
java.io.IOException
- if a key exchange is already running
-
-