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"
45 #define whitespaces " \n\t\r"
47 enum CanonicalizationAlgorithm
57 xmlTextReaderPtr reader;
60 TreeNode * currentRoot;
61 Subject * currentSubject;
62 Condition * currentCondition;
63 Attribute * currentAttribute;
64 std::string * currentText;
66 bool processingSignature;
67 bool canonicalizeOnce;
69 void processNode(xmlTextReaderPtr reader);
72 void endNodeHandler(xmlTextReaderPtr reader);
73 void textNodeHandler(xmlTextReaderPtr reader);
74 void startNodeHandler(xmlTextReaderPtr reader);
77 void handleAttr(xmlTextReaderPtr reader);
78 void handleRule(xmlTextReaderPtr reader);
80 void handleCondition(xmlTextReaderPtr reader);
81 void handleSubjectMatch(xmlTextReaderPtr reader);
82 void handleMatch(xmlTextReaderPtr reader,
84 void handlePolicy(xmlTextReaderPtr reader,
85 TreeNode::TypeID type);
88 Policy::CombineAlgorithm convertToCombineAlgorithm(xmlChar*);
89 Effect convertToEffect(xmlChar *effect);
90 Attribute::Match convertToMatchFunction(xmlChar * func);
91 void consumeCurrentText();
92 void consumeCurrentAttribute();
93 void consumeSubjectMatch(xmlChar * value = NULL);
94 void consumeCurrentSubject();
95 void consumeCurrentCondition();
96 void trim(std::string *);
97 // KW void canonicalize(const char *, const char *, CanonicalizationAlgorithm canonicalizationAlgorithm);
98 // KW int extractNodeToFile(xmlTextReaderPtr reader, const char * filename);
100 static const char *TOKEN_PARAM;
104 TreeNode * parse(const std::string& filename, const std::string& schema);