From: Zofia Abramowska Date: Fri, 17 Oct 2014 16:28:34 +0000 (+0200) Subject: Add PluginManager to CapacityCache X-Git-Tag: submit/R4/20141115.054144~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F78%2F28978%2F7;p=platform%2Fcore%2Fsecurity%2Fcynara.git Add PluginManager to CapacityCache Change-Id: Icdaf1df3793db0a43ae4aadcf2d8d306b04f650f --- diff --git a/src/client-common/cache/CapacityCache.cpp b/src/client-common/cache/CapacityCache.cpp index 7eb7e34..3174744 100644 --- a/src/client-common/cache/CapacityCache.cpp +++ b/src/client-common/cache/CapacityCache.cpp @@ -47,15 +47,22 @@ int CapacityCache::get(const ClientSession &session, const PolicyKey &key) { auto &cachedValue = resultIt->second; auto &policyResult = std::get<0>(cachedValue); + ClientPluginInterfacePtr plugin; auto pluginIt = m_plugins.find(policyResult.policyType()); - if (pluginIt == m_plugins.end()) { - LOGE("No plugin registered for given PolicyType : %" PRIu16, - policyResult.policyType()); - return CYNARA_API_ACCESS_DENIED; + if (pluginIt != m_plugins.end()) { + plugin = pluginIt->second; + } else { + plugin = std::dynamic_pointer_cast( + m_pluginManager.getPlugin(policyResult.policyType())); + if (!plugin) { + LOGE("No plugin registered for given PolicyType : %" PRIu16, + policyResult.policyType()); + return CYNARA_API_ACCESS_DENIED; + } } //Is it still usable? - ClientPluginInterfacePtr plugin = pluginIt->second; + auto &prevSession = std::get<1>(cachedValue); auto usageIt = std::get<2>(cachedValue); bool updateSession = false; diff --git a/src/client-common/cache/CapacityCache.h b/src/client-common/cache/CapacityCache.h index 4218078..24e1092 100644 --- a/src/client-common/cache/CapacityCache.h +++ b/src/client-common/cache/CapacityCache.h @@ -29,6 +29,9 @@ #include +#include +#include + namespace Cynara { class CapacityCache : public PluginCache { @@ -36,7 +39,7 @@ public: static const std::size_t CACHE_DEFAULT_CAPACITY = 10000; CapacityCache(std::size_t capacity = CACHE_DEFAULT_CAPACITY) : - m_capacity(capacity) {} + m_capacity(capacity), m_pluginManager(PathConfig::PluginPath::clientDir) {} int get(const ClientSession &session, const PolicyKey &key); int update(const ClientSession& session, @@ -57,6 +60,7 @@ private: KeyUsageList m_keyUsage; KeyValueMap m_keyValue; + PluginManager m_pluginManager; }; } //namespace Cynara diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 9dc48de..98f5133 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -29,6 +29,7 @@ SET(COMMON_SOURCES ${COMMON_PATH}/config/PathConfig.cpp ${COMMON_PATH}/containers/BinaryQueue.cpp ${COMMON_PATH}/log/log.cpp + ${COMMON_PATH}/plugin/PluginManager.cpp ${COMMON_PATH}/protocol/ProtocolAdmin.cpp ${COMMON_PATH}/protocol/ProtocolClient.cpp ${COMMON_PATH}/protocol/ProtocolFrame.cpp diff --git a/src/service/plugin/PluginManager.cpp b/src/common/plugin/PluginManager.cpp similarity index 100% rename from src/service/plugin/PluginManager.cpp rename to src/common/plugin/PluginManager.cpp diff --git a/src/service/plugin/PluginManager.h b/src/common/plugin/PluginManager.h similarity index 100% rename from src/service/plugin/PluginManager.h rename to src/common/plugin/PluginManager.h diff --git a/src/service/CMakeLists.txt b/src/service/CMakeLists.txt index f8d2eb8..c317d8e 100644 --- a/src/service/CMakeLists.txt +++ b/src/service/CMakeLists.txt @@ -22,7 +22,6 @@ SET(CYNARA_SOURCES ${CYNARA_SERVICE_PATH}/logic/Logic.cpp ${CYNARA_SERVICE_PATH}/main/Cynara.cpp ${CYNARA_SERVICE_PATH}/main/main.cpp - ${CYNARA_SERVICE_PATH}/plugin/PluginManager.cpp ${CYNARA_SERVICE_PATH}/sockets/Descriptor.cpp ${CYNARA_SERVICE_PATH}/sockets/SocketManager.cpp )