tizen 2.3 release
[framework/web/wearable/wrt-security.git] / src / services / ace / logic / security_controller.h
1 /*
2  * Copyright (c) 2011 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  * This class simply redirects the access requests to access control engine.
18  * The aim is to hide access control engine specific details from WRT modules.
19  * It also implements WRT_INTERFACE.h interfaces, so that ACE could access
20  * WRT specific and other information during the decision making.
21  *
22  * @file    security_controller.h
23  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
24  * @author  Ming Jin(ming79.jin@samsung.com)
25  * @version 1.0
26  * @brief   Header file for security controller
27  */
28 #ifndef SECURITY_CONTROLLER_H
29 #define SECURITY_CONTROLLER_H
30
31 #include <dpl/singleton.h>
32 #include <dpl/event/controller.h>
33 #include <dpl/generic_event.h>
34 #include <dpl/type_list.h>
35 #include <string>
36 #include <ace-dao-ro/PreferenceTypes.h>
37 #include <ace/AbstractPolicyEnforcementPoint.h>
38 #include <ace-dao-ro/PromptModel.h>
39 #include <string>
40 #include <dpl/event/inter_context_delegate.h>
41
42 namespace Jobs {
43 class Job;
44 }
45
46 namespace SecurityControllerEvents {
47 DECLARE_GENERIC_EVENT_0(InitializeSyncEvent)
48 DECLARE_GENERIC_EVENT_0(TerminateSyncEvent)
49 DECLARE_GENERIC_EVENT_0(UpdatePolicySyncEvent)
50
51 DECLARE_GENERIC_EVENT_2(CheckFunctionCallSyncEvent,
52                         PolicyResult *,
53                         Request *
54                        )
55
56 DECLARE_GENERIC_EVENT_3(CheckRuntimeCallSyncEvent,
57                         PolicyResult *,
58                         Request *,
59                         std::string //sessionId
60                        )
61
62 DECLARE_GENERIC_EVENT_5(ValidatePopupResponseEvent,
63                         Request *,
64                         bool, //is allowed
65                         Prompt::Validity,
66                         std::string, //sessionId
67                         bool* //check return value
68                        )
69
70 } // namespace SecurityControllerEvents
71
72 typedef DPL::TypeListDecl<
73     SecurityControllerEvents::InitializeSyncEvent,
74     SecurityControllerEvents::TerminateSyncEvent,
75     SecurityControllerEvents::UpdatePolicySyncEvent,
76     SecurityControllerEvents::ValidatePopupResponseEvent,
77     SecurityControllerEvents::CheckRuntimeCallSyncEvent,
78     SecurityControllerEvents::CheckFunctionCallSyncEvent>::Type
79 SecurityControllerEventsTypeList;
80
81 class SecurityController :
82         public DPL::Event::Controller<SecurityControllerEventsTypeList>
83 {
84   protected:
85     virtual void OnEventReceived(
86             const SecurityControllerEvents::InitializeSyncEvent &event);
87     virtual void OnEventReceived(
88             const SecurityControllerEvents::UpdatePolicySyncEvent &event);
89     virtual void OnEventReceived(
90             const SecurityControllerEvents::ValidatePopupResponseEvent &e);
91     virtual void OnEventReceived(
92             const SecurityControllerEvents::TerminateSyncEvent &event);
93     virtual void OnEventReceived(
94             const SecurityControllerEvents::CheckFunctionCallSyncEvent &e);
95     virtual void OnEventReceived(
96             const SecurityControllerEvents::CheckRuntimeCallSyncEvent &e);
97
98   private:
99     class Impl;
100     std::unique_ptr<Impl> m_impl;
101
102     SecurityController();
103     //This desctructor must be in implementation file (cannot be autogenerated)
104     ~SecurityController();
105
106     friend class DPL::Singleton<SecurityController>;
107 };
108
109 typedef DPL::Singleton<SecurityController> SecurityControllerSingleton;
110
111 #endif // SECURITY_CONTROLLER_H