37 #include <libxml/xpath.h> 38 #include <libxml/relaxng.h> 39 #include <libxml/xmlreader.h> 44 static const char* parser_str =
"parser";
54 xmlXPathContextPtr xpathCtx = NULL;
55 xmlXPathObjectPtr xpathObj = NULL;
56 xmlNode* curNode = NULL;
57 xmlChar* xexpr = NULL;
70 doc = xmlParseFile(cfgfile);
72 ods_log_error(
"[%s] could not parse <RepositoryList>: " 73 "xmlParseFile() failed", parser_str);
77 xpathCtx = xmlXPathNewContext(doc);
78 if(xpathCtx == NULL) {
80 ods_log_error(
"[%s] could not parse <RepositoryList>: " 81 "xmlXPathNewContext() failed", parser_str);
85 xexpr = (xmlChar*)
"//Configuration/RepositoryList/Repository";
86 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
87 if(xpathObj == NULL) {
88 xmlXPathFreeContext(xpathCtx);
90 ods_log_error(
"[%s] could not parse <RepositoryList>: " 91 "xmlXPathEvalExpression failed", parser_str);
95 if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
96 for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {
105 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
106 name = (
char *) xmlGetProp(xpathObj->nodesetval->nodeTab[i],
107 (
const xmlChar *)
"name");
109 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"RequireBackup"))
111 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Module"))
112 module = (
char *) xmlNodeGetContent(curNode);
113 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"TokenLabel"))
114 tokenlabel = (
char *) xmlNodeGetContent(curNode);
115 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"PIN"))
116 pin = (
char *) xmlNodeGetContent(curNode);
117 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"SkipPublicKey"))
120 curNode = curNode->next;
122 if (name && module && tokenlabel) {
124 use_pubkey, require_backup);
127 ods_log_error(
"[%s] unable to add %s repository: " 128 "hsm_repository_new() failed", parser_str, name?name:
"-");
132 ods_log_debug(
"[%s] added %s repository to repositorylist",
137 free((
void*)tokenlabel);
141 xmlXPathFreeObject(xpathObj);
142 xmlXPathFreeContext(xpathCtx);
hsm_repository_t * hsm_repository_new(char *name, char *module, char *tokenlabel, char *pin, uint8_t use_pubkey, uint8_t require_backup)
hsm_repository_t * parse_conf_repositories(const char *cfgfile)