tizen beta release
[framework/web/wrt-installer.git] / src / security / security_controller.cpp
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.cpp
23  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
24  * @author  Ming Jin(ming79.jin@samsung.com)
25  * @version 1.0
26  * @brief   Implementation file for security controller
27  */
28 #include <security_controller.h>
29
30 #include <dpl/ace/PolicyEnforcementPoint.h>
31 #include <dpl/ace/WRT_INTERFACE.h>
32 #include <dpl/ace/PolicyEvaluatorFactory.h>
33 #include <dpl/singleton_impl.h>
34 #include <dpl/log/log.h>
35
36 #include <attribute_facade.h>
37 #include <security_logic.h>
38
39 IMPLEMENT_SINGLETON(SecurityController)
40
41 struct SecurityController::Impl
42 {
43     SecurityLogic logic;
44 };
45
46 SecurityController::SecurityController()
47 {
48     m_impl.Reset(new Impl);
49 }
50
51 SecurityController::~SecurityController()
52 {
53 }
54
55 void SecurityController::OnEventReceived(
56     const SecurityControllerEvents::InitializeSyncEvent & /* event */)
57 {
58     m_impl->logic.initialize();
59 }
60
61 void SecurityController::OnEventReceived(
62     const SecurityControllerEvents::TerminateSyncEvent & /*event*/)
63 {
64     m_impl->logic.terminate();
65 }
66
67 void SecurityController::OnEventReceived(
68     const SecurityControllerEvents::AuthorizeWidgetInstallEvent &event)
69 {
70     m_impl->logic.authorizeWidgetInstall(event.GetArg0(), event.GetArg1());
71 }
72
73 void SecurityController::OnEventReceived(
74     const SecurityControllerEvents::CheckFunctionCallSyncEvent &ev)
75 {
76     *ev.GetArg0() = m_impl->logic.checkFunctionCall(ev.GetArg1());
77 }
78
79 void SecurityController::OnEventReceived(
80         const SecurityControllerEvents::SetWidgetPreferenceEvent & /*event*/)
81 {
82 //    m_impl->logic.setWidgetPreference(event.GetArg0(),
83 //                                      event.GetArg1(),
84 //                                      event.GetArg2());
85 }
86
87 void SecurityController::OnEventReceived(
88         const SecurityControllerEvents::SetResourcePreferenceEvent & /*event*/)
89 {
90 //    m_impl->logic.setResourcePreference(event.GetArg0(), event.GetArg1());
91 }
92
93 void SecurityController::OnEventReceived(
94         const SecurityControllerEvents::GetWidgetsPreferencesSyncEvent & /*event*/)
95 {
96 //    *event.GetArg0() = m_impl->logic.getWidgetsPreferences();
97 }
98
99 void SecurityController::OnEventReceived(
100         const SecurityControllerEvents::GetResourcesPreferencesSyncEvent & /*event*/)
101 {
102 //    *event.GetArg0() = m_impl->logic.getResourcesPreferences();
103 }
104
105 void SecurityController::OnEventReceived(
106         const SecurityControllerEvents::ResetWidgetsPreferencesEvent & /*evt*/)
107 {
108 //    m_impl->logic.resetWidgetsPreferences();
109 }
110
111 void SecurityController::OnEventReceived(
112         const SecurityControllerEvents::ResetResourcesPreferencesEvent & /*evt*/)
113 {
114 //    m_impl->logic.resetResourcesPreferences();
115 }