Class SshdSessionFactoryBuilder.State.SessionFactory
- java.lang.Object
-
- org.eclipse.jgit.transport.SshSessionFactory
-
- org.eclipse.jgit.transport.sshd.SshdSessionFactory
-
- org.eclipse.jgit.transport.sshd.SshdSessionFactoryBuilder.State.SessionFactory
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Enclosing class:
- SshdSessionFactoryBuilder.State
private class SshdSessionFactoryBuilder.State.SessionFactory extends SshdSessionFactory
-
-
Constructor Summary
Constructors Constructor Description SessionFactory(KeyCache cache, ProxyDataFactory proxyDataFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected KeyPasswordProvidercreateKeyPasswordProvider(CredentialsProvider provider)Creates aKeyPasswordProviderfor a new session.protected ServerKeyDatabasecreateServerKeyDatabase(java.io.File homeDir, java.io.File sshDir)Creates aServerKeyDatabaseto verify server host keys.protected SshConfigStorecreateSshConfigStore(java.io.File homeDir, java.io.File configFile, java.lang.String localUserName)Obtains aSshConfigStore, ornullif not SSH config is to be used.protected java.util.List<java.nio.file.Path>getDefaultIdentities(java.io.File sshDir)Gets a list of default identities, i.e., private key files that shall always be tried for public key authentication.protected java.lang.Iterable<java.security.KeyPair>getDefaultKeys(java.io.File sshDir)Determines the default keys.protected java.util.List<java.nio.file.Path>getDefaultKnownHostsFiles(java.io.File sshDir)Gets the list of default user known hosts files.protected java.lang.StringgetDefaultPreferredAuthentications()Gets the list of default preferred authentication mechanisms.protected java.io.FilegetSshConfig(java.io.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 Detail
-
SessionFactory
public SessionFactory(KeyCache cache, ProxyDataFactory proxyDataFactory)
-
-
Method Detail
-
getSshConfig
protected java.io.File getSshConfig(java.io.File sshDir)
Description copied from class:SshdSessionFactoryDetermines 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:
getSshConfigin classSshdSessionFactory- Parameters:
sshDir- representing ~/.ssh/- Returns:
- the file (need not exist), or
nullif no config file shall be used
-
getDefaultKnownHostsFiles
protected java.util.List<java.nio.file.Path> getDefaultKnownHostsFiles(java.io.File sshDir)
Description copied from class:SshdSessionFactoryGets the list of default user known hosts files. The default returns ~/.ssh/known_hosts and ~/.ssh/known_hosts2. The ssh configUserKnownHostsFileoverrides this default.- Overrides:
getDefaultKnownHostsFilesin classSshdSessionFactory- Returns:
- the possibly empty list of default known host file paths.
-
getDefaultIdentities
protected java.util.List<java.nio.file.Path> getDefaultIdentities(java.io.File sshDir)
Description copied from class:SshdSessionFactoryGets 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:
getDefaultIdentitiesin classSshdSessionFactory- Parameters:
sshDir- the directory that represents ~/.ssh/- Returns:
- a possibly empty list of paths containing default identities (private keys)
-
getDefaultPreferredAuthentications
protected java.lang.String getDefaultPreferredAuthentications()
Description copied from class:SshdSessionFactoryGets the list of default preferred authentication mechanisms. Ifnullis returned the openssh default list will be in effect. If the ssh config definesPreferredAuthenticationsthe value from the ssh config takes precedence.- Overrides:
getDefaultPreferredAuthenticationsin classSshdSessionFactory- Returns:
- a comma-separated list of mechanism names, or
nullif none
-
getDefaultKeys
protected java.lang.Iterable<java.security.KeyPair> getDefaultKeys(java.io.File sshDir)
Description copied from class:SshdSessionFactoryDetermines the default keys. The default implementation will lazy load thedefault identity files.Subclasses may override and return an
Iterableof whatever keys are appropriate. If the returned iterable lazily loads keys, it should be an instance ofAbstractResourceKeyPairProviderso that the session can later pass it thepassword providerwrapped as aFilePasswordProviderviaAbstractResourceKeyPairProvider#setPasswordFinder(FilePasswordProvider)so that encrypted, password-protected keys can be loaded.The default implementation uses exactly this mechanism; class
CachingKeyPairProvidermay serve as a model for a customized lazy-loadingIterableimplementationIf the
Iterablereturned has the keys already pre-loaded or otherwise doesn't need to decrypt encrypted keys, it can be anyIterable, for instance a simpleList.- Overrides:
getDefaultKeysin classSshdSessionFactory- Parameters:
sshDir- to look in for keys- Returns:
- an
Iterableover the default keys
-
createKeyPasswordProvider
protected KeyPasswordProvider createKeyPasswordProvider(CredentialsProvider provider)
Description copied from class:SshdSessionFactoryCreates aKeyPasswordProviderfor a new session.- Overrides:
createKeyPasswordProviderin classSshdSessionFactory- Parameters:
provider- theCredentialsProviderto delegate to for user interactions- Returns:
- a new
KeyPasswordProvider
-
createServerKeyDatabase
protected ServerKeyDatabase createServerKeyDatabase(java.io.File homeDir, java.io.File sshDir)
Description copied from class:SshdSessionFactoryCreates aServerKeyDatabaseto verify server host keys. The default implementation returns aServerKeyDatabasethat recognizes the two openssh standard files~/.ssh/known_hostsand~/.ssh/known_hosts2as well as any files configured via theUserKnownHostsFileoption in the ssh config file.- Overrides:
createServerKeyDatabasein classSshdSessionFactory- Parameters:
homeDir- home directory to use for ~ replacementsshDir- representing ~/.ssh/- Returns:
- the
ServerKeyDatabase
-
createSshConfigStore
protected SshConfigStore createSshConfigStore(java.io.File homeDir, java.io.File configFile, java.lang.String localUserName)
Description copied from class:SshdSessionFactoryObtains aSshConfigStore, ornullif not SSH config is to be used. The default implementation returnsnullifconfigFile == nulland otherwise an OpenSSH-compatible store reading host entries from the given file.- Overrides:
createSshConfigStorein classSshdSessionFactory- Parameters:
homeDir- may be used for ~-replacements by the returned config storeconfigFile- to use, ornullif nonelocalUserName- user name of the current user on the local OS- Returns:
- A
SshConfigStore, ornullif none is to be used
-
-