Package org.eclipse.jgit.transport.sshd
Class SshdSessionFactoryBuilder
- java.lang.Object
-
- org.eclipse.jgit.transport.sshd.SshdSessionFactoryBuilder
-
public final class SshdSessionFactoryBuilder extends Object
A builder API to configureSshdSessionFactories
.- Since:
- 5.8
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
SshdSessionFactoryBuilder.ConfigStoreFactory
A factory interface for creating aSshConfigStore
.
-
Constructor Summary
Constructors Constructor Description SshdSessionFactoryBuilder()
-
Method Summary
-
-
-
Method Detail
-
setProxyDataFactory
public SshdSessionFactoryBuilder setProxyDataFactory(ProxyDataFactory proxyDataFactory)
- Parameters:
proxyDataFactory
- to use- Returns:
- this
SshdSessionFactoryBuilder
-
setHomeDirectory
public SshdSessionFactoryBuilder setHomeDirectory(File homeDirectory)
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
public SshdSessionFactoryBuilder setSshDirectory(File sshDirectory)
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
public SshdSessionFactoryBuilder setPreferredAuthentications(String authentications)
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
public SshdSessionFactoryBuilder setConfigFile(Function<File,File> supplier)
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
public SshdSessionFactoryBuilder setDefaultKnownHostsFiles(Function<File,List<Path>> supplier)
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
public SshdSessionFactoryBuilder setDefaultIdentities(Function<File,List<Path>> supplier)
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
public SshdSessionFactoryBuilder setDefaultKeysProvider(Function<File,Iterable<KeyPair>> provider)
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
public SshdSessionFactoryBuilder setConnectorFactory(ConnectorFactory factory)
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
public SshdSessionFactoryBuilder 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
public SshdSessionFactory build(KeyCache cache)
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
-
-