當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。