00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __BDBSECURITYPLUGIN_H_
00016 #define __BDBSECURITYPLUGIN_H_
00017
00018 using namespace std;
00019
00023 #define __SECDATAFILE "securitydb"
00024
00025
00026 #include <SecurityPlugin.h>
00027 #include <db_cxx.h>
00028
00050 class BDBSecurityPlugin : public SecurityPlugin
00051 {
00052 typedef DbTxn transaction_t;
00053 typedef struct
00054 {
00055 NumID userID;
00056 bool hasWritePermission;
00057 bool hasDeletePermission;
00058 } docperm_t;
00059
00060 public:
00061
00062 BDBSecurityPlugin( const Config &cfg );
00063 ~BDBSecurityPlugin();
00064
00065
00066
00067 bool init();
00068
00069
00070
00071 void getLoginChallenge( string username, string &challenge );
00072 bool hasReadPermission(NumID userid, NumID docid);
00073 bool hasWritePermission(NumID userid, NumID docid);
00074 bool hasDeletePermission( NumID userid, NumID docid );
00075 CoreError fileCreated(NumID userid, NumID docid, Permission permission);
00076 CoreError changeUserPermission(NumID userid, Permission permission, NumID adminid);
00077 CoreError changeFilePermission(NumID docid, Permission permission, NumID userid);
00078 CoreError filterSearchResults(QueryResult &queryResult);
00079 CoreError addUser( const UserProfile &userProfile, string challenge, string password, NumID &userid );
00080 CoreError delUser( NumID userid );
00081 CoreError login( string username, string challenge, string response, UserProfile &user );
00082 CoreError getUserProfile( NumID userid, UserProfile &userProfile );
00083 CoreError changeUserProfile( NumID userid, const UserProfile &userProfile );
00084 CoreError setPassword( NumID userid, string challenge, string oldPassword, string newPassword );
00085 CoreError clearPassword( NumID userid );
00086 CoreError listUsers( vector<NumID> &users );
00087
00088
00089
00090 private:
00091
00092
00093
00094
00095
00096
00097 bool checkSysKeyOrSetDefault( const char *key, uint64_t defaultValue );
00098
00099
00100
00101
00102
00103
00104 transaction_t *startTransaction();
00105
00106
00107
00108
00109 void commitTransaction( transaction_t *transaction );
00110
00111
00112
00113
00114 void abortTransaction( transaction_t *transaction );
00115
00116
00117
00118
00119
00120
00121
00122 bool fetchUserID( transaction_t *txn, std::string username, NumID *userid );
00123
00124
00125
00126
00127
00128
00129
00130 bool fetchUserProfile( transaction_t *txn, NumID userid, std::string &xmlprofile );
00131
00132 Db *usrTableHandle;
00133 Db *docTableHandle;
00134 Db *sysTableHandle;
00135 DbEnv *dbEnvHandle;
00136 bool _initialized;
00137 };
00138
00139
00140
00141 static const char *key_highest_uid = "HIGHEST_UID";
00142
00143 #endif