@@ -1137,20 +1137,17 @@ def _parse_response(self, xmlstr, response_cls, service, binding,
1137
1137
if not xmlstr : # Not a valid reponse
1138
1138
return None
1139
1139
1140
- # Record the response signature requirement.
1141
- require_response_signature = response .require_response_signature
1142
-
1143
- # Force the requirement that the response be signed in order to
1144
- # force signature checking to happen so that we can know whether
1145
- # or not the response is signed. The attribute on the response class
1146
- # is reset to the recorded value in the finally clause below.
1147
- response .require_response_signature = True
1148
-
1149
1140
try :
1141
+ response_is_signed = False
1142
+ # Record the response signature requirement.
1143
+ require_response_signature = response .require_response_signature
1144
+ # Force the requirement that the response be signed in order to
1145
+ # force signature checking to happen so that we can know whether
1146
+ # or not the response is signed. The attribute on the response class
1147
+ # is reset to the recorded value in the finally clause below.
1148
+ response .require_response_signature = True
1150
1149
response = response .loads (xmlstr , False , origxml = xmlstr )
1151
- response_is_signed = True
1152
1150
except SigverError as err :
1153
- response_is_signed = False
1154
1151
if require_response_signature :
1155
1152
logger .error ("Signature Error: %s" , err )
1156
1153
raise
@@ -1160,15 +1157,15 @@ def _parse_response(self, xmlstr, response_cls, service, binding,
1160
1157
# value and attempt to consume the unpacked XML again.
1161
1158
response .require_response_signature = require_response_signature
1162
1159
response = response .loads (xmlstr , False , origxml = xmlstr )
1163
-
1164
1160
except UnsolicitedResponse :
1165
1161
logger .error ("Unsolicited response" )
1166
1162
raise
1167
1163
except Exception as err :
1168
- response_is_signed = False
1169
1164
if "not well-formed" in "%s" % err :
1170
1165
logger .error ("Not well-formed XML" )
1171
1166
raise
1167
+ else :
1168
+ response_is_signed = True
1172
1169
finally :
1173
1170
response .require_response_signature = require_response_signature
1174
1171
@@ -1195,22 +1192,19 @@ def _parse_response(self, xmlstr, response_cls, service, binding,
1195
1192
only_identity_in_encrypted_assertion = kwargs [
1196
1193
"only_identity_in_encrypted_assertion" ]
1197
1194
1198
- # Record the assertions signature requirement.
1199
- require_signature = response .require_signature
1200
-
1201
- # Force the requirement that the assertions be signed in order to
1202
- # force signature checking to happen so that we can know whether
1203
- # or not the assertions are signed. The attribute on the response class
1204
- # is reset to the recorded value in the finally clause below.
1205
- response .require_signature = True
1206
-
1207
1195
try :
1196
+ assertions_are_signed = False
1197
+ # Record the assertions signature requirement.
1198
+ require_signature = response .require_signature
1199
+ # Force the requirement that the assertions be signed in order to
1200
+ # force signature checking to happen so that we can know whether
1201
+ # or not the assertions are signed. The attribute on the response class
1202
+ # is reset to the recorded value in the finally clause below.
1203
+ response .require_signature = True
1208
1204
# Verify that the assertion is syntactically correct and the
1209
1205
# signature on the assertion is correct if present.
1210
1206
response = response .verify (keys )
1211
- assertions_are_signed = True
1212
1207
except SignatureError as err :
1213
- assertions_are_signed = False
1214
1208
if require_signature :
1215
1209
logger .error ("Signature Error: %s" , err )
1216
1210
raise
@@ -1219,6 +1213,8 @@ def _parse_response(self, xmlstr, response_cls, service, binding,
1219
1213
response = response .verify (keys )
1220
1214
except Exception as err :
1221
1215
logger .error ("Exception verifying assertion: %s" % err )
1216
+ else :
1217
+ assertions_are_signed = True
1222
1218
finally :
1223
1219
response .require_signature = require_signature
1224
1220
0 commit comments