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 interfaceSshdSessionFactoryBuilder.ConfigStoreFactoryA factory interface for creating a @link SshConfigStore}.
-
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 forSshdSessionFactoriescreated 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 forSshdSessionFactoriescreated bybuild(KeyCache).- Parameters:
sshDirectory- to use; may benull, in which case ".ssh" under thehome directoryis assumed- Returns:
- this
SshdSessionFactoryBuilder
-
setPreferredAuthentications
public SshdSessionFactoryBuilder setPreferredAuthentications(String authentications)
Sets the default preferred authentication mechanisms to use forSshdSessionFactoriescreated bybuild(KeyCache).- Parameters:
authentications- comma-separated list of authentication mechanism names; ifnullor 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.CONFIGin theSSH directoryis used.- Parameters:
supplier- returning aFilefor the SSH config file to use, or returningnullif no config file is to be used- Returns:
- this
SshdSessionFactoryBuilder
-
setConfigStoreFactory
public SshdSessionFactoryBuilder setConfigStoreFactory(SshdSessionFactoryBuilder.ConfigStoreFactory factory)
Sets a factory for theSshConfigStoreto 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 thefactoryreturnsnull, the default as specified bySshdSessionFactory.createServerKeyDatabase(File, File)is used.- Parameters:
factory- to create aServerKeyDatabase- Returns:
- this
SshdSessionFactoryBuilder
-
build
public SshdSessionFactory build(KeyCache cache)
Builds aSshdSessionFactoryas configured, using the givenKeyCachefor caching keys.Different
SshdSessionFactoriesshould not share the sameKeyCachesince the cache is invalidated when the factory itself or when the lastSshdSessioncreated from the factory is closed.- Parameters:
cache- to use for caching ssh keys; may benullif no caching is desired.- Returns:
- the
SshdSessionFactory
-
-