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;
71 doc = xmlParseFile(cfgfile);
73 ods_log_error(
"[%s] could not parse <RepositoryList>: "
74 "xmlParseFile() failed", parser_str);
78 xpathCtx = xmlXPathNewContext(doc);
79 if(xpathCtx == NULL) {
81 ods_log_error(
"[%s] could not parse <RepositoryList>: "
82 "xmlXPathNewContext() failed", parser_str);
86 xexpr = (xmlChar*)
"//Configuration/RepositoryList/Repository";
87 xpathObj = xmlXPathEvalExpression(xexpr, xpathCtx);
88 if(xpathObj == NULL) {
89 xmlXPathFreeContext(xpathCtx);
91 ods_log_error(
"[%s] could not parse <RepositoryList>: "
92 "xmlXPathEvalExpression failed", parser_str);
96 if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr > 0) {
97 for (i = 0; i < xpathObj->nodesetval->nodeNr; i++) {
107 curNode = xpathObj->nodesetval->nodeTab[i]->xmlChildrenNode;
108 name = (
char *) xmlGetProp(xpathObj->nodesetval->nodeTab[i],
109 (
const xmlChar *)
"name");
111 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"RequireBackup"))
113 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"Module"))
114 module = (
char *) xmlNodeGetContent(curNode);
115 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"TokenLabel"))
116 tokenlabel = (
char *) xmlNodeGetContent(curNode);
117 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"PIN"))
118 pin = (
char *) xmlNodeGetContent(curNode);
119 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"SkipPublicKey"))
121 if (xmlStrEqual(curNode->name, (
const xmlChar *)
"AllowExtraction"))
124 curNode = curNode->next;
126 if (name && module && tokenlabel) {
128 use_pubkey, allowextract, require_backup);
131 ods_log_error(
"[%s] unable to add %s repository: "
132 "hsm_repository_new() failed", parser_str, name?name:
"-");
136 ods_log_debug(
"[%s] added %s repository to repositorylist",
141 free((
void*)tokenlabel);
145 xmlXPathFreeObject(xpathObj);
146 xmlXPathFreeContext(xpathCtx);
hsm_repository_t * parse_conf_repositories(const char *cfgfile)
hsm_repository_t * hsm_repository_new(char *name, char *module, char *tokenlabel, char *pin, uint8_t use_pubkey, uint8_t allowextract, uint8_t require_backup)