com.jcraft.jsch.Session.getHostKeyRepository()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中com.jcraft.jsch.Session.getHostKeyRepository()方法的一些代码示例,展示了Session.getHostKeyRepository()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getHostKeyRepository()方法的具体详情如下:
包路径:com.jcraft.jsch.Session
类名称:Session
方法名:getHostKeyRepository

Session.getHostKeyRepository介绍

[英]Gets the hostkeyRepository. If this.hostkeyRepository is null, JSch#getHostKeyRepository() will be invoked.
[中]获取hostkeyRepository。如果是这样的话。hostkeyRepository为[$0$],将调用JSch#getHostKeyRepository()。

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private static void setPreferredKeyTypesOrder(Session session) {
  HostKeyRepository hkr = session.getHostKeyRepository();
  List<String> known = Stream.of(hkr.getHostKey(hostName(session), null))
      .map(HostKey::getType)
      .collect(toList());
  if (!known.isEmpty()) {
    String serverHostKey = "server_host_key"; //$NON-NLS-1$
    String current = session.getConfig(serverHostKey);
    if (current == null) {
      session.setConfig(serverHostKey, String.join(",", known)); //$NON-NLS-1$
      return;
    }
    String knownFirst = Stream.concat(
            known.stream(),
            Stream.of(current.split(",")) //$NON-NLS-1$
                .filter(s -> !known.contains(s)))
        .collect(joining(",")); //$NON-NLS-1$
    session.setConfig(serverHostKey, knownFirst);
  }
}

代码示例来源:origin: berlam/github-bucket

private static void setPreferredKeyTypesOrder(Session session) {
  HostKeyRepository hkr = session.getHostKeyRepository();
  List<String> known = Stream.of(hkr.getHostKey(hostName(session), null))
      .map(HostKey::getType)
      .collect(toList());
  if (!known.isEmpty()) {
    String serverHostKey = "server_host_key"; //$NON-NLS-1$
    String current = session.getConfig(serverHostKey);
    if (current == null) {
      session.setConfig(serverHostKey, String.join(",", known)); //$NON-NLS-1$
      return;
    }
    String knownFirst = Stream.concat(
            known.stream(),
            Stream.of(current.split(",")) //$NON-NLS-1$
                .filter(s -> !known.contains(s)))
        .collect(joining(",")); //$NON-NLS-1$
    session.setConfig(serverHostKey, knownFirst);
  }
}

代码示例来源:origin: org.xbib/jsch-core

chost = ("[" + chost + "]:" + port);
HostKeyRepository hkr = getHostKeyRepository();
String hkh = getConfig("HashKnownHosts");
if (hkh.equals("yes") && (hkr instanceof KnownHosts)) {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jsch

HostKeyRepository hkr=getHostKeyRepository();

代码示例来源:origin: org.mule.jsch/jsch

HostKeyRepository hkr=getHostKeyRepository();

代码示例来源:origin: ePaul/jsch-documentation

HostKeyRepository hkr=getHostKeyRepository();

相关文章

微信公众号

最新文章

更多