diff options
author | JackLivio <jack@livio.io> | 2019-02-24 13:45:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-24 13:45:46 -0500 |
commit | 13155e460f972f967b2197cf209e2d6417cf89b0 (patch) | |
tree | eb1d28209a17150cb0b6b2239429f4babf70f354 /src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src | |
parent | c3f3360bebde3f1c6a52234c94749434cfa69693 (diff) | |
parent | da17adca89fa2cc7429230aae5c179cd3b1f4832 (diff) | |
download | sdl_core-13155e460f972f967b2197cf209e2d6417cf89b0.tar.gz |
Merge pull request #2801 from smartdevicelink/feature/app_service_policies
App Service Policy Implementation
Diffstat (limited to 'src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src')
2 files changed, 51 insertions, 0 deletions
diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc index b46bc7934e..1aa8504ff9 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/on_app_service_data_notification_from_mobile.cc @@ -59,6 +59,22 @@ void OnAppServiceDataNotificationFromMobile::Run() { LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "Received an OnAppServiceData"); MessageHelper::PrintSmartObject(*message_); + + std::string service_type = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_type].asString(); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + bool result = policy_handler_.CheckAppServiceParameters( + app->policy_app_id(), std::string(), service_type, NULL); + + if (!result) { + LOG4CXX_DEBUG(logger_, + "Incorrect service type received in " + "OnAppServiceDataNotificationFromMobile"); + return; + } } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc index ed60bb14df..f951d2b126 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/commands/mobile/publish_app_service_request.cc @@ -84,6 +84,41 @@ void PublishAppServiceRequest::Run() { } ApplicationSharedPtr app = application_manager_.application(connection_key()); + + std::string requested_service_name = ""; + + if ((*message_)[strings::msg_params][strings::app_service_manifest].keyExists( + strings::service_name)) { + requested_service_name = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_name].asString(); + } + + std::string requested_service_type = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::service_type].asString(); + + smart_objects::SmartArray* requested_handled_rpcs = NULL; + if ((*message_)[strings::msg_params][strings::app_service_manifest].keyExists( + strings::handled_rpcs)) { + requested_handled_rpcs = + (*message_)[strings::msg_params][strings::app_service_manifest] + [strings::handled_rpcs].asArray(); + } + + bool result = + policy_handler_.CheckAppServiceParameters(app->policy_app_id(), + requested_service_name, + requested_service_type, + requested_handled_rpcs); + + if (!result) { + SendResponse(false, + mobile_apis::Result::DISALLOWED, + "Service disallowed by policies", + NULL); + } + auto& ext = sdl_rpc_plugin::SystemCapabilityAppExtension::ExtractExtension(*app); ext.SubscribeTo(mobile_apis::SystemCapabilityType::APP_SERVICES); |