2b3de291ecc01f92b35d0146f637f9ae33c0efa8
[framework/web/wrt-commons.git] / modules / ace / include / dpl / ace / PolicyInformationPoint.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 //
18 //
19 //  @ Project : Access Control Engine
20 //  @ File Name : PolicyInformationPoint.h
21 //  @ Date : 2009-05-06
22 //  @ Author : Samsung
23 //
24 //
25
26 #ifndef _POLICY_INFORMATION_POINT_H
27 #define _POLICY_INFORMATION_POINT_H
28
29 #include <set>
30
31 #include <dpl/ace/Attribute.h>
32 #include <dpl/ace/Request.h>
33
34 #include <dpl/ace-dao-ro/BaseAttribute.h>
35
36 #include <dpl/ace/WRT_INTERFACE.h>
37
38 typedef int PipResponse;
39
40 class PolicyInformationPoint
41 {
42   private:
43
44     /** queries for interfaces*/
45     std::list<ATTRIBUTE> resourceAttributesQuery;
46     std::list<ATTRIBUTE> environmentAttributesQuery;
47     std::list<ATTRIBUTE> subjectAttributesQuery;
48     std::list<ATTRIBUTE> functionParamAttributesQuery;
49
50     /** create queries */
51     void createQueries(AttributeSet* attributes);
52
53     IWebRuntime* wrtInterface;
54     IResourceInformation* resourceInformation;
55     IOperationSystem* operationSystem;
56
57   public:
58     static const int ERROR_SHIFT_RESOURCE = 3;
59     static const int ERROR_SHIFT_OS = 6;
60     static const int ERROR_SHIFT_FP = 9;
61
62     /** Mask used to identify PIP error */
63     enum ResponseTypeMask
64     {
65         SUCCESS               = 0,
66         /* WebRuntime Error */
67         WRT_UNKNOWN_SUBJECT   = 1 << 0,
68         WRT_UNKNOWN_ATTRIBUTE = 1 << 1,
69         WRT_INTERNAL_ERROR    = 1 << 2,
70         /* Resource Information Storage Error */
71         RIS_UNKNOWN_RESOURCE  = 1 << 3,
72         RIS_UNKNOWN_ATTRIBUTE = 1 << 4,
73         RIS_INTERNAL_ERROR    = 1 << 5,
74         /*Operating system */
75         OS_UNKNOWN_ATTRIBUTE  = 1 << 6,
76         OS_INTERNAL_ERROR     = 1 << 7
77     };
78
79     //TODO add checking values of attributes
80     /** gather attributes values from adequate interfaces */
81     virtual PipResponse getAttributesValues(const Request* request,
82             AttributeSet* attributes);
83     virtual ~PolicyInformationPoint();
84     PolicyInformationPoint(IWebRuntime *wrt,
85             IResourceInformation *resource,
86             IOperationSystem *system) : wrtInterface(wrt),
87         resourceInformation(resource),
88         operationSystem(system)
89     {
90     }
91     virtual void update(IWebRuntime *wrt,
92             IResourceInformation *resource,
93             IOperationSystem *system)
94     {
95         wrtInterface = wrt;
96         resourceInformation = resource;
97         operationSystem = system;
98     }
99     IWebRuntime * getWebRuntime()
100     {
101         return wrtInterface;
102     }
103 };
104
105 #endif  //_POLICY_INFORMATION_POINT_H