def __decrypt_assertion(self, xml):
key = self.__settings.get_sp_key()<EOL>debug = self.__settings.is_debug_active()<EOL>if not key:<EOL><INDENT>raise OneLogin_Saml2_Error(<EOL>'<STR_LIT>',<EOL>OneLogin_Saml2_Error.PRIVATE_KEY_NOT_FOUND<EOL>)<EOL><DEDENT>encrypted_assertion_nodes = OneLogin_Saml2_XML.query(xml, '<STR_LIT>')<EOL>if encrypted_assertion_nodes:<EOL><INDENT>encrypted_data_nodes = OneLogin_Saml2_XML.query(encrypted_assertion_nodes[<NUM_LIT:0>], '<STR_LIT>')<EOL>if encrypted_data_nodes:<EOL><INDENT>keyinfo = OneLogin_Saml2_XML.query(encrypted_assertion_nodes[<NUM_LIT:0>], '<STR_LIT>')<EOL>if not keyinfo:<EOL><INDENT>raise OneLogin_Saml2_ValidationError(<EOL>'<STR_LIT>',<EOL>OneLogin_Saml2_ValidationError.KEYINFO_NOT_FOUND_IN_ENCRYPTED_DATA<EOL>)<EOL><DEDENT>keyinfo = keyinfo[<NUM_LIT:0>]<EOL>children = keyinfo.getchildren()<EOL>if not children:<EOL><INDENT>raise OneLogin_Saml2_ValidationError(<EOL>'<STR_LIT>',<EOL>OneLogin_Saml2_ValidationError.CHILDREN_NODE_NOT_FOUND_IN_KEYINFO<EOL>)<EOL><DEDENT>for child in children:<EOL><INDENT>if '<STR_LIT>' in child.tag:<EOL><INDENT>if child.attrib['<STR_LIT>'] != '<STR_LIT>':<EOL><INDENT>raise OneLogin_Saml2_ValidationError(<EOL>'<STR_LIT>',<EOL>OneLogin_Saml2_ValidationError.UNSUPPORTED_RETRIEVAL_METHOD<EOL>)<EOL><DEDENT>uri = child.attrib['<STR_LIT>']<EOL>if not uri.startswith('<STR_LIT:#>'):<EOL><INDENT>break<EOL><DEDENT>uri = uri.split('<STR_LIT:#>')[<NUM_LIT:1>]<EOL>encrypted_key = OneLogin_Saml2_XML.query(encrypted_assertion_nodes[<NUM_LIT:0>], '<STR_LIT>', None, uri)<EOL>if encrypted_key:<EOL><INDENT>keyinfo.append(encrypted_key[<NUM_LIT:0>])<EOL><DEDENT><DEDENT><DEDENT>encrypted_data = encrypted_data_nodes[<NUM_LIT:0>]<EOL>decrypted = OneLogin_Saml2_Utils.decrypt_element(encrypted_data, key, debug=debug, inplace=True)<EOL>xml.replace(encrypted_assertion_nodes[<NUM_LIT:0>], decrypted)<EOL><DEDENT><DEDENT>return xml<EOL>
Decrypts the Assertion

:raises: Exception if no private key available
:param xml: Encrypted Assertion
:type xml: Element
:returns: Decrypted Assertion
:rtype: Element