Class SshdSessionFactoryBuilder.State.SessionFactory
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Enclosing class:
SshdSessionFactoryBuilder.State
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected KeyPasswordProvider
createKeyPasswordProvider
(CredentialsProvider provider) Creates aKeyPasswordProvider
for a new session.protected ServerKeyDatabase
createServerKeyDatabase
(File homeDir, File sshDir) Creates aServerKeyDatabase
to verify server host keys.protected SshConfigStore
createSshConfigStore
(File homeDir, File configFile, String localUserName) Obtains aSshConfigStore
, ornull
if not SSH config is to be used.getDefaultIdentities
(File sshDir) Gets a list of default identities, i.e., private key files that shall always be tried for public key authentication.getDefaultKeys
(File sshDir) Determines the default keys.getDefaultKnownHostsFiles
(File sshDir) Gets the list of default user known hosts files.protected String
Gets the list of default preferred authentication mechanisms.protected File
getSshConfig
(File sshDir) Determines the ssh config file.Methods inherited from class org.eclipse.jgit.transport.sshd.SshdSessionFactory
close, getHomeDirectory, getKeyCache, getServerKeyDatabase, getSession, getSshDirectory, getType, setHomeDirectory, setSshDirectory
Methods inherited from class org.eclipse.jgit.transport.SshSessionFactory
getInstance, getLocalUserName, releaseSession, setInstance
-
Constructor Details
-
SessionFactory
-
-
Method Details
-
getSshConfig
Description copied from class:SshdSessionFactory
Determines the ssh config file. The default implementation returns ~/.ssh/config. If the file does not exist and is created later it will be picked up. To not use a config file at all, returnnull
.- Overrides:
getSshConfig
in classSshdSessionFactory
- Parameters:
sshDir
- representing ~/.ssh/- Returns:
- the file (need not exist), or
null
if no config file shall be used
-
getDefaultKnownHostsFiles
Description copied from class:SshdSessionFactory
Gets the list of default user known hosts files. The default returns ~/.ssh/known_hosts and ~/.ssh/known_hosts2. The ssh configUserKnownHostsFile
overrides this default.- Overrides:
getDefaultKnownHostsFiles
in classSshdSessionFactory
- Parameters:
sshDir
-- Returns:
- the possibly empty list of default known host file paths.
-
getDefaultIdentities
Description copied from class:SshdSessionFactory
Gets a list of default identities, i.e., private key files that shall always be tried for public key authentication. Typically those are ~/.ssh/id_dsa, ~/.ssh/id_rsa, and so on. The default implementation returns the files defined inSshConstants.DEFAULT_IDENTITIES
.- Overrides:
getDefaultIdentities
in classSshdSessionFactory
- Parameters:
sshDir
- the directory that represents ~/.ssh/- Returns:
- a possibly empty list of paths containing default identities (private keys)
-
getDefaultPreferredAuthentications
Description copied from class:SshdSessionFactory
Gets the list of default preferred authentication mechanisms. Ifnull
is returned the openssh default list will be in effect. If the ssh config definesPreferredAuthentications
the value from the ssh config takes precedence.- Overrides:
getDefaultPreferredAuthentications
in classSshdSessionFactory
- Returns:
- a comma-separated list of mechanism names, or
null
if none
-
getDefaultKeys
Description copied from class:SshdSessionFactory
Determines the default keys. The default implementation will lazy load thedefault identity files
.Subclasses may override and return an
Iterable
of whatever keys are appropriate. If the returned iterable lazily loads keys, it should be an instance ofAbstractResourceKeyPairProvider
so that the session can later pass it thepassword provider
wrapped as aFilePasswordProvider
viaAbstractResourceKeyPairProvider#setPasswordFinder(FilePasswordProvider)
so that encrypted, password-protected keys can be loaded.The default implementation uses exactly this mechanism; class
CachingKeyPairProvider
may serve as a model for a customized lazy-loadingIterable
implementationIf the
Iterable
returned has the keys already pre-loaded or otherwise doesn't need to decrypt encrypted keys, it can be anyIterable
, for instance a simpleList
.- Overrides:
getDefaultKeys
in classSshdSessionFactory
- Parameters:
sshDir
- to look in for keys- Returns:
- an
Iterable
over the default keys
-
createKeyPasswordProvider
Description copied from class:SshdSessionFactory
Creates aKeyPasswordProvider
for a new session.- Overrides:
createKeyPasswordProvider
in classSshdSessionFactory
- Parameters:
provider
- theCredentialsProvider
to delegate to for user interactions- Returns:
- a new
KeyPasswordProvider
-
createServerKeyDatabase
Description copied from class:SshdSessionFactory
Creates aServerKeyDatabase
to verify server host keys. The default implementation returns aServerKeyDatabase
that recognizes the two openssh standard files~/.ssh/known_hosts
and~/.ssh/known_hosts2
as well as any files configured via theUserKnownHostsFile
option in the ssh config file.- Overrides:
createServerKeyDatabase
in classSshdSessionFactory
- Parameters:
homeDir
- home directory to use for ~ replacementsshDir
- representing ~/.ssh/- Returns:
- the
ServerKeyDatabase
-
createSshConfigStore
Description copied from class:SshdSessionFactory
Obtains aSshConfigStore
, ornull
if not SSH config is to be used. The default implementation returnsnull
ifconfigFile == null
and otherwise an OpenSSH-compatible store reading host entries from the given file.- Overrides:
createSshConfigStore
in classSshdSessionFactory
- Parameters:
homeDir
- may be used for ~-replacements by the returned config storeconfigFile
- to use, ornull
if nonelocalUserName
- user name of the current user on the local OS- Returns:
- A
SshConfigStore
, ornull
if none is to be used
-