def Valid(self, raise_signature_invalid=False): """ ``Valid()`` should check every one of packet header fields: 1) that command is one of the legal commands 2) signature is good (which means the hashcode is good) Rest PREPRO: 3) all the number fields are just numbers 4) length is within legal limits 5) check that URL is a good URL 6) that DataOrParity is either "data" or "parity" 7) that Creator is equal to owner or a scrubber for owner 8) etc. """ if not self.Ready(): if _Debug: lg.out(_DebugLevel, "signed.Valid packet is not ready yet " + str(self)) return False if not commands.IsCommand(self.Command): lg.warn("signed.Valid bad Command " + str(self.Command)) return False if not self.SignatureChecksOut( raise_signature_invalid=raise_signature_invalid): if raise_signature_invalid: creator_xml = contactsdb.get_contact_identity(self.CreatorID) if creator_xml: creator_xml = creator_xml.serialize(as_text=True) owner_xml = contactsdb.get_contact_identity(self.OwnerID) if owner_xml: owner_xml = owner_xml.serialize(as_text=True) raise Exception( 'signature is not valid for %r:\n\n%r\n\ncreator:\n\n%r\n\nowner:\n\n%r' % (self, self.Serialize(), creator_xml, owner_xml)) lg.warn("signed.Valid Signature IS NOT VALID!!!") return False return True
def Valid(self): """ ``Valid()`` should check every one of packet header fields: 1) that command is one of the legal commands 2) signature is good (which means the hashcode is good) Rest PREPRO: 3) all the number fields are just numbers 4) length is within legal limits 5) check that URL is a good URL 6) that DataOrParity is either "data" or "parity" 7) that Creator is equal to owner or a scrubber for owner 8) etc. """ if not self.Ready(): lg.out(4, "signed.Valid packet is not ready yet " + str(self)) return False if not commands.IsCommand(self.Command): lg.warn("signed.Valid bad Command " + str(self.Command)) return False if not self.SignatureChecksOut(): lg.warn("signed.Valid Signature IS NOT VALID!!!") return False return True