From 848c4d530e0c3dd6493289b38366e08260d437ca Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Wed, 7 Aug 2013 07:02:35 +0100 Subject: Some nitpicky securemessage cleanups Remove redundant parenthesis and use a consistent commenting style. Some redundant parenthesis are retained to avoid this pep8 silliness: https://github.com/jcrocholl/pep8/issues/126 i.e. to avoid E125 we have the choice of: if (md['source'] != source or md['destination'] != target or md['expiration'] < time.time()): raise InvalidEncryptedTicket(md['source'], md['destination']) or: if ((md['source'] != source or md['destination'] != target or md['expiration'] < time.time())): raise InvalidEncryptedTicket(md['source'], md['destination']) the latter is my preference. Change-Id: Ic890bfc787a17fc77821e01e586806d1b558d530 --- openstack/common/rpc/securemessage.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'openstack/common') diff --git a/openstack/common/rpc/securemessage.py b/openstack/common/rpc/securemessage.py index 4ecab02..bcec47e 100644 --- a/openstack/common/rpc/securemessage.py +++ b/openstack/common/rpc/securemessage.py @@ -267,7 +267,7 @@ class _KDSClient(object): def get_ticket(self, source, target, crypto, key): - #prepare metadata + # prepare metadata md = {'requestor': source, 'target': target, 'timestamp': time.time(), @@ -281,17 +281,17 @@ class _KDSClient(object): reply = self._get_ticket({'metadata': metadata, 'signature': signature}) - # Verify reply + # verify reply signature = crypto.sign(key, (reply['metadata'] + reply['ticket'])) if signature != reply['signature']: raise InvalidEncryptedTicket(md['source'], md['destination']) md = jsonutils.loads(base64.b64decode(reply['metadata'])) - if (((md['source'] != source) or - (md['destination'] != target) or - (md['expiration'] < time.time()))): + if ((md['source'] != source or + md['destination'] != target or + md['expiration'] < time.time())): raise InvalidEncryptedTicket(md['source'], md['destination']) - #return ticket data + # return ticket data tkt = jsonutils.loads(crypto.decrypt(key, reply['ticket'])) return tkt, md['expiration'] -- cgit