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.
19 // @ Project : Access Control Engine
20 // @ File Name : parser.h
21 // @ Date : 2009-05-06
29 //#include "/usr/include/libxml2/libxml/parser.h"
31 #include <libxml/xmlreader.h>
32 #include <libxml/c14n.h>
33 #include <libxml/xpath.h>
34 #include <libxml/xpathInternals.h>
37 #include "PolicySet.h"
40 #include "Attribute.h"
43 #include "Condition.h"
46 #define whitespaces " \n\t\r"
48 enum CanonicalizationAlgorithm
58 xmlTextReaderPtr reader;
61 TreeNode * currentRoot;
62 Subject * currentSubject;
63 Condition * currentCondition;
64 Attribute * currentAttribute;
65 std::string * currentText;
67 bool processingSignature;
68 bool canonicalizeOnce;
70 void processNode(xmlTextReaderPtr reader);
73 void endNodeHandler(xmlTextReaderPtr reader);
74 void textNodeHandler(xmlTextReaderPtr reader);
75 void startNodeHandler(xmlTextReaderPtr reader);
78 void handleAttr(xmlTextReaderPtr reader);
79 void handleRule(xmlTextReaderPtr reader);
81 void handleCondition(xmlTextReaderPtr reader);
82 void handleSubjectMatch(xmlTextReaderPtr reader);
83 void handleMatch(xmlTextReaderPtr reader,
85 void handlePolicy(xmlTextReaderPtr reader,
86 TreeNode::TypeID type);
89 Policy::CombineAlgorithm convertToCombineAlgorithm(xmlChar*);
90 ExtendedEffect convertToEffect(xmlChar *effect);
91 Attribute::Match convertToMatchFunction(xmlChar * func);
92 void consumeCurrentText();
93 void consumeCurrentAttribute();
94 void consumeSubjectMatch(xmlChar * value = NULL);
95 void consumeCurrentSubject();
96 void consumeCurrentCondition();
97 void trim(std::string *);
98 // KW void canonicalize(const char *, const char *, CanonicalizationAlgorithm canonicalizationAlgorithm);
99 // KW int extractNodeToFile(xmlTextReaderPtr reader, const char * filename);
101 static const char *TOKEN_PARAM;
105 TreeNode * parse(const std::string& filename, const std::string& schema);