From: Adam Dickmeiss Date: Tue, 9 Jun 2009 13:31:25 +0000 (+0200) Subject: Z39.50 authentication for SRU (bug #2893) X-Git-Tag: v1.0.16~3 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=55cec3a8dbc35efbcfd5ccfb806ef8c56833a9a5;p=metaproxy-moved-to-github.git Z39.50 authentication for SRU (bug #2893) --- diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 5ae4f7e..dfd98a0 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -363,6 +363,28 @@ yf::SRUtoZ3950::Impl::z3950_init_request(mp::Package &package, Z_APDU *apdu = zget_APDU(odr_en, Z_APDU_initRequest); Z_InitRequest *init_req = apdu->u.initRequest; + Z_IdAuthentication *auth = NULL; + if (sru_pdu_req->username && !sru_pdu_req->password) + { + yaz_log(YLOG_LOG, "username: %s\n", sru_pdu_req->username); + auth = (Z_IdAuthentication *) odr_malloc(odr_en, sizeof(Z_IdAuthentication)); + auth->which = Z_IdAuthentication_open; + auth->u.open = odr_strdup(odr_en, sru_pdu_req->username); + } + else if (sru_pdu_req->username && sru_pdu_req->password) + { + yaz_log(YLOG_LOG, "username/password: %s/%s\n", + sru_pdu_req->username, sru_pdu_req->password); + auth = (Z_IdAuthentication *) odr_malloc(odr_en, sizeof(Z_IdAuthentication)); + auth->which = Z_IdAuthentication_idPass; + auth->u.idPass = (Z_IdPass *) odr_malloc(odr_en, sizeof(Z_IdPass)); + auth->u.idPass->groupId = NULL; + auth->u.idPass->password = odr_strdup(odr_en, sru_pdu_req->password); + auth->u.idPass->userId = odr_strdup(odr_en, sru_pdu_req->username); + } + + init_req->idAuthentication = auth; + //TODO: add user name in apdu //TODO: add user passwd in apdu //init_req->idAuthentication = org_init->idAuthentication;