Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Examples

vos/corelibs/vos/accesscontrol.cc

Go to the documentation of this file.
00001 /*
00002     This file is part of the Virtual Object System of
00003     the Interreality project (http://interreality.org).
00004 
00005     Copyright (C) 2001-2003 Peter Amstutz
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00020 
00021     Peter Amstutz <tetron@interreality.org>
00022 */
00023 
00024 #include "accesscontrol.hh"
00025 
00026 using namespace VOS;
00027 
00028 /** @file
00029     implements NoAccessControl, ReadOnlyAccessControl, and LocalOnlyAccessControl
00030 */
00031 
00032 map<string, VobjectAccessControl::AssignAC> VobjectAccessControl::policies;
00033 
00034 NoAccessControl NoAccessControl::static_;
00035 ReadOnlyAccessControl ReadOnlyAccessControl::static_;
00036 LocalOnlyAccessControl LocalOnlyAccessControl::static_;
00037 
00038 
00039 void VobjectAccessControl::addPolicy(VobjectAccessControl* ac)
00040 {
00041     policies[ac->getPolicyName()].ac = ac;
00042     policies[ac->getPolicyName()].fac = 0;
00043 }
00044 
00045 void VobjectAccessControl::addPolicyFactory(const string& name, VobjectAccessControlFactory ac)
00046 {
00047     policies[name].ac = 0;
00048     policies[name].fac = ac;
00049 }
00050 
00051 VobjectAccessControl* VobjectAccessControl::getPolicy(const string& name, LocalVobject* lv)
00052 {
00053     if(policies.count(name)) {
00054         if(policies[name].ac) return policies[name].ac;
00055         else {
00056             return (*policies[name].fac)(name, lv);
00057         }
00058     } else return 0;
00059 }
00060 
00061 void VobjectAccessControl::removePolicy(const string& name)
00062 {
00063     policies.erase(name);
00064 }
00065 
00066 bool NoAccessControl::checkReadChildPermission(VobjectEvent& e, string& message)
00067 { return true; }
00068 
00069 bool NoAccessControl::checkReadTypePermission(VobjectEvent& e, string& message)
00070 { return true; }
00071 
00072 bool NoAccessControl::checkReadParentPermission(VobjectEvent& e, string& message)
00073 { return true; }
00074 
00075 bool NoAccessControl::checkAddTypePermission(VobjectEvent& e, string& message)
00076 { return true; }
00077 
00078 bool NoAccessControl::checkSetChildPermission(VobjectEvent& e, string& message)
00079 { return true; }
00080 
00081 bool NoAccessControl::checkInsertChildPermission(VobjectEvent& e, string& message)
00082 { return true; }
00083 
00084 bool NoAccessControl::checkRemoveChildPermission(VobjectEvent& e, string& message)
00085 { return true; }
00086 
00087 bool NoAccessControl::checkCreateVobjectPermission(Vobject& requester, Site& site, const string name,
00088                                                    const deque<string> types, string& message)
00089 { return true; }
00090 
00091 bool NoAccessControl::checkChildListenPermission(VobjectEvent& e, string& message)
00092 { return true; }
00093 
00094 bool NoAccessControl::checkParentListenPermission(VobjectEvent& e, string& message)
00095 { return true; }
00096 
00097 const string NoAccessControl::getPolicyName()
00098 { return "insecure"; }
00099 
00100 
00101 
00102 bool ReadOnlyAccessControl::checkReadChildPermission(VobjectEvent& e, string& message)
00103 { return true; }
00104 
00105 bool ReadOnlyAccessControl::checkReadTypePermission(VobjectEvent& e, string& message)
00106 { return true; }
00107 
00108 bool ReadOnlyAccessControl::checkReadParentPermission(VobjectEvent& e, string& message)
00109 { return true; }
00110 
00111 bool ReadOnlyAccessControl::checkAddTypePermission(VobjectEvent& e, string& message)
00112 { return false; }
00113 
00114 bool ReadOnlyAccessControl::checkSetChildPermission(VobjectEvent& e, string& message)
00115 { return false; }
00116 
00117 bool ReadOnlyAccessControl::checkInsertChildPermission(VobjectEvent& e, string& message)
00118 { return false; }
00119 
00120 bool ReadOnlyAccessControl::checkRemoveChildPermission(VobjectEvent& e, string& message)
00121 { return false; }
00122 
00123 bool ReadOnlyAccessControl::checkCreateVobjectPermission(Vobject& e, Site& site, const string name,
00124                                                          const deque<string> types, string& message)
00125 { return false; }
00126 
00127 bool ReadOnlyAccessControl::checkChildListenPermission(VobjectEvent& e, string& message)
00128 { return true; }
00129 
00130 bool ReadOnlyAccessControl::checkParentListenPermission(VobjectEvent& e, string& message)
00131 { return true; }
00132 
00133 const string ReadOnlyAccessControl::getPolicyName()
00134 { return "readonly"; }
00135 
00136 
00137 
00138 bool LocalOnlyAccessControl::checkReadChildPermission(VobjectEvent& e, string& message)
00139 { return false; }
00140 
00141 bool LocalOnlyAccessControl::checkReadTypePermission(VobjectEvent& e, string& message)
00142 { return false; }
00143 
00144 bool LocalOnlyAccessControl::checkReadParentPermission(VobjectEvent& e, string& message)
00145 { return false; }
00146 
00147 bool LocalOnlyAccessControl::checkAddTypePermission(VobjectEvent& e, string& message)
00148 { return false; }
00149 
00150 bool LocalOnlyAccessControl::checkSetChildPermission(VobjectEvent& e, string& message)
00151 { return false; }
00152 
00153 bool LocalOnlyAccessControl::checkInsertChildPermission(VobjectEvent& e, string& message)
00154 { return false; }
00155 
00156 bool LocalOnlyAccessControl::checkRemoveChildPermission(VobjectEvent& e, string& message)
00157 { return false; }
00158 
00159 bool LocalOnlyAccessControl::checkCreateVobjectPermission(Vobject& requester, Site& site,
00160                                                           const string name, const deque<string> types,
00161                                                           string& message)
00162 { return false; }
00163 
00164 bool LocalOnlyAccessControl::checkChildListenPermission(VobjectEvent& e, string& message)
00165 { return false; }
00166 
00167 bool LocalOnlyAccessControl::checkParentListenPermission(VobjectEvent& e, string& message)
00168 { return false; }
00169 
00170 const string LocalOnlyAccessControl::getPolicyName()
00171 { return "localonly"; }

Generated on Tue Aug 12 03:55:39 2003 for Interreality Project - VOS by doxygen 1.3.2