Class HostKeyHelper


  • public final class HostKeyHelper
    extends Object
    Helper methods to allow loading and saving of host keys for a computer. Verifiers don't have a reference to the Node or Computer that they're running for at the point they're created, so can only load the existing key to run comparisons against at the point the verifier is invoked during the connection attempt.
    Since:
    TODO
    Author:
    Michael Clarke, M Ramon Leon
    • Method Detail

      • getHostKey

        public HostKey getHostKey​(Computer host)
                           throws IOException
        Retrieve the currently trusted host key for the requested computer, or null if no key is currently trusted.
        Parameters:
        host - the Computer to retrieve the key for.
        Returns:
        the currently trusted key for the requested host, or null if no key is trusted.
        Throws:
        IOException - if the host key can not be read from storage
      • saveHostKey

        public void saveHostKey​(Computer host,
                                HostKey hostKey)
                         throws IOException
        Persists an SSH key to disk for the requested host. This effectively marks the requested key as trusted for all future connections to the host, until any future save attempt replaces this key.
        Parameters:
        host - the host the key is being saved for
        hostKey - the key to be saved as the trusted key for this host
        Throws:
        IOException - on failure saving the key for the host