summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAKalinich-Luxoft <AKalinich@luxoft.com>2017-12-22 15:30:03 +0200
committerAKalinich-Luxoft <AKalinich@luxoft.com>2018-01-29 09:05:11 +0200
commitdfabf1fa94c897e6ff853a6217f5b6484f6658fd (patch)
treee1c21d57ad585d44fc62b913df5ed87c43202d00
parentb82fb0657f0964053ad5994831cd28deb78bb97d (diff)
downloadsdl_core-dfabf1fa94c897e6ff853a6217f5b6484f6658fd.tar.gz
Added overriden functions for SecurityManager listeners
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h30
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc15
-rw-r--r--src/components/include/connection_handler/connection_handler_observer.h13
-rw-r--r--src/components/include/security_manager/security_manager.h18
-rw-r--r--src/components/include/security_manager/security_manager_listener.h11
5 files changed, 86 insertions, 1 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h
index e91bdf5d59..01503a7794 100644
--- a/src/components/application_manager/include/application_manager/application_manager_impl.h
+++ b/src/components/application_manager/include/application_manager/application_manager_impl.h
@@ -921,15 +921,43 @@ class ApplicationManagerImpl
const connection_handler::CloseSessionReason& close_reason) OVERRIDE;
#ifdef ENABLE_SECURITY
- // Overriden SecurityManagerListener method
+ /**
+ * @brief Notification about protection result
+ * @param connection_key Unique key of session which triggrs handshake
+ * @param result result of connection protection
+ * @return true on success notification handling or false otherwise
+ */
bool OnHandshakeDone(
uint32_t connection_key,
security_manager::SSLContext::HandshakeResult result) OVERRIDE;
+ /**
+ * @brief Notification that certificate update is required.
+ */
void OnCertificateUpdateRequired() OVERRIDE;
+ /**
+ * @brief Get certificate data from policy
+ * @param reference to string where to save certificate data
+ * @return true if listener saved some data to string otherwise false
+ */
+ bool GetPolicyCertificateData(std::string& data) OVERRIDE;
+
+ /**
+ * @brief Get unique handshake context by application id
+ * @param key id of application
+ * @return generated handshake context or empty context if application with
+ * provided id does not exist
+ */
security_manager::SSLContext::HandshakeContext GetHandshakeContext(
uint32_t key) const OVERRIDE;
+
+ /**
+ * @brief Check if application with specified app_id has NAVIGATION HMI type
+ * @param app_id id of application to check
+ * @return true if application is navi otherwise returns false
+ */
+ bool CheckAppIsNavi(const uint32_t app_id) OVERRIDE;
#endif // ENABLE_SECURITY
/**
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index eb3313e492..da11a4ac5b 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -1655,6 +1655,12 @@ void ApplicationManagerImpl::OnCertificateUpdateRequired() {
GetPolicyHandler().OnPTExchangeNeeded();
}
+bool ApplicationManagerImpl::GetPolicyCertificateData(std::string& data) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ data = GetPolicyHandler().RetrieveCertificate();
+ return true;
+}
+
security_manager::SSLContext::HandshakeContext
ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1666,6 +1672,15 @@ ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const {
}
return SSLContext::HandshakeContext();
}
+
+bool ApplicationManagerImpl::CheckAppIsNavi(const uint32_t app_id) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application(app_id);
+ if (app) {
+ return app->is_navi();
+ }
+ return false;
+}
#endif // ENABLE_SECURITY
void ApplicationManagerImpl::set_hmi_message_handler(
diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h
index 7eb17264eb..f2f885d1f4 100644
--- a/src/components/include/connection_handler/connection_handler_observer.h
+++ b/src/components/include/connection_handler/connection_handler_observer.h
@@ -141,8 +141,21 @@ class ConnectionHandlerObserver {
virtual void OnDeviceSwitchingFinish(const std::string& device_uid) = 0;
#ifdef ENABLE_SECURITY
+ /**
+ * @brief Get unique handshake context by application id
+ * @param key id of application
+ * @return generated handshake context or empty context if application with
+ * provided id does not exist
+ */
virtual security_manager::SSLContext::HandshakeContext GetHandshakeContext(
uint32_t key) const = 0;
+
+ /**
+ * @brief Check if application with specified app_id has NAVIGATION HMI type
+ * @param app_id id of application to check
+ * @return true if application is navi otherwise returns false
+ */
+ virtual bool CheckAppIsNavi(const uint32_t app_id) = 0;
#endif // ENABLE_SECURITY
protected:
/**
diff --git a/src/components/include/security_manager/security_manager.h b/src/components/include/security_manager/security_manager.h
index 8ed0ff2912..a95c31432e 100644
--- a/src/components/include/security_manager/security_manager.h
+++ b/src/components/include/security_manager/security_manager.h
@@ -128,6 +128,24 @@ class SecurityManager : public protocol_handler::ProtocolObserver {
virtual void StartHandshake(uint32_t connection_key) = 0;
/**
+ * @brief Check whether certificate should be updated
+ * @return true if certificate should be updated otherwise false
+ */
+ virtual bool IsCertificateUpdateRequired() = 0;
+
+ /**
+ * @brief Notify all listeners that certificate update required
+ * Allows to notify that certificate should be updated
+ */
+ virtual void NotifyOnCertififcateUpdateRequired() = 0;
+
+ /**
+ * @brief Check if policy certificate data is empty
+ * @return true if policy certificate data is empty otherwise false
+ */
+ virtual bool IsPolicyCertificateDataEmpty() = 0;
+
+ /**
* \brief Add/Remove for SecurityManagerListener
*/
virtual void AddListener(SecurityManagerListener* const listener) = 0;
diff --git a/src/components/include/security_manager/security_manager_listener.h b/src/components/include/security_manager/security_manager_listener.h
index 577c7c4378..37b3a09f91 100644
--- a/src/components/include/security_manager/security_manager_listener.h
+++ b/src/components/include/security_manager/security_manager_listener.h
@@ -31,6 +31,9 @@
*/
#ifndef SRC_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_LISTENER_H_
#define SRC_COMPONENTS_INCLUDE_SECURITY_MANAGER_SECURITY_MANAGER_LISTENER_H_
+
+#include <string>
+
namespace security_manager {
class SecurityManagerListener {
@@ -48,6 +51,14 @@ class SecurityManagerListener {
* @brief Notify listeners that certificate update is required.
*/
virtual void OnCertificateUpdateRequired() = 0;
+
+ /**
+ * @brief Get certificate data from policy
+ * @param reference to string where to save certificate data
+ * @return true if listener saved some data to string otherwise false
+ */
+ virtual bool GetPolicyCertificateData(std::string& data) = 0;
+
virtual ~SecurityManagerListener() {}
};
} // namespace security_manager