List of usage examples for org.eclipse.jgit.transport SshSessionFactory SshSessionFactory
SshSessionFactory
From source file:org.eclipse.ptp.internal.rdt.sync.git.core.JGitRepo.java
License:Open Source License
/** * Creates a new transport object for executing commands at the given remote location. * /* w ww . jav a 2s .c o m*/ * @param remoteLocation * the remote location * * @return new transport instance - never null. * @throws TransportException * on problem creating transport * @throws RuntimeException * if the requested transport is not supported by JGit. */ private TransportGitSsh buildTransport(final RemoteLocation remoteLoc, IProgressMonitor monitor) throws TransportException { RecursiveSubMonitor subMon = RecursiveSubMonitor.convert(monitor, 10); RemoteConfig remoteConfig = buildRemoteConfig(git.getRepository().getConfig()); final URIish uri = buildURI(remoteLoc.getDirectory()); TransportGitSsh transport; try { subMon.subTask(Messages.JGitRepo_15); transport = (TransportGitSsh) Transport.open(git.getRepository(), uri); } catch (NotSupportedException e) { throw new RuntimeException(e); } finally { if (monitor != null) { monitor.done(); } } // Set the transport to use our own means of executing remote commands. transport.setSshSessionFactory(new SshSessionFactory() { @Override public RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException { return new PTPSession(remoteLoc); } }); transport.applyConfig(remoteConfig); return transport; }
From source file:org.eclipse.ptp.rdt.sync.git.core.GitRemoteSyncConnection.java
License:Open Source License
/** * Creates the transport object that JGit uses for executing commands * remotely./*from w w w . j av a 2 s . c o m*/ * * @param remoteConfig * the remote configuration for our local Git repo * @throws RuntimeException * if the requested transport is not supported by JGit. */ private void buildTransport(RemoteConfig remoteConfig) { final URIish uri = buildURI(); try { transport = (TransportGitSsh) Transport.open(git.getRepository(), uri); } catch (NotSupportedException e) { throw new RuntimeException(e); } catch (TransportException e) { throw new RuntimeException(e); } // Set the transport to use our own means of executing remote commands. transport.setSshSessionFactory(new SshSessionFactory() { @Override public RemoteSession getSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws TransportException { return new PTPSession(uri); } }); transport.applyConfig(remoteConfig); }