diff options
| author | Devendra | 2013-12-14 03:09:03 +0530 |
|---|---|---|
| committer | Devendra | 2013-12-14 03:09:03 +0530 |
| commit | 1d601e3411af27c1b39e697849a538b692a535e7 (patch) | |
| tree | 44e494f838da6fe2369718ef3c580c887bf018ae | |
| parent | 56a6a2cf5e798f412621a2ed4a6d2cb5356ee156 (diff) | |
| download | pubnub-python-staging-3.3.5.tar.bz2 | |
fixing encryption to be compatible with JS and javastaging-3.3.5
| -rw-r--r-- | VERSION | 2 | ||||
| -rw-r--r-- | common/PubnubBase.py | 34 | ||||
| -rw-r--r-- | common/PubnubCore.py | 2 | ||||
| -rw-r--r-- | python-tornado/Pubnub.py | 37 | ||||
| -rw-r--r-- | python-tornado/unassembled/Platform.py | 1 | ||||
| -rw-r--r-- | python-twisted/Pubnub.py | 37 | ||||
| -rw-r--r-- | python-twisted/unassembled/Platform.py | 1 | ||||
| -rw-r--r-- | python/Pubnub.py | 38 |
8 files changed, 20 insertions, 132 deletions
@@ -1 +1 @@ -3.3.4 +3.3.5 diff --git a/common/PubnubBase.py b/common/PubnubBase.py index 64d43ed..5856921 100644 --- a/common/PubnubBase.py +++ b/common/PubnubBase.py @@ -42,6 +42,7 @@ class PubnubBase(object): self.secret_key = secret_key self.cipher_key = cipher_key self.ssl = ssl_on + self.pc = PubnubCrypto() if self.ssl : self.origin = 'https://' + self.origin @@ -69,22 +70,7 @@ class PubnubBase(object): def encrypt(self, message): if self.cipher_key: - pc = PubnubCrypto() - out = [] - if type( message ) == type(list()): - for item in message: - encryptItem = pc.encrypt(self.cipher_key, item ).rstrip() - out.append(encryptItem) - message = json.dumps(out) - elif type( message ) == type(dict()): - outdict = {} - for k, item in message.iteritems(): - encryptItem = pc.encrypt(self.cipher_key, item ).rstrip() - outdict[k] = encryptItem - out.append(outdict) - message = json.dumps(out[0]) - else: - message = json.dumps(pc.encrypt(self.cipher_key, json.dumps(message)).replace('\n','')) + message = json.dumps(self.pc.encrypt(self.cipher_key, json.dumps(message)).replace('\n','')) else : message = json.dumps(message) @@ -92,21 +78,7 @@ class PubnubBase(object): def decrypt(self, message): if self.cipher_key: - pc = PubnubCrypto() - if type( message ) == type(list()): - for item in message: - encryptItem = pc.decrypt(self.cipher_key, item ) - out.append(encryptItem) - message = out - elif type( message ) == type(dict()): - outdict = {} - for k, item in message.iteritems(): - encryptItem = pc.decrypt(self.cipher_key, item ) - outdict[k] = encryptItem - out.append(outdict) - message = out[0] - else: - message = pc.decrypt(self.cipher_key, message) + message = self.pc.decrypt(self.cipher_key, message) return message diff --git a/common/PubnubCore.py b/common/PubnubCore.py index 9a4fcae..dcfd319 100644 --- a/common/PubnubCore.py +++ b/common/PubnubCore.py @@ -106,7 +106,7 @@ class PubnubCore(PubnubBase): ## Run user Callback and Reconnect if user permits. for message in messages : - if not callback(message) : + if not callback(self.decrypt(message)) : return except Exception: diff --git a/python-tornado/Pubnub.py b/python-tornado/Pubnub.py index 268cd6a..89c0d97 100644 --- a/python-tornado/Pubnub.py +++ b/python-tornado/Pubnub.py @@ -6,7 +6,7 @@ ## http://www.pubnub.com/ ## ----------------------------------- -## PubNub 3.3.4 Real-time Push Cloud API +## PubNub 3.3.5 Real-time Push Cloud API ## ----------------------------------- @@ -137,6 +137,7 @@ class PubnubBase(object): self.secret_key = secret_key self.cipher_key = cipher_key self.ssl = ssl_on + self.pc = PubnubCrypto() if self.ssl : self.origin = 'https://' + self.origin @@ -164,22 +165,7 @@ class PubnubBase(object): def encrypt(self, message): if self.cipher_key: - pc = PubnubCrypto() - out = [] - if type( message ) == type(list()): - for item in message: - encryptItem = pc.encrypt(self.cipher_key, item ).rstrip() - out.append(encryptItem) - message = json.dumps(out) - elif type( message ) == type(dict()): - outdict = {} - for k, item in message.iteritems(): - encryptItem = pc.encrypt(self.cipher_key, item ).rstrip() - outdict[k] = encryptItem - out.append(outdict) - message = json.dumps(out[0]) - else: - message = json.dumps(pc.encrypt(self.cipher_key, json.dumps(message)).replace('\n','')) + message = json.dumps(self.pc.encrypt(self.cipher_key, json.dumps(message)).replace('\n','')) else : message = json.dumps(message) @@ -187,21 +173,7 @@ class PubnubBase(object): def decrypt(self, message): if self.cipher_key: - pc = PubnubCrypto() - if type( message ) == type(list()): - for item in message: - encryptItem = pc.decrypt(self.cipher_key, item ) - out.append(encryptItem) - message = out - elif type( message ) == type(dict()): - outdict = {} - for k, item in message.iteritems(): - encryptItem = pc.decrypt(self.cipher_key, item ) - outdict[k] = encryptItem - out.append(outdict) - message = out[0] - else: - message = pc.decrypt(self.cipher_key, message) + message = self.pc.decrypt(self.cipher_key, message) return message @@ -681,7 +653,6 @@ except ImportError: import hmac import tornado.ioloop from tornado.stack_context import ExceptionStackContext -from PubnubCrypto import PubnubCrypto ioloop = tornado.ioloop.IOLoop.instance() diff --git a/python-tornado/unassembled/Platform.py b/python-tornado/unassembled/Platform.py index 7565fd2..62d3a26 100644 --- a/python-tornado/unassembled/Platform.py +++ b/python-tornado/unassembled/Platform.py @@ -10,7 +10,6 @@ except ImportError: import hmac import tornado.ioloop from tornado.stack_context import ExceptionStackContext -from PubnubCrypto import PubnubCrypto ioloop = tornado.ioloop.IOLoop.instance() diff --git a/python-twisted/Pubnub.py b/python-twisted/Pubnub.py index 283e121..66534b5 100644 --- a/python-twisted/Pubnub.py +++ b/python-twisted/Pubnub.py @@ -6,7 +6,7 @@ ## http://www.pubnub.com/ ## ----------------------------------- -## PubNub 3.3.4 Real-time Push Cloud API +## PubNub 3.3.5 Real-time Push Cloud API ## ----------------------------------- @@ -137,6 +137,7 @@ class PubnubBase(object): self.secret_key = secret_key self.cipher_key = cipher_key self.ssl = ssl_on + self.pc = PubnubCrypto() if self.ssl : self.origin = 'https://' + self.origin @@ -164,22 +165,7 @@ class PubnubBase(object): def encrypt(self, message): if self.cipher_key: - pc = PubnubCrypto() - out = [] - if type( message ) == type(list()): - for item in message: - encryptItem = pc.encrypt(self.cipher_key, item ).rstrip() - out.append(encryptItem) - message = json.dumps(out) - elif type( message ) == type(dict()): - outdict = {} - for k, item in message.iteritems(): - encryptItem = pc.encrypt(self.cipher_key, item ).rstrip() - outdict[k] = encryptItem - out.append(outdict) - message = json.dumps(out[0]) - else: - message = json.dumps(pc.encrypt(self.cipher_key, json.dumps(message)).replace('\n','')) + message = json.dumps(self.pc.encrypt(self.cipher_key, json.dumps(message)).replace('\n','')) else : message = json.dumps(message) @@ -187,21 +173,7 @@ class PubnubBase(object): def decrypt(self, message): if self.cipher_key: - pc = PubnubCrypto() - if type( message ) == type(list()): - for item in message: - encryptItem = pc.decrypt(self.cipher_key, item ) - out.append(encryptItem) - message = out - elif type( message ) == type(dict()): - outdict = {} - for k, item in message.iteritems(): - encryptItem = pc.decrypt(self.cipher_key, item ) - outdict[k] = encryptItem - out.append(outdict) - message = out[0] - else: - message = pc.decrypt(self.cipher_key, message) + message = self.pc.decrypt(self.cipher_key, message) return message @@ -703,6 +675,7 @@ class Pubnub(PubnubCoreAsync): publish_key=publish_key, subscribe_key=subscribe_key, secret_key=secret_key, + cipher_key=cipher_key, ssl_on=ssl_on, origin=origin, ) diff --git a/python-twisted/unassembled/Platform.py b/python-twisted/unassembled/Platform.py index e4ae680..7318703 100644 --- a/python-twisted/unassembled/Platform.py +++ b/python-twisted/unassembled/Platform.py @@ -32,6 +32,7 @@ class Pubnub(PubnubCoreAsync): publish_key=publish_key, subscribe_key=subscribe_key, secret_key=secret_key, + cipher_key=cipher_key, ssl_on=ssl_on, origin=origin, ) diff --git a/python/Pubnub.py b/python/Pubnub.py index 680e64c..59a38af 100644 --- a/python/Pubnub.py +++ b/python/Pubnub.py @@ -6,7 +6,7 @@ ## http://www.pubnub.com/ ## ----------------------------------- -## PubNub 3.3.4 Real-time Push Cloud API +## PubNub 3.3.5 Real-time Push Cloud API ## ----------------------------------- @@ -137,6 +137,7 @@ class PubnubBase(object): self.secret_key = secret_key self.cipher_key = cipher_key self.ssl = ssl_on + self.pc = PubnubCrypto() if self.ssl : self.origin = 'https://' + self.origin @@ -164,22 +165,7 @@ class PubnubBase(object): def encrypt(self, message): if self.cipher_key: - pc = PubnubCrypto() - out = [] - if type( message ) == type(list()): - for item in message: - encryptItem = pc.encrypt(self.cipher_key, item ).rstrip() - out.append(encryptItem) - message = json.dumps(out) - elif type( message ) == type(dict()): - outdict = {} - for k, item in message.iteritems(): - encryptItem = pc.encrypt(self.cipher_key, item ).rstrip() - outdict[k] = encryptItem - out.append(outdict) - message = json.dumps(out[0]) - else: - message = json.dumps(pc.encrypt(self.cipher_key, json.dumps(message)).replace('\n','')) + message = json.dumps(self.pc.encrypt(self.cipher_key, json.dumps(message)).replace('\n','')) else : message = json.dumps(message) @@ -187,21 +173,7 @@ class PubnubBase(object): def decrypt(self, message): if self.cipher_key: - pc = PubnubCrypto() - if type( message ) == type(list()): - for item in message: - encryptItem = pc.decrypt(self.cipher_key, item ) - out.append(encryptItem) - message = out - elif type( message ) == type(dict()): - outdict = {} - for k, item in message.iteritems(): - encryptItem = pc.decrypt(self.cipher_key, item ) - outdict[k] = encryptItem - out.append(outdict) - message = out[0] - else: - message = pc.decrypt(self.cipher_key, message) + message = self.pc.decrypt(self.cipher_key, message) return message @@ -595,7 +567,7 @@ class PubnubCore(PubnubBase): ## Run user Callback and Reconnect if user permits. for message in messages : - if not callback(message) : + if not callback(self.decrypt(message)) : return except Exception: |
