The configure method takes test_only flag so we can avoid
[metaproxy-moved-to-github.git] / src / filter_auth_simple.cpp
index 7b0cba8..d394777 100644 (file)
@@ -1,7 +1,22 @@
-/* $Id: filter_auth_simple.cpp,v 1.18 2006-03-16 10:40:59 adam Exp $
-   Copyright (c) 2005-2006, Index Data.
+/* $Id: filter_auth_simple.cpp,v 1.25 2008-02-20 15:07:51 adam Exp $
+   Copyright (c) 2005-2007, Index Data.
 
-%LICENSE%
+This file is part of Metaproxy.
+
+Metaproxy is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Metaproxy; see the file LICENSE.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
  */
 
 #include "config.hpp"
@@ -61,7 +76,7 @@ static void die(std::string s) { throw mp::filter::FilterException(s); }
 
 
 // Read XML config.. Put config info in m_p.
-void mp::filter::AuthSimple::configure(const xmlNode * ptr)
+void mp::filter::AuthSimple::configure(const xmlNode * ptr, bool test_only)
 {
     std::string userRegisterName;
     std::string targetRegisterName;
@@ -242,9 +257,10 @@ void yf::AuthSimple::process_init(mp::Package &package) const
 static bool contains(std::list<std::string> list, std::string thing) {
     std::list<std::string>::const_iterator i;
     for (i = list.begin(); i != list.end(); i++)
-        if (*i == thing)
+        if (mp::util::database_name_normalize(*i) == 
+            mp::util::database_name_normalize(thing))
             return true;
-
+    
     return false;
 }
 
@@ -341,8 +357,8 @@ void yf::AuthSimple::check_targets(mp::Package & package) const
     std::list<std::string> authorisedTargets = m_p->targetsByUser[user];
 
     std::list<std::string> targets;
-    Z_OtherInformation *otherInfo = initReq->otherInfo;
-    mp::util::get_vhost_otherinfo(&otherInfo, 1, targets);
+    Z_OtherInformation **otherInfo = &initReq->otherInfo;
+    mp::util::remove_vhost_otherinfo(otherInfo, targets);
 
     // Check each of the targets specified in the otherInfo package
     std::list<std::string>::iterator i;
@@ -365,9 +381,8 @@ void yf::AuthSimple::check_targets(mp::Package & package) const
                            YAZ_BIB1_ACCESS_TO_SPECIFIED_DATABASE_DENIED,
                            // ### It would be better to use the Z-db name
                            "all databases");
-
     mp::odr odr;
-    mp::util::set_vhost_otherinfo(&otherInfo, odr, targets);
+    mp::util::set_vhost_otherinfo(otherInfo, odr, targets);
     package.move();
 }