Package org.eclipse.jgit.transport.sshd
Class SshdSessionFactoryBuilder
java.lang.Object
org.eclipse.jgit.transport.sshd.SshdSessionFactoryBuilder
A builder API to configure
SshdSessionFactories
.- Since:
- 5.8
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A factory interface for creating aSshConfigStore
.private static class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBuilds aSshdSessionFactory
as configured, using the givenKeyCache
for caching keys.setConfigFile
(Function<File, File> supplier) Sets a function that returns the SSH config file, given the SSH directory.Sets a factory for theSshConfigStore
to use.setConnectorFactory
(ConnectorFactory factory) Sets an explicitConnectorFactory
.setDefaultIdentities
(Function<File, List<Path>> supplier) Sets a function that returns the default private key files, given the SSH directory.setDefaultKeysProvider
(Function<File, Iterable<KeyPair>> provider) Sets a function that returns the default private keys, given the SSH directory.setDefaultKnownHostsFiles
(Function<File, List<Path>> supplier) Sets a function that returns the default known hosts files, given the SSH directory.setHomeDirectory
(File homeDirectory) Sets the home directory to use forSshdSessionFactories
created bybuild(KeyCache)
.Sets a factory function to create aKeyPasswordProvider
.setPreferredAuthentications
(String authentications) Sets the default preferred authentication mechanisms to use forSshdSessionFactories
created bybuild(KeyCache)
.setProxyDataFactory
(ProxyDataFactory proxyDataFactory) setServerKeyDatabase
(BiFunction<File, File, ServerKeyDatabase> factory) Sets a function that creates a newServerKeyDatabase
, given the SSH and home directory.setSshDirectory
(File sshDirectory) Sets the SSH directory to use forSshdSessionFactories
created bybuild(KeyCache)
.Removes a previously setConnectorFactory
.
-
Field Details
-
state
-
-
Constructor Details
-
SshdSessionFactoryBuilder
public SshdSessionFactoryBuilder()
-
-
Method Details
-
setProxyDataFactory
- Parameters:
proxyDataFactory
- to use- Returns:
- this
SshdSessionFactoryBuilder
-
setHomeDirectory
Sets the home directory to use forSshdSessionFactories
created bybuild(KeyCache)
.- Parameters:
homeDirectory
- to use; may benull
, in which case the home directory as defined byFS.userHome()
is assumed- Returns:
- this
SshdSessionFactoryBuilder
-
setSshDirectory
Sets the SSH directory to use forSshdSessionFactories
created bybuild(KeyCache)
.- Parameters:
sshDirectory
- to use; may benull
, in which case ".ssh" under thehome directory
is assumed- Returns:
- this
SshdSessionFactoryBuilder
-
setPreferredAuthentications
Sets the default preferred authentication mechanisms to use forSshdSessionFactories
created bybuild(KeyCache)
.- Parameters:
authentications
- comma-separated list of authentication mechanism names; ifnull
or empty, the default as specified bySshdSessionFactory.getDefaultPreferredAuthentications()
will be used- Returns:
- this
SshdSessionFactoryBuilder
-
setConfigFile
Sets a function that returns the SSH config file, given the SSH directory. The function may returnnull
, in which case no SSH config file will be used. If a non-null file is returned, it will be used when it exists. If no supplier has been set, or the supplier has been set explicitly tonull
, by default a file namedSshConstants.CONFIG
in theSSH directory
is used.- Parameters:
supplier
- returning aFile
for the SSH config file to use, or returningnull
if no config file is to be used- Returns:
- this
SshdSessionFactoryBuilder
-
setConfigStoreFactory
public SshdSessionFactoryBuilder setConfigStoreFactory(SshdSessionFactoryBuilder.ConfigStoreFactory factory) Sets a factory for theSshConfigStore
to use. If not set or explicitly set tonull
, the default as specified bySshdSessionFactory.createSshConfigStore(File, File, String)
is used.- Parameters:
factory
- to set- Returns:
- this
SshdSessionFactoryBuilder
-
setDefaultKnownHostsFiles
Sets a function that returns the default known hosts files, given the SSH directory. If not set or explicitly set tonull
, the defaults as specified bySshdSessionFactory.getDefaultKnownHostsFiles(File)
are used.- Parameters:
supplier
- to get the default known hosts files- Returns:
- this
SshdSessionFactoryBuilder
-
setDefaultIdentities
Sets a function that returns the default private key files, given the SSH directory. If not set or explicitly set tonull
, the defaults as specified bySshdSessionFactory.getDefaultIdentities(File)
are used.- Parameters:
supplier
- to get the default private key files- Returns:
- this
SshdSessionFactoryBuilder
-
setDefaultKeysProvider
Sets a function that returns the default private keys, given the SSH directory. If not set or explicitly set tonull
, the defaults as specified bySshdSessionFactory.getDefaultKeys(File)
are used.- Parameters:
provider
- to get the default private key files- Returns:
- this
SshdSessionFactoryBuilder
-
setKeyPasswordProvider
public SshdSessionFactoryBuilder setKeyPasswordProvider(Function<CredentialsProvider, KeyPasswordProvider> factory) Sets a factory function to create aKeyPasswordProvider
. If not set or explicitly set tonull
, or if the factory returnsnull
, the default as specified bySshdSessionFactory.createKeyPasswordProvider(CredentialsProvider)
is used.- Parameters:
factory
- to create aKeyPasswordProvider
- Returns:
- this
SshdSessionFactoryBuilder
-
setServerKeyDatabase
public SshdSessionFactoryBuilder setServerKeyDatabase(BiFunction<File, File, ServerKeyDatabase> factory) Sets a function that creates a newServerKeyDatabase
, given the SSH and home directory. If not set or explicitly set tonull
, or if thefactory
returnsnull
, the default as specified bySshdSessionFactory.createServerKeyDatabase(File, File)
is used.- Parameters:
factory
- to create aServerKeyDatabase
- Returns:
- this
SshdSessionFactoryBuilder
-
setConnectorFactory
Sets an explicitConnectorFactory
. Ifnull
, there will be no support for SSH agents.If not set, the created
SshdSessionFactory
will use theServiceLoader
to find anConnectorFactory
.- Parameters:
factory
-ConnectorFactory
to use- Returns:
- this
SshdSessionFactoryBuilder
- Since:
- 6.0
-
withDefaultConnectorFactory
Removes a previously setConnectorFactory
. The createdSshdSessionFactory
will use theServiceLoader
to find anConnectorFactory
. This is also the default ifsetConnectorFactory(ConnectorFactory)
isn't called at all.- Returns:
- this
SshdSessionFactoryBuilder
- Since:
- 6.0
-
build
Builds aSshdSessionFactory
as configured, using the givenKeyCache
for caching keys.Different
SshdSessionFactories
should not share the sameKeyCache
since the cache is invalidated when the factory itself or when the lastSshdSession
created from the factory is closed.- Parameters:
cache
- to use for caching ssh keys; may benull
if no caching is desired.- Returns:
- the
SshdSessionFactory
-