File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -449,6 +449,25 @@ def __decrypt_assertion(self, dom):
449449 if encrypted_assertion_nodes :
450450 encrypted_data_nodes = OneLogin_Saml2_Utils .query (encrypted_assertion_nodes [0 ], '//saml:EncryptedAssertion/xenc:EncryptedData' )
451451 if encrypted_data_nodes :
452+ keyinfo = OneLogin_Saml2_Utils .query (encrypted_assertion_nodes [0 ], '//saml:EncryptedAssertion/xenc:EncryptedData/ds:KeyInfo' )
453+ if not keyinfo :
454+ raise Exception ('No KeyInfo present, invalid Assertion' )
455+ keyinfo = keyinfo [0 ]
456+ children = keyinfo .getchildren ()
457+ if not children :
458+ raise Exception ('No child to KeyInfo, invalid Assertion' )
459+ for child in children :
460+ if 'RetrievalMethod' in child .tag :
461+ if child .attrib ['Type' ] != 'http://www.w3.org/2001/04/xmlenc#EncryptedKey' :
462+ raise Exception ('Unsupported Retrieval Method found' )
463+ uri = child .attrib ['URI' ]
464+ if not uri .startswith ('#' ):
465+ break
466+ uri = uri .split ('#' )[1 ]
467+ encrypted_key = OneLogin_Saml2_Utils .query (encrypted_assertion_nodes [0 ], './xenc:EncryptedKey[@Id="' + uri + '"]' )
468+ if encrypted_key :
469+ keyinfo .append (encrypted_key [0 ])
470+
452471 encrypted_data = encrypted_data_nodes [0 ]
453472 OneLogin_Saml2_Utils .decrypt_element (encrypted_data , key )
454473 return dom
You can’t perform that action at this time.
0 commit comments