com.mindbright.ssh2
Class SSH2HostKeyVerifier

java.lang.Object
  extended bycom.mindbright.ssh2.SSH2TransportEventAdapter
      extended bycom.mindbright.ssh2.SSH2HostKeyVerifier
All Implemented Interfaces:
SSH2TransportEventHandler

public class SSH2HostKeyVerifier
extends SSH2TransportEventAdapter

This class is an adapter for the interface SSH2TransportEventHandler.

See Also:
SSH2TransportEventHandler

Field Summary
protected  java.lang.String fingerprint
           
protected  PublicKey publickey
           
 
Constructor Summary
SSH2HostKeyVerifier(PublicKey publickey)
          Create an instance which will verify that the hostkey matches the given public key.
SSH2HostKeyVerifier(java.lang.String fingerprint)
          Create an instance which will verify that the hostkey matches a public key with the given fingerprint.
 
Method Summary
static boolean compareFingerprints(java.lang.String fingerprint, SSH2Signature serverHostKey)
          Static utility function which can be used to compare a server key against a fingerprint.
static boolean comparePublicKeys(PublicKey p1, PublicKey p2)
          Static utility functions which can compare two public keys.
 boolean kexAuthenticateHost(SSH2Transport tp, SSH2Signature serverHostKey)
          Perform the authenticate host stage of key exchange.
 
Methods inherited from class com.mindbright.ssh2.SSH2TransportEventAdapter
fatalDisconnect, gotConnectInfoText, gotPeerVersion, kexAgreed, kexComplete, kexStart, msgDebug, msgIgnore, msgUnimplemented, normalDisconnect, peerDisconnect, peerSentUnknownMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fingerprint

protected java.lang.String fingerprint

publickey

protected PublicKey publickey
Constructor Detail

SSH2HostKeyVerifier

public SSH2HostKeyVerifier(PublicKey publickey)
Create an instance which will verify that the hostkey matches the given public key.

Parameters:
publickey - The public key to verify against.

SSH2HostKeyVerifier

public SSH2HostKeyVerifier(java.lang.String fingerprint)
Create an instance which will verify that the hostkey matches a public key with the given fingerprint.

Parameters:
fingerprint - The fingerprint which should match the public key.
Method Detail

kexAuthenticateHost

public boolean kexAuthenticateHost(SSH2Transport tp,
                                   SSH2Signature serverHostKey)
Perform the authenticate host stage of key exchange.

Specified by:
kexAuthenticateHost in interface SSH2TransportEventHandler
Overrides:
kexAuthenticateHost in class SSH2TransportEventAdapter
Parameters:
tp - Indentifies the SSH2Transport object handling the connection.
serverHostKey - Signature object which holds the server keys.
Returns:
True if the keys match.

compareFingerprints

public static boolean compareFingerprints(java.lang.String fingerprint,
                                          SSH2Signature serverHostKey)
Static utility function which can be used to compare a server key against a fingerprint.

Parameters:
fingerprint - The fingerprint to check.
serverHostKey - Signature object which holds the server keys.
Returns:
True if the server key generates an identical fingerprint as the one we are comparing against.

comparePublicKeys

public static boolean comparePublicKeys(PublicKey p1,
                                        PublicKey p2)
Static utility functions which can compare two public keys.

Parameters:
p1 - Public key to compare.
p2 - Public key to compare.
Returns:
True if they are identical.