@return_false_on_exception<EOL><INDENT>def validate_signed_elements(self, signed_elements):<DEDENT>
if len(signed_elements) > <NUM_LIT:2>:<EOL><INDENT>return False<EOL><DEDENT>response_tag = '<STR_LIT>' % OneLogin_Saml2_Constants.NS_SAMLP<EOL>assertion_tag = '<STR_LIT>' % OneLogin_Saml2_Constants.NS_SAML<EOL>if (response_tag in signed_elements and signed_elements.count(response_tag) > <NUM_LIT:1>) or(assertion_tag in signed_elements and signed_elements.count(assertion_tag) > <NUM_LIT:1>) or(response_tag not in signed_elements and assertion_tag not in signed_elements):<EOL><INDENT>return False<EOL><DEDENT>if response_tag in signed_elements:<EOL><INDENT>expected_signature_nodes = OneLogin_Saml2_XML.query(self.document, OneLogin_Saml2_Utils.RESPONSE_SIGNATURE_XPATH)<EOL>if len(expected_signature_nodes) != <NUM_LIT:1>:<EOL><INDENT>raise OneLogin_Saml2_ValidationError(<EOL>'<STR_LIT>',<EOL>OneLogin_Saml2_ValidationError.WRONG_NUMBER_OF_SIGNATURES_IN_RESPONSE<EOL>)<EOL><DEDENT><DEDENT>if assertion_tag in signed_elements:<EOL><INDENT>expected_signature_nodes = self.__query(OneLogin_Saml2_Utils.ASSERTION_SIGNATURE_XPATH)<EOL>if len(expected_signature_nodes) != <NUM_LIT:1>:<EOL><INDENT>raise OneLogin_Saml2_ValidationError(<EOL>'<STR_LIT>',<EOL>OneLogin_Saml2_ValidationError.WRONG_NUMBER_OF_SIGNATURES_IN_ASSERTION<EOL>)<EOL><DEDENT><DEDENT>return True<EOL>
Verifies that the document has the expected signed nodes.

:param signed_elements: The signed elements to be checked
:type signed_elements: list
:param raise_exceptions: Whether to return false on failure or raise an exception
:type raise_exceptions: Boolean