}
} catch (IOException ex) {
throw new HgAuthFailedException("Failed to read private key", ex);
}
try {
boolean success = conn.authenticateWithPublicKey(username, a.toCharArray(), passphrase);
if (!success) {
throw authFailed(username);
}
} catch (IOException ex) {
throw commFailed(ex);