1 /* $Id: mod_sample.cpp,v 1.6 2006-03-30 10:31:53 adam Exp $
2 Copyright (c) 1998-2006, Index Data.
4 This file is part of the yazproxy.
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,
52 // see if we have an "args" attribute
55 xmlNodePtr ptr = (xmlNodePtr) element_ptr;
56 struct _xmlAttr *attr;
58 for (attr = ptr->properties; attr; attr = attr->next)
60 if (!strcmp((const char *) attr->name, "args") &&
61 attr->children && attr->children->type == XML_TEXT_NODE)
62 args = (const char *) attr->children->content;
65 // args holds args (or NULL if none is provided)
68 fprintf(stderr, "my_authenticate: target=%s user=%s group=%s args=%s IP=%s"
70 target_name ? target_name : "none",
71 user ? user : "none", group ? group : "none",
74 // authentication handler
75 if (!user && !group && !password)
76 return YAZPROXY_RET_OK; // OK if anonymous
77 if (user && !strcmp(user, "guest")
78 && password && !strcmp(password, "guest")) // or guest guest
79 return YAZPROXY_RET_OK;
80 return YAZPROXY_RET_PERM; // fail otherwise
83 Yaz_ProxyModule_int0 interface0 = {
89 Yaz_ProxyModule_entry yazproxy_module = {
90 0, // interface version
92 "Sample Module for YAZ Proxy",// description
98 * indent-tabs-mode: nil
100 * vim: shiftwidth=4 tabstop=8 expandtab