summaryrefslogtreecommitdiff
path: root/__init__.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2012-12-03 10:32:54 -0200
committerdrebs <drebs@leap.se>2012-12-03 10:32:54 -0200
commit920ba331bd5c11f54231c8a57fe88a5af9755725 (patch)
treecb0712b1f430853be78afff0ac46291b555644f6 /__init__.py
parentd01ca3e02798c5b4058147fbfb846be7662a2bb9 (diff)
Add LeapDocument methods for encrypting/decrypting
Diffstat (limited to '__init__.py')
-rw-r--r--__init__.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/__init__.py b/__init__.py
index 3d685635..94286370 100644
--- a/__init__.py
+++ b/__init__.py
@@ -16,6 +16,7 @@ from u1db import (
)
from swiftclient import client
+import base64
class OpenStackDatabase(CommonBackend):
@@ -148,10 +149,20 @@ class OpenStackDatabase(CommonBackend):
class LeapDocument(Document):
def get_content_encrypted(self):
- raise NotImplementedError(self.get_content_encrypted)
+ """
+ Returns document's json serialization encrypted with user's public key.
+ """
+ # TODO: replace for openpgp encryption with users's pub key.
+ return base64.b64encode(self.get_json())
def set_content_encrypted(self):
- raise NotImplementedError(self.set_content_encrypted)
+ """
+ Set document's content based on encrypted version of json string.
+ """
+ # TODO:
+ # - replace for openpgp decryption using user's priv key.
+ # - raise error if unsuccessful.
+ return self.set_json(base64.b64decode(self.get_json()))
class OpenStackSyncTarget(CommonSyncTarget):