Skip to content

Commit c78a932

Browse files
author
Roland Hedberg
committed
Slowly moving from six to future.backports
pycryptodomex from pypi now constructs Cryptodome module on OS X too.
1 parent 6950abd commit c78a932

File tree

8 files changed

+37
-18
lines changed

8 files changed

+37
-18
lines changed

src/saml2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
provides methods and functions to convert SAML classes to and from strings.
1818
"""
1919

20-
__version__ = "4.0.3"
20+
__version__ = "4.0.4rc1"
2121

2222
import logging
2323
import six

src/saml2/aes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env python
22
import os
3+
from base64 import b64encode
4+
from base64 import b64decode
5+
36
from Cryptodome import Random
47
from Cryptodome.Cipher import AES
5-
from base64 import b64encode, b64decode
68

79
__author__ = 'rolandh'
810

src/saml2/entity.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import base64
2-
# from binascii import hexlify
3-
from binascii import hexlify
42
import copy
53
import logging
6-
from hashlib import sha1
7-
from Cryptodome.PublicKey import RSA
84
import requests
95
import six
6+
7+
from binascii import hexlify
8+
from hashlib import sha1
9+
10+
# from Crypto.PublicKey import RSA
11+
from Cryptodome.PublicKey import RSA
12+
1013
from saml2.metadata import ENDPOINTS
1114
from saml2.profile import paos, ecp
1215
from saml2.soap import parse_soap_enveloped_saml_artifact_resolve

src/saml2/httputil.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
import cgi
66
import six
77

8-
from six.moves.urllib.parse import quote, parse_qs
9-
from six.moves.http_cookies import SimpleCookie
8+
from future.backports.http.cookies import SimpleCookie
9+
from future.backports.urllib.parse import quote
10+
from future.backports.urllib.parse import parse_qs
1011

11-
from saml2 import BINDING_HTTP_ARTIFACT, SAMLError
12+
from saml2 import BINDING_HTTP_ARTIFACT
1213
from saml2 import BINDING_HTTP_REDIRECT
1314
from saml2 import BINDING_HTTP_POST
1415
from saml2 import BINDING_URI
1516
from saml2 import BINDING_SOAP
17+
from saml2 import SAMLError
1618
from saml2 import time_util
1719

1820
__author__ = 'rohe0002'
@@ -240,10 +242,7 @@ def unpack_redirect(environ):
240242

241243

242244
def unpack_post(environ):
243-
try:
244-
return dict([(k, v[0]) for k, v in parse_qs(get_post(environ))])
245-
except Exception:
246-
return None
245+
return dict([(k, v[0]) for k, v in parse_qs(get_post(environ))])
247246

248247

249248
def unpack_soap(environ):

src/saml2/s2repoze/plugins/sp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
WSGI application.
66
77
"""
8-
import cgi
98
import logging
109
import sys
1110
import platform
1211
import shelve
1312
import traceback
1413
import saml2
1514
import six
16-
from six.moves.urllib.parse import parse_qs, urlparse
1715
from saml2.samlp import Extensions
1816
from saml2 import xmldsig as ds
1917

18+
from future.backports.urllib.parse import parse_qs
19+
from future.backports.urllib.parse import urlparse
20+
2021
from six import StringIO
2122

2223
from paste.httpexceptions import HTTPSeeOther, HTTPRedirection

src/saml2/s_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def rndstr(size=16, alphabet=""):
169169
alphabet = string.ascii_letters[0:52] + string.digits
170170
return type(alphabet)().join(rng.choice(alphabet) for _ in range(size))
171171

172+
172173
def rndbytes(size=16, alphabet=""):
173174
"""
174175
Returns rndstr always as a binary type

src/saml2/saml.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ def _decode_attribute_value(typ, text):
101101

102102

103103
def _verify_value_type(typ, val):
104-
#print("verify value type: %s, %s" % (typ, val))
104+
# print("verify value type: %s, %s" % (typ, val))
105105
if typ == XSD + "string":
106106
try:
107107
return str(val)
108108
except UnicodeEncodeError:
109-
return unicode(val)
109+
if six.PY2:
110+
return unicode(val)
111+
else:
112+
return val.decode('utf8')
110113
if typ == XSD + "integer" or typ == XSD + "int":
111114
return int(val)
112115
if typ == XSD + "float" or typ == XSD + "double":

src/saml2/sigver.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@
1212
import logging
1313
import os
1414
import ssl
15-
from six.moves.urllib.parse import urlencode
1615

1716
from time import mktime
1817
from binascii import hexlify
18+
from future.backports.urllib.parse import urlencode
1919
import six
2020

21+
# from Crypto.PublicKey.RSA import importKey
22+
# from Crypto.Signature import PKCS1_v1_5
23+
# from Crypto.Util.asn1 import DerSequence
24+
# from Crypto.PublicKey import RSA
25+
# from Crypto.Hash import SHA
26+
# from Crypto.Hash import SHA224
27+
# from Crypto.Hash import SHA256
28+
# from Crypto.Hash import SHA384
29+
# from Crypto.Hash import SHA512
30+
2131
from Cryptodome.PublicKey.RSA import importKey
2232
from Cryptodome.Signature import PKCS1_v1_5
2333
from Cryptodome.Util.asn1 import DerSequence

0 commit comments

Comments
 (0)