Skip to content

Commit 257e3ab

Browse files
committed
Merge branch 'master' of https://github.com/coolbootscoder/python-saml into coolbootscoder-master
2 parents 3c77f55 + 040a4a6 commit 257e3ab

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/onelogin/saml2/auth.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
from base64 import b64encode
1515
from urllib import quote_plus
1616

17-
import dm.xmlsec.binding as xmlsec
17+
# import dm.xmlsec.binding as xmlsec
1818

1919
from onelogin.saml2.settings import OneLogin_Saml2_Settings
2020
from onelogin.saml2.response import OneLogin_Saml2_Response
2121
from onelogin.saml2.errors import OneLogin_Saml2_Error
2222
from onelogin.saml2.logout_response import OneLogin_Saml2_Logout_Response
2323
from onelogin.saml2.constants import OneLogin_Saml2_Constants
24-
from onelogin.saml2.utils import OneLogin_Saml2_Utils
24+
from onelogin.saml2.utils import OneLogin_Saml2_Utils, xmlsec
2525
from onelogin.saml2.logout_request import OneLogin_Saml2_Logout_Request
2626
from onelogin.saml2.authn_request import OneLogin_Saml2_Authn_Request
2727

@@ -433,7 +433,7 @@ def __build_signature(self, saml_data, relay_state, saml_type, sign_algorithm=On
433433
OneLogin_Saml2_Error.SP_CERTS_NOT_FOUND
434434
)
435435

436-
xmlsec.initialize()
436+
# xmlsec.initialize() # already done in utils module
437437

438438
dsig_ctx = xmlsec.DSigCtx()
439439
dsig_ctx.signKey = xmlsec.Key.loadMemory(key, xmlsec.KeyDataFormatPem, None)

src/onelogin/saml2/utils.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
from onelogin.saml2.constants import OneLogin_Saml2_Constants
3535
from onelogin.saml2.errors import OneLogin_Saml2_Error
3636

37+
if not globals().get('xmlsec_setup', False):
38+
xmlsec.initialize()
39+
globals()['xmlsec_setup'] = True
40+
3741

3842
def print_xmlsec_errors(filename, line, func, error_object, error_subject, reason, msg):
3943
"""
@@ -626,7 +630,7 @@ def generate_name_id(value, sp_nq, sp_format, cert=None, debug=False, nq=None):
626630
xml = name_id_container.toxml()
627631
elem = fromstring(xml)
628632

629-
xmlsec.initialize()
633+
# xmlsec.initialize('openssl') # done when the module is loaded
630634

631635
if debug:
632636
xmlsec.set_error_callback(print_xmlsec_errors)
@@ -735,7 +739,7 @@ def decrypt_element(encrypted_data, key, debug=False):
735739
elif isinstance(encrypted_data, basestring):
736740
encrypted_data = fromstring(str(encrypted_data))
737741

738-
xmlsec.initialize()
742+
# xmlsec.initialize() # Initialized at the start of the module
739743

740744
if debug:
741745
xmlsec.set_error_callback(print_xmlsec_errors)
@@ -810,7 +814,7 @@ def add_sign(xml, key, cert, debug=False, sign_algorithm=OneLogin_Saml2_Constant
810814
else:
811815
raise Exception('Error parsing xml string')
812816

813-
xmlsec.initialize()
817+
# xmlsec.initialize() # Initialized at the start of the module
814818

815819
if debug:
816820
xmlsec.set_error_callback(print_xmlsec_errors)
@@ -916,7 +920,7 @@ def validate_sign(xml, cert=None, fingerprint=None, fingerprintalg='sha1', valid
916920
else:
917921
raise Exception('Error parsing xml string')
918922

919-
xmlsec.initialize()
923+
# xmlsec.initialize() # Initialized at the start of the module
920924

921925
if debug:
922926
xmlsec.set_error_callback(print_xmlsec_errors)
@@ -981,7 +985,7 @@ def validate_metadata_sign(xml, cert=None, fingerprint=None, fingerprintalg='sha
981985
else:
982986
raise Exception('Error parsing xml string')
983987

984-
xmlsec.initialize()
988+
# xmlsec.initialize() # Initialized at the start of the module
985989

986990
if debug:
987991
xmlsec.set_error_callback(print_xmlsec_errors)
@@ -1034,7 +1038,7 @@ def validate_node_sign(signature_node, elem, cert=None, fingerprint=None, finger
10341038
:type: bool
10351039
"""
10361040
try:
1037-
xmlsec.initialize()
1041+
# xmlsec.initialize() # Initialized at the start of the module
10381042

10391043
if debug:
10401044
xmlsec.set_error_callback(print_xmlsec_errors)
@@ -1099,7 +1103,7 @@ def validate_binary_sign(signed_query, signature, cert=None, algorithm=OneLogin_
10991103
:type: bool
11001104
"""
11011105
try:
1102-
xmlsec.initialize()
1106+
# xmlsec.initialize() # Initialized at the start of the module
11031107

11041108
if debug:
11051109
xmlsec.set_error_callback(print_xmlsec_errors)

0 commit comments

Comments
 (0)