code: def validate_signed_elements(self, signed_elements):
          
          if len(signed_elements) > 2:
              return False
  
          response_tag = '{%s}Response' % OneLogin_Saml2_Constants.NS_SAMLP
          assertion_tag = '{%s}Assertion' % OneLogin_Saml2_Constants.NS_SAML
  
          if (response_tag in signed_elements and signed_elements.count(response_tag) > 1) or \
             (assertion_tag in signed_elements and signed_elements.count(assertion_tag) > 1) or \
             (response_tag not in signed_elements and assertion_tag not in signed_elements):
              return False
  
          # Check that the signed elements found here, are the ones that will be verified
          # by OneLogin_Saml2_Utils.validate_sign
          if response_tag in signed_elements:
              expected_signature_nodes = OneLogin_Saml2_Utils.query(self.document, OneLogin_Saml2_Utils.RESPONSE_SIGNATURE_XPATH)
              if len(expected_signature_nodes) != 1:
                  raise OneLogin_Saml2_ValidationError(
                      'Unexpected number of Response signatures found. SAML Response rejected.',
                      OneLogin_Saml2_ValidationError.WRONG_NUMBER_OF_SIGNATURES_IN_RESPONSE
                  )
  
          if assertion_tag in signed_elements:
              expected_signature_nodes = self.__query(OneLogin_Saml2_Utils.ASSERTION_SIGNATURE_XPATH)
              if len(expected_signature_nodes) != 1:
                  raise OneLogin_Saml2_ValidationError(
                      'Unexpected number of Assertion signatures found. SAML Response rejected.',
                      OneLogin_Saml2_ValidationError.WRONG_NUMBER_OF_SIGNATURES_IN_ASSERTION
                  )
  
          return True
docs: 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