#define SRC_CLIENT_API_APIINTERFACE_H_
#include <string>
+
#include <cynara-client.h>
+#include <types/ClientSession.h>
namespace Cynara {
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;
};
#include <string>
#include <cynara-client.h>
+#include <types/ClientSession.h>
#include <types/PolicyKey.h>
#include <types/PolicyResult.h>
#include <types/PolicyType.h>
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;
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());
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.
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);
std::size_t m_capacity;
- std::string m_session;
+ ClientSession m_session;
KeyUsageList m_keyUsage;
KeyValueMap m_keyValue;
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()){
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;
};
--- /dev/null
+/*
+ * 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_ */