- java.lang.Object
-
- org.eclipse.jgit.transport.SshSessionFactory
-
public abstract class SshSessionFactory extends Object
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
RemoteSessionmust 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.
-
-
Constructor Summary
Constructors Constructor Description SshSessionFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static SshSessionFactorygetInstance()Gets the currently configured JVM-wide factory.static StringgetLocalUserName()Retrieves 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.voidreleaseSession(RemoteSession session)Closes (or recycles) a session to a host.static voidsetInstance(SshSessionFactory newFactory)Changes the JVM-wide factory to a different implementation.
-
-
-
Method Detail
-
getInstance
public static SshSessionFactory 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
public static void setInstance(SshSessionFactory newFactory)
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
public static String 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
public abstract String getType()
The name of the type of session factory.- Returns:
- the name of the type of session factory.
- Since:
- 5.8
-
releaseSession
public void releaseSession(RemoteSession session)
Closes (or recycles) a session to a host.- Parameters:
session- a session previously obtained from this factory'sgetSession(URIish, CredentialsProvider, FS, int)method.
-
-