1 /* $Id: mod_sample.cpp,v 1.2 2005-02-21 14:27:32 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
25 #include <yazproxy/module.h>
28 #include <libxml/parser.h>
29 #include <libxml/tree.h>
30 #include <libxml/xinclude.h>
31 #include <libxslt/xsltutils.h>
32 #include <libxslt/transform.h>
37 return 0; // no private data for handler
40 void my_destroy(void *p)
42 // private data destroy
45 int my_authenticate(void *user_handle,
46 const char *target_name,
48 const char *user, const char *group, const char *password)
50 // see if we have an "args" attribute
53 xmlNodePtr ptr = (xmlNodePtr) element_ptr;
54 struct _xmlAttr *attr;
56 for (attr = ptr->properties; attr; attr = attr->next)
58 if (!strcmp((const char *) attr->name, "args") &&
59 attr->children && attr->children->type == XML_TEXT_NODE)
60 args = (const char *) attr->children->content;
63 // args holds args (or NULL if none is provided)
65 fprintf(stderr, "my_authenticate: target=%s user=%s group=%s args=%s\n",
66 target_name ? target_name : "none",
67 user ? user : "none", group ? group : "none",
68 args ? args : "none");
69 // authentication handler
70 if (!user && !group && !password)
71 return YAZPROXY_RET_OK; // OK if anonymous
72 if (user && !strcmp(user, "guest")
73 && password && !strcmp(password, "guest")) // or guest guest
74 return YAZPROXY_RET_OK;
75 return YAZPROXY_RET_PERM; // fail otherwise
78 Yaz_ProxyModule_int0 interface0 = {
84 Yaz_ProxyModule_entry yazproxy_module = {
85 0, // interface version
87 "Sample Module for YAZ Proxy",// description