Class FingerprintVerifier

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FingerprintVerifier​(java.lang.String digestAlgorithm, java.lang.String base64Fingerprint)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.lang.String> findExistingAlgorithms​(java.lang.String hostname, int port)
      It is necessary to connect with the type of algorithm that matches an existing know_host entry.
      static HostKeyVerifier getInstance​(java.lang.String fingerprint)
      Valid examples: 4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21 MD5:4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21 SHA1:FghNYu1l/HyE/qWbdQ2mkxrd0rU SHA1:FghNYu1l/HyE/qWbdQ2mkxrd0rU= SHA256:l/SjyCoKP8jAx3d8k8MWH+UZG0gcuIR7TQRE/A3faQo SHA256:l/SjyCoKP8jAx3d8k8MWH+UZG0gcuIR7TQRE/A3faQo=
      java.lang.String toString()  
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • MD5_FINGERPRINT_PATTERN

        private static final java.util.regex.Pattern MD5_FINGERPRINT_PATTERN
      • digestAlgorithm

        private final java.lang.String digestAlgorithm
      • fingerprintData

        private final byte[] fingerprintData
    • Constructor Detail

      • FingerprintVerifier

        private FingerprintVerifier​(java.lang.String digestAlgorithm,
                                    java.lang.String base64Fingerprint)
        Parameters:
        digestAlgorithm - the used digest algorithm
        base64Fingerprint - base64 encoded fingerprint data
    • Method Detail

      • getInstance

        public static HostKeyVerifier getInstance​(java.lang.String fingerprint)
        Valid examples:
        • 4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21
        • MD5:4b:69:6c:72:6f:79:20:77:61:73:20:68:65:72:65:21
        • SHA1:FghNYu1l/HyE/qWbdQ2mkxrd0rU
        • SHA1:FghNYu1l/HyE/qWbdQ2mkxrd0rU=
        • SHA256:l/SjyCoKP8jAx3d8k8MWH+UZG0gcuIR7TQRE/A3faQo
        • SHA256:l/SjyCoKP8jAx3d8k8MWH+UZG0gcuIR7TQRE/A3faQo=
        Parameters:
        fingerprint - of an SSH fingerprint in MD5 (hex), SHA-1 (base64) or SHA-256(base64) format
        Returns:
        Host Key Verifier
      • verify

        public boolean verify​(java.lang.String hostname,
                              int port,
                              java.security.PublicKey key)
        Description copied from interface: HostKeyVerifier
        This callback is invoked when the server's host key needs to be verified. The return value indicates to the caller whether the SSH connection should proceed.

        Note: host key verification is the basis for security in SSH, therefore exercise due caution in implementing!

        Specified by:
        verify in interface HostKeyVerifier
        Parameters:
        hostname - remote hostname
        port - remote port
        key - host key of server
        Returns:
        true if key is acceptable, false otherwise
      • findExistingAlgorithms

        public java.util.List<java.lang.String> findExistingAlgorithms​(java.lang.String hostname,
                                                                       int port)
        Description copied from interface: HostKeyVerifier
        It is necessary to connect with the type of algorithm that matches an existing know_host entry. This will allow a match when we later verify with the negotiated key HostKeyVerifier.verify
        Specified by:
        findExistingAlgorithms in interface HostKeyVerifier
        Parameters:
        hostname - remote hostname
        port - remote port
        Returns:
        existing key types or empty list if no keys known for hostname
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object