1 /* $Id: mod_sample.cpp,v 1.3 2005-06-10 22:54:22 adam Exp $
2 Copyright (c) 1998-2005, Index Data.
4 This file is part of the yaz-proxy.
6 YAZ proxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with YAZ proxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
26 #include <yazproxy/module.h>
29 #include <libxml/parser.h>
30 #include <libxml/tree.h>
31 #include <libxml/xinclude.h>
32 #include <libxslt/xsltutils.h>
33 #include <libxslt/transform.h>
38 return 0; // no private data for handler
41 void my_destroy(void *p)
43 // private data destroy
46 int my_authenticate(void *user_handle,
47 const char *target_name,
49 const char *user, const char *group, const char *password)
51 // see if we have an "args" attribute
54 xmlNodePtr ptr = (xmlNodePtr) element_ptr;
55 struct _xmlAttr *attr;
57 for (attr = ptr->properties; attr; attr = attr->next)
59 if (!strcmp((const char *) attr->name, "args") &&
60 attr->children && attr->children->type == XML_TEXT_NODE)
61 args = (const char *) attr->children->content;
64 // args holds args (or NULL if none is provided)
67 fprintf(stderr, "my_authenticate: target=%s user=%s group=%s args=%s\n",
68 target_name ? target_name : "none",
69 user ? user : "none", group ? group : "none",
70 args ? args : "none");
71 // authentication handler
72 if (!user && !group && !password)
73 return YAZPROXY_RET_OK; // OK if anonymous
74 if (user && !strcmp(user, "guest")
75 && password && !strcmp(password, "guest")) // or guest guest
76 return YAZPROXY_RET_OK;
77 return YAZPROXY_RET_PERM; // fail otherwise
80 Yaz_ProxyModule_int0 interface0 = {
86 Yaz_ProxyModule_entry yazproxy_module = {
87 0, // interface version
89 "Sample Module for YAZ Proxy",// description