summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2019-04-08 12:47:46 -0400
committerJackLivio <jack@livio.io>2019-04-08 12:47:46 -0400
commit839cdf8dbf3efaebeb43e905ccd0f067e165cf2b (patch)
tree2b9122256313b028468f55c7e3f17c54e65488d1
parent53fc68a800da61123a1e5f34d17912e01630060c (diff)
downloadsdl_core-839cdf8dbf3efaebeb43e905ccd0f067e165cf2b.tar.gz
Add new app policy property: allow_unknown_rpc_pass_through
-rw-r--r--src/components/application_manager/include/application_manager/policies/policy_handler.h8
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc7
-rw-r--r--src/components/include/application_manager/policies/policy_handler_interface.h8
-rw-r--r--src/components/include/policy/policy_external/policy/policy_manager.h8
-rw-r--r--src/components/include/policy/policy_regular/policy/policy_manager.h8
-rw-r--r--src/components/include/test/application_manager/policies/mock_policy_handler_interface.h2
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_cache_manager.h2
-rw-r--r--src/components/include/test/policy/policy_external/policy/mock_policy_manager.h2
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h3
-rw-r--r--src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h2
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager.h8
-rw-r--r--src/components/policy/policy_external/include/policy/cache_manager_interface.h8
-rw-r--r--src/components/policy/policy_external/include/policy/policy_manager_impl.h9
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table/types.h1
-rw-r--r--src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml1
-rw-r--r--src/components/policy/policy_external/src/cache_manager.cc15
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc6
-rw-r--r--src/components/policy/policy_external/src/policy_table/types.cc18
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_queries.cc8
-rw-r--r--src/components/policy/policy_external/src/sql_pt_ext_representation.cc5
-rw-r--r--src/components/policy/policy_external/src/sql_pt_queries.cc18
-rw-r--r--src/components/policy/policy_external/src/sql_pt_representation.cc7
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager.h8
-rw-r--r--src/components/policy/policy_regular/include/policy/cache_manager_interface.h8
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_manager_impl.h9
-rw-r--r--src/components/policy/policy_regular/include/policy/policy_table/types.h1
-rw-r--r--src/components/policy/policy_regular/src/cache_manager.cc15
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc6
-rw-r--r--src/components/policy/policy_regular/src/policy_table/types.cc18
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_queries.cc18
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc6
31 files changed, 223 insertions, 20 deletions
diff --git a/src/components/application_manager/include/application_manager/policies/policy_handler.h b/src/components/application_manager/include/application_manager/policies/policy_handler.h
index abc98876a2..c722719dab 100644
--- a/src/components/application_manager/include/application_manager/policies/policy_handler.h
+++ b/src/components/application_manager/include/application_manager/policies/policy_handler.h
@@ -474,6 +474,14 @@ class PolicyHandler : public PolicyHandlerInterface,
const std::string& requested_service_type,
smart_objects::SmartArray* requested_handled_rpcs) const OVERRIDE;
+ /**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const OVERRIDE;
+
virtual void OnUpdateHMIAppType(
std::map<std::string, StringArray> app_hmi_types) OVERRIDE;
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index 6a164d196a..e3eb56109e 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -2055,6 +2055,13 @@ bool PolicyHandler::CheckAppServiceParameters(
return true;
}
+bool PolicyHandler::UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ POLICY_LIB_CHECK(false);
+ return policy_manager_->UnknownRPCPassThroughAllowed(policy_app_id);
+}
+
uint32_t PolicyHandler::HeartBeatTimeout(const std::string& app_id) const {
POLICY_LIB_CHECK(0);
return policy_manager_->HeartBeatTimeout(app_id);
diff --git a/src/components/include/application_manager/policies/policy_handler_interface.h b/src/components/include/application_manager/policies/policy_handler_interface.h
index 7003e11473..924e992c34 100644
--- a/src/components/include/application_manager/policies/policy_handler_interface.h
+++ b/src/components/include/application_manager/policies/policy_handler_interface.h
@@ -515,6 +515,14 @@ class PolicyHandlerInterface {
const std::string& requested_service_type,
smart_objects::SmartArray* requested_handled_rpcs) const = 0;
+ /**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const = 0;
+
#ifdef EXTERNAL_PROPRIETARY_MODE
/**
* @brief Gets meta information
diff --git a/src/components/include/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h
index 80365f10ab..81b5e8ad9b 100644
--- a/src/components/include/policy/policy_external/policy/policy_manager.h
+++ b/src/components/include/policy/policy_external/policy/policy_manager.h
@@ -626,6 +626,14 @@ class PolicyManager : public usage_statistics::StatisticsManager {
policy_table::AppServiceParameters* app_service_parameters) const = 0;
/**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const = 0;
+
+ /**
* @brief Gets meta information
* @return meta information
*/
diff --git a/src/components/include/policy/policy_regular/policy/policy_manager.h b/src/components/include/policy/policy_regular/policy/policy_manager.h
index bcb55ed681..e4247df151 100644
--- a/src/components/include/policy/policy_regular/policy/policy_manager.h
+++ b/src/components/include/policy/policy_regular/policy/policy_manager.h
@@ -607,6 +607,14 @@ class PolicyManager : public usage_statistics::StatisticsManager {
policy_table::AppServiceParameters* app_service_parameters) const = 0;
/**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const = 0;
+
+ /**
* @brief OnAppRegisteredOnMobile allows to handle event when application were
* succesfully registered on mobile device.
* It will send OnAppPermissionSend notification and will try to start PTU. *
diff --git a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
index b6d8ab4cfa..fc6e735df5 100644
--- a/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
+++ b/src/components/include/test/application_manager/policies/mock_policy_handler_interface.h
@@ -237,6 +237,8 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface {
const std::string& requested_service_name,
const std::string& requested_service_type,
smart_objects::SmartArray* requested_handled_rpcs));
+ MOCK_CONST_METHOD1(UnknownRPCPassThroughAllowed,
+ bool(const std::string& policy_app_id));
#ifdef EXTERNAL_PROPRIETARY_MODE
MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo());
diff --git a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
index ee8a111100..533714a86c 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_cache_manager.h
@@ -108,6 +108,8 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface {
GetAppServiceParameters,
void(const std::string& policy_app_id,
policy_table::AppServiceParameters* app_service_parameters));
+ MOCK_CONST_METHOD1(UnknownRPCPassThroughAllowed,
+ bool(const std::string& policy_app_id));
MOCK_CONST_METHOD1(GetDeviceConsent,
DeviceConsent(const std::string& device_id));
MOCK_METHOD2(SetDeviceConsent,
diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
index 0ec4883448..21585e4ee6 100644
--- a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h
@@ -217,6 +217,8 @@ class MockPolicyManager : public PolicyManager {
GetAppServiceParameters,
void(const std::string& policy_app_id,
policy_table::AppServiceParameters* app_service_parameters));
+ MOCK_CONST_METHOD1(UnknownRPCPassThroughAllowed,
+ bool(const std::string& policy_app_id));
MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo());
MOCK_CONST_METHOD0(RetrieveCertificate, std::string());
MOCK_CONST_METHOD0(HasCertificate, bool());
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
index c92b310fcd..f954f14b77 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_cache_manager.h
@@ -100,7 +100,8 @@ class MockCacheManagerInterface : public CacheManagerInterface {
GetAppServiceParameters,
void(const std::string& policy_app_id,
policy_table::AppServiceParameters* app_service_parameters));
-
+ MOCK_CONST_METHOD1(UnknownRPCPassThroughAllowed,
+ bool(const std::string& policy_app_id));
MOCK_METHOD1(
GetNotificationsNumber,
policy_table::NumberOfNotificationsType(const std::string& priority));
diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
index ab49a6caae..6dfa631247 100644
--- a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
+++ b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h
@@ -213,6 +213,8 @@ class MockPolicyManager : public PolicyManager {
GetAppServiceParameters,
void(const std::string& policy_app_id,
policy_table::AppServiceParameters* app_service_parameters));
+ MOCK_CONST_METHOD1(UnknownRPCPassThroughAllowed,
+ bool(const std::string& policy_app_id));
MOCK_CONST_METHOD0(GetMetaInfo, const policy::MetaInfo());
MOCK_CONST_METHOD0(RetrieveCertificate, std::string());
MOCK_CONST_METHOD0(HasCertificate, bool());
diff --git a/src/components/policy/policy_external/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h
index 8dd8c3a9b9..5e3e3bcb34 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager.h
@@ -253,6 +253,14 @@ class CacheManager : public CacheManagerInterface {
policy_table::AppServiceParameters* app_service_parameters) const;
/**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const;
+
+ /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_external/include/policy/cache_manager_interface.h b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
index e5185ed1d3..1b6485c7b5 100644
--- a/src/components/policy/policy_external/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_external/include/policy/cache_manager_interface.h
@@ -262,6 +262,14 @@ class CacheManagerInterface {
policy_table::AppServiceParameters* app_service_parameters) const = 0;
/**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const = 0;
+
+ /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_external/include/policy/policy_manager_impl.h b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
index 09da4d6c9f..e2920b1176 100644
--- a/src/components/policy/policy_external/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_external/include/policy/policy_manager_impl.h
@@ -673,6 +673,15 @@ class PolicyManagerImpl : public PolicyManager {
app_service_parameters) const OVERRIDE;
/**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ * @return bool true if allowed
+ */
+ bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const OVERRIDE;
+
+ /**
* @brief OnAppRegisteredOnMobile allows to handle event when application were
* succesfully registered on mobile device.
* It will send OnAppPermissionSend notification and will try to start PTU. *
diff --git a/src/components/policy/policy_external/include/policy/policy_table/types.h b/src/components/policy/policy_external/include/policy/policy_table/types.h
index f354a3176f..c85405b3fc 100644
--- a/src/components/policy/policy_external/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_external/include/policy/policy_table/types.h
@@ -236,6 +236,7 @@ struct ApplicationParams : PolicyBase {
// App Service Params
Optional<AppServiceParameters> app_service_parameters;
+ Optional<Boolean> allow_unknown_rpc_pass_through;
public:
ApplicationParams();
diff --git a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
index d2ce9f1022..f11706c03c 100644
--- a/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
+++ b/src/components/policy/policy_external/include/policy/policy_table_interface_ext.xml
@@ -113,6 +113,7 @@
<param name="service_name" type="String" mandatory="false" />
<param name="service_type" type="String" mandatory="false" />
<param name="handled_rpcs" array="true" mandatory="false" />
+ <param name="allow_unknown_rpc_pass_through" type="Boolean" mandatory="false" />
</struct>
<typedef name="HmiLevels" type="HmiLevel" array="true"
diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc
index bfc0825d65..e87120e600 100644
--- a/src/components/policy/policy_external/src/cache_manager.cc
+++ b/src/components/policy/policy_external/src/cache_manager.cc
@@ -1541,6 +1541,21 @@ void CacheManager::GetAppServiceParameters(
}
}
+bool CacheManager::UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const {
+ const policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ auto app_policy = (*policy_iter).second;
+ if (app_policy.allow_unknown_rpc_pass_through.is_initialized()) {
+ return *(app_policy.allow_unknown_rpc_pass_through);
+ }
+ }
+ return false;
+}
+
std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes,
const std::string& language,
diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc
index 4858611ba1..08dc459433 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -799,6 +799,12 @@ void PolicyManagerImpl::GetAppServiceParameters(
cache_->GetAppServiceParameters(policy_app_id, app_service_parameters);
}
+bool PolicyManagerImpl::UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->UnknownRPCPassThroughAllowed(policy_app_id);
+}
+
void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
const PTString& hmi_level,
const PTString& rpc,
diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc
index ca14b20987..a01e8eee33 100644
--- a/src/components/policy/policy_external/src/policy_table/types.cc
+++ b/src/components/policy/policy_external/src/policy_table/types.cc
@@ -353,7 +353,9 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
, auth_token(impl::ValueMember(value__, "auth_token"))
, cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type"))
, icon_url(impl::ValueMember(value__, "icon_url"))
- , app_service_parameters(impl::ValueMember(value__, "app_services")) {}
+ , app_service_parameters(impl::ValueMember(value__, "app_services"))
+ , allow_unknown_rpc_pass_through(
+ impl::ValueMember(value__, "allow_unknown_rpc_pass_through")) {}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
@@ -374,6 +376,9 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__);
impl::WriteJsonField("icon_url", auth_token, &result__);
impl::WriteJsonField("app_services", app_service_parameters, &result__);
+ impl::WriteJsonField("allow_unknown_rpc_pass_through",
+ allow_unknown_rpc_pass_through,
+ &result__);
return result__;
}
@@ -422,6 +427,9 @@ bool ApplicationParams::is_valid() const {
if (!app_service_parameters.is_valid()) {
return false;
}
+ if (!allow_unknown_rpc_pass_through.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -478,6 +486,9 @@ bool ApplicationParams::struct_empty() const {
if (app_service_parameters.is_initialized()) {
return false;
}
+ if (allow_unknown_rpc_pass_through.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -552,6 +563,10 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
app_service_parameters.ReportErrors(
&report__->ReportSubobject("app_services"));
}
+ if (!allow_unknown_rpc_pass_through.is_valid()) {
+ allow_unknown_rpc_pass_through.ReportErrors(
+ &report__->ReportSubobject("allow_unknown_rpc_pass_through"));
+ }
}
void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
@@ -569,6 +584,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
hybrid_app_preference.SetPolicyTableType(pt_type);
icon_url.SetPolicyTableType(pt_type);
app_service_parameters.SetPolicyTableType(pt_type);
+ allow_unknown_rpc_pass_through.SetPolicyTableType(pt_type);
}
// RpcParameters methods
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
index 58206e2c69..06527cd0ac 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_queries.cc
@@ -207,8 +207,9 @@ const std::string kInsertApplication =
" `default_hmi`, `priority_value`, `is_revoked`, `memory_kb`, "
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
" `endpoint`, `enabled`, `auth_token`, "
- " `cloud_transport_type`, `icon_url`) VALUES "
- "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ " `cloud_transport_type`, `icon_url`, `allow_unknown_rpc_pass_through`) "
+ "VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kCollectFriendlyMsg = "SELECT * FROM `message`";
@@ -237,7 +238,8 @@ const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `default_hmi`, `keep_context`, "
" `steal_focus`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
" `hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token` "
- " `cloud_transport_type`, `icon_url` FROM `application`";
+ " `cloud_transport_type`, `icon_url`, `allow_unknown_rpc_pass_through` "
+ "FROM `application`";
const std::string kSelectFunctionalGroupNames =
"SELECT `id`, `user_consent_prompt`, `name`"
diff --git a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
index 29970a4424..94ddac2250 100644
--- a/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_ext_representation.cc
@@ -793,6 +793,9 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy(
app.second.icon_url.is_initialized()
? app_query.Bind(14, *app.second.icon_url)
: app_query.Bind(14);
+ app.second.allow_unknown_rpc_pass_through.is_initialized()
+ ? app_query.Bind(15, *app.second.allow_unknown_rpc_pass_through)
+ : app_query.Bind(15);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -936,7 +939,7 @@ bool SQLPTExtRepresentation::GatherApplicationPoliciesSection(
*params.auth_token = query.GetString(11);
*params.cloud_transport_type = query.GetString(12);
*params.icon_url = query.GetString(13);
-
+ *params.allow_unknown_rpc_pass_through = query.GetBoolean(14);
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
: app_id;
diff --git a/src/components/policy/policy_external/src/sql_pt_queries.cc b/src/components/policy/policy_external/src/sql_pt_queries.cc
index dea0fb4166..479628b597 100644
--- a/src/components/policy/policy_external/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_external/src/sql_pt_queries.cc
@@ -157,6 +157,7 @@ const std::string kCreateSchema =
" `auth_token` VARCHAR(65535), "
" `cloud_transport_type` VARCHAR(255), "
" `icon_url` VARCHAR(65535), "
+ " `allow_unknown_rpc_pass_through` BOOLEAN, "
" `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, "
" CONSTRAINT `fk_application_hmi_level1` "
" FOREIGN KEY(`default_hmi`) "
@@ -677,8 +678,9 @@ const std::string kInsertApplication =
"INSERT OR IGNORE INTO `application` (`id`, `priority_value`, "
"`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
"`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, "
- "`cloud_transport_type`, `icon_url`) VALUES "
- "(?,?,?,?,?,?,?,?,?,?,?,?)";
+ "`cloud_transport_type`, `icon_url`, `allow_unknown_rpc_pass_through`) "
+ "VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kInsertAppGroup =
"INSERT INTO `app_group` (`application_id`, `functional_group_id`)"
@@ -817,7 +819,8 @@ const std::string kSelectUserMsgsVersion =
const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `memory_kb`, "
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
- " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url`, "
+ " `allow_unknown_rpc_pass_through` "
"FROM "
" `application`";
@@ -941,14 +944,17 @@ const std::string kInsertApplicationFull =
" `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
" `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, "
" `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, "
- " `auth_token`, `cloud_transport_type`, `icon_url`) "
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ " `auth_token`, `cloud_transport_type`, `icon_url`, "
+ "`allow_unknown_rpc_pass_through`) "
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
const std::string kSelectApplicationFull =
"SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, "
" `is_revoked`, `is_default`, `is_predata`, `memory_kb`,"
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
- " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, "
+ "`icon_url`, "
+ " `allow_unknown_rpc_pass_through` "
"FROM `application` "
"WHERE `id` = ?";
diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc
index b9ccf70b7a..d7d0f131ec 100644
--- a/src/components/policy/policy_external/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_external/src/sql_pt_representation.cc
@@ -778,7 +778,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
*params.auth_token = query.GetString(8);
*params.cloud_transport_type = query.GetString(9);
*params.icon_url = query.GetString(10);
-
+ *params.allow_unknown_rpc_pass_through = query.GetBoolean(11);
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
: app_id;
@@ -1093,6 +1093,9 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
app.second.icon_url.is_initialized()
? app_query.Bind(11, *app.second.icon_url)
: app_query.Bind(11);
+ app.second.allow_unknown_rpc_pass_through.is_initialized()
+ ? app_query.Bind(12, *app.second.allow_unknown_rpc_pass_through)
+ : app_query.Bind(12);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -2343,6 +2346,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
: query.Bind(15, source_app.GetString(14));
source_app.IsNull(15) ? query.Bind(16)
: query.Bind(16, source_app.GetString(15));
+ source_app.IsNull(16) ? query.Bind(17)
+ : query.Bind(17, source_app.GetBoolean(16));
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Failed inserting into application.");
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager.h b/src/components/policy/policy_regular/include/policy/cache_manager.h
index 72a6aae4ad..1927f740f9 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager.h
@@ -241,6 +241,14 @@ class CacheManager : public CacheManagerInterface {
policy_table::AppServiceParameters* app_service_parameters) const;
/**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const;
+
+ /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
index 6f6c8f97ab..27a66215be 100644
--- a/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
+++ b/src/components/policy/policy_regular/include/policy/cache_manager_interface.h
@@ -247,6 +247,14 @@ class CacheManagerInterface {
policy_table::AppServiceParameters* app_service_parameters) const = 0;
/**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ */
+ virtual bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const = 0;
+
+ /**
* @brief Allows to update 'vin' field in module_meta table.
*
* @param new 'vin' value.
diff --git a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
index df2b44ba9a..8c0a87dbd1 100644
--- a/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
+++ b/src/components/policy/policy_regular/include/policy/policy_manager_impl.h
@@ -668,6 +668,15 @@ class PolicyManagerImpl : public PolicyManager {
app_service_parameters) const OVERRIDE;
/**
+ * @brief Check if an app can send unknown rpc requests to an app service
+ * provider
+ * @param policy_app_id Unique application id
+ * @return bool true if allowed
+ */
+ bool UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const OVERRIDE;
+
+ /**
* @brief OnAppRegisteredOnMobile allows to handle event when application were
* succesfully registered on mobile device.
* It will send OnAppPermissionSend notification and will try to start PTU. *
diff --git a/src/components/policy/policy_regular/include/policy/policy_table/types.h b/src/components/policy/policy_regular/include/policy/policy_table/types.h
index 65a489ef27..17ca247084 100644
--- a/src/components/policy/policy_regular/include/policy/policy_table/types.h
+++ b/src/components/policy/policy_regular/include/policy/policy_table/types.h
@@ -202,6 +202,7 @@ struct ApplicationParams : PolicyBase {
// App Service Params
Optional<AppServiceParameters> app_service_parameters;
+ Optional<Boolean> allow_unknown_rpc_pass_through;
public:
ApplicationParams();
diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc
index 42e2af5804..deb099605c 100644
--- a/src/components/policy/policy_regular/src/cache_manager.cc
+++ b/src/components/policy/policy_regular/src/cache_manager.cc
@@ -836,6 +836,21 @@ void CacheManager::GetAppServiceParameters(
}
}
+bool CacheManager::UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const {
+ const policy_table::ApplicationPolicies& policies =
+ pt_->policy_table.app_policies_section.apps;
+ policy_table::ApplicationPolicies::const_iterator policy_iter =
+ policies.find(policy_app_id);
+ if (policies.end() != policy_iter) {
+ auto app_policy = (*policy_iter).second;
+ if (app_policy.allow_unknown_rpc_pass_through.is_initialized()) {
+ return *(app_policy.allow_unknown_rpc_pass_through);
+ }
+ }
+ return false;
+}
+
std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg(
const std::vector<std::string>& msg_codes, const std::string& language) {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc
index 62e40433aa..da0cb2f439 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -618,6 +618,12 @@ void PolicyManagerImpl::GetAppServiceParameters(
cache_->GetAppServiceParameters(policy_app_id, app_service_parameters);
}
+bool PolicyManagerImpl::UnknownRPCPassThroughAllowed(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ return cache_->UnknownRPCPassThroughAllowed(policy_app_id);
+}
+
void PolicyManagerImpl::CheckPermissions(const PTString& device_id,
const PTString& app_id,
const PTString& hmi_level,
diff --git a/src/components/policy/policy_regular/src/policy_table/types.cc b/src/components/policy/policy_regular/src/policy_table/types.cc
index ac100984da..af2a556d91 100644
--- a/src/components/policy/policy_regular/src/policy_table/types.cc
+++ b/src/components/policy/policy_regular/src/policy_table/types.cc
@@ -278,7 +278,9 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
, auth_token(impl::ValueMember(value__, "auth_token"))
, cloud_transport_type(impl::ValueMember(value__, "cloud_transport_type"))
, icon_url(impl::ValueMember(value__, "icon_url"))
- , app_service_parameters(impl::ValueMember(value__, "app_services")) {}
+ , app_service_parameters(impl::ValueMember(value__, "app_services"))
+ , allow_unknown_rpc_pass_through(
+ impl::ValueMember(value__, "allow_unknown_rpc_pass_through")) {}
Json::Value ApplicationParams::ToJsonValue() const {
Json::Value result__(PolicyBase::ToJsonValue());
@@ -300,6 +302,9 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField("cloud_transport_type", cloud_transport_type, &result__);
impl::WriteJsonField("icon_url", auth_token, &result__);
impl::WriteJsonField("app_services", app_service_parameters, &result__);
+ impl::WriteJsonField("allow_unknown_rpc_pass_through",
+ allow_unknown_rpc_pass_through,
+ &result__);
return result__;
}
@@ -352,6 +357,9 @@ bool ApplicationParams::is_valid() const {
if (!app_service_parameters.is_valid()) {
return false;
}
+ if (!allow_unknown_rpc_pass_through.is_valid()) {
+ return false;
+ }
return Validate();
}
@@ -411,6 +419,9 @@ bool ApplicationParams::struct_empty() const {
if (app_service_parameters.is_initialized()) {
return false;
}
+ if (allow_unknown_rpc_pass_through.is_initialized()) {
+ return false;
+ }
return true;
}
@@ -472,6 +483,10 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
app_service_parameters.ReportErrors(
&report__->ReportSubobject("app_services"));
}
+ if (!allow_unknown_rpc_pass_through.is_valid()) {
+ allow_unknown_rpc_pass_through.ReportErrors(
+ &report__->ReportSubobject("allow_unknown_rpc_pass_through"));
+ }
}
void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
@@ -490,6 +505,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
hybrid_app_preference.SetPolicyTableType(pt_type);
icon_url.SetPolicyTableType(pt_type);
app_service_parameters.SetPolicyTableType(pt_type);
+ allow_unknown_rpc_pass_through.SetPolicyTableType(pt_type);
}
// RpcParameters methods
diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc
index 708a29c34a..c1c79e6628 100644
--- a/src/components/policy/policy_regular/src/sql_pt_queries.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc
@@ -143,6 +143,7 @@ const std::string kCreateSchema =
" `auth_token` VARCHAR(65535), "
" `cloud_transport_type` VARCHAR(255), "
" `icon_url` VARCHAR(65535), "
+ " `allow_unknown_rpc_pass_through` BOOLEAN, "
" `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, "
" CONSTRAINT `fk_application_hmi_level1` "
" FOREIGN KEY(`default_hmi`) "
@@ -626,8 +627,9 @@ const std::string kInsertApplication =
"INSERT OR IGNORE INTO `application` (`id`, `priority_value`, "
"`is_revoked`, `memory_kb`, `heart_beat_timeout_ms`, `certificate`, "
"`hybrid_app_preference_value`, `endpoint`, `enabled`, `auth_token`, "
- "`cloud_transport_type`, `icon_url`) VALUES "
- "(?,?,?,?,?,?,?,?,?,?,?,?)";
+ "`cloud_transport_type`, `icon_url`, `allow_unknown_rpc_pass_through`) "
+ "VALUES "
+ "(?,?,?,?,?,?,?,?,?,?,?,?,?)";
const std::string kInsertAppGroup =
"INSERT INTO `app_group` (`application_id`, `functional_group_id`)"
@@ -752,7 +754,8 @@ const std::string kSelectUserMsgsVersion =
const std::string kSelectAppPolicies =
"SELECT `id`, `priority_value`, `memory_kb`, "
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
- " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url`, "
+ " `allow_unknown_rpc_pass_through` "
"FROM "
" `application`";
@@ -876,14 +879,17 @@ const std::string kInsertApplicationFull =
" `default_hmi`, `priority_value`, `is_revoked`, `is_default`, "
" `is_predata`, `memory_kb`, `heart_beat_timeout_ms`, "
" `certificate`, `hybrid_app_preference_value`, `endpoint`, `enabled`, "
- " `auth_token`, `cloud_transport_type`, `icon_url`) "
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ " `auth_token`, `cloud_transport_type`, `icon_url`, "
+ "`allow_unknown_rpc_pass_through`) "
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
const std::string kSelectApplicationFull =
"SELECT `keep_context`, `steal_focus`, `default_hmi`, `priority_value`, "
" `is_revoked`, `is_default`, `is_predata`, `memory_kb`,"
" `heart_beat_timeout_ms`, `certificate`, `hybrid_app_preference_value`, "
- " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, `icon_url` "
+ " `endpoint`, `enabled`, `auth_token`, `cloud_transport_type`, "
+ "`icon_url`, "
+ " `allow_unknown_rpc_pass_through` "
"FROM `application` "
"WHERE `id` = "
"?";
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc
index 604e69f6fa..a339e94f19 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -734,6 +734,7 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection(
*params.auth_token = query.GetString(8);
*params.cloud_transport_type = query.GetString(9);
*params.icon_url = query.GetString(10);
+ *params.allow_unknown_rpc_pass_through = query.GetBoolean(11);
const auto& gather_app_id = ((*policies).apps[app_id].is_string())
? (*policies).apps[app_id].get_string()
@@ -1035,6 +1036,9 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy(
app.second.icon_url.is_initialized()
? app_query.Bind(11, *app.second.icon_url)
: app_query.Bind(11);
+ app.second.allow_unknown_rpc_pass_through.is_initialized()
+ ? app_query.Bind(12, *app.second.allow_unknown_rpc_pass_through)
+ : app_query.Bind(12);
if (!app_query.Exec() || !app_query.Reset()) {
LOG4CXX_WARN(logger_, "Incorrect insert into application.");
@@ -2296,6 +2300,8 @@ bool SQLPTRepresentation::CopyApplication(const std::string& source,
: query.Bind(15, source_app.GetString(14));
source_app.IsNull(15) ? query.Bind(16)
: query.Bind(16, source_app.GetString(15));
+ source_app.IsNull(16) ? query.Bind(17)
+ : query.Bind(17, source_app.GetBoolean(16));
if (!query.Exec()) {
LOG4CXX_WARN(logger_, "Failed inserting into application.");