Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Authentication Class Reference

#include <AccessList.h>

List of all members.

Public Member Functions

 Authentication ()
void set (const std::string &AuthString)
const std::string & getType (void)
const std::string & getField (int nr)
int getNrOfFields (void)
void modifyField (unsigned int nr, const char *v)
void modify (unsigned int start, Authentication &source)
void appendField (const char *v)
void printParameters (std::ostream *pOut) const
int typeEqual (const std::string &v)

Private Attributes

std::vector< std::string > fields
string defAuth


Constructor & Destructor Documentation

Authentication::Authentication  )  [inline]
 

Definition at line 42 of file AccessList.h.

References defAuth.

00042 : defAuth("none"){};


Member Function Documentation

void Authentication::appendField const char *  v  )  [inline]
 

Definition at line 230 of file AccessList.h.

References fields.

Referenced by check_auth_file().

00231 {
00232         fields.push_back (v);
00233 }

const std::string & Authentication::getField int  nr  )  [inline]
 

Definition at line 199 of file AccessList.h.

References fields.

Referenced by check_auth_file(), and check_auth_unix().

00200 {
00201         return fields[nr];
00202 }

int Authentication::getNrOfFields void   )  [inline]
 

Definition at line 203 of file AccessList.h.

References fields.

Referenced by nnrpd().

00204 {
00205         return fields.size();
00206 }

const std::string & Authentication::getType void   )  [inline]
 

Definition at line 190 of file AccessList.h.

References defAuth, and fields.

Referenced by check_authentication(), and nnrpd().

00191 {
00192         if (fields.size() == 0) {
00193                 return defAuth;
00194         } else {
00195                 return fields[0];
00196         }
00197 }

void Authentication::modify unsigned int  start,
Authentication source
 

Definition at line 321 of file AccessList.cc.

References fields.

00322 {
00323         unsigned int i;
00324         vector<string>::iterator sp, se;
00325         vector<string>::iterator dp, de;
00326 
00327         sp = source.fields.begin();
00328         se = source.fields.end();
00329         dp = fields.begin();
00330         de = fields.end();
00331 
00332         for (i=0; sp != se && dp != de; i++) {
00333                 if (dp == de) {
00334                         if (i>=start)
00335                                 fields.push_back (*sp);
00336                         sp++;
00337                 } else if (sp == se) {
00338                         if (i>=start)
00339                                 fields.push_back (string(""));
00340                         dp++;
00341                 } else {
00342                         if (i>=start)
00343                                 (*dp) += (*sp);
00344                         sp++; dp++;
00345                 }
00346         }
00347 }

void Authentication::modifyField unsigned int  nr,
const char *  v
[inline]
 

Definition at line 222 of file AccessList.h.

References fields.

00223 {
00224         if (nr >= fields.size())
00225                 throw ("bounding error");
00226 
00227         fields[nr] += v;
00228 }

void Authentication::printParameters std::ostream *  pOut  )  const
 

Definition at line 302 of file AccessList.cc.

References fields.

Referenced by operator<<(), and AccessEntry::printParameters().

00303 {
00304         int i,e=fields.size();
00305 
00306         if (e == 0) {
00307                 return;
00308         }
00309 
00310         for (i=0; i<e; i++) {
00311                 if (i==0) {
00312                         *pOut << "\t\tAuthentication ";
00313                 } else {
00314                         *pOut << ":";
00315                 }
00316                 *pOut << fields[i];
00317         }
00318         *pOut << endl;
00319 }

void Authentication::set const std::string &  AuthString  ) 
 

Definition at line 274 of file AccessList.cc.

References fields.

Referenced by check_auth_file(), and AccessList::readClient().

00275 {
00276         string::size_type beg=0, end=0; 
00277 
00278         fields.clear();
00279 
00280         if (AuthString.length() == 0) {
00281                 return;
00282         }
00283 
00284         do {
00285                 if ((end=AuthString.find(":",beg)) == string::npos) {
00286                         end=AuthString.length();
00287                 }
00288                 if (end>beg) {
00289                         fields.push_back (AuthString.substr(beg, end-beg));
00290                 } else {
00291                         fields.push_back (string(""));
00292                 }
00293                 beg=++end;
00294         } while (end<AuthString.length());
00295 
00296         // empty field at the end of AuthString?
00297         if (AuthString[AuthString.length()-1] == ':') {
00298                 fields.push_back (string(""));
00299         }
00300 }

int Authentication::typeEqual const std::string &  v  ) 
 

Definition at line 349 of file AccessList.cc.

References fields.

Referenced by check_auth_file(), and check_auth_unix().

00350 {
00351         const char *s = fields[0].c_str();
00352         const char *p = v.c_str();
00353 
00354         while (*s!='\0') {
00355                 if (*p=='\0')
00356                         return -1;
00357                 if (*s!=*p)
00358                         return -1;
00359                 s++; p++;
00360         }
00361         if (*p=='\0' || *p==':')
00362                 return 0;
00363         else 
00364                 return -1;
00365 
00366 }


Member Data Documentation

string Authentication::defAuth [private]
 

Definition at line 102 of file AccessList.h.

Referenced by Authentication(), and getType().

std::vector<std::string> Authentication::fields [private]
 

Definition at line 101 of file AccessList.h.

Referenced by appendField(), getField(), getNrOfFields(), getType(), modify(), modifyField(), printParameters(), set(), and typeEqual().


The documentation for this class was generated from the following files:
Generated on Fri Aug 20 10:58:09 2004 for NewsCache by doxygen 1.3.6-20040222