00001 #ifndef __SESSION_TRACKER__
00002 #define __SESSION_TRACKER__
00003 #include <UserSession.h>
00004 #include <map>
00005 #include <string>
00006
00007
00008 using namespace std;
00009
00010
00011 class UserProfile;
00012
00019 class SessionTracker{
00020 public:
00025 SessionTracker(int timeout);
00026
00027 virtual ~SessionTracker();
00028
00032 void harvest();
00033
00038 UserProfile *getUser(string secret);
00039
00043 void closeSession(string secret);
00044
00048 string openSession();
00049
00054 void annotateSession(string secret,string username,string challenge);
00055
00059 string *getUsername(string secret);
00060
00064 string *getChallenge(string secret);
00065
00069 bool validateSession(string secret);
00070
00074 void invalidateSession(string secret);
00075
00079 bool sessionExists(string secret);
00080
00081 private:
00085 string generateSecret();
00086
00090 map<string, UserSession, less<string> > sessions;
00091
00095 int timeout;
00096
00097 pthread_mutex_t seslock;
00098 pthread_t reaper;
00099
00100 };
00101 #endif