02cd8c6dedb3b540ef167bc5769e30906a1cd264
[framework/web/wrt-commons.git] / modules / ace / include / dpl / ace / CombinerImpl.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 : CombinerImpl.h
21 //  @ Date : 2009-05-06
22 //  @ Author : Samsung
23 //
24 //
25
26 #ifndef _COMBINER_IMPL_H
27 #define _COMBINER_IMPL_H
28
29 #include <list>
30 #include <dpl/log/log.h>
31
32 #include "Combiner.h"
33 #include "Effect.h"
34 #include "Policy.h"
35 #include "Subject.h"
36
37 class CombinerImpl : public Combiner
38 {
39   public:
40
41     virtual Effect combineRules(const TreeNode * rule);
42     virtual Effect combinePolicies(const TreeNode * policy);
43
44     virtual ~CombinerImpl()
45     {
46     }
47
48   protected:
49
50     bool checkIfTargetMatches(const std::list<const Subject *> * subjectsSet,
51             bool &isUndetermined);
52
53     Effect combine(Policy::CombineAlgorithm algorithm,
54             std::list<Effect> & effects);
55
56     Effect denyOverrides(const std::list<Effect> & effects);
57     Effect permitOverrides(const std::list<Effect> & effects);
58     Effect firstApplicable(const std::list<Effect> & effects);
59     Effect firstMatchingTarget(const std::list<Effect> & effects);
60
61     std::list<int> * convertEffectsToInts(const std::list<Effect> * effects);
62     Effect convertIntToEffect(int intEffect);
63
64     void showEffectList(std::list<Effect> & effects)
65     {
66         std::list<Effect>::iterator it = effects.begin();
67         for (; it != effects.end(); ++it) {
68             LogDebug(toString(*it));
69         }
70     }
71
72   private:
73     bool isError(const std::list<Effect> & effects);
74     static const int
75         DenyInt,
76         UndeterminedInt,
77         PromptOneShotInt,
78         PromptSessionInt,
79         PromptBlanketInt,
80         PermitInt,
81         InapplicableInt,
82         NotMatchingTargetInt,
83         ErrorInt;
84 };
85
86 #endif  //_COMBINERIMPL_H