@@ -263,6 +263,7 @@ def __init__(self, sec_context, return_addrs=None, timeslack=0,
263
263
self .request_id = request_id
264
264
265
265
self .xmlstr = ""
266
+ self .origxml = ""
266
267
self .name_id = None
267
268
self .response = None
268
269
self .not_on_or_after = 0
@@ -290,7 +291,7 @@ def _postamble(self):
290
291
291
292
try :
292
293
valid_instance (self .response )
293
- except NotValid , exc :
294
+ except NotValid as exc :
294
295
logger .error ("Not valid response: %s" % exc .args [0 ])
295
296
self ._clear ()
296
297
return self
@@ -318,18 +319,22 @@ def _loads(self, xmldata, decode=True, origxml=None):
318
319
# own copy
319
320
self .xmlstr = xmldata [:]
320
321
logger .debug ("xmlstr: %s" % (self .xmlstr ,))
322
+ if origxml :
323
+ self .origxml = origxml
324
+ else :
325
+ self .origxml = self .xmlstr
321
326
322
327
try :
323
- self .response = self .signature_check (xmldata , origdoc = origxml ,
324
- must = self .require_signature ,
325
- require_response_signature = self .require_response_signature )
328
+ self .response = self .signature_check (
329
+ xmldata , origdoc = origxml , must = self .require_signature ,
330
+ require_response_signature = self .require_response_signature )
326
331
327
332
except TypeError :
328
333
raise
329
334
except SignatureError :
330
335
raise
331
- except Exception , excp :
332
- # logger.exception("EXCEPTION: %s", excp)
336
+ except Exception as excp :
337
+ logger .exception ("EXCEPTION: %s" , excp )
333
338
raise
334
339
335
340
#print "<", self.response
@@ -577,7 +582,7 @@ def condition_ok(self, lax=False):
577
582
conditions .not_on_or_after , self .timeslack )
578
583
if conditions .not_before :
579
584
validate_before (conditions .not_before , self .timeslack )
580
- except Exception , excp :
585
+ except Exception as excp :
581
586
logger .error ("Exception on conditions: %s" % (excp ,))
582
587
if not lax :
583
588
raise
@@ -746,6 +751,19 @@ def _assertion(self, assertion):
746
751
:return: True/False depending on if the assertion is sane or not
747
752
"""
748
753
754
+ if not hasattr (assertion , 'signature' ) or not assertion .signature :
755
+ logger .debug ("unsigned" )
756
+ if self .require_signature :
757
+ raise SignatureError ("Signature missing for assertion" )
758
+ else :
759
+ logger .debug ("signed" )
760
+
761
+ try :
762
+ self .sec .check_signature (assertion , class_name (assertion ),
763
+ self .xmlstr )
764
+ except Exception as exc :
765
+ logger .error ("correctly_signed_response: %s" % exc )
766
+ raise
749
767
self .assertion = assertion
750
768
logger .debug ("assertion context: %s" % (self .context ,))
751
769
logger .debug ("assertion keys: %s" % (assertion .keyswv ()))
@@ -1041,6 +1059,7 @@ def __init__(self, sec_context, attribute_converters, timeslack=0,
1041
1059
self .sec = sec_context
1042
1060
self .timeslack = timeslack
1043
1061
self .xmlstr = ""
1062
+ self .origxml = ""
1044
1063
self .name_id = ""
1045
1064
self .response = None
1046
1065
self .not_signed = False
@@ -1053,6 +1072,7 @@ def loads(self, xmldata, decode=True, origxml=None):
1053
1072
# own copy
1054
1073
self .xmlstr = xmldata [:]
1055
1074
logger .debug ("xmlstr: %s" % (self .xmlstr ,))
1075
+ self .origxml = origxml
1056
1076
1057
1077
try :
1058
1078
self .response = self .signature_check (xmldata , origdoc = origxml )
@@ -1061,7 +1081,7 @@ def loads(self, xmldata, decode=True, origxml=None):
1061
1081
raise
1062
1082
except SignatureError :
1063
1083
raise
1064
- except Exception , excp :
1084
+ except Exception as excp :
1065
1085
logger .exception ("EXCEPTION: %s" , excp )
1066
1086
raise
1067
1087
@@ -1072,7 +1092,7 @@ def loads(self, xmldata, decode=True, origxml=None):
1072
1092
def verify (self , key_file = "" ):
1073
1093
try :
1074
1094
valid_instance (self .response )
1075
- except NotValid , exc :
1095
+ except NotValid as exc :
1076
1096
logger .error ("Not valid response: %s" % exc .args [0 ])
1077
1097
raise
1078
1098
return self
0 commit comments