def addPrivilege(self, privilege): """ Adds the passed privilege to list if it's not in it, yet. @param privilege: A privilege. @type privilege: L{Privilege} object """ inList = False for priv in self.privileges: if priv == privilege: inList = True if not inList: newPrivilege = Privilege() newPrivilege.copy(privilege) self.privileges.append(newPrivilege)
def __init__(self, domroot=None): """ Constructor should be called with either no parameters (create blank GrantDeny), or one parameter (a DOM tree). @param domroot: A DOM tree (default: None). @type domroot: L{webdav.WebdavResponse.Element} object @raise WebdavError: When non-valid parameters are passed a L{WebdavError} is raised. """ self.grantDeny = 0 # 0: deny, 1: grant self.privileges = [] if domroot: self.grantDeny = (domroot.name == Constants.TAG_GRANT) for child in domroot.children: if child.name == Constants.TAG_PRIVILEGE and child.ns == Constants.NS_DAV: self.privileges.append(Privilege(domroot=child)) else: # This shouldn't happen, someone screwed up with the params ... raise WebdavError('Non-privilege tag handed to GrantDeny constructor: %s' \ % child.name) elif domroot == None: # no param ==> blank object pass else: # This shouldn't happen, someone screwed up with the params ... raise WebdavError('Non-valid parameters handed to GrantDeny constructor.')
def getCurrentUserPrivileges(self): """ Returns a tuple of the current user privileges. @return: list of Privilege instances @rtype: list of L{Privilege<webdav.acp.Privilege.Privilege>} """ privileges = self.readProperty(Constants.NS_DAV, Constants.PROP_CURRENT_USER_PRIVILEGE_SET) result = [] for child in privileges.children: result.append(Privilege(domroot=child)) return result
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from webdav import Constants from webdav.acp.Acl import ACL from webdav.acp.Ace import ACE from webdav.acp.GrantDeny import GrantDeny from webdav.acp.Privilege import Privilege from webdav.acp.Principal import Principal __version__ = "$LastChangedRevision$" privileges = [ Constants.TAG_READ, Constants.TAG_WRITE, Constants.TAG_WRITE_PROPERTIES, Constants.TAG_WRITE_CONTENT, Constants.TAG_UNLOCK, Constants.TAG_READ_ACL, Constants.TAG_READ_CURRENT_USER_PRIVILEGE_SET, Constants.TAG_WRITE_ACL, Constants.TAG_ALL, Constants.TAG_BIND, Constants.TAG_UNBIND, Constants.TAG_TAMINO_SECURITY, Constants.TAG_BIND_COLLECTION, Constants.TAG_UNBIND_COLLECTION, Constants.TAG_READ_PRIVATE_PROPERTIES, Constants.TAG_WRITE_PRIVATE_PROPERTIES ] Privilege.registerPrivileges(privileges)
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from webdav import Constants from webdav.acp.Acl import ACL from webdav.acp.Ace import ACE from webdav.acp.GrantDeny import GrantDeny from webdav.acp.Privilege import Privilege from webdav.acp.Principal import Principal __version__ = "$LastChangedRevision$" privileges = [Constants.TAG_READ, Constants.TAG_WRITE, Constants.TAG_WRITE_PROPERTIES, Constants.TAG_WRITE_CONTENT, Constants.TAG_UNLOCK, Constants.TAG_READ_ACL, Constants.TAG_READ_CURRENT_USER_PRIVILEGE_SET, Constants.TAG_WRITE_ACL, Constants.TAG_ALL, Constants.TAG_BIND, Constants.TAG_UNBIND, Constants.TAG_TAMINO_SECURITY, Constants.TAG_BIND_COLLECTION, Constants.TAG_UNBIND_COLLECTION, Constants.TAG_READ_PRIVATE_PROPERTIES, Constants.TAG_WRITE_PRIVATE_PROPERTIES] Privilege.registerPrivileges(privileges)