'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:'

def correctly_signed_message(self, decoded_xml, msgtype, must=False, origdoc=None, only_valid_cert=False):

    try:
        _func = getattr(samlp, ('%s_from_string' % msgtype))
    except AttributeError:
        _func = getattr(saml, ('%s_from_string' % msgtype))
    msg = _func(decoded_xml)
    if (not msg):
        raise TypeError(('Not    a    %s' % msgtype))
    if (not msg.signature):
        if must:
            raise SignatureError(('Required    signature    missing    on    %s' % msgtype))
        else:
            return msg
    return self._check_signature(decoded_xml, msg, class_name(msg), origdoc, must=must, only_valid_cert=only_valid_cert)
