* <p>
* If user interactivity is required by SSH (e.g. to obtain a password), the
* connection will immediately fail.
+ *
+ * @since 5.7
*/
-class DefaultSshSessionFactory extends JschConfigSessionFactory {
+public class DefaultSshSessionFactory extends JschConfigSessionFactory {
/** {@inheritDoc} */
@Override
protected void configure(OpenSshConfig.Host hc, Session session) {
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.Iterator;
+import java.util.ServiceLoader;
import org.eclipse.jgit.errors.TransportException;
import org.eclipse.jgit.lib.Constants;
* SshSessionFactory for the duration of the period they are using the Session.
*/
public abstract class SshSessionFactory {
- private static SshSessionFactory INSTANCE = new DefaultSshSessionFactory();
+ private static SshSessionFactory INSTANCE = loadSshSessionFactory();
+ private static SshSessionFactory loadSshSessionFactory() {
+ ServiceLoader<SshSessionFactory> loader = ServiceLoader.load(SshSessionFactory.class);
+ Iterator<SshSessionFactory> iter = loader.iterator();
+ if(iter.hasNext()) {
+ return iter.next();
+ }
+ return null;
+ }
/**
* Get the currently configured JVM-wide factory.
* <p>