code: def correctly_signed_message(self, decoded_xml, msgtype, must=False, origdoc=None, only_valid_cert=False):
          
  
          attr = '{type}_from_string'.format(type=msgtype)
          _func = getattr(saml, attr, None)
          _func = getattr(samlp, attr, _func)
  
          msg = _func(decoded_xml)
          if not msg:
              raise TypeError('Not a {type}'.format(type=msgtype))
  
          if not msg.signature:
              if must:
                  err_msg = 'Required signature missing on {type}'
                  err_msg = err_msg.format(type=msgtype)
                  raise SignatureError(err_msg)
              else:
                  return msg
  
          return self._check_signature(
                  decoded_xml,
                  msg,
                  class_name(msg),
                  origdoc,
                  must=must,
                  only_valid_cert=only_valid_cert)
docs: Check if a request is correctly signed, if we have metadata for
          the entity that sent the info use that, if not use the key that are in
          the message if any.
  
          :param decoded_xml: The SAML message as an XML infoset (a string)
          :param msgtype: SAML protocol message type
          :param must: Whether there must be a signature
          :param origdoc:
          :return: