def report_invalid_voip_addresses(logger, report): """Find voipAddress-objects owned by persons without primary account. @param logger @type list @param report is a list of dicts. """ logger.debug('-' * 8 + 'voipAddresses' + '-' * 8) db = Factory.get("Database")() va = VoipAddress(db) for entry in va.list_voip_attributes(): if entry['voipOwnerType'] != 'person': continue # skip objects owned by services if not entry.get("cn"): entry["cn"] = () # find addresses owner va.clear() va.find(entry['entity_id']) entry["voipOwnerId"] = va.owner_entity_id if entry["uid"] is None: logger.debug('uid is None') entry['reason'] = find_reason(db, entry) entr = {} for k, v in entry.iteritems(): if k in ('entity_id', 'voipOwnerId', 'cn', 'reason', 'voipExtensionUri', 'uid'): if k == 'voipExtensionUri': k = 'extension' if isinstance(v, basestring): v = v.strip('sip:@uio.no') entr[k] = v report.append(entr) logger.debug('-' * 8 + 'end voipAddresses' + '-' * 8)
def can_set_new_secret(self, account_id, client_id): """Whether account_id can set a new sipSecret on client_id. """ if self.is_superuser(account_id): return True if self._is_voip_admin(account_id): return True # We allow resetting a secret to the owner of client_id. # # The test goes like this: find voip_address to which client_id is # bound. Compare it to account_id's owner_id. For non-personal # accounts this test is bound to fail. acc = Factory.get("Account")(self._db) acc.find(account_id) client = VoipClient(self._db) client.find(client_id) address = VoipAddress(self._db) address.find(client.voip_address_id) if address.owner_entity_id == acc.owner_id: return True raise PermissionDenied("Account id=%d cannot change sipSecret of " "voip_client id=%d" % (account_id, client_id))
def report_invalid_voip_addresses(logger, report): """Find voipAddress-objects owned by persons without primary account. @param logger @type list @param report is a list of dicts. """ logger.debug("-" * 8 + "voipAddresses" + "-" * 8) db = Factory.get("Database")() va = VoipAddress(db) for entry in va.list_voip_attributes(): if entry["voipOwnerType"] != "person": continue # skip objects owned by services if not entry.get("cn"): entry["cn"] = () # find addresses owner va.clear() va.find(entry["entity_id"]) entry["voipOwnerId"] = va.owner_entity_id if entry["uid"] is None: logger.debug("uid is None") entry["reason"] = find_reason(db, entry) entr = {} for k, v in entry.iteritems(): if k in ("entity_id", "voipOwnerId", "cn", "reason", "voipExtensionUri", "uid"): if k == "voipExtensionUri": k = "extension" if isinstance(v, basestring): v = v.strip("sip:@uio.no") entr[k] = v report.append(entr) logger.debug("-" * 8 + "end voipAddresses" + "-" * 8)
def _get_voip_address_by_entity_id(self, designation): """Return all voip_addresses matching the specified entity_id.""" if not self._is_numeric_id(designation): return list() value = int(designation) try: va = VoipAddress(self.db) va.find(value) return [va, ] except Errors.NotFoundError: return list() assert False, "NOTREACHED"
def _get_voip_address_by_entity_id(self, designation): """Return all voip_addresses matching the specified entity_id.""" if not self._is_numeric_id(designation): return list() value = int(designation) try: va = VoipAddress(self.db) va.find(value) return [ va, ] except Errors.NotFoundError: return list() assert False, "NOTREACHED"