Top Description Inners Fields Constructors Methods
org.eclipse.jgit.internal.transport.sshd

public Class JGitSshClient

extends SshClient
Class Inheritance
Static Imports
java.text.MessageFormat.format, org.apache.sshd.core.CoreModuleProperties.PASSWORD_PROMPTS, .CoreModuleProperties.PREFERRED_AUTHS, org.eclipse.jgit.internal.transport.ssh.OpenSshConfigFile.positive

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 and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private CredentialsProvider
public static final AttributeRepository.AttributeKey<Path>
HOME_DIRECTORY

An attribute key for the home directory.

pack-priv static final AttributeRepository.AttributeKey<HostConfigEntry>
HOST_CONFIG_ENTRY

We need access to this during the constructor of the ClientSession, before setConnectAddress() can have been called.

private KeyCache
private Supplier<KeyPasswordProvider>
public static final AttributeRepository.AttributeKey<SshdSocketAddress>
LOCAL_FORWARD_ADDRESS

An attribute key for storing an alternate local address to connect to if a local forward from a ProxyJump ssh config is present.

pack-priv static final AttributeRepository.AttributeKey<InetSocketAddress>
public static final AttributeRepository.AttributeKey<String>
PREFERRED_AUTHENTICATIONS

An attribute key for the comma-separated list of default preferred authentication mechanisms.

private ProxyDataFactory
Inherited from org.apache.sshd.client.SshClient:
connectorDEFAULT_SERVICE_FACTORIESDEFAULT_SSH_CLIENT_FACTORYDEFAULT_USER_AUTH_FACTORIESsessionFactoryuserAuthFactories

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private AttributeRepository
private InetSocketAddress
configureProxy(ProxyData proxyData, InetSocketAddress remoteAddress)

public ConnectFuture
connect(HostConfigEntry
The effective HostConfigEntry to connect to - never null
hostConfig
,
AttributeRepository
An optional "context" to be attached to the established session if successfully connected
context
,
SocketAddress
The local address to use - if null an automatic ephemeral port and bind address is used
localAddress
)

Overrides org.apache.sshd.client.SshClient.connect.

Implements org.apache.sshd.client.session.ClientSessionCreator.connect.

private SshFutureListener<IoConnectFuture>
private JGitClientSession
createSession(IoSession ioSession, String username, InetSocketAddress address, HostConfigEntry hostConfig)

protected SessionFactory
public CredentialsProvider

Returns:

the provider, or null if none is set.
getCredentialsProvider
()

Retrieves the CredentialsProvider set for this client.

public Supplier<KeyPasswordProvider>

Returns:

a factory to create KeyPasswordProviders
getKeyPasswordProviderFactory
()

Retrieves the KeyPasswordProvider factory of this client.

private int
private ProxyData
protected ProxyDataFactory

Returns:

the factory, or null if none is set
getProxyDatabase
()

Retrieves the ProxyDataFactory.

private AttributeRepository
public void
setCredentialsProvider(CredentialsProvider
to set
provider
)

Sets the CredentialsProvider for this client.

public void
setKeyCache(KeyCache
to use
cache
)

Set a cache for loaded keys.

public void
setKeyPasswordProviderFactory(Supplier<KeyPasswordProvider>
to set
factory
)

Sets a supplier for a KeyPasswordProvider for this client.

public void
setProxyDatabase(ProxyDataFactory
to use, or null if proxying is not desired or supported
factory
)

Sets a ProxyDataFactory for connecting through proxies.

Inherited from org.apache.sshd.client.SshClient:
addPasswordIdentityaddPublicKeyIdentitycheckConfigconnectconnectconnectcreateConnectCompletionListenercreateConnectordoConnectdoConnectensureFilePasswordProvidergetClientIdentityLoadergetClientProxyConnectorgetFilePasswordProvidergetHostBasedAuthenticationReportergetHostConfigEntryResolvergetInnerCloseablegetKeyIdentityProvidergetPasswordAuthenticationReportergetPasswordIdentityProvidergetPublicKeyAuthenticationReportergetRegisteredIdentitiesgetServerKeyVerifiergetSessionFactorygetUserAuthFactoriesgetUserInteractionisStartedonConnectOperationCompleteopenparseProxyJumpsparseProxyJumpspreloadClientIdentitiesremovePasswordIdentityremovePublicKeyIdentityresolveHostsetClientIdentityLoadersetClientProxyConnectorsetFilePasswordProvidersetHostBasedAuthenticationReportersetHostConfigEntryResolversetKeyIdentityProvidersetKeyPairProvidersetKeyPairProvidersetPasswordAuthenticationReportersetPasswordIdentityProvidersetPublicKeyAuthenticationReportersetServerKeyVerifiersetSessionFactorysetUpDefaultClientsetupDefaultSessionIdentitiessetUpDefaultSimpleClientsetUserAuthFactoriessetUserInteractionstartstoptoStringwrapAsSimpleClient

Field Detail

credentialsProviderback to summary
private CredentialsProvider credentialsProvider
HOME_DIRECTORYback to summary
public static final AttributeRepository.AttributeKey<Path> HOME_DIRECTORY

An attribute key for the home directory.

HOST_CONFIG_ENTRYback to summary
pack-priv static final AttributeRepository.AttributeKey<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.

keyCacheback to summary
private KeyCache keyCache
keyPasswordProviderFactoryback to summary
private Supplier<KeyPasswordProvider> keyPasswordProviderFactory
LOCAL_FORWARD_ADDRESSback to summary
public static final AttributeRepository.AttributeKey<SshdSocketAddress> LOCAL_FORWARD_ADDRESS

An 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 the HostConfigEntry but to the address stored in this key (which is assumed to forward the HostConfigEntry address).

ORIGINAL_REMOTE_ADDRESSback to summary
pack-priv static final AttributeRepository.AttributeKey<InetSocketAddress> ORIGINAL_REMOTE_ADDRESS
PREFERRED_AUTHENTICATIONSback to summary
public static final AttributeRepository.AttributeKey<String> PREFERRED_AUTHENTICATIONS

An attribute key for the comma-separated list of default preferred authentication mechanisms.

proxyDatabaseback to summary
private ProxyDataFactory proxyDatabase

Constructor Detail

JGitSshClientback to summary
public JGitSshClient()

Method Detail

chainback to summary
private AttributeRepository chain(AttributeRepository self, AttributeRepository parent)
configureProxyback to summary
private InetSocketAddress configureProxy(ProxyData proxyData, InetSocketAddress remoteAddress)
connectback to summary
public ConnectFuture connect(HostConfigEntry hostConfig, AttributeRepository context, SocketAddress localAddress) throws IOException

Overrides org.apache.sshd.client.SshClient.connect.

Implements org.apache.sshd.client.session.ClientSessionCreator.connect.

Parameters
hostConfig:HostConfigEntry

Doc from org.apache.sshd.client.session.ClientSessionCreator.connect.

The effective HostConfigEntry to connect to - never null

context:AttributeRepository

Doc from org.apache.sshd.client.session.ClientSessionCreator.connect.

An optional "context" to be attached to the established session if successfully connected

localAddress:SocketAddress

Doc from org.apache.sshd.client.session.ClientSessionCreator.connect.

The local address to use - if null an automatic ephemeral port and bind address is used

Returns:ConnectFuture

Doc from org.apache.sshd.client.session.ClientSessionCreator.connect.

A ConnectFuture

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.client.session.ClientSessionCreator.connect.

If failed to create the connection future

createConnectCompletionListenerback to summary
private SshFutureListener<IoConnectFuture> createConnectCompletionListener(ConnectFuture connectFuture, String username, InetSocketAddress address, HostConfigEntry hostConfig)
createSessionback to summary
private JGitClientSession createSession(IoSession ioSession, String username, InetSocketAddress address, HostConfigEntry hostConfig)
createSessionFactoryback to summary
protected SessionFactory createSessionFactory()

Overrides org.apache.sshd.client.SshClient.createSessionFactory.

Annotations
@Override
getCredentialsProviderback to summary
public CredentialsProvider getCredentialsProvider()

Retrieves the CredentialsProvider set for this client.

Returns:CredentialsProvider

the provider, or null if none is set.

getKeyPasswordProviderFactoryback to summary
public Supplier<KeyPasswordProvider> getKeyPasswordProviderFactory()

Retrieves the KeyPasswordProvider factory of this client.

Returns:Supplier<KeyPasswordProvider>

a factory to create KeyPasswordProviders

getNumberOfPasswordPromptsback to summary
private int getNumberOfPasswordPrompts(HostConfigEntry hostConfig)
getProxyDataback to summary
private ProxyData getProxyData(InetSocketAddress remoteAddress)
getProxyDatabaseback to summary
protected ProxyDataFactory getProxyDatabase()

Retrieves the ProxyDataFactory.

Returns:ProxyDataFactory

the factory, or null if none is set

sessionAttributesback to summary
private AttributeRepository sessionAttributes(AttributeRepository parent, HostConfigEntry hostConfig, InetSocketAddress originalAddress)
setCredentialsProviderback to summary
public void setCredentialsProvider(CredentialsProvider provider)

Sets the CredentialsProvider for this client.

Parameters
provider:CredentialsProvider

to set

setKeyCacheback to summary
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:KeyCache

to use

setKeyPasswordProviderFactoryback to summary
public void setKeyPasswordProviderFactory(Supplier<KeyPasswordProvider> factory)

Sets a supplier for a KeyPasswordProvider for this client.

Parameters
factory:Supplier<KeyPasswordProvider>

to set

setProxyDatabaseback to summary
public void setProxyDatabase(ProxyDataFactory factory)

Sets a ProxyDataFactory for connecting through proxies.

Parameters
factory:ProxyDataFactory

to use, or null if proxying is not desired or supported

org.eclipse.jgit.internal.transport.sshd back to summary

private Class JGitSshClient.CombinedKeyIdentityProvider

extends Object
implements KeyIdentityProvider
Class Inheritance
  • java.lang.Object
  • org.eclipse.jgit.internal.transport.sshd.JGitSshClient.CombinedKeyIdentityProvider
All Implemented Interfaces
org.apache.sshd.common.keyprovider.KeyIdentityProvider

A KeyIdentityProvider that iterates over the Iterables returned by other KeyIdentityProviders.

Field Summary

Modifier and TypeField and Description
private final List<KeyIdentityProvider>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public Iterable<KeyPair>
loadKeys(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
context
)

Implements org.apache.sshd.common.keyprovider.KeyIdentityProvider.loadKeys.

Load available keys.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

providersback to summary
private final List<KeyIdentityProvider> providers

Constructor Detail

CombinedKeyIdentityProviderback to summary
public CombinedKeyIdentityProvider(KeyIdentityProvider... providers)
CombinedKeyIdentityProviderback to summary
public CombinedKeyIdentityProvider(List<KeyIdentityProvider> providers)

Method Detail

loadKeysback to summary
public Iterable<KeyPair> loadKeys(SessionContext context)

Implements org.apache.sshd.common.keyprovider.KeyIdentityProvider.loadKeys.

Doc from org.apache.sshd.common.keyprovider.KeyIdentityProvider.loadKeys.

Load available keys.

Parameters
context:SessionContext

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

Returns:Iterable<KeyPair>

an Iterable instance of available keys - ignored if null

Annotations
@Override
org.eclipse.jgit.internal.transport.sshd back to summary

private Class JGitSshClient.JGitSessionFactory

extends SessionFactory
Class Inheritance

A SessionFactory to create our own specialized JGitClientSessions.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected ClientSessionImpl
Inherited from org.apache.sshd.client.session.SessionFactory:
getClient

Constructor Detail

JGitSessionFactoryback to summary
public JGitSessionFactory(JGitSshClient client)

Method Detail

doCreateSessionback to summary
protected ClientSessionImpl doCreateSession(IoSession ioSession) throws Exception

Overrides org.apache.sshd.client.session.SessionFactory.doCreateSession.

Annotations
@Override