Tizen 2.1 base
[framework/security/security-server.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 //#include <dpl/optional.h>
39 #include <dpl/event/inter_context_delegate.h>
40 #include <dpl/event/property.h>
41
42 #include <ace/AbstractPolicyEnforcementPoint.h>
43 #include <ace/PolicyResult.h>
44
45 // Forwards
46 class IWebRuntime;
47 class IResourceInformation;
48 class IOperationSystem;
49 class PolicyEvaluator;
50 class PolicyInformationPoint;
51 class Request;
52
53 class PolicyEnforcementPoint : public AbstractPolicyEnforcementPoint
54 {
55   public:
56     OptionalExtendedPolicyResult checkFromCache(Request &request);
57     ExtendedPolicyResult check(Request &request);
58     OptionalExtendedPolicyResult check(Request &request,
59                                bool fromCacheOnly);
60
61     virtual ~PolicyEnforcementPoint();
62
63     class PEPException
64     {
65       public:
66         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
67         DECLARE_EXCEPTION_TYPE(Base, AlreadyInitialized)
68     };
69
70     /**
71      * This function take ownership of objects pass in call.
72      * Object will be deleted after call Deinitialize function.
73      */
74     void initialize(IWebRuntime *wrt,
75                     IResourceInformation *resource,
76                     IOperationSystem *operation);
77     void terminate();
78
79     void updatePolicy(const std::string &policy);
80     void updatePolicy();
81
82     PolicyEvaluator *getPdp() const { return this->m_pdp; }
83     PolicyInformationPoint *getPip() const { return this->m_pip; }
84
85   protected:
86     PolicyEnforcementPoint();
87     friend class SecurityLogic;
88   private: // private data
89     IWebRuntime                     *m_wrt;
90     IResourceInformation            *m_res;
91     IOperationSystem                *m_sys;
92     PolicyEvaluator                 *m_pdp;
93     PolicyInformationPoint          *m_pip;
94 };
95
96 #endif // POLICY_ENFORCEMENT_POINT_H