diff options
author | Jack Byrne <jack@livio.io> | 2015-07-28 13:52:34 -0400 |
---|---|---|
committer | Jack Byrne <jack@livio.io> | 2015-07-28 13:52:34 -0400 |
commit | 11687835d071d211ed9e57272fa28711c74be3b6 (patch) | |
tree | 25274036dc9f1528bc5f39c0d8f0d200f3ae4764 | |
parent | 6d4237ccd3609ddf13fe629dbe1755455ab6f92b (diff) | |
download | sdl_core-11687835d071d211ed9e57272fa28711c74be3b6.tar.gz |
Added ifdefs for enabling/disabling PTU decryption by HMI
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/components/policy/src/policy/include/policy/policy_manager_impl.h | 5 | ||||
-rw-r--r-- | src/components/policy/src/policy/src/policy_manager_impl.cc | 26 |
3 files changed, 38 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 40feb61eb0..ffea5a2c3f 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" OFF) 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 b7cf7a36d2..50f9cf1481 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 f6554653e5..b20671ddc4 100644 --- a/src/components/policy/src/policy/src/policy_manager_impl.cc +++ b/src/components/policy/src/policy/src/policy_manager_impl.cc @@ -69,12 +69,28 @@ 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) { std::string json(pt_content.begin(), pt_content.end()); Json::Value value; Json::Reader reader; if (reader.parse(json.c_str(), value)) { + 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"]; @@ -89,6 +105,8 @@ utils::SharedPtr<policy_table::Table> PolicyManagerImpl::Parse( } } +#endif + void PolicyManagerImpl::CheckTriggers() { LOG4CXX_AUTO_TRACE(logger_); const bool exceed_ignition_cycles = ExceededIgnitionCycles(); @@ -108,8 +126,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(); |