metaproxy  1.13.0
Classes | Namespaces | Functions | Variables
filter_auth_simple.cpp File Reference
#include "config.hpp"
#include <metaproxy/filter.hpp>
#include <metaproxy/package.hpp>
#include <boost/thread/mutex.hpp>
#include <metaproxy/util.hpp>
#include "filter_auth_simple.hpp"
#include <fstream>
#include <yaz/zgdu.h>
#include <yaz/diagbib1.h>
#include <yaz/tpath.h>
#include <stdio.h>
#include <errno.h>
Include dependency graph for filter_auth_simple.cpp:

Go to the source code of this file.

Classes

class  metaproxy_1::filter::AuthSimple::Rep
 
struct  metaproxy_1::filter::AuthSimple::Rep::PasswordAndDBs
 

Namespaces

 metaproxy_1
 
 metaproxy_1::filter
 

Functions

static void die (std::string s)
 
static std::string get_user (Z_InitRequest *initReq, std::string &password)
 
static void split_db (std::list< std::string > &dbs, const char *databasesp)
 
static void reject_init (mp::Package &package, int err, const char *addinfo)
 
static bool contains (std::list< std::string > list, std::string thing)
 
static mp::filter::Base * filter_creator ()
 

Variables

struct metaproxy_1_filter_struct metaproxy_1_filter_auth_simple
 

Function Documentation

static bool contains ( std::list< std::string >  list,
std::string  thing 
)
static

Definition at line 301 of file filter_auth_simple.cpp.

References metaproxy_1::filter::AuthSimple::m_p.

Referenced by reject_init().

301  {
302  std::list<std::string>::const_iterator i;
303  for (i = list.begin(); i != list.end(); i++)
304  if (mp::util::database_name_normalize(*i) ==
305  mp::util::database_name_normalize(thing))
306  return true;
307 
308  return false;
309 }
static void die ( std::string  s)
static
static mp::filter::Base* filter_creator ( )
static

Definition at line 427 of file filter_auth_simple.cpp.

428 {
429  return new mp::filter::AuthSimple;
430 }
static std::string get_user ( Z_InitRequest *  initReq,
std::string &  password 
)
static

Definition at line 75 of file filter_auth_simple.cpp.

Referenced by metaproxy_1::filter::AuthSimple::config_targetRegister(), and reject_init().

76 {
77  Z_IdAuthentication *auth = initReq->idAuthentication;
78  std::string user;
79  if (auth)
80  {
81  const char *cp;
82  switch (auth->which)
83  {
84  case Z_IdAuthentication_open:
85  cp = strchr(auth->u.open, '/');
86  if (cp)
87  {
88  user.assign(auth->u.open, cp - auth->u.open);
89  password.assign(cp + 1);
90  }
91  else
92  user = auth->u.open;
93  break;
94  case Z_IdAuthentication_idPass:
95  if (auth->u.idPass->userId)
96  user = auth->u.idPass->userId;
97  if (auth->u.idPass->password)
98  password = auth->u.idPass->password;
99  break;
100  }
101  }
102  return user;
103 }
static void reject_init ( mp::Package &  package,
int  err,
const char *  addinfo 
)
static

Definition at line 376 of file filter_auth_simple.cpp.

References contains(), get_user(), metaproxy_1::filter::AuthSimple::m_p, and metaproxy_1::filter::AuthSimple::Rep::PasswordAndDBs::password.

Referenced by metaproxy_1::filter::AuthSimple::config_targetRegister().

376  {
377  if (err == 0)
378  err = YAZ_BIB1_INIT_AC_AUTHENTICATION_SYSTEM_ERROR;
379  // Make an Init rejection APDU
380  Z_GDU *gdu = package.request().get();
381  mp::odr odr;
382  Z_APDU *apdu = odr.create_initResponse(gdu->u.z3950, err, addinfo);
383  *apdu->u.initResponse->result = 0; // reject
384  package.response() = apdu;
385  package.session().close();
386 }

Here is the call graph for this function:

static void split_db ( std::list< std::string > &  dbs,
const char *  databasesp 
)
static

Definition at line 140 of file filter_auth_simple.cpp.

Referenced by metaproxy_1::filter::AuthSimple::config_targetRegister(), and metaproxy_1::filter::AuthSimple::config_userRegister().

142 {
143  const char *cp;
144  while ((cp = strchr(databasesp, ',')))
145  {
146  dbs.push_back(std::string(databasesp, cp - databasesp));
147  databasesp = cp + 1;
148  }
149  dbs.push_back(std::string(databasesp));
150 }

Variable Documentation

struct metaproxy_1_filter_struct metaproxy_1_filter_auth_simple
Initial value:
= {
0,
"auth_simple",
}
static mp::filter::Base * filter_creator()

Definition at line 433 of file filter_auth_simple.cpp.

Referenced by metaproxy_1::FactoryStatic::FactoryStatic().