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


Java KeyType.fromKey方法代码示例

本文整理汇总了Java中net.schmizz.sshj.common.KeyType.fromKey方法的典型用法代码示例。如果您正苦于以下问题:Java KeyType.fromKey方法的具体用法?Java KeyType.fromKey怎么用?Java KeyType.fromKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.schmizz.sshj.common.KeyType的用法示例。


在下文中一共展示了KeyType.fromKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: allow

import net.schmizz.sshj.common.KeyType; //导入方法依赖的package包/类
@Override
public void allow(final String hostname, final PublicKey key, final boolean persist) {
    if(null == database) {
        super.allow(hostname, key, persist);
    }
    else {
        try {
            // Add the host key to the in-memory database
            final OpenSSHKnownHosts.HostEntry entry
                = new OpenSSHKnownHosts.HostEntry(null, PreferencesFactory.get().getBoolean(
                "ssh.knownhosts.hostname.hash") ? hash(hostname) : hostname,
                KeyType.fromKey(key), key);
            database.entries().add(entry);
            if(persist) {
                if(file.attributes().getPermission().isWritable()) {
                    // Also try to add the key to a known_host file
                    database.write(entry);
                }
            }
        }
        catch(IOException e) {
            log.error(String.format("Failure adding host key to database: %s", e.getMessage()));
            super.allow(hostname, key, persist);
        }
    }
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:27,代码来源:OpenSSHHostKeyVerifier.java

示例2: hostKeyUnverifiableAction

import net.schmizz.sshj.common.KeyType; //导入方法依赖的package包/类
@Override
protected boolean hostKeyUnverifiableAction(String hostname, PublicKey key) {
    final KeyType type = KeyType.fromKey(key);

    String msg = String.format("The authenticity of host '%s' can't be established.%n"
            + "%s key fingerprint is %s.%n%nAre you sure you want to continue connecting?",
            hostname, type, SecurityUtils.getFingerprint(key));
    NotifyDescriptor nd = new NotifyDescriptor.Confirmation(msg, NotifyDescriptor.YES_NO_OPTION);
    if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.YES_OPTION) {
        entries().add(new OpenSSHKnownHosts.SimpleEntry(null, hostname, KeyType.fromKey(key), key));
        try {
            write();
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
            System.out.printf("## Warning: Could not add '%s' (%s) to the list of known hosts.%n", hostname, type); // TODO: replace with logger
            return true;
        }
        System.out.printf("## Warning: Permanently added '%s' (%s) to the list of known hosts.%n", hostname, type); // TODO: replace with logger
        return true;
    } else {
        return false;
    }
}
 
开发者ID:Alidron,项目名称:designer,代码行数:24,代码来源:OpenSSHKnownHostsInteractive.java

示例3: hostKeyChangedAction

import net.schmizz.sshj.common.KeyType; //导入方法依赖的package包/类
@Override
protected boolean hostKeyChangedAction(OpenSSHKnownHosts.HostEntry entry, String hostname, PublicKey key) {
    final KeyType type = KeyType.fromKey(key);
    final String fp = SecurityUtils.getFingerprint(key);
    final String path = getFile().getAbsolutePath();
    String msg = String.format(
            "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%n"
            + "@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @%n"
            + "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%n"
            + "IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!%n"
            + "Someone could be eavesdropping on you right now (man-in-the-middle attack)!%n"
            + "It is also possible that the host key has just been changed.%n"
            + "The fingerprint for the %s key sent by the remote host is%n"
            + "%s.%n"
            + "Please contact your system administrator or"
            + "add correct host key in %s to get rid of this message.%n",
            type, fp, path);
    NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.WARNING_MESSAGE);
    DialogDisplayer.getDefault().notifyLater(nd);
    return false;
}
 
开发者ID:Alidron,项目名称:designer,代码行数:22,代码来源:OpenSSHKnownHostsInteractive.java


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