Add ClientSession type 76/26576/6
authorZofia Abramowska <z.abramowska@samsung.com>
Tue, 26 Aug 2014 11:17:40 +0000 (13:17 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Thu, 28 Aug 2014 15:30:54 +0000 (17:30 +0200)
Change-Id: Ia62dac02a652c2f252708ed05320eb66ea5506b1

src/client/api/ApiInterface.h
src/client/cache/CacheInterface.h
src/client/cache/CapacityCache.cpp
src/client/cache/CapacityCache.h
src/client/logic/Logic.cpp
src/client/logic/Logic.h
src/common/types/ClientSession.h [new file with mode: 0644]

index 73bcec5..656cc1d 100644 (file)
@@ -24,7 +24,9 @@
 #define SRC_CLIENT_API_APIINTERFACE_H_
 
 #include <string>
+
 #include <cynara-client.h>
+#include <types/ClientSession.h>
 
 namespace Cynara {
 
@@ -33,7 +35,7 @@ public:
     ApiInterface() = default;
     virtual ~ApiInterface() {};
 
-    virtual int check(const std::string &client, const std::string &session,
+    virtual int check(const std::string &client, const ClientSession &session,
                       const std::string &user, const std::string &privilege) = 0;
 };
 
index ec76a2e..ee2b27d 100644 (file)
@@ -29,6 +29,7 @@
 #include <string>
 
 #include <cynara-client.h>
+#include <types/ClientSession.h>
 #include <types/PolicyKey.h>
 #include <types/PolicyResult.h>
 #include <types/PolicyType.h>
@@ -62,8 +63,8 @@ public:
 class PluginCache {
 public:
     PluginCache() {}
-    virtual int get(const std::string &session, const PolicyKey &key) = 0;
-    virtual int update(const std::string &session,
+    virtual int get(const ClientSession &session, const PolicyKey &key) = 0;
+    virtual int update(const ClientSession &session,
                        const PolicyKey &key,
                        const PolicyResult &result) = 0;
 
index 412d231..1d2c658 100644 (file)
@@ -29,7 +29,7 @@
 
 namespace Cynara {
 
-int CapacityCache::get(const std::string &session, const PolicyKey &key) {
+int CapacityCache::get(const ClientSession &session, const PolicyKey &key) {
     //This can be very time heavy. This part is welcomed to be optimized.
     if (session != m_session) {
         LOGD("Session changed from %s to %s.", m_session.c_str(), session.c_str());
@@ -100,7 +100,7 @@ void CapacityCache::evict(void) {
     m_keyValue.erase(value_it);
 }
 
-int CapacityCache::update(const std::string &session,
+int CapacityCache::update(const ClientSession &session,
                           const PolicyKey &key,
                           const PolicyResult &result) {
     //This can be very time heavy. This part is welcomed to be optimized.
index 921a16b..6fe9c83 100644 (file)
@@ -37,8 +37,8 @@ public:
     CapacityCache(std::size_t capacity = CACHE_DEFAULT_CAPACITY) :
         m_capacity(capacity) {}
 
-    int get(const std::string &session, const PolicyKey &key);
-    int update(const std::string& session,
+    int get(const ClientSession &session, const PolicyKey &key);
+    int update(const ClientSession& session,
                const PolicyKey &key,
                const PolicyResult &result);
     void clear(void);
@@ -54,7 +54,7 @@ private:
 
 
     std::size_t m_capacity;
-    std::string m_session;
+    ClientSession m_session;
 
     KeyUsageList m_keyUsage;
     KeyValueMap m_keyValue;
index 0c8ffc9..a609314 100644 (file)
@@ -47,7 +47,7 @@ Logic::Logic() {
     m_cache->registerPlugin(PredefinedPolicyType::BUCKET, naiveInterpreter);
 }
 
-int Logic::check(const std::string &client, const std::string &session, const std::string &user,
+int Logic::check(const std::string &client, const ClientSession &session, const std::string &user,
                  const std::string &privilege) noexcept
 {
     if (!m_socket->isConnected()){
index 3d2ee95..daab6f4 100644 (file)
@@ -44,7 +44,7 @@ public:
     Logic();
     virtual ~Logic() {};
 
-    virtual int check(const std::string &client, const std::string &session,
+    virtual int check(const std::string &client, const ClientSession &session,
                       const std::string &user, const std::string &privilege) noexcept;
 };
 
diff --git a/src/common/types/ClientSession.h b/src/common/types/ClientSession.h
new file mode 100644 (file)
index 0000000..a848137
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+/*
+ * @file        ClientSession.h
+ * @author      Zofia Abramowska <z.abramowska@samsung.com>
+ * @version     1.0
+ * @brief       Description of user defined session type
+ */
+
+#ifndef SRC_COMMON_TYPES_CLIENTSESSION_H_
+#define SRC_COMMON_TYPES_CLIENTSESSION_H_
+
+#include <string>
+
+namespace Cynara {
+
+typedef std::string ClientSession;
+
+} // namespace Cynara
+
+#endif /* SRC_COMMON_TYPES_CLIENTSESSION_H_ */