summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAGaliuzov <AGaliuzov@luxoft.com>2015-08-28 16:05:20 +0300
committerAGaliuzov <AGaliuzov@luxoft.com>2015-08-28 16:05:20 +0300
commit025032099a075a740cfef5a714ac84c48ffaf953 (patch)
tree984345e4f35537189551c4038e49d75c2f6f7221
parente9e9e14eb9348558420c534bb88eed7a5234343b (diff)
parent95fd0a067a15bdfd48645c2ede2d86728120925c (diff)
downloadsmartdevicelink-025032099a075a740cfef5a714ac84c48ffaf953.tar.gz
Merge pull request #175 from smartdevicelink/hotfix/issue#166
Add flags to enable/disable HMI policy table decryption
-rw-r--r--CMakeLists.txt7
-rw-r--r--src/components/policy/src/policy/include/policy/policy_manager_impl.h5
-rw-r--r--src/components/policy/src/policy/src/policy_manager_impl.cc35
3 files changed, 46 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 40feb61eb..b5cf7d118 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,6 +48,7 @@ option(ENABLE_LOG "Logging feature" ON)
option(ENABLE_GCOV "gcov code coverage feature" OFF)
option(ENABLE_SANITIZE "Sanitize tool" OFF)
option(ENABLE_SECURITY "Security Ford protocol protection" ON)
+option(ENABLE_HMI_PTU_DECRYPTION "Policy table update parsed by hmi" ON)
set(OS_TYPE_OPTION "$ENV{OS_TYPE}")
set(DEBUG_OPTION "$ENV{DEBUG}")
@@ -238,6 +239,7 @@ pkg_check_modules(GLIB2 REQUIRED glib-2.0)
add_definitions(${GLIB2_CFLAGS})
endif()
+
# --- Interface generator
find_package(PythonInterp)
@@ -618,6 +620,11 @@ if(ENABLE_SECURITY)
#set(SecurityManagerTestIncludeDir ${CMAKE_SOURCE_DIR}/test/components/security_manager/include)
endif()
+if(ENABLE_HMI_PTU_DECRYPTION)
+ MESSAGE("USE DHMI_PTU_PARSER")
+ add_definitions(-DUSE_HMI_PTU_DECRYPTION)
+endif()
+
set(RTLIB rt)
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(RTLIB )
diff --git a/src/components/policy/src/policy/include/policy/policy_manager_impl.h b/src/components/policy/src/policy/include/policy/policy_manager_impl.h
index b7cf7a36d..50f9cf148 100644
--- a/src/components/policy/src/policy/include/policy/policy_manager_impl.h
+++ b/src/components/policy/src/policy/include/policy/policy_manager_impl.h
@@ -172,8 +172,13 @@ class PolicyManagerImpl : public PolicyManager {
virtual const std::vector<std::string> GetAppRequestTypes(
const std::string policy_app_id) const;
protected:
+ #ifdef USE_HMI_PTU_DECRYPTION
virtual utils::SharedPtr<policy_table::Table> Parse(
const BinaryMessage& pt_content);
+ #else
+ virtual utils::SharedPtr<policy_table::Table> ParseArray(
+ const BinaryMessage& pt_content);
+ #endif
private:
void CheckTriggers();
diff --git a/src/components/policy/src/policy/src/policy_manager_impl.cc b/src/components/policy/src/policy/src/policy_manager_impl.cc
index 955dbf126..4cfab1506 100644
--- a/src/components/policy/src/policy/src/policy_manager_impl.cc
+++ b/src/components/policy/src/policy/src/policy_manager_impl.cc
@@ -69,8 +69,10 @@ void PolicyManagerImpl::set_listener(PolicyListener* listener) {
update_status_manager_.set_listener(listener);
}
+#ifdef USE_HMI_PTU_DECRYPTION
+
utils::SharedPtr<policy_table::Table> PolicyManagerImpl::Parse(
- const BinaryMessage& pt_content) {
+ const BinaryMessage& pt_content) {
std::string json(pt_content.begin(), pt_content.end());
Json::Value value;
Json::Reader reader;
@@ -78,9 +80,32 @@ utils::SharedPtr<policy_table::Table> PolicyManagerImpl::Parse(
return new policy_table::Table(&value);
} else {
return utils::SharedPtr<policy_table::Table>();
+ }
+}
+
+#else
+
+utils::SharedPtr<policy_table::Table> PolicyManagerImpl::ParseArray(
+ const BinaryMessage& pt_content) {
+ std::string json(pt_content.begin(), pt_content.end());
+ Json::Value value;
+ Json::Reader reader;
+ if (reader.parse(json.c_str(), value)) {
+ //For PT Update received from SDL Server.
+ if (value["data"].size()!=0) {
+ Json::Value data = value["data"];
+ //First Element in
+ return new policy_table::Table(&data[0]);
+ } else {
+ return new policy_table::Table(&value);
+ }
+ } else {
+ return utils::SharedPtr<policy_table::Table>();
}
}
+#endif
+
void PolicyManagerImpl::CheckTriggers() {
LOG4CXX_AUTO_TRACE(logger_);
const bool exceed_ignition_cycles = ExceededIgnitionCycles();
@@ -100,8 +125,16 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
const BinaryMessage& pt_content) {
LOG4CXX_INFO(logger_, "LoadPT of size " << pt_content.size());
+ #ifdef USE_HMI_PTU_DECRYPTION
+ // Assuemes Policy Table was parsed, formatted, and/or decrypted by
+ // the HMI after system request before calling OnReceivedPolicyUpdate
// Parse message into table struct
utils::SharedPtr<policy_table::Table> pt_update = Parse(pt_content);
+ #else
+ //Message Received from server unecnrypted with PTU in first element
+ //of 'data' array. No Parsing was done by HMI.
+ utils::SharedPtr<policy_table::Table> pt_update = ParseArray(pt_content);
+ #endif
if (!pt_update) {
LOG4CXX_WARN(logger_, "Parsed table pointer is 0.");
update_status_manager_.OnWrongUpdateReceived();