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:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.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.ChannelStreamPacketWriterResolver
,org.apache.sshd.common.channel.throttle.ChannelStreamPacketWriterResolverManager
,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.SignatureFactoriesManager
public class JGitSshClient extends org.apache.sshd.client.SshClient
CustomizedSshClient
for JGit. It creates specializedJGitClientSession
s that know about theHostConfigEntry
they were created for, and it loads all KeyPair identities lazily.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JGitSshClient.CombinedKeyIdentityProvider
AKeyIdentityProvider
that iterates over theIterable
s returned by otherKeyIdentityProvider
s.private static class
JGitSshClient.JGitSessionFactory
ASessionFactory
to create our own specializedJGitClientSession
s.-
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable.State
-
-
Field Summary
Fields Modifier and Type Field Description private CredentialsProvider
credentialsProvider
(package private) static org.apache.sshd.common.AttributeRepository.AttributeKey<org.apache.sshd.client.config.hosts.HostConfigEntry>
HOST_CONFIG_ENTRY
We need access to this during the constructor of the ClientSession, before setConnectAddress() can have been called.private KeyCache
keyCache
(package private) static org.apache.sshd.common.AttributeRepository.AttributeKey<java.net.InetSocketAddress>
ORIGINAL_REMOTE_ADDRESS
static org.apache.sshd.common.AttributeRepository.AttributeKey<java.lang.String>
PREFERRED_AUTHENTICATIONS
An attribute key for the comma-separated list of default preferred authentication mechanisms.private ProxyDataFactory
proxyDatabase
-
Fields inherited from class org.apache.sshd.client.SshClient
connector, DEFAULT_SERVICE_FACTORIES, DEFAULT_SSH_CLIENT_FACTORY, DEFAULT_USER_AUTH_FACTORIES, sessionFactory, userAuthFactories, userInteraction
-
Fields 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, tunnelListeners
-
Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, state
-
Fields inherited from interface org.apache.sshd.common.channel.throttle.ChannelStreamPacketWriterResolver
NONE
-
Fields inherited from interface org.apache.sshd.client.ClientAuthenticationManager
DEFAULT_PASSWORD_PROMPTS, PASSWORD_PROMPTS, PREFERRED_AUTHS
-
Fields inherited from interface org.apache.sshd.client.ClientFactoryManager
CLIENT_IDENTIFICATION, DEFAULT_HEARTBEAT_INTERVAL, DEFAULT_HEARTBEAT_REPLY_WAIT, DEFAULT_IGNORE_INVALID_IDENTITIES, DEFAULT_KEEP_ALIVE_HEARTBEAT_STRING, DEFAULT_SEND_IMMEDIATE_IDENTIFICATION, DEFAULT_SEND_KEXINIT, HEARTBEAT_INTERVAL, HEARTBEAT_REPLY_WAIT, HEARTBEAT_REQUEST, IGNORE_INVALID_IDENTITIES, SEND_IMMEDIATE_IDENTIFICATION, SEND_IMMEDIATE_KEXINIT
-
Fields inherited from interface org.apache.sshd.common.Closeable
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
-
Fields inherited from interface org.apache.sshd.common.FactoryManager
AGENT_FORWARDING_TYPE, AGENT_FORWARDING_TYPE_IETF, AGENT_FORWARDING_TYPE_OPENSSH, AUTH_TIMEOUT, CHANNEL_CLOSE_TIMEOUT, DEFAULT_AUTH_TIMEOUT, DEFAULT_CHANNEL_CLOSE_TIMEOUT, DEFAULT_DISCONNECT_TIMEOUT, DEFAULT_IDLE_TIMEOUT, DEFAULT_IGNORE_MESSAGE_FREQUENCY, DEFAULT_IGNORE_MESSAGE_SIZE, DEFAULT_IGNORE_MESSAGE_VARIANCE, DEFAULT_LIMIT_PACKET_SIZE, DEFAULT_MAX_IDENTIFICATION_SIZE, DEFAULT_MAX_PACKET_SIZE, DEFAULT_NIO_WORKERS, DEFAULT_NIO2_MIN_WRITE_TIMEOUT, DEFAULT_NIO2_READ_TIMEOUT, DEFAULT_REKEY_BYTES_LIMIT, DEFAULT_REKEY_PACKETS_LIMIT, DEFAULT_REKEY_TIME_LIMIT, DEFAULT_STOP_WAIT_TIME, DEFAULT_VERSION, DEFAULT_WINDOW_SIZE, DEFAULT_WINDOW_TIMEOUT, DISCONNECT_TIMEOUT, IDLE_TIMEOUT, IGNORE_MESSAGE_FREQUENCY, IGNORE_MESSAGE_SIZE, IGNORE_MESSAGE_VARIANCE, LIMIT_PACKET_SIZE, MAX_IDENTIFICATION_SIZE, MAX_PACKET_SIZE, NIO_WORKERS, NIO2_MIN_WRITE_TIMEOUT, NIO2_READ_BUFFER_SIZE, NIO2_READ_TIMEOUT, REKEY_BLOCKS_LIMIT, REKEY_BYTES_LIMIT, REKEY_PACKETS_LIMIT, REKEY_TIME_LIMIT, SOCKET_BACKLOG, SOCKET_KEEPALIVE, SOCKET_LINGER, SOCKET_RCVBUF, SOCKET_REUSEADDR, SOCKET_SNDBUF, STOP_WAIT_TIME, TCP_NODELAY, WINDOW_SIZE, WINDOW_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description JGitSshClient()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private org.apache.sshd.common.AttributeRepository
chain(org.apache.sshd.common.AttributeRepository self, org.apache.sshd.common.AttributeRepository parent)
private java.net.InetSocketAddress
configureProxy(ProxyData proxyData, java.net.InetSocketAddress remoteAddress)
org.apache.sshd.client.future.ConnectFuture
connect(org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig, org.apache.sshd.common.AttributeRepository context, java.net.SocketAddress localAddress)
private org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoConnectFuture>
createConnectCompletionListener(org.apache.sshd.client.future.ConnectFuture connectFuture, java.lang.String username, java.net.InetSocketAddress address, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig)
private JGitClientSession
createSession(org.apache.sshd.common.io.IoSession ioSession, java.lang.String username, java.net.InetSocketAddress address, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig)
protected org.apache.sshd.client.session.SessionFactory
createSessionFactory()
CredentialsProvider
getCredentialsProvider()
Retrieves theCredentialsProvider
set for this client.private int
getNumberOfPasswordPrompts(org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig)
private ProxyData
getProxyData(java.net.InetSocketAddress remoteAddress)
protected ProxyDataFactory
getProxyDatabase()
Retrieves theProxyDataFactory
.private org.apache.sshd.common.AttributeRepository
sessionAttributes(org.apache.sshd.common.AttributeRepository parent, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig, java.net.InetSocketAddress originalAddress)
void
setCredentialsProvider(CredentialsProvider provider)
Sets theCredentialsProvider
for this client.void
setKeyCache(KeyCache cache)
Set a cache for loaded keys.void
setProxyDatabase(ProxyDataFactory factory)
Sets aProxyDataFactory
for connecting through proxies.-
Methods inherited from class org.apache.sshd.client.SshClient
addPasswordIdentity, addPublicKeyIdentity, checkConfig, connect, connect, createConnectCompletionListener, createConnector, doConnect, getClientIdentityLoader, getClientProxyConnector, getFilePasswordProvider, getHostConfigEntryResolver, getInnerCloseable, getKeyIdentityProvider, getPasswordIdentityProvider, getRegisteredIdentities, getServerKeyVerifier, getSessionFactory, getUserAuthFactories, getUserInteraction, isStarted, onConnectOperationComplete, open, preloadClientIdentities, removePasswordIdentity, removePublicKeyIdentity, setClientIdentityLoader, setClientProxyConnector, setFilePasswordProvider, setHostConfigEntryResolver, setKeyIdentityProvider, setKeyPairProvider, setKeyPairProvider, setPasswordIdentityProvider, setServerKeyVerifier, setSessionFactory, setUpDefaultClient, setupDefaultSessionIdentities, setUpDefaultSimpleClient, setUserAuthFactories, setUserInteraction, start, stop, toString, wrapAsSimpleClient
-
Methods inherited from class org.apache.sshd.common.helpers.AbstractFactoryManager
addChannelListener, addPortForwardingEventListener, addSessionListener, attributeKeys, clearAttributes, computeAttributeIfAbsent, createSessionTimeoutListener, getAgentFactory, getAttribute, getAttributesCount, getChannelFactories, getChannelListenerProxy, getChannelStreamPacketWriterResolver, 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, setChannelStreamPacketWriterResolver, setFileSystemFactory, setForwarderFactory, setForwardingFilter, setGlobalRequestHandlers, setIoServiceEventListener, setIoServiceFactoryFactory, setNioWorkers, setParentPropertyResolver, setRandomFactory, setReservedSessionMessagesHandler, setScheduledExecutorService, setScheduledExecutorService, setServiceFactories, setSessionDisconnectHandler, setUnknownChannelReferenceHandler, setupSessionTimeout, stopSessionTimeoutListener
-
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, preClose, removeCloseFutureListener
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
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.ChannelStreamPacketWriterResolverManager
getChannelStreamPacketWriterResolver, resolveChannelStreamPacketWriter, resolveChannelStreamPacketWriterResolver, setChannelStreamPacketWriterResolver
-
Methods inherited from interface org.apache.sshd.client.ClientAuthenticationManager
setUserAuthFactoriesNames
-
Methods inherited from interface org.apache.sshd.client.session.ClientSessionCreator
connect, connect, connect, connect, connect, connect, connect, connect, connect
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
Methods inherited from interface org.apache.sshd.common.FactoryManager
getAgentFactory, getAgentForwardingFilter, getChannelFactories, getFileSystemFactory, getForwarderFactory, getForwardingFilter, getGlobalRequestHandlers, getIoServiceFactory, getRandomFactory, getScheduledExecutorService, getServiceFactories, getTcpForwardingFilter, getVersion, getX11ForwardingFilter, resolveAttribute
-
Methods inherited from interface org.apache.sshd.common.io.IoServiceEventListenerManager
getIoServiceEventListener, setIoServiceEventListener
-
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.forward.PortForwardingEventListenerManager
addPortForwardingEventListener, getPortForwardingEventListenerProxy, removePortForwardingEventListener
-
Methods inherited from interface org.apache.sshd.common.PropertyResolver
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty
-
Methods inherited from interface org.apache.sshd.common.session.ReservedSessionMessagesManager
getReservedSessionMessagesHandler, setReservedSessionMessagesHandler
-
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
-
Methods inherited from interface org.apache.sshd.common.session.SessionListenerManager
addSessionListener, getSessionListenerProxy, removeSessionListener
-
Methods inherited from interface org.apache.sshd.common.signature.SignatureFactoriesManager
getSignatureFactories, getSignatureFactoriesNameList, getSignatureFactoriesNames, setSignatureFactories, setSignatureFactoriesNameList, setSignatureFactoriesNames, setSignatureFactoriesNames
-
-
-
-
Field Detail
-
HOST_CONFIG_ENTRY
static final org.apache.sshd.common.AttributeRepository.AttributeKey<org.apache.sshd.client.config.hosts.HostConfigEntry> HOST_CONFIG_ENTRY
We 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<java.net.InetSocketAddress> ORIGINAL_REMOTE_ADDRESS
-
PREFERRED_AUTHENTICATIONS
public static final org.apache.sshd.common.AttributeRepository.AttributeKey<java.lang.String> PREFERRED_AUTHENTICATIONS
An attribute key for the comma-separated list of default preferred authentication mechanisms.
-
keyCache
private KeyCache keyCache
-
credentialsProvider
private CredentialsProvider credentialsProvider
-
proxyDatabase
private ProxyDataFactory proxyDatabase
-
-
Method Detail
-
createSessionFactory
protected org.apache.sshd.client.session.SessionFactory createSessionFactory()
- Overrides:
createSessionFactory
in 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, java.net.SocketAddress localAddress) throws java.io.IOException
- Specified by:
connect
in interfaceorg.apache.sshd.client.session.ClientSessionCreator
- Overrides:
connect
in classorg.apache.sshd.client.SshClient
- Throws:
java.io.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, java.net.InetSocketAddress originalAddress)
-
getProxyData
private ProxyData getProxyData(java.net.InetSocketAddress remoteAddress)
-
configureProxy
private java.net.InetSocketAddress configureProxy(ProxyData proxyData, java.net.InetSocketAddress remoteAddress)
-
createConnectCompletionListener
private org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoConnectFuture> createConnectCompletionListener(org.apache.sshd.client.future.ConnectFuture connectFuture, java.lang.String username, java.net.InetSocketAddress address, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig)
-
createSession
private JGitClientSession createSession(org.apache.sshd.common.io.IoSession ioSession, java.lang.String username, java.net.InetSocketAddress address, org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig)
-
getNumberOfPasswordPrompts
private int getNumberOfPasswordPrompts(org.apache.sshd.client.config.hosts.HostConfigEntry hostConfig)
-
setKeyCache
public void setKeyCache(KeyCache cache)
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
public void setProxyDatabase(ProxyDataFactory factory)
Sets aProxyDataFactory
for connecting through proxies.- Parameters:
factory
- to use, ornull
if proxying is not desired or supported
-
getProxyDatabase
protected ProxyDataFactory getProxyDatabase()
Retrieves theProxyDataFactory
.- Returns:
- the factory, or
null
if none is set
-
setCredentialsProvider
public void setCredentialsProvider(CredentialsProvider provider)
Sets theCredentialsProvider
for this client.- Parameters:
provider
- to set
-
getCredentialsProvider
public CredentialsProvider getCredentialsProvider()
Retrieves theCredentialsProvider
set for this client.- Returns:
- the provider, or
null
if none is set.
-
-