/* This file is part of Metaproxy.
- Copyright (C) 2005-2012 Index Data
+ Copyright (C) 2005-2013 Index Data
Metaproxy is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
class Zoom::Searchable : boost::noncopyable {
public:
std::string authentication;
+ std::string authenticationMode;
std::string cfAuth;
std::string cfProxy;
std::string cfSubDB;
s->authentication = mp::xml::get_text(ptr);
}
else if (!strcmp((const char *) ptr->name,
+ "authenticationMode"))
+ {
+ s->authenticationMode = mp::xml::get_text(ptr);
+ }
+ else if (!strcmp((const char *) ptr->name,
"cfAuth"))
{
s->cfAuth = mp::xml::get_text(ptr);
if (sptr->query_encoding.length())
b->set_option("rpnCharset", sptr->query_encoding);
- if (sptr->extraArgs.length())
- b->set_option("extraArgs", sptr->extraArgs);
+ std::string extraArgs = sptr->extraArgs;
b->set_option("timeout", m_p->zoom_timeout.c_str());
}
else
{
- size_t found = authentication.find('/');
-
- if (sptr->sru.length() && found != std::string::npos)
- {
- b->set_option("user", authentication.substr(0, found));
- b->set_option("password", authentication.substr(found+1));
- }
+ if (sptr->sru.length() == 0)
+ b->set_option("user", authentication); /* Z39.50 */
else
- b->set_option("user", authentication);
+ {
+ std::string user;
+ std::string password;
+ std::string authtype = sptr->authenticationMode;
+
+ {
+ const char *cstr = authentication.c_str();
+ const char *cp1 = strchr(cstr, '/');
+ if (cp1)
+ {
+ password.assign(cp1 + 1);
+ user.assign(cstr, cp1 - cstr);
+ }
+ else
+ user.assign(cstr);
+ }
+ if (authtype.compare("url") == 0)
+ {
+ /* SRU URL encoding of auth stuff */
+ ODR o = odr_createmem(ODR_ENCODE);
+ char *path = 0;
+ const char *names[3];
+ const char *values[3];
+
+ names[0] = "x-username";
+ values[0] = user.c_str();
+ names[1] = "x-password";
+ values[1] = password.c_str();
+ names[2] = 0;
+ values[2] = 0;
+
+ yaz_array_to_uri(&path, o, (char **) names, (char **) values);
+ if (extraArgs.length())
+ extraArgs.append("&");
+ extraArgs.append(path);
+ odr_destroy(o);
+ }
+ else
+ {
+ b->set_option("user", user);
+ if (password.length())
+ b->set_option("password", password);
+ }
+ }
if (proxy.length())
b->set_option("proxy", proxy);
}
+ if (extraArgs.length())
+ b->set_option("extraArgs", extraArgs);
+
std::string url(sptr->target);
if (sptr->sru.length())
{
b->set_option("sru", sptr->sru);
- if (url.find_first_of("://") == std::string::npos)
+ if (url.find("://") == std::string::npos)
url = "http://" + url;
if (sptr->sru_version.length())
b->set_option("sru_version", sptr->sru_version);
if (status)
{
error = YAZ_BIB1_MALFORMED_QUERY;
- const char *addinfo = "can not convert from RPN to CQL/SOLR";
+ const char *addinfo = "can not convert from RPN to CQL/Solr";
log_diagnostic(package, error, addinfo);
apdu_res = odr.create_searchResponse(apdu_req, error, addinfo);
package.response() = apdu_res;