Package org.eclipse.jgit.transport
Class SshSessionFactory
java.lang.Object
org.eclipse.jgit.transport.SshSessionFactory
- Direct Known Subclasses:
JschConfigSessionFactory,SshdSessionFactory
Creates and destroys SSH connections to a remote system.
Different implementations of the session factory may be used to control communicating with the end-user as well as reading their personal SSH configuration settings, such as known hosts and private keys.
A RemoteSession must be returned to the factory that created it.
Callers are encouraged to retain the SshSessionFactory for the duration of
the period they are using the session.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SshSessionFactoryGets the currently configured JVM-wide factory.static StringRetrieves the local user name as defined by the system property "user.name".abstract RemoteSessiongetSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) Opens (or reuses) a session to a host.abstract StringgetType()The name of the type of session factory.private static SshSessionFactoryvoidreleaseSession(RemoteSession session) Closes (or recycles) a session to a host.static voidsetInstance(SshSessionFactory newFactory) Changes the JVM-wide factory to a different implementation.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
SshSessionFactory
public SshSessionFactory()
-
-
Method Details
-
loadSshSessionFactory
-
getInstance
Gets the currently configured JVM-wide factory.By default the factory will read from the user's
$HOME/.sshand assume OpenSSH compatibility.- Returns:
- factory the current factory for this JVM.
-
setInstance
Changes the JVM-wide factory to a different implementation.- Parameters:
newFactory- factory for future sessions to be created through; ifnullthe default factory will be restored.
-
getLocalUserName
Retrieves the local user name as defined by the system property "user.name".- Returns:
- the user name
- Since:
- 5.2
-
getSession
public abstract RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException Opens (or reuses) a session to a host. The returned session is connected and authenticated and is ready for further use.- Parameters:
uri- URI of the remote host to connect tocredentialsProvider- provider to support authentication, may benullif no user input for authentication is neededfs- the file system abstraction to use for certain file operations, such as reading configuration filestms- connection timeout for creating the session, in milliseconds- Returns:
- a connected and authenticated session for communicating with the
remote host given by the
uri - Throws:
TransportException- if the session could not be created
-
getType
The name of the type of session factory.- Returns:
- the name of the type of session factory.
- Since:
- 5.8
-
releaseSession
Closes (or recycles) a session to a host.- Parameters:
session- a session previously obtained from this factory'sgetSession(URIish, CredentialsProvider, FS, int)method.
-