From: Anders S. Mortensen Date: Mon, 16 Sep 2002 13:55:53 +0000 (+0000) Subject: Added support for authentication into SimpleServer. X-Git-Tag: release.0.0.8.lau~34 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=e1b6b500a91f4b57549f74d21ac335fdc9c7309b;p=simpleserver-moved-to-github.git Added support for authentication into SimpleServer. --- diff --git a/SimpleServer.xs b/SimpleServer.xs index d8df0bf..b233e69 100644 --- a/SimpleServer.xs +++ b/SimpleServer.xs @@ -25,7 +25,10 @@ */ /*$Log: SimpleServer.xs,v $ -/*Revision 1.14 2002-03-05 00:34:13 mike +/*Revision 1.15 2002-09-16 13:55:53 sondberg +/*Added support for authentication into SimpleServer. +/* +/*Revision 1.14 2002/03/05 00:34:13 mike /*Support for implementation_id (commented out until it's /*in mainstream Yaz) /* @@ -1111,6 +1114,8 @@ bend_initresult *bend_init(bend_initrequest *q) /*char *name_ptr; char *ver_ptr;*/ char *ptr; + char *user = NULL; + char *passwd = NULL; dSP; ENTER; @@ -1143,6 +1148,20 @@ bend_initresult *bend_init(bend_initrequest *q) hv_store(href, "PEER_NAME", 9, newSVpv(q->peer_name, 0), 0); hv_store(href, "HANDLE", 6, newSVsv(&sv_undef), 0); hv_store(href, "PID", 3, newSViv(getpid()), 0); + if (q->auth) { + if (q->auth->which == Z_IdAuthentication_open) { + char *openpass = xstrdup (q->auth->u.open); + char *cp = strchr (openpass, '/'); + if (cp) { + *cp = '\0'; + user = nmem_strdup (odr_getmem (q->stream), openpass); + passwd = nmem_strdup (odr_getmem (q->stream), cp + 1); + } + xfree(openpass); + } + hv_store(href, "USER", 4, newSVpv(user, 0), 0); + hv_store(href, "PASS", 4, newSVpv(passwd, 0), 0); + } PUSHMARK(sp); diff --git a/ztest.pl b/ztest.pl index 7ed6b68..ba3f63d 100755 --- a/ztest.pl +++ b/ztest.pl @@ -23,6 +23,10 @@ sub my_init_handler { $args->{IMP_VER} = "3.14159"; $args->{ERR_CODE} = 0; $args->{HANDLE} = $session; + if (defined($args->{PASS}) && defined($args->{USER})) { + printf("Received USER/PASS=%s/%s\n", $args->{USER},$args->{PASS}); + } + } sub my_scan_handler { @@ -126,7 +130,10 @@ $handler->launch_server("ztest.pl", @ARGV); ## $Log: ztest.pl,v $ -## Revision 1.10 2001-08-30 13:15:11 sondberg +## Revision 1.11 2002-09-16 13:55:53 sondberg +## Added support for authentication into SimpleServer. +## +## Revision 1.10 2001/08/30 13:15:11 sondberg ## Corrected a memory leak, one more to go. ## ## Revision 1.9 2001/08/29 11:48:36 sondberg