00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _ACCESSCONTROL_HH_
00024 #define _ACCESSCONTROL_HH_
00025
00026 #include <vos/corelibs/vos/vosdefs.hh>
00027
00028 #include <string>
00029 #include <map>
00030 #include <deque>
00031
00032
00033
00034
00035
00036 namespace VOS
00037 {
00038 class VobjectAccessControl;
00039 class LocalVobject;
00040 class Vobject;
00041 class VobjectEvent;
00042 class Site;
00043
00044 typedef VobjectAccessControl* (*VobjectAccessControlFactory)(const string& type, LocalVobject* lv);
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 class VOS_API VobjectAccessControl
00057 {
00058 private:
00059 struct AssignAC
00060 {
00061 VobjectAccessControl* ac;
00062 VobjectAccessControlFactory fac;
00063 };
00064 static map<string, AssignAC> policies;
00065
00066 public:
00067
00068
00069
00070
00071 virtual bool checkReadChildPermission(VobjectEvent& e, string& message) = 0;
00072
00073
00074
00075
00076
00077 virtual bool checkReadTypePermission(VobjectEvent& e, string& message) = 0;
00078
00079
00080
00081
00082
00083 virtual bool checkAddTypePermission(VobjectEvent& e, string& message) = 0;
00084
00085
00086
00087
00088
00089 virtual bool checkReadParentPermission(VobjectEvent& e, string& message) = 0;
00090
00091
00092
00093
00094
00095 virtual bool checkSetChildPermission(VobjectEvent& e, string& message) = 0;
00096
00097
00098
00099
00100
00101 virtual bool checkInsertChildPermission(VobjectEvent& e, string& message) = 0;
00102
00103
00104
00105
00106
00107 virtual bool checkRemoveChildPermission(VobjectEvent& e, string& message) = 0;
00108
00109
00110
00111
00112
00113
00114 virtual bool checkChildListenPermission(VobjectEvent& e, string& message) = 0;
00115
00116
00117
00118
00119
00120
00121 virtual bool checkParentListenPermission(VobjectEvent& e, string& message) = 0;
00122
00123
00124
00125 virtual const string getPolicyName() = 0;
00126
00127
00128
00129
00130
00131 static void addPolicy(VobjectAccessControl* ac);
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 static void addPolicyFactory(const string& name, VobjectAccessControlFactory ac);
00145
00146
00147
00148
00149
00150
00151
00152
00153 static VobjectAccessControl* getPolicy(const string& name, LocalVobject* lv);
00154
00155
00156
00157
00158 static void removePolicy(const string& name);
00159 };
00160
00161
00162
00163 class VOS_API SiteAccessControl : public VobjectAccessControl
00164 {
00165 public:
00166
00167
00168
00169
00170
00171
00172
00173 virtual bool checkCreateVobjectPermission(Vobject& requester, Site& site, const string name,
00174 const deque<string> types, string& message) = 0;
00175 };
00176
00177
00178
00179 class VOS_API NoAccessControl : public SiteAccessControl
00180 {
00181 public:
00182 static NoAccessControl static_;
00183
00184
00185 virtual bool checkReadChildPermission(VobjectEvent& e, string& message);
00186
00187 virtual bool checkReadTypePermission(VobjectEvent& e, string& message);
00188
00189 virtual bool checkReadParentPermission(VobjectEvent& e, string& message);
00190
00191 virtual bool checkAddTypePermission(VobjectEvent& e, string& message);
00192
00193 virtual bool checkSetChildPermission(VobjectEvent& e, string& message);
00194
00195 virtual bool checkInsertChildPermission(VobjectEvent& e, string& message);
00196
00197 virtual bool checkRemoveChildPermission(VobjectEvent& e, string& message);
00198
00199 virtual bool checkCreateVobjectPermission(Vobject& requester, Site& site, const string name,
00200 const deque<string> types, string& message);
00201
00202 virtual bool checkChildListenPermission(VobjectEvent& e, string& message);
00203
00204 virtual bool checkParentListenPermission(VobjectEvent& e, string& message);
00205
00206 virtual const string getPolicyName();
00207 };
00208
00209
00210
00211
00212 class VOS_API ReadOnlyAccessControl : public SiteAccessControl
00213 {
00214 public:
00215 static ReadOnlyAccessControl static_;
00216
00217
00218 virtual bool checkReadChildPermission(VobjectEvent& e, string& message);
00219
00220 virtual bool checkReadTypePermission(VobjectEvent& e, string& message);
00221
00222 virtual bool checkReadParentPermission(VobjectEvent& e, string& message);
00223
00224 virtual bool checkAddTypePermission(VobjectEvent& e, string& message);
00225
00226 virtual bool checkSetChildPermission(VobjectEvent& e, string& message);
00227
00228 virtual bool checkInsertChildPermission(VobjectEvent& e, string& message);
00229
00230 virtual bool checkRemoveChildPermission(VobjectEvent& e, string& message);
00231
00232 virtual bool checkCreateVobjectPermission(Vobject& requester, Site& site, const string name,
00233 const deque<string> types, string& message);
00234
00235 virtual bool checkChildListenPermission(VobjectEvent& e, string& message);
00236
00237 virtual bool checkParentListenPermission(VobjectEvent& e, string& message);
00238
00239 virtual const string getPolicyName();
00240 };
00241
00242
00243
00244 class VOS_API LocalOnlyAccessControl : public SiteAccessControl
00245 {
00246 public:
00247 static LocalOnlyAccessControl static_;
00248
00249
00250 virtual bool checkReadChildPermission(VobjectEvent& e, string& message);
00251
00252 virtual bool checkReadTypePermission(VobjectEvent& e, string& message);
00253
00254 virtual bool checkReadParentPermission(VobjectEvent& e, string& message);
00255
00256 virtual bool checkAddTypePermission(VobjectEvent& e, string& message);
00257
00258 virtual bool checkSetChildPermission(VobjectEvent& e, string& message);
00259
00260 virtual bool checkInsertChildPermission(VobjectEvent& e, string& message);
00261
00262 virtual bool checkRemoveChildPermission(VobjectEvent& e, string& message);
00263
00264 virtual bool checkCreateVobjectPermission(Vobject& requester, Site& site, const string name,
00265 const deque<string> types, string& message);
00266
00267 virtual bool checkChildListenPermission(VobjectEvent& e, string& message);
00268
00269 virtual bool checkParentListenPermission(VobjectEvent& e, string& message);
00270
00271 virtual const string getPolicyName();
00272 };
00273 }
00274
00275 #endif