00001 // This is part of tacppd project (extended tacacs++ daemon) 00002 // (c) Copyright 2000-2004 by tacppd team and contributors 00003 // see http://tacppd.org for more information 00004 // 00005 // file: UserTrack.h 00006 // description: work users tracker 00007 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 00022 // modifications: 00023 // 00024 00025 // all comments which start from /** - this is comments for KDoc */ 00026 // for classes 00027 // @short [short description of the class] 00028 // @author [class author] 00029 // @version [class version] 00030 // @see [references to other classes or methods] 00031 // for methods 00032 // @see [references] 00033 // @return [sentence describing the return value] 00034 // @exception [list the exeptions that could be thrown] 00035 // @param [name id] [description] - can be multiple 00036 00037 #ifndef __USERTRACK_H__ 00038 #define __USERTRACK_H__ 00039 00040 #include "global.h" 00041 00042 namespace tacpp { 00043 00045 00051 class dbc_entry { 00054 pthread_mutex_t mutex_; 00057 void lock(); 00060 void unlock(); 00063 db_user entry_; 00066 time_t date_; 00067 public: 00070 dbc_entry(db_user); 00073 ~dbc_entry(); 00077 db_user get(); 00081 time_t getTime(); 00082 }; 00083 00089 class dbc_man { 00092 pthread_mutex_t mutex_dbc_; 00095 void lock(); 00098 void unlock(); 00101 list<dbc_entry*> dbec_; 00102 public: 00105 dbc_man(); 00108 ~dbc_man(); 00112 bool present(string); 00116 db_user get(string); 00119 void add(db_user); 00120 }; 00121 00127 class UserTrack { 00130 pthread_mutex_t mutex_; 00133 void lock(); 00136 void unlock(); 00139 dbc_man dbc_; 00140 public: 00143 UserTrack(); 00146 ~UserTrack(); 00150 db_user get2add(string,ipaddr,string,string); 00154 bool add(string,ipaddr,string,string,ipaddr); 00158 bool del(string,ipaddr,string); 00161 void periodic(); 00162 }; 00163 00164 }; 00165 00166 #endif //__USERTRACK_H__