| java.lang.Object com.sshtools.j2ssh.transport.AbstractKnownHostsKeyVerification
All known Subclasses: com.sshtools.common.hosts.DialogKnownHostsKeyVerification, com.sshtools.j2ssh.transport.ConsoleKnownHostsKeyVerification,
AbstractKnownHostsKeyVerification | abstract public class AbstractKnownHostsKeyVerification implements HostKeyVerification(Code) | |
An abstract HostKeyVerification class providing validation
against the known_hosts format.
author: Lee David Painter version: $Revision: 1.18 $ since: 0.2.0 |
Method Summary | |
public void | allowHost(String host, SshPublicKey pk, boolean always)
Allows a host key, optionally recording the key to the known_hosts file. | public Map | allowedHosts()
Returns a Map of the allowed hosts.
The keys of the returned Map are comma separated strings of
"hostname,ipaddress". | public boolean | isHostFileWriteable()
Determines whether the host file is writable. | abstract public void | onHostKeyMismatch(String host, SshPublicKey allowedHostKey, SshPublicKey actualHostKey)
Called by the verifyHost method when the host key supplied
by the host does not match the current key recording in the known hosts
file. | abstract public void | onUnknownHost(String host, SshPublicKey key)
Called by the verifyHost method when the host key supplied
is not recorded in the known_hosts file. | public void | removeAllowedHost(String host)
Removes an allowed host. | public void | saveHostFile()
Save's the host key file to be saved. | public String | toString()
Outputs the allowed hosts in the known_hosts file format.
The format consists of any number of lines each representing one key for
a single host.
titan,192.168.1.12 ssh-dss AAAAB3NzaC1kc3MAAACBAP1/U4Ed.....
titan,192.168.1.12 ssh-rsa AAAAB3NzaC1kc3MAAACBAP1/U4Ed.....
einstein,192.168.1.40 ssh-dss AAAAB3NzaC1kc3MAAACBAP1/U4Ed..... | public boolean | verifyHost(String host, SshPublicKey pk)
Verifies a host key against the list of known_hosts. |
AbstractKnownHostsKeyVerification | public AbstractKnownHostsKeyVerification(String knownhosts) throws InvalidHostFileException(Code) | |
Constructs a host key verification instance reading the specified
known_hosts file.
Parameters: knownhosts - the path of the known_hosts file throws: InvalidHostFileException - if the known_hosts file is invalid since: 0.2.0 |
allowHost | public void allowHost(String host, SshPublicKey pk, boolean always) throws InvalidHostFileException(Code) | |
Allows a host key, optionally recording the key to the known_hosts file.
Parameters: host - the name of the host Parameters: pk - the public key to allow Parameters: always - true if the key should be written to the known_hosts file throws: InvalidHostFileException - if the host file cannot be written since: 0.2.0 |
allowedHosts | public Map allowedHosts()(Code) | |
Returns a Map of the allowed hosts.
The keys of the returned Map are comma separated strings of
"hostname,ipaddress". The value objects are Maps containing a string
key of the public key alogorithm name and the public key as the value.
the allowed hosts since: 0.2.0 |
isHostFileWriteable | public boolean isHostFileWriteable()(Code) | |
Determines whether the host file is writable.
true if the host file is writable, otherwise false since: 0.2.0 |
onHostKeyMismatch | abstract public void onHostKeyMismatch(String host, SshPublicKey allowedHostKey, SshPublicKey actualHostKey) throws TransportProtocolException(Code) | |
Called by the verifyHost method when the host key supplied
by the host does not match the current key recording in the known hosts
file.
Parameters: host - the name of the host Parameters: allowedHostKey - the current key recorded in the known_hosts file. Parameters: actualHostKey - the actual key supplied by the user throws: TransportProtocolException - if an error occurs since: 0.2.0 |
removeAllowedHost | public void removeAllowedHost(String host)(Code) | |
Removes an allowed host.
Parameters: host - the host to remove since: 0.2.0 |
toString | public String toString()(Code) | |
Outputs the allowed hosts in the known_hosts file format.
The format consists of any number of lines each representing one key for
a single host.
titan,192.168.1.12 ssh-dss AAAAB3NzaC1kc3MAAACBAP1/U4Ed.....
titan,192.168.1.12 ssh-rsa AAAAB3NzaC1kc3MAAACBAP1/U4Ed.....
einstein,192.168.1.40 ssh-dss AAAAB3NzaC1kc3MAAACBAP1/U4Ed.....
since: 0.2.0 |
verifyHost | public boolean verifyHost(String host, SshPublicKey pk) throws TransportProtocolException(Code) | |
Verifies a host key against the list of known_hosts.
If the host unknown or the key does not match the currently allowed host
key the abstract onUnknownHost or
onHostKeyMismatch methods are called so that the caller
may identify and allow the host.
Parameters: host - the name of the host Parameters: pk - the host key supplied true if the host is accepted, otherwise false throws: TransportProtocolException - if an error occurs since: 0.2.0 |
|
|