diff options
author | Andrii Kalinich <AKalinich@luxoft.com> | 2018-06-12 14:34:31 +0300 |
---|---|---|
committer | AKalinich-Luxoft <AKalinich@luxoft.com> | 2018-06-13 14:16:58 +0300 |
commit | a194d35bcc39560ef47f39a5dd95cd75cfd193ba (patch) | |
tree | 5195bf7a6f4f897ecb41a7c03ef17ce514830691 | |
parent | a7ba8634cc5de72d0a5bd8249ecbe38083d8c934 (diff) | |
download | sdl_core-a194d35bcc39560ef47f39a5dd95cd75cfd193ba.tar.gz |
Updates after Livio review
12 files changed, 41 insertions, 37 deletions
diff --git a/src/components/connection_handler/test/connection_handler_impl_test.cc b/src/components/connection_handler/test/connection_handler_impl_test.cc index 56dbf6b9de..b231ee625f 100644 --- a/src/components/connection_handler/test/connection_handler_impl_test.cc +++ b/src/components/connection_handler/test/connection_handler_impl_test.cc @@ -1273,6 +1273,9 @@ TEST_F(ConnectionHandlerTest, SessionStarted_WithRpc) { true, ByRef(empty))); + EXPECT_CALL(mock_connection_handler_observer, CheckAppIsNavi(_)) + .WillOnce(Return(true)); + connection_handler_->set_protocol_handler(&mock_protocol_handler_); EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _)) .WillOnce(SaveArg<0>(&out_context_)); @@ -1309,6 +1312,8 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_SUCCESS) { session_key, true, ByRef(empty))); + EXPECT_CALL(mock_connection_handler_observer, CheckAppIsNavi(_)) + .WillOnce(Return(true)); // confirm that NotifySessionStarted() is called connection_handler_->set_protocol_handler(&mock_protocol_handler_); @@ -1349,6 +1354,8 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_FAILURE) { session_key, false, ByRef(empty))); + EXPECT_CALL(mock_connection_handler_observer, CheckAppIsNavi(_)) + .WillOnce(Return(true)); // confirm that NotifySessionStarted() is called connection_handler_->set_protocol_handler(&mock_protocol_handler_); @@ -1439,6 +1446,9 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_Multiple) { session_key1, true, ByRef(empty)))); + EXPECT_CALL(mock_connection_handler_observer, CheckAppIsNavi(_)) + .Times(2) + .WillOnce(Return(true)); // verify that connection handler will not mix up the two results SessionContext new_context_first, new_context_second; diff --git a/src/components/include/test/utils/mock_system_time_handler.h b/src/components/include/test/utils/mock_system_time_handler.h index ef80e698f5..7bb2a7f0a5 100644 --- a/src/components/include/test/utils/mock_system_time_handler.h +++ b/src/components/include/test/utils/mock_system_time_handler.h @@ -46,7 +46,7 @@ class MockSystemTimeHandler : public ::utils::SystemTimeHandler { MOCK_METHOD0(QuerySystemTime, void()); MOCK_METHOD1(SubscribeOnSystemTime, void(utils::SystemTimeListener* listener)); - MOCK_METHOD1(UnSubscribeFromSystemTime, + MOCK_METHOD1(UnsubscribeFromSystemTime, void(utils::SystemTimeListener* listener)); MOCK_METHOD0(GetUTCTime, time_t()); MOCK_CONST_METHOD0(system_time_can_be_received, bool()); diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index ef891f86a1..6b192a8d0d 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -2842,14 +2842,15 @@ <interface name="BasicCommunication" version="1.2.1" date="2017-08-02"> <function name="GetSystemTime" messagetype="request"> - <description> Allows to obtain current sytem time</description> + <description>Request from SDL to HMI to obtain current UTC time.</description> </function> <function name="GetSystemTime" messagetype="response"> <param name="systemTime" type="Common.DateTime" mandatory="true"> + <description>Current UTC system time</description> </param> </function> <function name="OnSystemTimeReady" messagetype="notification"> - <description>HMI notifies SDL with this notification that NAVI module is ready to provide system time.</description> + <description>HMI must notify SDL about readiness to provide system time.</description> </function> <function name="OnReady" messagetype="notification"> <description>HMI must notify SDL about its readiness to start communication. In fact, this has to be the first message between SDL and HMI.</description> 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 5226a15aeb..4e744cf716 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1061,6 +1061,13 @@ StatusNotifier PolicyManagerImpl::AddApplication( device_consent); } else { PromoteExistedApplication(application_id, device_consent); + const policy_table::AppHMIType type = policy_table::AHT_NAVIGATION; + if (helpers::in_range(hmi_types, + (rpc::Enum<policy_table::AppHMIType>)type) && + !HasCertificate()) { + LOG4CXX_DEBUG(logger_, "Certificate does not exist, scheduling update."); + update_status_manager_.ScheduleUpdate(); + } return utils::MakeShared<utils::CallNothing>(); } } diff --git a/src/components/security_manager/include/security_manager/crypto_manager_impl.h b/src/components/security_manager/include/security_manager/crypto_manager_impl.h index c31e02cf48..228666d22f 100644 --- a/src/components/security_manager/include/security_manager/crypto_manager_impl.h +++ b/src/components/security_manager/include/security_manager/crypto_manager_impl.h @@ -152,15 +152,8 @@ class CryptoManagerImpl : public CryptoManager { private: bool set_certificate(const std::string& cert_data); - - /** - * @brief Sets initial certificate datetime - */ - void InitCertExpTime(); - const utils::SharedPtr<const CryptoManagerSettings> settings_; SSL_CTX* context_; - mutable struct tm expiration_time_; static uint32_t instance_count_; static sync_primitives::Lock instance_lock_; DISALLOW_COPY_AND_ASSIGN(CryptoManagerImpl); diff --git a/src/components/security_manager/include/security_manager/security_manager_impl.h b/src/components/security_manager/include/security_manager/security_manager_impl.h index dc0284c128..70b87de0ef 100644 --- a/src/components/security_manager/include/security_manager/security_manager_impl.h +++ b/src/components/security_manager/include/security_manager/security_manager_impl.h @@ -143,6 +143,7 @@ class SecurityManagerImpl : public SecurityManager, * Do not notify listeners, send security error on occure * \param connection_key Unique key used by other components as session * identifier + * @param cc_strategy - SSL context creation strategy * @return new \c SSLContext or \c NULL on any error */ SSLContext* CreateSSLContext(const uint32_t& connection_key, @@ -163,6 +164,7 @@ class SecurityManagerImpl : public SecurityManager, /** * @brief Checks whether certificate should be updated + * @param connection_key the connection identifier to check certificate for. * @return true if certificate should be updated otherwise false */ bool IsCertificateUpdateRequired(const uint32_t connection_key) OVERRIDE; diff --git a/src/components/security_manager/src/crypto_manager_impl.cc b/src/components/security_manager/src/crypto_manager_impl.cc index bdf266fda8..1e1b4ef44a 100644 --- a/src/components/security_manager/src/crypto_manager_impl.cc +++ b/src/components/security_manager/src/crypto_manager_impl.cc @@ -98,7 +98,6 @@ CryptoManagerImpl::CryptoManagerImpl( OpenSSL_add_all_algorithms(); SSL_library_init(); } - InitCertExpTime(); } CryptoManagerImpl::~CryptoManagerImpl() { @@ -360,18 +359,4 @@ bool CryptoManagerImpl::set_certificate(const std::string& cert_data) { return true; } -int CryptoManagerImpl::SSLContextImpl::get_number_from_char_buf( - char* buf, int* idx) const { - if (!idx) { - return 0; - } - const int val = ((buf[*idx] - '0') * 10) + buf[(*idx) + 1] - '0'; - *idx = *idx + 2; - return val; -} - -void CryptoManagerImpl::InitCertExpTime() { - strptime("1 Jan 1970 00:00:00", "%d %b %Y %H:%M:%S", &expiration_time_); -} - } // namespace security_manager diff --git a/src/components/security_manager/src/security_manager_impl.cc b/src/components/security_manager/src/security_manager_impl.cc index 66a85956a5..401491c5dc 100644 --- a/src/components/security_manager/src/security_manager_impl.cc +++ b/src/components/security_manager/src/security_manager_impl.cc @@ -60,7 +60,7 @@ SecurityManagerImpl::SecurityManagerImpl( } SecurityManagerImpl::~SecurityManagerImpl() { - system_time_handler_->UnSubscribeFromSystemTime(this); + system_time_handler_->UnsubscribeFromSystemTime(this); } void SecurityManagerImpl::OnMessageReceived( @@ -242,7 +242,7 @@ void SecurityManagerImpl::StartHandshake(uint32_t connection_key) { LOG4CXX_ERROR(logger_, "Security certificate is absent"); sync_primitives::AutoLock lock(waiters_lock_); waiting_for_certificate_ = true; - NotifyOnCertififcateUpdateRequired(); + NotifyOnCertificateUpdateRequired(); } { @@ -293,7 +293,7 @@ void SecurityManagerImpl::ProceedHandshake( waiting_for_certificate_ = true; } PostponeHandshake(connection_key); - NotifyOnCertififcateUpdateRequired(); + NotifyOnCertificateUpdateRequired(); return; } @@ -369,7 +369,7 @@ bool SecurityManagerImpl::OnCertificateUpdated(const std::string& data) { awaiting_certificate_connections_.end(), std::bind1st(std::mem_fun(&SecurityManagerImpl::ResumeHandshake), this)); - std::set<uint32_t>().swap(awaiting_certificate_connections_); + awaiting_certificate_connections_.clear(); return true; } @@ -385,7 +385,7 @@ void SecurityManagerImpl::OnSystemTimeArrived(const time_t utc_time) { awaiting_time_connections_.end(), std::bind1st(std::mem_fun(&SecurityManagerImpl::ResumeHandshake), this)); - std::set<uint32_t>().swap(awaiting_time_connections_); + awaiting_time_connections_.clear(); } void SecurityManagerImpl::NotifyListenersOnHandshakeDone( diff --git a/src/components/security_manager/src/ssl_context_impl.cc b/src/components/security_manager/src/ssl_context_impl.cc index bccb885511..866e825e0b 100644 --- a/src/components/security_manager/src/ssl_context_impl.cc +++ b/src/components/security_manager/src/ssl_context_impl.cc @@ -280,6 +280,16 @@ CryptoManagerImpl::SSLContextImpl::CheckCertContext() { return Handshake_Result_Success; } +int CryptoManagerImpl::SSLContextImpl::get_number_from_char_buf( + char* buf, int* idx) const { + if (!idx) { + return 0; + } + const int val = ((buf[*idx] - '0') * 10) + buf[(*idx) + 1] - '0'; + *idx = *idx + 2; + return val; +} + time_t CryptoManagerImpl::SSLContextImpl::convert_asn1_time_to_time_t( ASN1_TIME* time_to_convert) const { struct tm cert_time; diff --git a/src/components/security_manager/test/ssl_certificate_handshake_test.cc b/src/components/security_manager/test/ssl_certificate_handshake_test.cc index f6521c253a..dc335c8da2 100644 --- a/src/components/security_manager/test/ssl_certificate_handshake_test.cc +++ b/src/components/security_manager/test/ssl_certificate_handshake_test.cc @@ -335,9 +335,6 @@ class SSLHandshakeTest : public testing::Test { std::string client_certificate_; std::string client_ciphers_list_; std::string client_ca_certificate_path_; - - std::vector<int> forced_protected_services_; - std::vector<int> forced_unprotected_services_; }; TEST_F(SSLHandshakeTest, NoVerification) { diff --git a/src/components/utils/include/utils/system_time_handler.h b/src/components/utils/include/utils/system_time_handler.h index 99bbfa39e5..15b2dd0cca 100644 --- a/src/components/utils/include/utils/system_time_handler.h +++ b/src/components/utils/include/utils/system_time_handler.h @@ -82,12 +82,12 @@ class SystemTimeHandler { void SubscribeOnSystemTime(SystemTimeListener* listener); /** - * @brief UnSubscribeFromSystemTime allows to unsubscribe listener + * @brief UnsubscribeFromSystemTime allows to unsubscribe listener * from the certain event. This class does not manipulate with storage. * It rather uses private pure virtual function. So the final behaviour * should be defined within the descendant class */ - void UnSubscribeFromSystemTime(SystemTimeListener* listener); + void UnsubscribeFromSystemTime(SystemTimeListener* listener); /** * @brief GetUTCTime allows to obtain cached result for the diff --git a/src/components/utils/src/system_time_handler.cc b/src/components/utils/src/system_time_handler.cc index ea04d1c0b9..0c3c62cc53 100644 --- a/src/components/utils/src/system_time_handler.cc +++ b/src/components/utils/src/system_time_handler.cc @@ -31,7 +31,6 @@ */ #include "utils/system_time_handler.h" -//#include <algorithm> namespace utils { @@ -47,7 +46,7 @@ void SystemTimeHandler::SubscribeOnSystemTime(SystemTimeListener* listener) { DoSubscribe(listener); } -void SystemTimeHandler::UnSubscribeFromSystemTime( +void SystemTimeHandler::UnsubscribeFromSystemTime( SystemTimeListener* listener) { DoUnsubscribe(listener); } |