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


Java KeyType类代码示例

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


KeyType类属于net.schmizz.sshj.common包,在下文中一共展示了KeyType类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例4: loadBundle

import net.schmizz.sshj.common.KeyType; //导入依赖的package包/类
@Override
public void loadBundle() {
    final NSAlert alert = NSAlert.alert();
    alert.setAlertStyle(NSAlert.NSWarningAlertStyle);
    alert.setMessageText(MessageFormat.format(LocaleFactory.localizedString("Unknown fingerprint", "Sftp"), hostname));
    alert.setInformativeText(MessageFormat.format(LocaleFactory.localizedString("The fingerprint for the {1} key sent by the server is {0}.", "Sftp"),
            fingerprint, KeyType.fromKey(key).name()));
    alert.addButtonWithTitle(LocaleFactory.localizedString("Allow"));
    alert.addButtonWithTitle(LocaleFactory.localizedString("Deny"));
    alert.setShowsSuppressionButton(true);
    alert.suppressionButton().setTitle(LocaleFactory.localizedString("Always"));
    super.loadBundle(alert);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:UnknownHostKeyAlertController.java

示例5: loadBundle

import net.schmizz.sshj.common.KeyType; //导入依赖的package包/类
@Override
public void loadBundle() {
    final NSAlert alert = NSAlert.alert();
    alert.setAlertStyle(NSAlert.NSWarningAlertStyle);
    alert.setMessageText(MessageFormat.format(LocaleFactory.localizedString("Changed fingerprint", "Sftp"), hostname));
    alert.setInformativeText(MessageFormat.format(LocaleFactory.localizedString("The fingerprint for the {1} key sent by the server is {0}.", "Sftp"),
            fingerprint, KeyType.fromKey(key).name()));
    alert.addButtonWithTitle(LocaleFactory.localizedString("Allow"));
    alert.addButtonWithTitle(LocaleFactory.localizedString("Deny"));
    alert.setShowsSuppressionButton(true);
    alert.suppressionButton().setTitle(LocaleFactory.localizedString("Always"));
    super.loadBundle(alert);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:ChangedHostKeyAlertController.java

示例6: isUnknownKeyAccepted

import net.schmizz.sshj.common.KeyType; //导入依赖的package包/类
@Override
protected boolean isUnknownKeyAccepted(final String hostname, final PublicKey key) throws ConnectionCanceledException, ChecksumException {
    final String message = String.format("%s. %s %s?", LocaleFactory.localizedString("Unknown fingerprint", "Sftp"),
            MessageFormat.format(LocaleFactory.localizedString("The fingerprint for the {1} key sent by the server is {0}.", "Sftp"),
                    new SSHFingerprintGenerator().fingerprint(key),
                    KeyType.fromKey(key).name()),
            LocaleFactory.localizedString("Continue", "Credentials"));
    if(!prompt.prompt(message)) {
        throw new ConnectionCanceledException();
    }
    this.allow(hostname, key, true);
    return true;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:TerminalHostKeyVerifier.java

示例7: isChangedKeyAccepted

import net.schmizz.sshj.common.KeyType; //导入依赖的package包/类
@Override
protected boolean isChangedKeyAccepted(final String hostname, final PublicKey key) throws ConnectionCanceledException, ChecksumException {
    final String message = String.format("%s. %s %s?", LocaleFactory.localizedString("Changed fingerprint", "Sftp"),
            MessageFormat.format(LocaleFactory.localizedString("The fingerprint for the {1} key sent by the server is {0}.", "Sftp"),
                    new SSHFingerprintGenerator().fingerprint(key),
                    KeyType.fromKey(key).name()),
            LocaleFactory.localizedString("Continue", "Credentials"));
    if(!prompt.prompt(message)) {
        throw new ConnectionCanceledException();
    }
    this.allow(hostname, key, true);
    return true;
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:14,代码来源:TerminalHostKeyVerifier.java

示例8: getFormat

import net.schmizz.sshj.common.KeyType; //导入依赖的package包/类
private String getFormat(final String hostname, final PublicKey key) {
    return String.format("ssh.hostkey.%s.%s", KeyType.fromKey(key), hostname);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:4,代码来源:PreferencesHostKeyVerifier.java


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