static void die(std::string s) { throw mp::filter::FilterException(s); }
+static std::string get_user(Z_InitRequest *initReq, std::string &password)
+{
+ Z_IdAuthentication *auth = initReq->idAuthentication;
+ std::string user;
+ if (auth)
+ {
+ const char *cp;
+ switch (auth->which)
+ {
+ case Z_IdAuthentication_open:
+ cp = strchr(auth->u.open, '/');
+ if (cp)
+ {
+ user.assign(auth->u.open, cp - auth->u.open);
+ password.assign(cp + 1);
+ }
+ else
+ user = auth->u.open;
+ break;
+ case Z_IdAuthentication_idPass:
+ if (auth->u.idPass->userId)
+ user = auth->u.idPass->userId;
+ if (auth->u.idPass->password)
+ password = auth->u.idPass->password;
+ break;
+ }
+ }
+ return user;
+}
+
// Read XML config.. Put config info in m_p.
void mp::filter::AuthSimple::configure(const xmlNode * ptr, bool test_only,
const char *path)
package.session().close();
}
-std::string yf::AuthSimple::get_user(Z_InitRequest *initReq,
- std::string &password) const
-{
- Z_IdAuthentication *auth = initReq->idAuthentication;
- std::string user;
- if (auth)
- {
- const char *cp;
- switch (auth->which)
- {
- case Z_IdAuthentication_open:
- cp = strchr(auth->u.open, '/');
- if (cp)
- {
- user.assign(auth->u.open, cp - auth->u.open);
- password.assign(cp + 1);
- }
- else
- user = auth->u.open;
- break;
- case Z_IdAuthentication_idPass:
- if (auth->u.idPass->userId)
- user = auth->u.idPass->userId;
- if (auth->u.idPass->password)
- password = auth->u.idPass->password;
- break;
- }
- }
- return user;
-}
-
void yf::AuthSimple::check_targets(mp::Package & package) const
{
Z_InitRequest *initReq = package.request().get()->u.z3950->u.initRequest;