35226d71a455f674d1a537eede10ea66b24ec068
[platform/core/security/cynara.git] / src / service / logic / Logic.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /**
17  * @file        src/service/logic/Logic.h
18  * @author      Lukasz Wojciechowski <l.wojciechow@partner.samsung.com>
19  * @version     1.0
20  * @brief       This file defines main class of logic layer in cynara service
21  */
22
23 #ifndef SRC_SERVICE_LOGIC_LOGIC_H_
24 #define SRC_SERVICE_LOGIC_LOGIC_H_
25
26 #include <types/PolicyKey.h>
27 #include <types/PolicyResult.h>
28
29 #include <main/pointers.h>
30 #include <plugin/PluginManager.h>
31 #include <request/CheckRequestManager.h>
32 #include <request/pointers.h>
33 #include <request/RequestTaker.h>
34
35 namespace Cynara {
36
37 class Logic : public RequestTaker {
38 public:
39     Logic();
40     virtual ~Logic();
41
42     void bindAgentManager(const AgentManagerPtr &agentManager) {
43         m_agentManager = agentManager;
44     }
45
46     void bindPluginManager(PluginManagerPtr pluginManager) {
47         m_pluginManager = pluginManager;
48     }
49
50     void bindStorage(StoragePtr storage) {
51         m_storage = storage;
52     }
53
54     void bindSocketManager(SocketManagerPtr socketManager) {
55         m_socketManager = socketManager;
56     }
57
58     void unbindAll(void) {
59         m_agentManager.reset();
60         m_pluginManager.reset();
61         m_storage.reset();
62         m_socketManager.reset();
63     }
64
65     virtual void execute(RequestContextPtr context, AdminCheckRequestPtr request);
66     virtual void execute(RequestContextPtr context, AgentRegisterRequestPtr request);
67     virtual void execute(RequestContextPtr context, CancelRequestPtr request);
68     virtual void execute(RequestContextPtr context, CheckRequestPtr request);
69     virtual void execute(RequestContextPtr context, InsertOrUpdateBucketRequestPtr request);
70     virtual void execute(RequestContextPtr context, RemoveBucketRequestPtr request);
71     virtual void execute(RequestContextPtr context, SetPoliciesRequestPtr request);
72     virtual void execute(RequestContextPtr context, SignalRequestPtr request);
73
74     virtual void contextClosed(RequestContextPtr context);
75
76 private:
77     AgentManagerPtr m_agentManager;
78     CheckRequestManager m_checkRequestManager;
79     PluginManagerPtr m_pluginManager;
80     StoragePtr m_storage;
81     SocketManagerPtr m_socketManager;
82
83     bool check(RequestContextPtr context, const PolicyKey &key, PolicyResult& result);
84
85     void onPoliciesChanged(void);
86 };
87
88 } // namespace Cynara
89
90 #endif /* SRC_SERVICE_LOGIC_LOGIC_H_ */