Save This Page
Home » j2ssh-0.2.9-src » com.sshtools.j2ssh.transport » [javadoc | source]
com.sshtools.j2ssh.transport
abstract public class: AbstractKnownHostsKeyVerification [javadoc | source]
java.lang.Object
   com.sshtools.j2ssh.transport.AbstractKnownHostsKeyVerification

All Implemented Interfaces:
    HostKeyVerification

Direct Known Subclasses:
    ConsoleKnownHostsKeyVerification, DialogKnownHostsKeyVerification

An abstract HostKeyVerification class providing validation against the known_hosts format.

Constructor:
 public AbstractKnownHostsKeyVerification(String knownhosts) throws InvalidHostFileException 

    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 -
Method from com.sshtools.j2ssh.transport.AbstractKnownHostsKeyVerification Summary:
allowHost,   allowedHosts,   isHostFileWriteable,   onHostKeyMismatch,   onUnknownHost,   removeAllowedHost,   saveHostFile,   toString,   verifyHost
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sshtools.j2ssh.transport.AbstractKnownHostsKeyVerification Detail:
 public  void allowHost(String host,
    SshPublicKey pk,
    boolean always) throws InvalidHostFileException 

    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". The value objects are Maps containing a string key of the public key alogorithm name and the public key as the value.

 public boolean isHostFileWriteable() 

    Determines whether the host file is writable.

 abstract public  void onHostKeyMismatch(String host,
    SshPublicKey allowedHostKey,
    SshPublicKey actualHostKey) throws TransportProtocolException

    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) throws TransportProtocolException

    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() throws InvalidHostFileException 

    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) throws TransportProtocolException 

    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.