Exemplo n.º 1
0
 def _do_validate_my_info(self, inp):
     if not inp:
         return None
     if not inp or not isinstance(inp, dict):
         return None
     out = inp.copy()
     try:
         my_revision = int(out['revision'])
         if my_revision < 1:
             raise Exception('invalid revision')
     except Exception as exc:
         lg.warn(str(exc))
         return None
     try:
         suppliers = out['suppliers']
         if not isinstance(suppliers, list) or len(suppliers) < 1:
             raise Exception('must include some suppliers')
     except Exception as exc:
         lg.warn(str(exc))
         return None
     try:
         ecc_map = out['ecc_map']
         if ecc_map and ecc_map not in eccmap.EccMapNames():
             raise Exception('invalid ecc_map name')
     except Exception as exc:
         lg.warn(str(exc))
         return None
     try:
         out['publisher_idurl']
         # TODO: if I am a publisher - revision number must be the same as my info
     except Exception as exc:
         lg.warn(str(exc))
         return None
     try:
         customer_idurl = out['customer_idurl']
         if customer_idurl != self.customer_idurl:
             raise Exception('invalid customer_idurl')
     except Exception as exc:
         lg.warn(str(exc))
         return None
     return out
Exemplo n.º 2
0
 def _do_validate_dht_info(self, inp):
     if not inp or not isinstance(inp, dict):
         return None
     out = inp.copy()
     try:
         dht_revision = int(out['revision'])
         suppliers = out['suppliers']
         ecc_map = out['ecc_map']
         if dht_revision < 1:
             raise Exception('invalid revision')
         if not isinstance(suppliers, list) or len(suppliers) < 1:
             raise Exception('must include some suppliers')
         if ecc_map and ecc_map not in eccmap.EccMapNames():
             raise Exception('invalid ecc_map name')
         out['publisher_idurl']
         # TODO: add publisher_signature and Validate method to check publisher signature
         out['customer_idurl']
         # TODO: add customer_signature and Validate method to check customer signature
     except:
         lg.exc()
         lg.warn('skip invalid DHT info and assume DHT record is not exist')
         return None
     return out