Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

ArServerUserInfo Class Reference

For a description of the algorithm used to match passwords and keys and all look at the documentation for ArServerBase. More...

#include <ArServerUserInfo.h>

List of all members.

Public Member Functions

 ArServerUserInfo (const char *baseDirectory=NULL)
 Constructor.
bool doNotUse (void) const
std::set< std::string, ArStrCaseCmpOp > getUsersGroups (const char *user) const
 Gets the groups a user is in (returns empty set if no user).
void logUsers (void) const
 Logs the users and groups.
bool matchUserPassword (const char *user, unsigned char password[16], const char *passwordKey, const char *serverKey) const
 Matchs a user and password, false if user or password is wrong.
bool readFile (const char *fileName)
 Loads the file, returns false if it wasn't there.
void setBaseDirectory (const char *baseDirectory)
 Sets the base directory.
 ~ArServerUserInfo ()
 Destructor.

Protected Member Functions

void removeHandlers (void)
bool v1DoNotUseCallback (ArArgumentBuilder *arg)
bool v1HeaderCallback (ArArgumentBuilder *arg)
bool v1UserCallback (ArArgumentBuilder *arg)

Protected Attributes

std::string myBaseDirectory
ArMutex myDataMutex
bool myDoNotUse
bool myGotHeader
std::map< std::string, std::set<
std::string, ArStrCaseCmpOp > *,
ArStrCaseCmpOp > 
myGroups
ArFileParser myParser
std::map< std::string, std::string,
ArStrCaseCmpOp > 
myPasswords
ArRetFunctor1C< bool, ArServerUserInfo,
ArArgumentBuilder * > 
myV1DoNotUseCB
ArRetFunctor1C< bool, ArServerUserInfo,
ArArgumentBuilder * > 
myV1HeaderCB
ArRetFunctor1C< bool, ArServerUserInfo,
ArArgumentBuilder * > 
myV1UserCB


Detailed Description

For a description of the algorithm used to match passwords and keys and all look at the documentation for ArServerBase.

The file format for this class is set up to be easy to make a new version of and yet read all the old versions.

For all of the versions everything after ; or # is ignored. The version information is then the first line of non comments.

The first version is described as such: The version string is 'UserInfoVersion1'. Then there are lines that follow for each user which are 'user userName password groups'. The passwords are plain text in the file, though they aren't sent that way over the network (look at ArServerBase docs for details). To display the groups available use ArServerBase::logCommandGroups().

There is an example user info file in ArNetworking/examples/serverDemo.userInfo

Definition at line 52 of file ArServerUserInfo.h.


Constructor & Destructor Documentation

ArServerUserInfo::ArServerUserInfo const char *  baseDirectory = NULL  ) 
 

Constructor.

Definition at line 31 of file ArServerUserInfo.cpp.

References myDoNotUse, myGotHeader, myParser, and ArFileParser::setBaseDirectory().

ArServerUserInfo::~ArServerUserInfo  ) 
 

Destructor.

Definition at line 41 of file ArServerUserInfo.cpp.


Member Function Documentation

bool ArServerUserInfo::doNotUse void   )  const
 

Definition at line 253 of file ArServerUserInfo.cpp.

References myDoNotUse.

Referenced by ArServerBase::loadUserInfo().

std::set< std::string, ArStrCaseCmpOp > ArServerUserInfo::getUsersGroups const char *  user  )  const
 

Gets the groups a user is in (returns empty set if no user).

Definition at line 204 of file ArServerUserInfo.cpp.

References ArLog::log(), and myGroups.

Referenced by logUsers(), and ArServerClient::processPacket().

void ArServerUserInfo::logUsers void   )  const
 

Logs the users and groups.

Definition at line 219 of file ArServerUserInfo.cpp.

References getUsersGroups(), ArLog::log(), myDoNotUse, and myPasswords.

Referenced by ArServerBase::logUserInfo().

bool ArServerUserInfo::matchUserPassword const char *  user,
unsigned char  password[16],
const char *  passwordKey,
const char *  serverKey
const
 

Matchs a user and password, false if user or password is wrong.

Definition at line 156 of file ArServerUserInfo.cpp.

References ArLog::log(), md5_append(), md5_finish(), md5_init(), and myPasswords.

Referenced by ArServerClient::processPacket().

bool ArServerUserInfo::readFile const char *  fileName  ) 
 

Loads the file, returns false if it wasn't there.

Definition at line 126 of file ArServerUserInfo.cpp.

References ArFileParser::addHandler(), ArUtil::deleteSetPairs(), ArMutex::lock(), ArLog::log(), myDataMutex, myGotHeader, myGroups, myParser, myPasswords, myV1HeaderCB, ArFileParser::parseFile(), removeHandlers(), and ArMutex::unlock().

Referenced by ArServerBase::loadUserInfo().

void ArServerUserInfo::removeHandlers void   )  [protected]
 

Definition at line 120 of file ArServerUserInfo.cpp.

References myParser, myV1HeaderCB, myV1UserCB, and ArFileParser::remHandler().

Referenced by readFile(), and v1HeaderCallback().

void ArServerUserInfo::setBaseDirectory const char *  baseDirectory  ) 
 

Sets the base directory.

Definition at line 46 of file ArServerUserInfo.cpp.

References ArMutex::lock(), myDataMutex, myParser, ArFileParser::setBaseDirectory(), and ArMutex::unlock().

Referenced by ArServerBase::loadUserInfo().

bool ArServerUserInfo::v1DoNotUseCallback ArArgumentBuilder arg  )  [protected]
 

Definition at line 114 of file ArServerUserInfo.cpp.

References myDoNotUse.

bool ArServerUserInfo::v1HeaderCallback ArArgumentBuilder arg  )  [protected]
 

Definition at line 54 of file ArServerUserInfo.cpp.

References ArFileParser::addHandler(), ArLog::log(), myDoNotUse, myGotHeader, myParser, myV1DoNotUseCB, myV1UserCB, and removeHandlers().

bool ArServerUserInfo::v1UserCallback ArArgumentBuilder arg  )  [protected]
 

Definition at line 71 of file ArServerUserInfo.cpp.

References ArLog::log(), myGroups, and myPasswords.


Member Data Documentation

std::string ArServerUserInfo::myBaseDirectory [protected]
 

Definition at line 87 of file ArServerUserInfo.h.

ArMutex ArServerUserInfo::myDataMutex [protected]
 

Definition at line 80 of file ArServerUserInfo.h.

Referenced by readFile(), and setBaseDirectory().

bool ArServerUserInfo::myDoNotUse [protected]
 

Definition at line 90 of file ArServerUserInfo.h.

Referenced by ArServerUserInfo(), doNotUse(), logUsers(), v1DoNotUseCallback(), and v1HeaderCallback().

bool ArServerUserInfo::myGotHeader [protected]
 

Definition at line 89 of file ArServerUserInfo.h.

Referenced by ArServerUserInfo(), readFile(), and v1HeaderCallback().

std::map<std::string, std::set<std::string, ArStrCaseCmpOp> *, ArStrCaseCmpOp> ArServerUserInfo::myGroups [protected]
 

Definition at line 83 of file ArServerUserInfo.h.

Referenced by getUsersGroups(), readFile(), and v1UserCallback().

ArFileParser ArServerUserInfo::myParser [protected]
 

Definition at line 88 of file ArServerUserInfo.h.

Referenced by ArServerUserInfo(), readFile(), removeHandlers(), setBaseDirectory(), and v1HeaderCallback().

std::map<std::string, std::string, ArStrCaseCmpOp> ArServerUserInfo::myPasswords [protected]
 

Definition at line 81 of file ArServerUserInfo.h.

Referenced by logUsers(), matchUserPassword(), readFile(), and v1UserCallback().

ArRetFunctor1C<bool, ArServerUserInfo, ArArgumentBuilder *> ArServerUserInfo::myV1DoNotUseCB [protected]
 

Definition at line 86 of file ArServerUserInfo.h.

Referenced by v1HeaderCallback().

ArRetFunctor1C<bool, ArServerUserInfo, ArArgumentBuilder *> ArServerUserInfo::myV1HeaderCB [protected]
 

Definition at line 84 of file ArServerUserInfo.h.

Referenced by readFile(), and removeHandlers().

ArRetFunctor1C<bool, ArServerUserInfo, ArArgumentBuilder *> ArServerUserInfo::myV1UserCB [protected]
 

Definition at line 85 of file ArServerUserInfo.h.

Referenced by removeHandlers(), and v1HeaderCallback().


The documentation for this class was generated from the following files:
Generated on Tue Feb 20 10:51:52 2007 for ArNetworking by  doxygen 1.4.0