1 /* $Id: filter_auth_simple.cpp,v 1.2 2006-01-13 15:09:35 adam Exp $
2 Copyright (c) 2005, Index Data.
10 #include "package.hpp"
12 #include <boost/thread/mutex.hpp>
15 #include "filter_auth_simple.hpp"
19 namespace yf = yp2::filter;
23 class AuthSimple::Rep {
24 friend class AuthSimple;
25 int dummy; // private data
30 yf::AuthSimple::AuthSimple() : m_p(new Rep)
35 yf::AuthSimple::~AuthSimple()
36 { // must have a destructor because of boost::scoped_ptr
39 void yf::AuthSimple::process(yp2::Package &package) const
41 Z_GDU *gdu = package.request().get();
43 if (gdu && gdu->which == Z_GDU_Z3950 && gdu->u.z3950->which ==
46 // we have a Z39.50 init request
47 Z_InitRequest *init = gdu->u.z3950->u.initRequest;
49 // for now reject if we don't supply _some_ auth
50 if (!init->idAuthentication)
53 Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, 0, 0);
55 apdu->u.initResponse->implementationName = "YP2/YAZ";
56 *apdu->u.initResponse->result = 0; // reject
58 package.response() = apdu;
60 package.session().close();
63 // if we get here access is granted..
65 // should authentication be altered of deleted?
66 // that could be configurable..
68 package.move(); // pass on package
71 void yp2::filter::AuthSimple::configure(const xmlNode * ptr)
73 // Read XML config.. Put config info in m_p..
77 static yp2::filter::Base* filter_creator()
79 return new yp2::filter::AuthSimple;
83 struct yp2_filter_struct yp2_filter_auth_simple = {
94 * indent-tabs-mode: nil
95 * c-file-style: "stroustrup"
97 * vim: shiftwidth=4 tabstop=8 expandtab