summaryrefslogtreecommitdiff
path: root/src/saml2/eptid.py
diff options
context:
space:
mode:
authorClint Byrum <clint@fewbar.com>2015-05-20 23:59:20 -0700
committerClint Byrum <clint@fewbar.com>2015-05-21 00:13:26 -0700
commit1fde97df3914400a15bd5c94f599634c239da628 (patch)
tree50f0c4eafde9df7168deabac8a0bb853d8a54ff7 /src/saml2/eptid.py
parent29221328be15255035b9ba221c8efaac52a68431 (diff)
downloadpysaml2-1fde97df3914400a15bd5c94f599634c239da628.tar.gz
Fix bytes/strings logical issues
Hashes, and other calls, require bytes or strings in python3 where they were different in python 2.x.
Diffstat (limited to 'src/saml2/eptid.py')
-rw-r--r--src/saml2/eptid.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/saml2/eptid.py b/src/saml2/eptid.py
index b2551b44..af5e9924 100644
--- a/src/saml2/eptid.py
+++ b/src/saml2/eptid.py
@@ -8,6 +8,7 @@ import hashlib
import shelve
import logging
+import six
logger = logging.getLogger(__name__)
@@ -21,13 +22,23 @@ class Eptid(object):
md5 = hashlib.md5()
for arg in args:
md5.update(arg.encode("utf-8"))
- md5.update(sp)
- md5.update(self.secret)
+ if isinstance(sp, six.binary_type):
+ md5.update(sp)
+ else:
+ md5.update(sp.encode('utf-8'))
+ if isinstance(self.secret, six.binary_type):
+ md5.update(self.secret)
+ else:
+ md5.update(self.secret.encode('utf-8'))
md5.digest()
hashval = md5.hexdigest()
+ if isinstance(hashval, six.binary_type):
+ hashval = hashval.decode('ascii')
return "!".join([idp, sp, hashval])
def __getitem__(self, key):
+ if six.PY3 and isinstance(key, six.binary_type):
+ key = key.decode('utf-8')
return self._db[key]
def __setitem__(self, key, value):