std::string m_backend_database;
std::string m_vhost;
std::string m_route;
+ std::string m_auth;
void operator() (void); // thread operation
};
struct Multi::Frontend {
class Multi::Map {
std::string m_target_pattern;
std::string m_route;
+ std::string m_auth;
public:
- Map(std::string pattern, std::string route) :
- m_target_pattern(pattern), m_route(route) {};
- bool match(const std::string target, std::string *ret) const {
+ Map(std::string pattern, std::string route, std::string auth) :
+ m_target_pattern(pattern), m_route(route), m_auth(auth) {};
+ bool match(const std::string target, std::string *ret,
+ std::string *auth) const {
if (yaz_match_glob(m_target_pattern.c_str(), target.c_str()))
{
*ret = m_route;
+ *auth = m_auth;
return true;
}
return false;
std::list<Multi::Map>::const_iterator it =
m_p->m_route_patterns.begin();
while (it != m_p->m_route_patterns.end()) {
- if (it->match(*t_it, &b->m_route))
+ if (it->match(*t_it, &b->m_route, &b->m_auth))
break;
it++;
}
Z_InitRequest *breq = init_apdu->u.initRequest;
- breq->idAuthentication = req->idAuthentication;
+ if (b->m_auth.length())
+ {
+ breq->idAuthentication =
+ (Z_IdAuthentication *)
+ odr_malloc(odr, sizeof(*breq->idAuthentication));
+ breq->idAuthentication->which = Z_IdAuthentication_open;
+ breq->idAuthentication->u.open = odr_strdup(odr, b->m_auth.c_str());
+ }
+ else
+ breq->idAuthentication = req->idAuthentication;
*breq->preferredMessageSize = *req->preferredMessageSize;
*breq->maximumRecordSize = *req->maximumRecordSize;
continue;
if (!strcmp((const char *) ptr->name, "target"))
{
- std::string route = mp::xml::get_route(ptr);
+ std::string auth;
+ std::string route = mp::xml::get_route(ptr, auth);
std::string target = mp::xml::get_text(ptr);
if (target.length() == 0)
target = route;
- m_p->m_route_patterns.push_back(Multi::Map(target, route));
+ m_p->m_route_patterns.push_back(Multi::Map(target, route, auth));
}
else if (!strcmp((const char *) ptr->name, "hideunavailable"))
{
return true;
}
-std::string mp_xml::get_route(const xmlNode *node)
+std::string mp_xml::get_route(const xmlNode *node, std::string &auth)
{
std::string route_value;
if (node)
if (name == "route")
route_value = value;
+ else if (name == "auth")
+ auth = value;
else
throw XMLError("Only attribute route allowed"
" in " + std::string((const char *)node->name)
return route_value;
}
+std::string mp_xml::get_route(const xmlNode *node)
+{
+ std::string auth;
+ return get_route(node, auth);
+}
const xmlNode* mp_xml::jump_to_children(const xmlNode* node,
int xml_node_type)