summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Wagner <bwgpro@gmail.com>2015-02-13 15:43:36 -0200
committerBruno Wagner <bwgpro@gmail.com>2015-02-13 15:43:36 -0200
commit8155a694833d7544411b9775caf97f7c11bd2411 (patch)
treeb2c451233dfd1353c3ca7f5b23fe46d0e4768566
parentbc38ec9aa38acb9f0488228ed95f2b951e7a0917 (diff)
Fixed encryption status check and changed signature status logic
-rw-r--r--service/pixelated/adapter/model/mail.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index dc05a4de..cf665c9e 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -299,14 +299,9 @@ class PixelatedMail(Mail):
@property
def security_casing(self):
casing = {"imprints": [], "locks": []}
- if self.signed:
- casing["imprints"].append({"state": "valid", "seal": {"validity": "valid"}})
- elif self.signed is None:
- casing["imprints"].append({"state": "no_signature_information"})
-
+ casing["imprints"] = self.signature_information
if self.encrypted:
- casing["locks"].append({"state": "valid"})
-
+ casing["locks"] = [{"state": "valid"}]
return casing
@property
@@ -370,17 +365,20 @@ class PixelatedMail(Mail):
return tag in self.tags
@property
- def signed(self):
+ def signature_information(self):
signature = self.hdoc.content["headers"].get("X-Leap-Signature", None)
- if signature is None:
- return None
+ if signature is None or signature.startswith("could not verify"):
+ return [{"state": "no_signature_information"}]
else:
- return signature.startswith("valid")
+ if signature.startswith("valid"):
+ return [{"state": "valid", "seal": {"validity": "valid"}}]
+ else:
+ return []
@property
def encrypted(self):
return self.hdoc.content["headers"].get("OpenPGP", None) is not None or \
- self.hdoc.content["headers"].get("X-Pixelated-encryption-status", "false") is "true"
+ self.hdoc.content["headers"].get("X-Pixelated-encryption-status", "false") == "true"
def as_dict(self):
dict_mail = {'header': {k.lower(): v for k, v in self.headers.items()},