tizen 2.3.1 release
[framework/web/wearable/wrt-security.git] / ace / include / ace / Policy.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 : Policy.h
21 //  @ Date : 2009-05-06
22 //  @ Author : Samsung
23 //
24 //
25
26 #if !defined(_POLICY_H)
27 #define _POLICY_H
28
29 #include <list>
30
31 #include <ace/AbstractTreeElement.h>
32 #include <ace/Effect.h>
33 #include <ace/Attribute.h>
34 #include <ace/Subject.h>
35 #include <iostream>
36 #include <dpl/noncopyable.h>
37
38 class Policy : public AbstractTreeElement,
39     DPL::Noncopyable
40 {
41   public:
42     enum CombineAlgorithm { DenyOverride, PermitOverride, FirstApplicable,
43                             FirstTargetMatching };
44
45     Policy()
46     {
47         combineAlgorithm = DenyOverride;
48         subjects = new std::list<const Subject *>();
49     }
50
51     CombineAlgorithm getCombineAlgorithm() const
52     {
53         return this->combineAlgorithm;
54     }
55
56     void setCombineAlgorithm(CombineAlgorithm algorithm)
57     {
58         this->combineAlgorithm = algorithm;
59     }
60
61     const std::list<const Subject *> * getSubjects() const
62     {
63         return this->subjects;
64     }
65
66     void addSubject(const Subject * subject)
67     {
68         if (this->subjects == NULL) {
69             return;
70         }
71         this->subjects->push_back(subject);
72     }
73
74     virtual ~Policy();
75
76     void printData();
77
78     std::string printCombineAlgorithm(CombineAlgorithm algorithm);
79
80   private:
81     std::list<const Subject *> *subjects;
82     CombineAlgorithm combineAlgorithm;
83 };
84
85 const char * toString(Policy::CombineAlgorithm algorithm);
86
87 #endif  //_POLICY_H