try {
return database.getUser(publicHash);
} catch (UserNotFoundException e) {
// TODO(drt24): potential security vulnerability - user existence oracle.
// Should not happen often - is only possible due to concurrency
throw new UnauthorisedException("No such user");
}
} else {
throw new UnauthorisedException("Invalid nonce or no such user");
}
} else {
throw new UnauthorisedException("The signature is invalid");
}
} catch (NoSuchAlgorithmException nsae) {
severe("authenticateUser",nsae);
throw new CryptoException("Internal error attempting to verify signature");
}
} catch (UserNotFoundException e1) {
warning("authenticateUser",e1);
throw new UnauthorisedException("No such user");
}
}