Class SshdSessionFactoryBuilder.State.SessionFactory
- All Implemented Interfaces:
Closeable,AutoCloseable
- Enclosing class:
- SshdSessionFactoryBuilder.State
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected KeyPasswordProvidercreateKeyPasswordProvider(CredentialsProvider provider) Creates aKeyPasswordProviderfor a new session.protected ServerKeyDatabasecreateServerKeyDatabase(File homeDir, File sshDir) Creates aServerKeyDatabaseto verify server host keys.protected SshConfigStorecreateSshConfigStore(File homeDir, File configFile, String localUserName) Obtains aSshConfigStore, ornullif not SSH config is to be used.protected ConnectorFactoryGets aConnectorFactory.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 StringGets the list of default preferred authentication mechanisms.protected FilegetSshConfig(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, setSshDirectoryMethods inherited from class org.eclipse.jgit.transport.SshSessionFactory
getInstance, getLocalUserName, releaseSession, setInstance
-
Constructor Details
-
SessionFactory
-
-
Method Details
-
getSshConfig
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
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
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
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
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
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
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
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
-
getConnectorFactory
Description copied from class:SshdSessionFactoryGets aConnectorFactory. If this returnsnull, SSH agents are not supported.The default implementation uses
ConnectorFactory.getDefault()- Overrides:
getConnectorFactoryin classSshdSessionFactory- Returns:
- the factory, or
nullif no SSH agent support is desired
-