当前位置: 首页>>代码示例>>Java>>正文


Java Host类代码示例

本文整理汇总了Java中org.eclipse.jgit.transport.OpenSshConfig.Host的典型用法代码示例。如果您正苦于以下问题:Java Host类的具体用法?Java Host怎么用?Java Host使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Host类属于org.eclipse.jgit.transport.OpenSshConfig包,在下文中一共展示了Host类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initSessionFactory

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
private void initSessionFactory() {
    JschConfigSessionFactory sshSessionFactory = new JschConfigSessionFactory() {
        @Override
        protected void configure(Host host, Session session) {
            session.setConfig("StrictHostKeyChecking", "no");
        }

        @Override
        protected JSch createDefaultJSch(FS fs) throws JSchException {
            JSch jSch = super.createDefaultJSch(fs);

            // apply customized private key
            if (privateKeyPath != null) {
                jSch.removeAllIdentity();
                jSch.addIdentity(privateKeyPath.toString());
            }

            return jSch;
        }
    };

    transportConfigCallback = transport -> {
        SshTransport sshTransport = (SshTransport) transport;
        sshTransport.setSshSessionFactory(sshSessionFactory);
    };
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:27,代码来源:GitSshClient.java

示例2: getJSch

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected JSch getJSch(Host hc, FS fs) throws JSchException {
	JSch jsch = super.getJSch(hc, fs);
	if (config.getKeyFile() != null) {
		jsch.addIdentity(config.getKeyFile().toString());
	}

	if (!config.getVerifyHostKey()) {
		jsch.setHostKeyRepository(new PromiscuousHostKeyRepository());
	}

	return jsch;
}
 
开发者ID:bugminer,项目名称:bugminer,代码行数:14,代码来源:CustomSshConfigSessionFactory.java

示例3: initSsh

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
public static void initSsh(TestAccount a) {
  final Properties config = new Properties();
  config.put("StrictHostKeyChecking", "no");
  JSch.setConfig(config);

  // register a JschConfigSessionFactory that adds the private key as identity
  // to the JSch instance of JGit so that SSH communication via JGit can
  // succeed
  SshSessionFactory.setInstance(
      new JschConfigSessionFactory() {
        @Override
        protected void configure(Host hc, Session session) {
          try {
            final JSch jsch = getJSch(hc, FS.DETECTED);
            jsch.addIdentity("KeyPair", a.privateKey(), a.sshKey.getPublicKeyBlob(), null);
          } catch (JSchException e) {
            throw new RuntimeException(e);
          }
        }
      });
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:GitUtil.java

示例4: configure

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected void configure(Host hc, Session session) {
	SshUri sshProperties = 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);
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:18,代码来源:PropertyBasedSshSessionFactory.java

示例5: createSession

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected Session createSession(Host hc, String user, String host, int port, FS fs) throws JSchException {
	if (sshKeysByHostname.containsKey(host)) {
		SshUri sshUriProperties = sshKeysByHostname.get(host);
		jSch.addIdentity(host, sshUriProperties.getPrivateKey().getBytes(), null, null);
		if (sshUriProperties.getKnownHostsFile() != null) {
			jSch.setKnownHosts(sshUriProperties.getKnownHostsFile());
		}
		if (sshUriProperties.getHostKey() != null) {
			HostKey hostkey = new HostKey(host, Base64.decode(sshUriProperties.getHostKey()));
			jSch.getHostKeyRepository().add(hostkey, null);
		}
		return jSch.getSession(user, host, port);
	}
	throw new JSchException("no keys configured for hostname " + host);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:17,代码来源:PropertyBasedSshSessionFactory.java

示例6: main

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
/**
 * Starts a new {@link GitServer} instance on a specified port. You can specify a HTTP port by providing an argument
 * of the form <code>--httpPort=xxxx</code> where <code>xxxx</code> is a port number. If no such argument is
 * specified the HTTP port defaults to 8080.
 * 
 * @param args
 *        The arguments to influence the start-up phase of the {@link GitServer} instance.
 * @throws Exception
 *         In case the {@link GitServer} instance could not be started.
 */
public static void main(String[] args) throws Exception {
	SLF4JBridgeHandler.removeHandlersForRootLogger();
	SLF4JBridgeHandler.install();

	// TODO: Fix this...
	SshSessionFactory.setInstance(new JschConfigSessionFactory() {
		@Override
		protected void configure(Host hc, Session session) {
			session.setConfig("StrictHostKeyChecking", "no");
		}
	});

	Config config = new Config();
	config.reload();
	
	GitServer server = new GitServer(config);
	server.start();
	server.join();
}
 
开发者ID:devhub-tud,项目名称:git-server,代码行数:30,代码来源:GitServer.java

示例7: setKeyLocation

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
public void setKeyLocation(final String keyPath) {
    SshSessionFactory.setInstance(new JschConfigSessionFactory() {
        public void configure(Host hc, Session session) {
            session.setConfig("StrictHostKeyChecking", "no");
            try {
                getJSch(hc, FS.DETECTED).addIdentity(keyPath);
            } catch (Exception e) {
                /*
                   runOnUiThread(new Runnable() {
                   public void run() {
                   Toast.makeText(context, "Could not find SSH key", Toast.LENGTH_LONG).show();
                   }
                   });
                   */
            }
        }
    });
}
 
开发者ID:blinry,项目名称:roboboy,代码行数:19,代码来源:Wiki.java

示例8: createSession

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:JGitSshSessionFactory.java

示例9: setupJSch

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JGitSshSessionFactory.java

示例10: gitSync

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
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();
}
 
开发者ID:Androxyde,项目名称:Flashtool,代码行数:13,代码来源:DevicesGit.java

示例11: initialize

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
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;
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:13,代码来源:JGitEnvironmentRepository.java

示例12: configure

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected void configure(final Host host, final Session session) {
	// ignored
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:5,代码来源:SshSessionFactory.java

示例13: getJSch

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected JSch getJSch(final Host host, final FS fs) throws JSchException {
	return configureIdentity(super.getJSch(host, fs));
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:5,代码来源:SshSessionFactory.java

示例14: configure

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected void configure (Host host, Session sn) {
    sn.setConfig("PreferredAuthentications", "publickey,password,keyboard-interactive"); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:JGitSshSessionFactory.java

示例15: configure

import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected void configure(Host hc, Session session) {
	// nothing to do
}
 
开发者ID:bugminer,项目名称:bugminer,代码行数:5,代码来源:CustomSshConfigSessionFactory.java


注:本文中的org.eclipse.jgit.transport.OpenSshConfig.Host类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。