'pz:authentication' allows you to set an authentication token for a given
target. This will allow support for targets which require one authentication
token for all users.. it should also be a foundation for adding more
fine-grained control.
-/* $Id: pazpar2.c,v 1.64 2007-04-08 20:52:09 quinn Exp $ */
+/* $Id: pazpar2.c,v 1.65 2007-04-08 21:51:58 quinn Exp $ */
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
static void connection_destroy(struct connection *co);
static int client_prep_connection(struct client *cl);
static void ingest_records(struct client *cl, Z_Records *r);
static void connection_destroy(struct connection *co);
static int client_prep_connection(struct client *cl);
static void ingest_records(struct client *cl, Z_Records *r);
-//static struct conf_retrievalprofile *database_retrieval_profile(struct database *db);
void session_alert_watch(struct session *s, int what);
char *session_setting_oneval(struct session *s, struct database *db, int offset);
void session_alert_watch(struct session *s, int what);
char *session_setting_oneval(struct session *s, struct database *db, int offset);
+// Set authentication token in init if one is set for the client
+// TODO: Extend this to handle other schemes than open (should be simple)
+static void init_authentication(struct client *cl, Z_InitRequest *req)
+{
+ struct database *db = cl->database;
+ struct session *se = cl->session;
+ char *auth = session_setting_oneval(se, db, PZ_AUTHENTICATION);
+
+ if (auth)
+ {
+ Z_IdAuthentication *idAuth = odr_malloc(global_parameters.odr_out,
+ sizeof(*idAuth));
+ idAuth->which = Z_IdAuthentication_open;
+ idAuth->u.open = auth;
+ req->idAuthentication = idAuth;
+ }
+}
static void send_init(IOCHAN i)
{
static void send_init(IOCHAN i)
{
ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_2);
ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_3);
ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_2);
ODR_MASK_SET(a->u.initRequest->protocolVersion, Z_ProtocolVersion_3);
+ init_authentication(cl, a->u.initRequest);
/* add virtual host if tunneling through Z39.50 proxy */
/* add virtual host if tunneling through Z39.50 proxy */
yaz_oi_set_string_oidval(&a->u.initRequest->otherInfo,
global_parameters.odr_out, VAL_PROXY,
1, cl->database->url);
yaz_oi_set_string_oidval(&a->u.initRequest->otherInfo,
global_parameters.odr_out, VAL_PROXY,
1, cl->database->url);
if (send_apdu(cl, a) >= 0)
{
if (send_apdu(cl, a) >= 0)
{
-// $Id: settings.c,v 1.7 2007-04-08 20:52:09 quinn Exp $
+// $Id: settings.c,v 1.8 2007-04-08 21:51:58 quinn Exp $
// This module implements a generic system of settings (attribute-value) that can
// be associated with search targets. The system supports both default values,
// per-target overrides, and per-user settings.
// This module implements a generic system of settings (attribute-value) that can
// be associated with search targets. The system supports both default values,
// per-target overrides, and per-user settings.
"pz:encoding",
"pz:xslt",
"pz:nativesyntax",
"pz:encoding",
"pz:xslt",
"pz:nativesyntax",
#ifndef SETTINGS_H
#define SETTINGS_H
#ifndef SETTINGS_H
#define SETTINGS_H
-#define PZ_PIGGYBACK 0
-#define PZ_ELEMENTS 1
-#define PZ_SYNTAX 2
-#define PZ_CCLMAP 3
-#define PZ_ENCODING 4
-#define PZ_XSLT 5
-#define PZ_NATIVESYNTAX 6
+#define PZ_PIGGYBACK 0
+#define PZ_ELEMENTS 1
+#define PZ_SYNTAX 2
+#define PZ_CCLMAP 3
+#define PZ_ENCODING 4
+#define PZ_XSLT 5
+#define PZ_NATIVESYNTAX 6
+#define PZ_AUTHENTICATION 7