summaryrefslogtreecommitdiff
path: root/src/saml2/eptid.py
diff options
context:
space:
mode:
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):