Class JGitSshClient
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.helpers.AbstractFactoryManager
org.apache.sshd.client.SshClient
org.eclipse.jgit.internal.transport.sshd.JGitSshClient
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,org.apache.sshd.client.ClientAuthenticationManager,org.apache.sshd.client.ClientFactoryManager,org.apache.sshd.client.config.keys.ClientIdentityLoaderHolder,org.apache.sshd.client.config.keys.ClientIdentityLoaderManager,org.apache.sshd.client.session.ClientProxyConnectorHolder,org.apache.sshd.client.session.ClientSessionCreator,org.apache.sshd.common.AttributeRepository,org.apache.sshd.common.AttributeStore,org.apache.sshd.common.auth.UserAuthFactoriesManager<org.apache.sshd.client.session.ClientSession,,org.apache.sshd.client.auth.UserAuth, org.apache.sshd.client.auth.UserAuthFactory> org.apache.sshd.common.channel.ChannelListenerManager,org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolver,org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolverManager,org.apache.sshd.common.Closeable,org.apache.sshd.common.config.keys.FilePasswordProviderHolder,org.apache.sshd.common.config.keys.FilePasswordProviderManager,org.apache.sshd.common.FactoryManager,org.apache.sshd.common.forward.PortForwardingEventListenerManager,org.apache.sshd.common.io.IoServiceEventListenerManager,org.apache.sshd.common.kex.extension.KexExtensionHandlerManager,org.apache.sshd.common.kex.KexFactoryManager,org.apache.sshd.common.keyprovider.KeyIdentityProviderHolder,org.apache.sshd.common.PropertyResolver,org.apache.sshd.common.session.ReservedSessionMessagesManager,org.apache.sshd.common.session.SessionDisconnectHandlerManager,org.apache.sshd.common.session.SessionHeartbeatController,org.apache.sshd.common.session.SessionListenerManager,org.apache.sshd.common.session.UnknownChannelReferenceHandlerManager,org.apache.sshd.common.signature.SignatureFactoriesHolder,org.apache.sshd.common.signature.SignatureFactoriesManager
public class JGitSshClient
extends org.apache.sshd.client.SshClient
Customized
SshClient for JGit. It creates specialized
JGitClientSessions that know about the HostConfigEntry they
were created for, and it loads all KeyPair identities lazily.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classASessionFactoryto create our own specializedJGitClientSessions.Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable.StateNested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
org.apache.sshd.common.AttributeRepository.AttributeKey<T extends Object>Nested classes/interfaces inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
org.apache.sshd.common.session.SessionHeartbeatController.HeartbeatType -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Supplier<org.apache.sshd.agent.SshAgentFactory>private CredentialsProvider(package private) static final org.apache.sshd.common.AttributeRepository.AttributeKey<org.apache.sshd.client.config.hosts.HostConfigEntry>We need access to this during the constructor of the ClientSession, before setConnectAddress() can have been called.private KeyCachestatic final org.apache.sshd.common.AttributeRepository.AttributeKey<org.apache.sshd.common.util.net.SshdSocketAddress>An attribute key for storing an alternate local address to connect to if a local forward from a ProxyJump ssh config is present.(package private) static final org.apache.sshd.common.AttributeRepository.AttributeKey<InetSocketAddress>static final org.apache.sshd.common.AttributeRepository.AttributeKey<String>An attribute key for the comma-separated list of default preferred authentication mechanisms.private ProxyDataFactoryFields inherited from class org.apache.sshd.client.SshClient
connector, DEFAULT_SERVICE_FACTORIES, DEFAULT_SSH_CLIENT_FACTORY, DEFAULT_USER_AUTH_FACTORIES, sessionFactory, userAuthFactoriesFields inherited from class org.apache.sshd.common.helpers.AbstractFactoryManager
agentFactory, channelFactories, channelListenerProxy, channelListeners, executor, fileSystemFactory, forwarderFactory, forwardingFilter, globalRequestHandlers, ioServiceFactory, ioServiceFactoryFactory, randomFactory, serviceFactories, sessionListenerProxy, sessionListeners, sessionTimeoutListener, shutdownExecutor, timeoutListenerFuture, tunnelListenerProxy, tunnelListenersFields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, stateFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
logFields inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolver
NONEFields inherited from interface org.apache.sshd.client.session.ClientSessionCreator
TARGET_SERVERFields inherited from interface org.apache.sshd.common.FactoryManager
DEFAULT_VERSIONFields inherited from interface org.apache.sshd.common.PropertyResolver
EMPTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate org.apache.sshd.common.AttributeRepositorychain(org.apache.sshd.common.AttributeRepository self, org.apache.sshd.common.AttributeRepository parent) protected voidprivate InetSocketAddressconfigureProxy(ProxyData proxyData, InetSocketAddress remoteAddress) org.apache.sshd.client.future.ConnectFutureconnect(org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig, org.apache.sshd.common.AttributeRepository context, SocketAddress localAddress) private org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoConnectFuture>createConnectCompletionListener(org.apache.sshd.client.future.ConnectFuture connectFuture, String username, InetSocketAddress address, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig) private JGitClientSessioncreateSession(org.apache.sshd.common.io.IoSession ioSession, String username, InetSocketAddress address, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig) protected org.apache.sshd.client.session.SessionFactoryorg.apache.sshd.agent.SshAgentFactoryRetrieves theCredentialsProviderset for this client.private intgetNumberOfPasswordPrompts(org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig) private ProxyDatagetProxyData(InetSocketAddress remoteAddress) protected ProxyDataFactoryRetrieves theProxyDataFactory.private org.apache.sshd.common.AttributeRepositorysessionAttributes(org.apache.sshd.common.AttributeRepository parent, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig, InetSocketAddress originalAddress) voidsetCredentialsProvider(CredentialsProvider provider) Sets theCredentialsProviderfor this client.voidsetKeyCache(KeyCache cache) Set a cache for loaded keys.voidsetProxyDatabase(ProxyDataFactory factory) Sets aProxyDataFactoryfor connecting through proxies.Methods inherited from class org.apache.sshd.client.SshClient
addPasswordIdentity, addPublicKeyIdentity, connect, connect, connect, createConnectCompletionListener, createConnector, doConnect, doConnect, getClientIdentityLoader, getClientProxyConnector, getFilePasswordProvider, getHostBasedAuthenticationReporter, getHostConfigEntryResolver, getInnerCloseable, getKeyIdentityProvider, getPasswordAuthenticationReporter, getPasswordIdentityProvider, getPublicKeyAuthenticationReporter, getRegisteredIdentities, getServerKeyVerifier, getSessionFactory, getUserAuthFactories, getUserInteraction, isStarted, onConnectOperationComplete, open, parseProxyJumps, preloadClientIdentities, removePasswordIdentity, removePublicKeyIdentity, resolveHost, setClientIdentityLoader, setClientProxyConnector, setFilePasswordProvider, setHostBasedAuthenticationReporter, setHostConfigEntryResolver, setKeyIdentityProvider, setKeyPairProvider, setKeyPairProvider, setPasswordAuthenticationReporter, setPasswordIdentityProvider, setPublicKeyAuthenticationReporter, setServerKeyVerifier, setSessionFactory, setUpDefaultClient, setupDefaultSessionIdentities, setUpDefaultSimpleClient, setUserAuthFactories, setUserInteraction, start, stop, toString, wrapAsSimpleClientMethods inherited from class org.apache.sshd.common.helpers.AbstractFactoryManager
addChannelListener, addPortForwardingEventListener, addSessionListener, attributeKeys, clearAttributes, computeAttributeIfAbsent, createSessionTimeoutListener, getAttribute, getAttributesCount, getChannelFactories, getChannelListenerProxy, getChannelStreamWriterResolver, getFileSystemFactory, getForwarderFactory, getForwardingFilter, getGlobalRequestHandlers, getIoServiceEventListener, getIoServiceFactory, getIoServiceFactoryFactory, getNioWorkers, getParentPropertyResolver, getPortForwardingEventListenerProxy, getProperties, getRandomFactory, getReservedSessionMessagesHandler, getScheduledExecutorService, getServiceFactories, getSessionDisconnectHandler, getSessionListenerProxy, getUnknownChannelReferenceHandler, getVersion, removeAttribute, removeChannelListener, removePortForwardingEventListener, removeSessionListener, removeSessionTimeout, resolveUnknownChannelReferenceHandler, setAgentFactory, setAttribute, setChannelFactories, setChannelStreamWriterResolver, setFileSystemFactory, setForwarderFactory, setForwardingFilter, setGlobalRequestHandlers, setIoServiceEventListener, setIoServiceFactoryFactory, setNioWorkers, setParentPropertyResolver, setRandomFactory, setReservedSessionMessagesHandler, setScheduledExecutorService, setScheduledExecutorService, setServiceFactories, setSessionDisconnectHandler, setUnknownChannelReferenceHandler, setupSessionTimeout, stopSessionTimeoutListenerMethods inherited from class org.apache.sshd.common.kex.AbstractKexFactoryManager
getCipherFactories, getCompressionFactories, getDelegate, getKexExtensionHandler, getKeyExchangeFactories, getMacFactories, getSignatureFactories, resolveEffectiveFactories, resolveEffectiveProvider, setCipherFactories, setCompressionFactories, setKexExtensionHandler, setKeyExchangeFactories, setMacFactories, setSignatureFactoriesMethods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediatelyMethods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, preClose, removeCloseFutureListenerMethods 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, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.AttributeRepository
attributeKeys, getAttribute, getAttributesCountMethods inherited from interface org.apache.sshd.common.AttributeStore
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttributeMethods inherited from interface org.apache.sshd.common.channel.ChannelListenerManager
addChannelListener, getChannelListenerProxy, removeChannelListenerMethods inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamWriterResolverManager
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolverMethods inherited from interface org.apache.sshd.client.ClientAuthenticationManager
setUserAuthFactoriesNamesMethods inherited from interface org.apache.sshd.client.session.ClientSessionCreator
connect, connect, connect, connect, connect, connect, connect, connect, connectMethods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListenerMethods inherited from interface org.apache.sshd.common.FactoryManager
getAgentForwardingFilter, getChannelFactories, getFileSystemFactory, getForwarderFactory, getForwardingFilter, getGlobalRequestHandlers, getIoServiceFactory, getRandomFactory, getScheduledExecutorService, getServiceFactories, getTcpForwardingFilter, getVersion, getX11ForwardingFilter, resolveAttributeMethods inherited from interface org.apache.sshd.common.io.IoServiceEventListenerManager
getIoServiceEventListener, setIoServiceEventListenerMethods inherited from interface org.apache.sshd.common.kex.extension.KexExtensionHandlerManager
getKexExtensionHandler, setKexExtensionHandlerMethods 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, setMacFactoriesNamesMethods inherited from interface org.apache.sshd.common.forward.PortForwardingEventListenerManager
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListenerMethods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmptyMethods inherited from interface org.apache.sshd.common.session.ReservedSessionMessagesManager
getReservedSessionMessagesHandler, setReservedSessionMessagesHandlerMethods inherited from interface org.apache.sshd.common.session.SessionDisconnectHandlerManager
getSessionDisconnectHandler, setSessionDisconnectHandlerMethods inherited from interface org.apache.sshd.common.session.SessionHeartbeatController
disableSessionHeartbeat, getSessionHeartbeatInterval, getSessionHeartbeatType, setSessionHeartbeat, setSessionHeartbeatMethods inherited from interface org.apache.sshd.common.session.SessionListenerManager
addSessionListener, getSessionListenerProxy, removeSessionListenerMethods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesHolder
getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNamesMethods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesManager
setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNamesMethods inherited from interface org.apache.sshd.common.session.UnknownChannelReferenceHandlerManager
getUnknownChannelReferenceHandler, resolveUnknownChannelReferenceHandler, setUnknownChannelReferenceHandlerMethods inherited from interface org.apache.sshd.common.auth.UserAuthFactoriesManager
getUserAuthFactoriesNameList, getUserAuthFactoriesNames, setUserAuthFactoriesNameList, setUserAuthFactoriesNames
-
Field Details
-
HOST_CONFIG_ENTRY
static final org.apache.sshd.common.AttributeRepository.AttributeKey<org.apache.sshd.client.config.hosts.HostConfigEntry> HOST_CONFIG_ENTRYWe need access to this during the constructor of the ClientSession, before setConnectAddress() can have been called. So we have to remember it in an attribute on the SshClient, from where we can then retrieve it. -
ORIGINAL_REMOTE_ADDRESS
static final org.apache.sshd.common.AttributeRepository.AttributeKey<InetSocketAddress> ORIGINAL_REMOTE_ADDRESS -
PREFERRED_AUTHENTICATIONS
public static final org.apache.sshd.common.AttributeRepository.AttributeKey<String> PREFERRED_AUTHENTICATIONSAn attribute key for the comma-separated list of default preferred authentication mechanisms. -
LOCAL_FORWARD_ADDRESS
public static final org.apache.sshd.common.AttributeRepository.AttributeKey<org.apache.sshd.common.util.net.SshdSocketAddress> LOCAL_FORWARD_ADDRESSAn attribute key for storing an alternate local address to connect to if a local forward from a ProxyJump ssh config is present. If set,connect(HostConfigEntry, AttributeRepository, SocketAddress)will not connect to the address obtained from theHostConfigEntrybut to the address stored in this key (which is assumed to forward theHostConfigEntryaddress). -
keyCache
-
credentialsProvider
-
proxyDatabase
-
agentFactorySupplier
-
-
Constructor Details
-
JGitSshClient
public JGitSshClient()
-
-
Method Details
-
createSessionFactory
protected org.apache.sshd.client.session.SessionFactory createSessionFactory()- Overrides:
createSessionFactoryin classorg.apache.sshd.client.SshClient
-
connect
public org.apache.sshd.client.future.ConnectFuture connect(org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig, org.apache.sshd.common.AttributeRepository context, SocketAddress localAddress) throws IOException - Specified by:
connectin interfaceorg.apache.sshd.client.session.ClientSessionCreator- Overrides:
connectin classorg.apache.sshd.client.SshClient- Throws:
IOException
-
chain
private org.apache.sshd.common.AttributeRepository chain(org.apache.sshd.common.AttributeRepository self, org.apache.sshd.common.AttributeRepository parent) -
sessionAttributes
private org.apache.sshd.common.AttributeRepository sessionAttributes(org.apache.sshd.common.AttributeRepository parent, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig, InetSocketAddress originalAddress) -
getProxyData
-
configureProxy
-
createConnectCompletionListener
private org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoConnectFuture> createConnectCompletionListener(org.apache.sshd.client.future.ConnectFuture connectFuture, String username, InetSocketAddress address, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig) -
createSession
private JGitClientSession createSession(org.apache.sshd.common.io.IoSession ioSession, String username, InetSocketAddress address, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig) -
getNumberOfPasswordPrompts
private int getNumberOfPasswordPrompts(org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig) -
setKeyCache
Set a cache for loaded keys. Newly discovered keys will be added when IdentityFile host entries from the ssh config file are used during session authentication.- Parameters:
cache- to use
-
setProxyDatabase
Sets aProxyDataFactoryfor connecting through proxies.- Parameters:
factory- to use, ornullif proxying is not desired or supported
-
getProxyDatabase
Retrieves theProxyDataFactory.- Returns:
- the factory, or
nullif none is set
-
setCredentialsProvider
Sets theCredentialsProviderfor this client.- Parameters:
provider- to set
-
getCredentialsProvider
Retrieves theCredentialsProviderset for this client.- Returns:
- the provider, or
nullif none is set.
-
getAgentFactory
public org.apache.sshd.agent.SshAgentFactory getAgentFactory()- Specified by:
getAgentFactoryin interfaceorg.apache.sshd.common.FactoryManager- Overrides:
getAgentFactoryin classorg.apache.sshd.common.helpers.AbstractFactoryManager
-
checkConfig
protected void checkConfig()- Overrides:
checkConfigin classorg.apache.sshd.client.SshClient
-