tizen 2.3 release
[framework/web/wearable/wrt-security.git] / ace / include / ace / PolicyEnforcementPoint.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_logic.h
23  * @author  Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
24  * @author  Ming Jin(ming79.jin@samsung.com)
25  * @brief   Implementation file for security logic
26  */
27 #ifndef POLICY_ENFORCEMENT_POINT_H
28 #define POLICY_ENFORCEMENT_POINT_H
29
30 #include <memory>
31 #include <string>
32 #include <map>
33
34 //#include <glib/gthread.h>
35 //#include <glib/gerror.h>
36 //#include <glib.h>
37
38 #ifdef DBUS_CONNECTION
39 #include <dpl/event/inter_context_delegate.h>
40 #include <dpl/event/property.h>
41 #endif
42
43 #include <ace/AbstractPolicyEnforcementPoint.h>
44 #include <ace/PolicyResult.h>
45
46 // Forwards
47 class IWebRuntime;
48 class IResourceInformation;
49 class IOperationSystem;
50 class PolicyEvaluator;
51 class PolicyInformationPoint;
52 class Request;
53
54 class PolicyEnforcementPoint : public AbstractPolicyEnforcementPoint
55 {
56   public:
57     OptionalExtendedPolicyResult checkFromCache(Request &request);
58     ExtendedPolicyResult check(Request &request);
59     OptionalExtendedPolicyResult check(Request &request,
60                                bool fromCacheOnly);
61
62     virtual ~PolicyEnforcementPoint();
63
64     class PEPException
65     {
66       public:
67         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
68         DECLARE_EXCEPTION_TYPE(Base, AlreadyInitialized)
69     };
70
71     /**
72      * This function take ownership of objects pass in call.
73      * Object will be deleted after call Deinitialize function.
74      */
75     void initialize(IWebRuntime *wrt,
76                     IResourceInformation *resource,
77                     IOperationSystem *operation);
78     void terminate();
79
80     void updatePolicy(const std::string &policy);
81     void updatePolicy();
82
83     PolicyEvaluator *getPdp() const { return this->m_pdp; }
84     PolicyInformationPoint *getPip() const { return this->m_pip; }
85
86   protected:
87     PolicyEnforcementPoint();
88     friend class SecurityLogic;
89   private: // private data
90     IWebRuntime                     *m_wrt;
91     IResourceInformation            *m_res;
92     IOperationSystem                *m_sys;
93     PolicyEvaluator                 *m_pdp;
94     PolicyInformationPoint          *m_pip;
95 };
96
97 #endif // POLICY_ENFORCEMENT_POINT_H