Package org.eclipse.jgit.transport.sshd
Class SshdSessionFactoryBuilder
- java.lang.Object
-
- org.eclipse.jgit.transport.sshd.SshdSessionFactoryBuilder
-
public final class SshdSessionFactoryBuilder extends java.lang.ObjectA 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}.private static classSshdSessionFactoryBuilder.State
-
Field Summary
Fields Modifier and Type Field Description private SshdSessionFactoryBuilder.Statestate
-
Constructor Summary
Constructors Constructor Description SshdSessionFactoryBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SshdSessionFactorybuild(KeyCache cache)Builds aSshdSessionFactoryas configured, using the givenKeyCachefor caching keys.SshdSessionFactoryBuildersetConfigFile(java.util.function.Function<java.io.File,java.io.File> supplier)Sets a function that returns the SSH config file, given the SSH directory.SshdSessionFactoryBuildersetConfigStoreFactory(SshdSessionFactoryBuilder.ConfigStoreFactory factory)Sets a factory for theSshConfigStoreto use.SshdSessionFactoryBuildersetDefaultIdentities(java.util.function.Function<java.io.File,java.util.List<java.nio.file.Path>> supplier)Sets a function that returns the default private key files, given the SSH directory.SshdSessionFactoryBuildersetDefaultKeysProvider(java.util.function.Function<java.io.File,java.lang.Iterable<java.security.KeyPair>> provider)Sets a function that returns the default private keys, given the SSH directory.SshdSessionFactoryBuildersetDefaultKnownHostsFiles(java.util.function.Function<java.io.File,java.util.List<java.nio.file.Path>> supplier)Sets a function that returns the default known hosts files, given the SSH directory.SshdSessionFactoryBuildersetHomeDirectory(java.io.File homeDirectory)Sets the home directory to use forSshdSessionFactoriescreated bybuild(KeyCache).SshdSessionFactoryBuildersetKeyPasswordProvider(java.util.function.Function<CredentialsProvider,KeyPasswordProvider> factory)Sets a factory function to create aKeyPasswordProvider.SshdSessionFactoryBuildersetPreferredAuthentications(java.lang.String authentications)Sets the default preferred authentication mechanisms to use forSshdSessionFactoriescreated bybuild(KeyCache).SshdSessionFactoryBuildersetProxyDataFactory(ProxyDataFactory proxyDataFactory)SshdSessionFactoryBuildersetServerKeyDatabase(java.util.function.BiFunction<java.io.File,java.io.File,ServerKeyDatabase> factory)Sets a function that creates a newServerKeyDatabase, given the SSH and home directory.SshdSessionFactoryBuildersetSshDirectory(java.io.File sshDirectory)Sets the SSH directory to use forSshdSessionFactoriescreated bybuild(KeyCache).
-
-
-
Field Detail
-
state
private final SshdSessionFactoryBuilder.State state
-
-
Method Detail
-
setProxyDataFactory
public SshdSessionFactoryBuilder setProxyDataFactory(ProxyDataFactory proxyDataFactory)
- Parameters:
proxyDataFactory- to use- Returns:
- this
SshdSessionFactoryBuilder
-
setHomeDirectory
public SshdSessionFactoryBuilder setHomeDirectory(java.io.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(java.io.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(java.lang.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(java.util.function.Function<java.io.File,java.io.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(java.util.function.Function<java.io.File,java.util.List<java.nio.file.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(java.util.function.Function<java.io.File,java.util.List<java.nio.file.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(java.util.function.Function<java.io.File,java.lang.Iterable<java.security.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(java.util.function.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(java.util.function.BiFunction<java.io.File,java.io.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
-
-