From 0d41f149005218b9e5d76f6e40b892ecbc2e4280 Mon Sep 17 00:00:00 2001 From: Collin Date: Wed, 28 Aug 2019 16:30:42 -0400 Subject: Fix/reject register too many requests (#2993) * still init the RAI when we cannot find a session for the connection send a response to mobile when it tries to register no matter what * style script --- .../mobile/register_app_interface_request.cc | 28 ++++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index b39e50b222..419f1ca0c5 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -192,7 +192,7 @@ RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {} bool RegisterAppInterfaceRequest::Init() { LOG4CXX_AUTO_TRACE(logger_); - return GetDataOnSessionKey(connection_key(), &device_handle_, &device_id_); + return true; } void RegisterAppInterfaceRequest::Run() { @@ -226,6 +226,23 @@ void RegisterAppInterfaceRequest::Run() { return; } + // Cache the original app ID (for legacy behavior) + const auto policy_app_id = + application_manager_.GetCorrectMobileIDFromMessage(message_); + + if (application_manager_.IsApplicationForbidden(connection_key(), + policy_app_id)) { + SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS); + return; + } + + if (!GetDataOnSessionKey(connection_key(), &device_handle_, &device_id_)) { + SendResponse(false, + mobile_apis::Result::GENERIC_ERROR, + "Could not find a session for your connection key!"); + return; + } + LOG4CXX_DEBUG( logger_, "device_handle: " << device_handle_ << " device_id: " << device_id_); @@ -234,10 +251,6 @@ void RegisterAppInterfaceRequest::Run() { return; } - // Cache the original app ID (for legacy behavior) - const auto policy_app_id = - application_manager_.GetCorrectMobileIDFromMessage(message_); - ApplicationSharedPtr application = application_manager_.application(device_id_, policy_app_id); @@ -267,11 +280,6 @@ void RegisterAppInterfaceRequest::Run() { ::tolower); (*message_)[strings::msg_params][strings::full_app_id] = new_app_id_full; } - if (application_manager_.IsApplicationForbidden(connection_key(), - policy_app_id)) { - SendResponse(false, mobile_apis::Result::TOO_MANY_PENDING_REQUESTS); - return; - } if (IsApplicationWithSameAppIdRegistered()) { SendResponse(false, mobile_apis::Result::DISALLOWED); -- cgit v1.2.1