org.eclipse.jgit.transport.OpenSshConfig.Host Java Examples
The following examples show how to use
org.eclipse.jgit.transport.OpenSshConfig.Host.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AgentProxyAwareJschConfigSessionFactory.java From gitflow-incremental-builder with MIT License | 6 votes |
@Override protected Session createSession(Host hc, String user, String host, int port, FS fs) throws JSchException { JSch jSch = getJSch(hc, fs); // assumption: identities from agent are always unencrypted final Collection<Identity> allUnencryptedIdentities = getIdentitiesFromAgentProxy(); @SuppressWarnings("unchecked") Collection<Identity> identities = ((Collection<Identity>) jSch.getIdentityRepository().getIdentities()); identities.stream() .filter(id -> !id.isEncrypted()) .forEach(allUnencryptedIdentities::add); Session session = jSch.getSession(user, host, port); session.setIdentityRepository(new ReadOnlyIdentityRepository(allUnencryptedIdentities)); return session; }
Example #2
Source File: PropertyBasedSshSessionFactory.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Override protected Session createSession(Host hc, String user, String host, int port, FS fs) throws JSchException { if (this.sshKeysByHostname.containsKey(host)) { JGitEnvironmentProperties sshUriProperties = this.sshKeysByHostname.get(host); this.jSch.addIdentity(host, sshUriProperties.getPrivateKey().getBytes(), null, null); if (sshUriProperties.getKnownHostsFile() != null) { this.jSch.setKnownHosts(sshUriProperties.getKnownHostsFile()); } if (sshUriProperties.getHostKey() != null) { HostKey hostkey = new HostKey(host, Base64.decode(sshUriProperties.getHostKey())); this.jSch.getHostKeyRepository().add(hostkey, null); } return this.jSch.getSession(user, host, port); } throw new JSchException("no keys configured for hostname " + host); }
Example #3
Source File: JGitSshSessionFactory.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected Session createSession (Host hc, String user, String host, int port, FS fs) throws JSchException { Session session = super.createSession(hc, user, host, port, fs); try { List<Proxy> proxies = ProxySelector.getDefault().select(new URI("socket", null, host, port == -1 ? 22 : port, null, null, null)); if (proxies.size() > 0) { Proxy p = proxies.iterator().next(); if (p.type() == Proxy.Type.DIRECT) { session.setProxy(null); } else { SocketAddress addr = p.address(); if (addr instanceof InetSocketAddress) { InetSocketAddress inetAddr = (InetSocketAddress) addr; String proxyHost = inetAddr.getHostName(); int proxyPort = inetAddr.getPort(); session.setProxy(createProxy(proxyHost, proxyPort)); } } } } catch (URISyntaxException ex) { Logger.getLogger(JGitSshSessionFactory.class.getName()).log(Level.INFO, "Invalid URI: " + host + ":" + port, ex); } return session; }
Example #4
Source File: JGitSshSessionFactory.java From netbeans with Apache License 2.0 | 5 votes |
private boolean setupJSch (FS fs, String host, CredentialItem.StringType identityFile, URIish uri, boolean preferAgent) throws TransportException { boolean agentUsed; if (sshConfig == null) { sshConfig = OpenSshConfig.get(fs); } final OpenSshConfig.Host hc = sshConfig.lookup(host); try { JSch jsch = getJSch(hc, fs); agentUsed = setupJSchIdentityRepository(jsch, identityFile.getValue(), preferAgent); } catch (JSchException ex) { throw new TransportException(uri, ex.getMessage(), ex); } return agentUsed; }
Example #5
Source File: DevicesGit.java From Flashtool with GNU General Public License v3.0 | 5 votes |
public static void gitSync() throws IOException, InvalidRemoteException, org.eclipse.jgit.api.errors.TransportException, GitAPIException { SshSessionFactory.setInstance(new JschConfigSessionFactory() { public void configure(Host hc, Session session) { session.setConfig("StrictHostKeyChecking", "no"); }; } ); if (openRepository()) { pullRepository(); } else cloneRepository(); }
Example #6
Source File: JGitEnvironmentRepository.java From spring-cloud-config with Apache License 2.0 | 5 votes |
private void initialize() { if (!this.initialized) { SshSessionFactory.setInstance(new JschConfigSessionFactory() { @Override protected void configure(Host hc, Session session) { session.setConfig("StrictHostKeyChecking", isStrictHostKeyChecking() ? "yes" : "no"); } }); this.initialized = true; } }
Example #7
Source File: PropertyBasedSshSessionFactory.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Override protected void configure(Host hc, Session session) { JGitEnvironmentProperties sshProperties = this.sshKeysByHostname .get(hc.getHostName()); String hostKeyAlgorithm = sshProperties.getHostKeyAlgorithm(); if (hostKeyAlgorithm != null) { session.setConfig(SERVER_HOST_KEY, hostKeyAlgorithm); } if (sshProperties.getHostKey() == null || !sshProperties.isStrictHostKeyChecking()) { session.setConfig(STRICT_HOST_KEY_CHECKING, NO_OPTION); } else { session.setConfig(STRICT_HOST_KEY_CHECKING, YES_OPTION); } String preferredAuthentications = sshProperties.getPreferredAuthentications(); if (preferredAuthentications != null) { session.setConfig(PREFERRED_AUTHENTICATIONS, preferredAuthentications); } ProxyHostProperties proxyHostProperties = sshProperties.getProxy() .get(ProxyHostProperties.ProxyForScheme.HTTP); if (proxyHostProperties != null) { ProxyHTTP proxy = createProxy(proxyHostProperties); proxy.setUserPasswd(proxyHostProperties.getUsername(), proxyHostProperties.getPassword()); session.setProxy(proxy); } }
Example #8
Source File: SshSessionFactory.java From n4js with Eclipse Public License 1.0 | 4 votes |
@Override protected void configure(final Host host, final Session session) { // ignored }
Example #9
Source File: SshSessionFactory.java From n4js with Eclipse Public License 1.0 | 4 votes |
@Override protected JSch getJSch(final Host host, final FS fs) throws JSchException { return configureIdentity(super.getJSch(host, fs)); }
Example #10
Source File: JGitSshSessionFactory.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected void configure (Host host, Session sn) { sn.setConfig("PreferredAuthentications", "publickey,password,keyboard-interactive"); //NOI18N }
Example #11
Source File: AgentProxyAwareJschConfigSessionFactory.java From gitflow-incremental-builder with MIT License | 4 votes |
@Override protected void configure(Host hc, Session session) { // nothing to do }