X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Ffilter_multi.cpp;h=e4bea124452b573ac9768ccb0efdb0f618f98990;hb=722c498e016a6eb94044c608a7d1dcb21e5013cd;hp=c49825ba7f76d4bf0a28b8bd2d945143db375968;hpb=cb616835c5599e3f13e5f32245a7856a1de6eb2f;p=metaproxy-moved-to-github.git diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index c49825b..e4bea12 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -88,6 +88,7 @@ namespace metaproxy_1 { 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 { @@ -111,13 +112,16 @@ namespace metaproxy_1 { 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; @@ -395,7 +399,7 @@ void yf::Multi::Frontend::init(mp::Package &package, Z_GDU *gdu) std::list::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++; } @@ -423,7 +427,16 @@ void yf::Multi::Frontend::init(mp::Package &package, Z_GDU *gdu) 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; @@ -542,7 +555,7 @@ void yf::Multi::Frontend::search(mp::Package &package, Z_APDU *apdu_req) // they are altered now - to disable piggyback *req->smallSetUpperBound = 0; *req->largeSetLowerBound = 1; - *req->mediumSetPresentNumber = 1; + *req->mediumSetPresentNumber = 0; int default_num_db = req->num_databaseNames; char **default_db = req->databaseNames; @@ -1293,9 +1306,12 @@ void mp::filter::Multi::configure(const xmlNode * ptr, bool test_only, 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); - m_p->m_route_patterns.push_back(Multi::Map(target, route)); + if (target.length() == 0) + target = route; + m_p->m_route_patterns.push_back(Multi::Map(target, route, auth)); } else if (!strcmp((const char *) ptr->name, "hideunavailable")) {