public void verifyHostKey(String hostName, int port, String keyAlgorithm, byte[] hostKey) throws SVNException {
String realm = hostName + ":" + port + " <" + keyAlgorithm + ">";
byte[] existingFingerprints = (byte[]) getRuntimeAuthStorage().getData("svn.ssh.server", realm);
if (existingFingerprints == null && myProviders[2] instanceof ISVNPersistentAuthenticationProvider) {
existingFingerprints = ((ISVNPersistentAuthenticationProvider) myProviders[2]).loadFingerprints(realm);
}
if (existingFingerprints == null || !equals(existingFingerprints, hostKey)) {
SVNURL url = SVNURL.create("svn+ssh", null, hostName, port, "", true);
final ISVNHostOptions hostOptions = getHostOptionsProvider().getHostOptions(url);
boolean storageEnabled = hostOptions.isAuthStorageEnabled();
if (getAuthenticationProvider() != null) {
int accepted = getAuthenticationProvider().acceptServerAuthentication(url, realm, hostKey, storageEnabled);
if (accepted == ISVNAuthenticationProvider.ACCEPTED && storageEnabled) {
if (storageEnabled && hostKey != null && myProviders[2] instanceof ISVNPersistentAuthenticationProvider) {
((ISVNPersistentAuthenticationProvider) myProviders[2]).saveFingerprints(realm, hostKey);
}
} else if (accepted == ISVNAuthenticationProvider.REJECTED) {
throw new SVNAuthenticationException(SVNErrorMessage.create(SVNErrorCode.AUTHN_CREDS_NOT_SAVED, "Host key ('" + realm + "') can not be verified."));
}
if (hostKey != null) {
getRuntimeAuthStorage().putData("svn.ssh.server", realm, hostKey);
}
}
}
}