From 55cec3a8dbc35efbcfd5ccfb806ef8c56833a9a5 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 9 Jun 2009 15:31:25 +0200 Subject: [PATCH] Z39.50 authentication for SRU (bug #2893) --- src/filter_sru_to_z3950.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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; -- 1.7.10.4