public class OpenSSHKnownHosts extends java.lang.Object implements HostKeyVerifier
HostKeyVerifier
implementation for a known_hosts
file i.e. in the format used by OpenSSH.Modifier and Type | Class and Description |
---|---|
static class |
OpenSSHKnownHosts.AbstractEntry |
static class |
OpenSSHKnownHosts.CommentEntry |
static class |
OpenSSHKnownHosts.EntryFactory
Each line in these files contains the following fields: markers
(optional), hostnames, bits, exponent, modulus, comment.
|
static class |
OpenSSHKnownHosts.HashedEntry |
static interface |
OpenSSHKnownHosts.HostEntry |
static class |
OpenSSHKnownHosts.Marker |
static class |
OpenSSHKnownHosts.SimpleEntry |
Modifier and Type | Field and Description |
---|---|
protected java.util.List<OpenSSHKnownHosts.HostEntry> |
entries |
protected java.io.File |
khFile |
protected org.slf4j.Logger |
log |
Constructor and Description |
---|
OpenSSHKnownHosts(java.io.File khFile) |
Modifier and Type | Method and Description |
---|---|
static java.io.File |
detectSSHDir() |
java.util.List<OpenSSHKnownHosts.HostEntry> |
entries() |
java.io.File |
getFile() |
protected boolean |
hostKeyChangedAction(OpenSSHKnownHosts.HostEntry entry,
java.lang.String hostname,
java.security.PublicKey key) |
protected boolean |
hostKeyUnverifiableAction(java.lang.String hostname,
java.security.PublicKey key) |
boolean |
verify(java.lang.String hostname,
int port,
java.security.PublicKey key)
This callback is invoked when the server's host key needs to be verified.
|
void |
write() |
void |
write(OpenSSHKnownHosts.HostEntry entry)
Append a single entry
|
protected final org.slf4j.Logger log
protected final java.io.File khFile
protected final java.util.List<OpenSSHKnownHosts.HostEntry> entries
public OpenSSHKnownHosts(java.io.File khFile) throws java.io.IOException
java.io.IOException
public java.io.File getFile()
public boolean verify(java.lang.String hostname, int port, java.security.PublicKey key)
HostKeyVerifier
verify
in interface HostKeyVerifier
hostname
- remote hostnameport
- remote portkey
- host key of servertrue
if key is acceptable, false
otherwiseprotected boolean hostKeyUnverifiableAction(java.lang.String hostname, java.security.PublicKey key)
protected boolean hostKeyChangedAction(OpenSSHKnownHosts.HostEntry entry, java.lang.String hostname, java.security.PublicKey key)
public java.util.List<OpenSSHKnownHosts.HostEntry> entries()
public void write() throws java.io.IOException
java.io.IOException
public void write(OpenSSHKnownHosts.HostEntry entry) throws java.io.IOException
java.io.IOException
public static java.io.File detectSSHDir()