Fix for several issues detected by Prevent
[platform/core/security/security-manager.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/scoped_ptr.h>
35 #include <dpl/type_list.h>
36 #include <string>
37 #include <ace-dao-ro/PreferenceTypes.h>
38 #include <ace/AbstractPolicyEnforcementPoint.h>
39 #include <ace-dao-ro/PromptModel.h>
40 #include <string>
41 #include <dpl/event/inter_context_delegate.h>
42
43 namespace Jobs {
44 class Job;
45 }
46
47 namespace SecurityControllerEvents {
48 DECLARE_GENERIC_EVENT_0(InitializeSyncEvent)
49 DECLARE_GENERIC_EVENT_0(TerminateSyncEvent)
50 DECLARE_GENERIC_EVENT_0(UpdatePolicySyncEvent)
51
52 DECLARE_GENERIC_EVENT_2(CheckFunctionCallSyncEvent,
53                         PolicyResult *,
54                         Request *
55                        )
56
57 DECLARE_GENERIC_EVENT_3(CheckRuntimeCallSyncEvent,
58                         PolicyResult *,
59                         Request *,
60                         std::string //sessionId
61                        )
62
63 DECLARE_GENERIC_EVENT_5(ValidatePopupResponseEvent,
64                         Request *,
65                         bool, //is allowed
66                         Prompt::Validity,
67                         std::string, //sessionId
68                         bool* //check return value
69                        )
70
71 } // namespace SecurityControllerEvents
72
73 typedef DPL::TypeListDecl<
74     SecurityControllerEvents::InitializeSyncEvent,
75     SecurityControllerEvents::TerminateSyncEvent,
76     SecurityControllerEvents::UpdatePolicySyncEvent,
77     SecurityControllerEvents::ValidatePopupResponseEvent,
78     SecurityControllerEvents::CheckRuntimeCallSyncEvent,
79     SecurityControllerEvents::CheckFunctionCallSyncEvent>::Type
80 SecurityControllerEventsTypeList;
81
82 class SecurityController :
83         public DPL::Event::Controller<SecurityControllerEventsTypeList>
84 {
85   protected:
86     virtual void OnEventReceived(
87             const SecurityControllerEvents::InitializeSyncEvent &event);
88     virtual void OnEventReceived(
89             const SecurityControllerEvents::UpdatePolicySyncEvent &event);
90     virtual void OnEventReceived(
91             const SecurityControllerEvents::ValidatePopupResponseEvent &e);
92     virtual void OnEventReceived(
93             const SecurityControllerEvents::TerminateSyncEvent &event);
94     virtual void OnEventReceived(
95             const SecurityControllerEvents::CheckFunctionCallSyncEvent &e);
96     virtual void OnEventReceived(
97             const SecurityControllerEvents::CheckRuntimeCallSyncEvent &e);
98
99   private:
100     class Impl;
101     DPL::ScopedPtr<Impl> m_impl;
102
103     SecurityController();
104     //This desctructor must be in implementation file (cannot be autogenerated)
105     ~SecurityController();
106
107     friend class DPL::Singleton<SecurityController>;
108 };
109
110 typedef DPL::Singleton<SecurityController> SecurityControllerSingleton;
111
112 #endif // SECURITY_CONTROLLER_H