tizen beta release
[framework/web/wrt-installer.git] / src / security / 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/scoped_ptr.h>
35 #include <dpl/type_list.h>
36 #include <string>
37 #include <ace_settings_logic.h>
38 #include <dpl/ace-dao-ro/PreferenceTypes.h>
39 #include <dpl/ace/AbstractPolicyEnforcementPoint.h>
40
41 #include <string>
42 #include <dpl/event/inter_context_delegate.h>
43
44 #include <dpl/ace-dao-ro/wrt_db_types.h>
45
46 namespace Jobs {
47 class Job;
48 }
49
50 namespace SecurityControllerEvents {
51 DECLARE_GENERIC_EVENT_0(InitializeSyncEvent)
52 DECLARE_GENERIC_EVENT_0(TerminateSyncEvent)
53
54 DECLARE_GENERIC_EVENT_2(AuthorizeWidgetInstallEvent,
55                         Request *,
56                         AbstractPolicyEnforcementPoint::ResponseReceiver)
57
58 DECLARE_GENERIC_EVENT_2(CheckFunctionCallSyncEvent,
59                         PolicyResult *,
60                         Request *)
61
62 DECLARE_GENERIC_EVENT_3(SetWidgetPreferenceEvent,
63                         std::string, // resource,
64                         WidgetHandle, // subject
65                         AceDB::PreferenceTypes) // preference
66
67 DECLARE_GENERIC_EVENT_2(SetResourcePreferenceEvent,
68                         std::string, // resource,
69                         AceDB::PreferenceTypes) // preference
70
71 DECLARE_GENERIC_EVENT_1(GetWidgetsPreferencesSyncEvent,
72                         AceSettings::WidgetsPreferences *)
73
74 DECLARE_GENERIC_EVENT_1(GetResourcesPreferencesSyncEvent,
75                         AceSettings::ResourcesPreferences *)
76
77 DECLARE_GENERIC_EVENT_0(ResetWidgetsPreferencesEvent)
78 DECLARE_GENERIC_EVENT_0(ResetResourcesPreferencesEvent)
79 } // namespace SecurityControllerEvents
80
81 typedef DPL::TypeListDecl<
82     SecurityControllerEvents::InitializeSyncEvent,
83     SecurityControllerEvents::TerminateSyncEvent,
84     SecurityControllerEvents::AuthorizeWidgetInstallEvent,
85     SecurityControllerEvents::CheckFunctionCallSyncEvent,
86     SecurityControllerEvents::SetWidgetPreferenceEvent,
87     SecurityControllerEvents::SetResourcePreferenceEvent,
88     SecurityControllerEvents::GetWidgetsPreferencesSyncEvent,
89     SecurityControllerEvents::GetResourcesPreferencesSyncEvent,
90     SecurityControllerEvents::ResetWidgetsPreferencesEvent,
91     SecurityControllerEvents::ResetResourcesPreferencesEvent>::Type
92 SecurityControllerEventsTypeList;
93
94 class SecurityController :
95         public DPL::Event::Controller<SecurityControllerEventsTypeList>
96 {
97   protected:
98     virtual void OnEventReceived(
99             const SecurityControllerEvents::InitializeSyncEvent &event);
100     virtual void OnEventReceived(
101             const SecurityControllerEvents::TerminateSyncEvent &event);
102     virtual void OnEventReceived(
103             const SecurityControllerEvents::AuthorizeWidgetInstallEvent &event);
104     virtual void OnEventReceived(
105             const SecurityControllerEvents::CheckFunctionCallSyncEvent &e);
106     virtual void OnEventReceived(
107             const SecurityControllerEvents::SetWidgetPreferenceEvent &event);
108     virtual void OnEventReceived(
109             const SecurityControllerEvents::SetResourcePreferenceEvent &event);
110     virtual void OnEventReceived(
111             const SecurityControllerEvents::GetWidgetsPreferencesSyncEvent &
112             event);
113     virtual void OnEventReceived(
114             const SecurityControllerEvents::GetResourcesPreferencesSyncEvent &
115             evt);
116     virtual void OnEventReceived(
117             const SecurityControllerEvents::ResetWidgetsPreferencesEvent &evt);
118     virtual void OnEventReceived(
119             const SecurityControllerEvents::ResetResourcesPreferencesEvent &
120             evt);
121
122   private:
123     class Impl;
124     DPL::ScopedPtr<Impl> m_impl;
125
126     SecurityController();
127     //This desctructor must be in implementation file (cannot be autogenerated)
128     ~SecurityController();
129
130     friend class DPL::Singleton<SecurityController>;
131 };
132
133 typedef DPL::Singleton<SecurityController> SecurityControllerSingleton;
134
135 #endif // SECURITY_CONTROLLER_H