metaproxy  1.13.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
metaproxy_1::filter::AuthSimple Class Reference

#include <filter_auth_simple.hpp>

Inheritance diagram for metaproxy_1::filter::AuthSimple:
Inheritance graph
Collaboration diagram for metaproxy_1::filter::AuthSimple:
Collaboration graph

Classes

class  Rep
 

Public Member Functions

 AuthSimple ()
 
 ~AuthSimple ()
 
void configure (const xmlNode *ptr, bool test_only, const char *path)
 
void process (metaproxy_1::Package &package) const
 

Private Member Functions

void config_userRegister (std::string filename, const char *path)
 
void config_targetRegister (std::string filename, const char *path)
 
void process_init (metaproxy_1::Package &package) const
 
void process_search (metaproxy_1::Package &package) const
 
void process_scan (metaproxy_1::Package &package) const
 
void check_targets (metaproxy_1::Package &package) const
 

Private Attributes

boost::scoped_ptr< Repm_p
 

Detailed Description

Definition at line 28 of file filter_auth_simple.hpp.

Constructor & Destructor Documentation

metaproxy_1::filter::AuthSimple::AuthSimple ( )
metaproxy_1::filter::AuthSimple::~AuthSimple ( )

Member Function Documentation

void metaproxy_1::filter::AuthSimple::check_targets ( metaproxy_1::Package &  package) const
private

Referenced by config_targetRegister().

void metaproxy_1::filter::AuthSimple::config_targetRegister ( std::string  filename,
const char *  path 
)
private

Definition at line 197 of file filter_auth_simple.cpp.

References check_targets(), die(), get_user(), m_p, metaproxy_1::filter::AuthSimple::Rep::PasswordAndDBs::password, process_init(), process_scan(), process_search(), reject_init(), and split_db().

Referenced by configure().

199 {
200  char fullpath[1024];
201  if (!yaz_filepath_resolve(filename.c_str(), path, 0, fullpath))
202  die("Could not open " + filename);
203  std::ifstream fp(fullpath);
204  if (!fp.is_open())
205  die("Could not open " + filename);
206 
207  while (!fp.eof()) {
208  char buf[1000];
209  fp.getline(buf, sizeof buf);
210  if (*buf == '\0' || *buf == '#')
211  continue;
212  char *targetsp = strchr(buf, ':');
213  if (targetsp == 0)
214  die("auth_simple target-register '" + filename + "': " +
215  "no targets on line: '" + buf + "'");
216  *targetsp++ = 0;
217  std::list<std::string> tmp;
218  split_db(tmp, targetsp);
219  m_p->targetsByUser[buf] = tmp;
220 
221  if (0) { // debugging
222  printf("Added user '%s' with targets:\n", buf);
223  std::list<std::string>::const_iterator i;
224  for (i = tmp.begin(); i != tmp.end(); i++) {
225  printf("\t%s\n", (*i).c_str());
226  }
227  }
228  }
229 }
static void split_db(std::list< std::string > &dbs, const char *databasesp)
static void die(std::string s)

Here is the call graph for this function:

void metaproxy_1::filter::AuthSimple::config_userRegister ( std::string  filename,
const char *  path 
)
private

Definition at line 152 of file filter_auth_simple.cpp.

References die(), m_p, and split_db().

Referenced by configure().

154 {
155  char fullpath[1024];
156  if (!yaz_filepath_resolve(filename.c_str(), path, 0, fullpath))
157  die("Could not open " + filename);
158 
159  std::ifstream fp(fullpath);
160  if (!fp.is_open())
161  die("Could not open " + filename);
162 
163  while (!fp.eof())
164  {
165  char buf[1000];
166  fp.getline(buf, sizeof buf);
167  if (*buf == '\0' || *buf == '#')
168  continue;
169  char *passwdp = strchr(buf, ':');
170  if (passwdp == 0)
171  die("auth_simple user-register '" + filename + "': " +
172  "no password on line: '" + buf + "'");
173  *passwdp++ = 0;
174  char *databasesp = strchr(passwdp, ':');
175  if (databasesp == 0)
176  die("auth_simple user-register '" + filename + "': " +
177  "no databases on line: '" + buf + ":" + passwdp + "'");
178  *databasesp++ = 0;
179  yf::AuthSimple::Rep::PasswordAndDBs tmp(passwdp);
180  split_db(tmp.dbs, databasesp);
181  m_p->userRegister[buf] = tmp;
182 
183  if (0)
184  { // debugging
185  printf("Added user '%s' -> password '%s'\n", buf, passwdp);
186  std::list<std::string>::const_iterator i;
187  for (i = tmp.dbs.begin(); i != tmp.dbs.end(); i++)
188  printf("db '%s'\n", (*i).c_str());
189  }
190  }
191 }
static void split_db(std::list< std::string > &dbs, const char *databasesp)
static void die(std::string s)

Here is the call graph for this function:

void metaproxy_1::filter::AuthSimple::configure ( const xmlNode *  ptr,
bool  test_only,
const char *  path 
)

Definition at line 106 of file filter_auth_simple.cpp.

References config_targetRegister(), config_userRegister(), die(), and m_p.

108 {
109  std::string userRegisterName;
110  std::string targetRegisterName;
111 
112  for (ptr = ptr->children; ptr != 0; ptr = ptr->next) {
113  if (ptr->type != XML_ELEMENT_NODE)
114  continue;
115  if (!strcmp((const char *) ptr->name, "userRegister")) {
116  userRegisterName = mp::xml::get_text(ptr);
117  m_p->got_userRegister = true;
118  } else if (!strcmp((const char *) ptr->name, "targetRegister")) {
119  targetRegisterName = mp::xml::get_text(ptr);
120  m_p->got_targetRegister = true;
121  } else if (!strcmp((const char *) ptr->name,
122  "discardUnauthorisedTargets")) {
123  m_p->discardUnauthorisedTargets = true;
124  } else {
125  die("Bad element in auth_simple: <"
126  + std::string((const char *) ptr->name) + ">");
127  }
128  }
129 
130  if (!m_p->got_userRegister && !m_p->got_targetRegister)
131  die("auth_simple: no user-register or target-register "
132  "filename specified");
133 
134  if (m_p->got_userRegister)
135  config_userRegister(userRegisterName, path);
136  if (m_p->got_targetRegister)
137  config_targetRegister(targetRegisterName, path);
138 }
void config_userRegister(std::string filename, const char *path)
void config_targetRegister(std::string filename, const char *path)
static void die(std::string s)

Here is the call graph for this function:

void metaproxy_1::filter::AuthSimple::process ( metaproxy_1::Package &  package) const
void metaproxy_1::filter::AuthSimple::process_init ( metaproxy_1::Package &  package) const
private

Referenced by config_targetRegister().

void metaproxy_1::filter::AuthSimple::process_scan ( metaproxy_1::Package &  package) const
private

Referenced by config_targetRegister().

void metaproxy_1::filter::AuthSimple::process_search ( metaproxy_1::Package &  package) const
private

Referenced by config_targetRegister().

Member Data Documentation

boost::scoped_ptr<Rep> metaproxy_1::filter::AuthSimple::m_p
private

The documentation for this class was generated from the following files: