2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include <dpl/log/log.h>
17 #include <dpl/foreach.h>
19 #include <ace/Subject.h>
21 bool Subject::matchSubject(const AttributeSet *attrSet,
22 bool &isUndetermined) const
25 Attribute::MatchResult match = Attribute::MatchResult::MRUndetermined;
27 FOREACH(it, targetAttributes)
29 AttributeSet::const_iterator attr =
30 std::find_if(attrSet->begin(),
32 AceDB::BaseAttribute::UnaryPredicate(&(*it)));
33 if (attr == attrSet->end()) {
34 LogError("Cannot find attribute value for " << *(it->getName()));
36 "Attribute for subject hasn't been found."
37 "It shoud not happen. This attribute should be undetermined,"
39 result = false; //According to BONDI 1.0 for signle subject all attributes must match
40 isUndetermined = true;
44 match = it->matchAttributes(&(*(*attr)));
46 if (match == Attribute::MatchResult::MRUndetermined) {
48 isUndetermined = true;
49 /// LogError("Subject doesn match and UNDETERMINED");
50 break; //According to BONDI 1.0 for signle subject all attributes must match
51 } else if (match == Attribute::MatchResult::MRFalse) {
53 // LogError("Subject doesn match and DETERMINED");
54 break; //According to BONDI 1.0 for signle subject all attributes must match
61 const std::list<Attribute>& Subject::getTargetAttributes() const
63 return targetAttributes;