JschConfigSessionFactory
public abstract class SshSessionFactory extends Object
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.
Constructor | Description |
---|---|
SshSessionFactory() |
Modifier and Type | Method | Description |
---|---|---|
static SshSessionFactory |
getInstance() |
Get the currently configured JVM-wide factory.
|
abstract RemoteSession |
getSession(URIish uri,
CredentialsProvider credentialsProvider,
FS fs,
int tms) |
Open (or reuse) a session to a host.
|
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.
|
public static SshSessionFactory getInstance()
A factory is always available. By default the factory will read from the
user's $HOME/.ssh
and assume OpenSSH compatibility.
public static void setInstance(SshSessionFactory newFactory)
newFactory
- factory for future sessions to be created through. If null the
default factory will be restored.spublic abstract RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException
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.
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.TransportException
- the session could not be created.public void releaseSession(RemoteSession session)
session
- a session previously obtained from this factory's
getSession(URIish, CredentialsProvider, FS, int)
method.Copyright © 2018. All rights reserved.