Package org.eclipse.jgit.transport
Class SshSessionFactory
- java.lang.Object
-
- org.eclipse.jgit.transport.SshSessionFactory
-
- Direct Known Subclasses:
JschConfigSessionFactory
,SshdSessionFactory
public abstract class SshSessionFactory extends java.lang.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
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 Modifier and Type Field Description private static SshSessionFactory
INSTANCE
-
Constructor Summary
Constructors Constructor Description SshSessionFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static SshSessionFactory
getInstance()
Get the currently configured JVM-wide factory.static java.lang.String
getLocalUserName()
Retrieves the local user name as defined by the system property "user.name".abstract RemoteSession
getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms)
Open (or reuse) a session to a host.abstract java.lang.String
getType()
The name of the type of session factory.private static SshSessionFactory
loadSshSessionFactory()
void
releaseSession(RemoteSession session)
Close (or recycle) a session to a host.static void
setInstance(SshSessionFactory newFactory)
Change the JVM-wide factory to a different implementation.
-
-
-
Field Detail
-
INSTANCE
private static SshSessionFactory INSTANCE
-
-
Method Detail
-
loadSshSessionFactory
private static SshSessionFactory loadSshSessionFactory()
-
getInstance
public static SshSessionFactory getInstance()
Get the currently configured JVM-wide factory.By default the factory will read from the user's
$HOME/.ssh
and assume OpenSSH compatibility.- Returns:
- factory the current factory for this JVM.
-
setInstance
public static void setInstance(SshSessionFactory newFactory)
Change the JVM-wide factory to a different implementation.- Parameters:
newFactory
- factory for future sessions to be created through. If null the default factory will be restored.
-
getLocalUserName
public static java.lang.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
Open (or reuse) a session to a host.A reasonable UserInfo that can interact with the end-user (if necessary) is installed on the returned session by this method.
The caller must connect the session by invoking
connect()
if it has not already been connected.- Parameters:
uri
- URI information about the remote hostcredentialsProvider
- provider to support authentication, may be null.fs
- the file system abstraction which will be necessary to perform certain file system operations.tms
- Timeout value, in milliseconds.- Returns:
- a session that can contact the remote host.
- Throws:
TransportException
- the session could not be created.
-
getType
public abstract java.lang.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)
Close (or recycle) a session to a host.- Parameters:
session
- a session previously obtained from this factory'sgetSession(URIish, CredentialsProvider, FS, int)
method.
-
-