tizen beta release
[framework/web/wrt-commons.git] / modules / ace / include / dpl / 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 <dpl/ace/AbstractTreeElement.h>
32 #include <dpl/ace/Effect.h>
33 #include <dpl/ace/Attribute.h>
34 #include <dpl/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(std::istream& is);
46
47     void serialize(std::ostream& os);
48
49     Policy()
50     {
51         combineAlgorithm = DenyOverride;
52         subjects = new std::list<const Subject *>();
53     }
54
55     CombineAlgorithm getCombineAlgorithm() const
56     {
57         return this->combineAlgorithm;
58     }
59
60     void setCombineAlgorithm(CombineAlgorithm algorithm)
61     {
62         this->combineAlgorithm = algorithm;
63     }
64
65     const std::list<const Subject *> * getSubjects() const
66     {
67         return this->subjects;
68     }
69
70     void addSubject(const Subject * subject)
71     {
72         if (this->subjects == NULL) {
73             return;
74         }
75         this->subjects->push_back(subject);
76     }
77
78     virtual ~Policy();
79
80     void printData();
81
82     std::string printCombineAlgorithm(CombineAlgorithm algorithm);
83
84   private:
85     std::list<const Subject *> *subjects;
86     CombineAlgorithm combineAlgorithm;
87 };
88
89 const char * toString(Policy::CombineAlgorithm algorithm);
90
91 #endif  //_POLICY_H