*/
private EventMessageBundle deserializeEvents(HttpServletRequest req) throws IOException {
String json = readRequestBody(req);
LOG.info("Incoming events: " + json);
EventMessageBundle bundle = SERIALIZER.fromJson(json, EventMessageBundle.class);
if (bundle.getRpcServerUrl() == null) {
throw new IllegalArgumentException("RPC server URL is not set in the event bundle.");
}
if (!isUnsignedRequestsAllowed()) {
if (!waveService.hasConsumerData(bundle.getRpcServerUrl())) {
throw new IllegalArgumentException("No consumer key is found for the RPC server URL: " +
bundle.getRpcServerUrl());
}
// Validates the request.
try {
@SuppressWarnings("unchecked")
Map<String, String[]> parameterMap = req.getParameterMap();
waveService.validateOAuthRequest(req.getRequestURL().toString(), parameterMap,
json, bundle.getRpcServerUrl());
} catch (OAuthException e) {
throw new IllegalArgumentException("Error validating OAuth request", e);
}
}
return bundle;