本文整理汇总了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);
};
}
示例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;
}
示例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);
}
}
});
}
示例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);
}
}
示例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);
}
示例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();
}
示例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();
}
});
*/
}
}
});
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
}
示例12: configure
import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected void configure(final Host host, final Session session) {
// ignored
}
示例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));
}
示例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
}
示例15: configure
import org.eclipse.jgit.transport.OpenSshConfig.Host; //导入依赖的package包/类
@Override
protected void configure(Host hc, Session session) {
// nothing to do
}