Package com.sshtools.common.knownhosts
Class KnownHostsFile
java.lang.Object
com.sshtools.common.knownhosts.KnownHostsKeyVerification
com.sshtools.common.knownhosts.KnownHostsFile
- All Implemented Interfaces:
HostKeyUpdater,HostKeyVerification
- Direct Known Subclasses:
ConsoleKnownHostsFile
-
Nested Class Summary
Nested classes/interfaces inherited from class com.sshtools.common.knownhosts.KnownHostsKeyVerification
KnownHostsKeyVerification.BlankEntry, KnownHostsKeyVerification.CertAuthorityEntry, KnownHostsKeyVerification.CommentEntry, KnownHostsKeyVerification.HostFileEntry, KnownHostsKeyVerification.InvalidEntry, KnownHostsKeyVerification.KeyEntry, KnownHostsKeyVerification.RevokedEntry, KnownHostsKeyVerification.Ssh2KeyEntry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PathgetFile()booleanprotected voidonHostKeyAdded(Set<String> names, SshPublicKey key) protected voidonHostKeyMismatch(String host, List<SshPublicKey> allowedHostKey, SshPublicKey actualHostKey) Called by theverifyHostmethod when the host key supplied by the host does not match the current key recording in the known hosts file.protected voidonHostKeyRemoved(Set<String> names, SshPublicKey key) protected voidonHostKeyUpdated(Set<String> names, SshPublicKey key) protected voidonInvalidHostEntry(String entry) protected voidonRevokedKey(String host, SshPublicKey key) Called by theverifyHostmethod when the host key supplied is listed as a revoked key.protected voidonUnknownHost(String host, SshPublicKey key) Called by theverifyHostmethod when the host key supplied is not recorded in the known_hosts file.protected voidsave()voidstore()Methods inherited from class com.sshtools.common.knownhosts.KnownHostsKeyVerification
addEntry, addEntry, allowHost, clear, getKeyEntries, isKnownHost, load, removeEntries, removeEntries, removeEntries, removeEntry, resolveNames, setComment, setHashHosts, setUseCanonicalHostnames, setUseReverseDNS, toString, updateHostKey, useCanonicalHostname, useHashHosts, useReverseDNS, verifyHost, verifyHost
-
Constructor Details
-
KnownHostsFile
- Throws:
SshException
-
KnownHostsFile
- Throws:
SshException
-
KnownHostsFile
- Throws:
SshException
-
-
Method Details
-
defaultKnownHostsFile
-
store
- Throws:
IOException
-
getFile
-
getKnownHostsFile
-
isHostFileWriteable
public boolean isHostFileWriteable()- Overrides:
isHostFileWriteablein classKnownHostsKeyVerification
-
onInvalidHostEntry
- Overrides:
onInvalidHostEntryin classKnownHostsKeyVerification- Throws:
SshException
-
onHostKeyMismatch
protected void onHostKeyMismatch(String host, List<SshPublicKey> allowedHostKey, SshPublicKey actualHostKey) throws SshException Description copied from class:KnownHostsKeyVerificationCalled by the
verifyHostmethod when the host key supplied by the host does not match the current key recording in the known hosts file.- Overrides:
onHostKeyMismatchin classKnownHostsKeyVerification- Parameters:
host- the name of the hostallowedHostKey- the current key recorded in the known_hosts file.actualHostKey- the actual key supplied by the user- Throws:
SshException- if an error occurs
-
onUnknownHost
Description copied from class:KnownHostsKeyVerificationCalled by the
verifyHostmethod when the host key supplied is not recorded in the known_hosts file.- Overrides:
onUnknownHostin classKnownHostsKeyVerification- Parameters:
host- the name of the hostkey- the public key supplied by the host- Throws:
SshException- if an error occurs
-
onRevokedKey
Description copied from class:KnownHostsKeyVerificationCalled by theverifyHostmethod when the host key supplied is listed as a revoked key. This is informational, any changes made to the current entries will still result in a failed host verification.- Overrides:
onRevokedKeyin classKnownHostsKeyVerification
-
onHostKeyUpdated
- Overrides:
onHostKeyUpdatedin classKnownHostsKeyVerification
-
onHostKeyAdded
- Overrides:
onHostKeyAddedin classKnownHostsKeyVerification
-
onHostKeyRemoved
- Overrides:
onHostKeyRemovedin classKnownHostsKeyVerification
-
save
protected void save()
-