37
37
import time
38
38
from saml2 .soap import make_soap_enveloped_saml_thingy
39
39
40
- try :
41
- from urlparse import parse_qs
42
- except ImportError :
43
- # Compatibility with Python <= 2.5
44
- from cgi import parse_qs
40
+ from urlparse import parse_qs
45
41
46
42
from saml2 .s_utils import signature , UnravelError
47
43
from saml2 .s_utils import do_attributes
@@ -124,7 +120,8 @@ def __init__(self, config=None, identity_cache=None, state_cache=None,
124
120
self .want_assertions_signed = False
125
121
self .want_response_signed = False
126
122
for foo in ["allow_unsolicited" , "authn_requests_signed" ,
127
- "logout_requests_signed" , "want_assertions_signed" , "want_response_signed" ]:
123
+ "logout_requests_signed" , "want_assertions_signed" ,
124
+ "want_response_signed" ]:
128
125
v = self .config .getattr (foo , "sp" )
129
126
if v is True or v == 'true' :
130
127
setattr (self , foo , True )
@@ -304,8 +301,8 @@ def create_authn_request(self, destination, vorg="", scoping=None,
304
301
except KeyError :
305
302
pass
306
303
307
- rid = ""
308
- if ( sign and self . sec . cert_handler . generate_cert ()) or client_crt is not None :
304
+ if ( sign and self . sec . cert_handler . generate_cert ()) or \
305
+ client_crt is not None :
309
306
with self .lock :
310
307
self .sec .cert_handler .update_cert (True , client_crt )
311
308
if client_crt is not None :
@@ -442,15 +439,11 @@ def create_assertion_id_request(self, assertion_id_refs, **kwargs):
442
439
:param assertion_id_refs:
443
440
:return: One ID ref
444
441
"""
445
- # id_refs = [AssertionIDRef(text=s) for s in assertion_id_refs]
446
- #
447
- # return self._message(AssertionIDRequest, destination, id, consent,
448
- # extensions, sign, assertion_id_ref=id_refs )
449
442
450
443
if isinstance (assertion_id_refs , basestring ):
451
- return assertion_id_refs
444
+ return 0 , assertion_id_refs
452
445
else :
453
- return assertion_id_refs [0 ]
446
+ return 0 , assertion_id_refs [0 ]
454
447
455
448
def create_authn_query (self , subject , destination = None , authn_context = None ,
456
449
session_index = "" , message_id = 0 , consent = None ,
@@ -509,7 +502,8 @@ def create_name_id_mapping_request(self, name_id_policy,
509
502
510
503
# ======== response handling ===========
511
504
512
- def parse_authn_request_response (self , xmlstr , binding , outstanding = None , outstanding_certs = None ):
505
+ def parse_authn_request_response (self , xmlstr , binding , outstanding = None ,
506
+ outstanding_certs = None ):
513
507
""" Deal with an AuthnResponse
514
508
515
509
:param xmlstr: The reply as a xml string
@@ -536,7 +530,8 @@ def parse_authn_request_response(self, xmlstr, binding, outstanding=None, outsta
536
530
"return_addrs" : self .service_urls (),
537
531
"entity_id" : self .config .entityid ,
538
532
"attribute_converters" : self .config .attribute_converters ,
539
- "allow_unknown_attributes" : self .config .allow_unknown_attributes ,
533
+ "allow_unknown_attributes" :
534
+ self .config .allow_unknown_attributes ,
540
535
}
541
536
try :
542
537
resp = self ._parse_response (xmlstr , AuthnResponse ,
@@ -654,6 +649,10 @@ def create_ecp_authn_request(self, entityid=None, relay_state="",
654
649
655
650
try :
656
651
authn_req = kwargs ["authn_req" ]
652
+ try :
653
+ req_id = authn_req .id
654
+ except AttributeError :
655
+ req_id = 0 # Unknown but since it's SOAP it doesn't matter
657
656
except KeyError :
658
657
try :
659
658
_binding = kwargs ["binding" ]
@@ -697,7 +696,8 @@ def parse_ecp_authn_response(self, txt, outstanding=None):
697
696
698
697
return response , _relay_state
699
698
700
- def can_handle_ecp_response (self , response ):
699
+ @staticmethod
700
+ def can_handle_ecp_response (response ):
701
701
try :
702
702
accept = response .headers ["accept" ]
703
703
except KeyError :
@@ -715,7 +715,8 @@ def can_handle_ecp_response(self, response):
715
715
# IDP discovery
716
716
# ----------------------------------------------------------------------
717
717
718
- def create_discovery_service_request (self , url , entity_id , ** kwargs ):
718
+ @staticmethod
719
+ def create_discovery_service_request (url , entity_id , ** kwargs ):
719
720
"""
720
721
Created the HTTP redirect URL needed to send the user to the
721
722
discovery service.
0 commit comments