'Check a request\'s supplied signature to make sure the request is
valid.
Servers should return HTTP status 400 if a ValueError exception
is raised and HTTP status 401 on return value False.
Per `section 3.2`_ of the spec.
.. _`section 3.2`: http://tools.ietf.org/html/rfc5849#section-3.2'

def check_request_signature(self, uri, http_method=u'GET', body='', headers=None):

    headers = (headers or {})
    signature_type = None
    uri_query = urlparse.urlparse(uri).query
    (signature_type, params) = self.get_signature_type_and_params(uri_query, headers, body)
    filtered_params = utils.filter_oauth_params(params)
    if (len(filtered_params) != len(params)):
        raise ValueError('Duplicate    OAuth    entries.')
    params = dict(params)
    request_signature = params.get(u'oauth_signature')
    client_key = params.get(u'oauth_consumer_key')
    resource_owner_key = params.get(u'oauth_token')
    nonce = params.get(u'oauth_nonce')
    timestamp = params.get(u'oauth_timestamp')
    callback_uri = params.get(u'oauth_callback')
    verifier = params.get(u'oauth_verifier')
    signature_method = params.get(u'oauth_signature_method')
    if (not all((request_signature, client_key, nonce, timestamp, signature_method))):
        raise ValueError('Missing    OAuth    parameters.')
    if ((u'oauth_version' in params) and (params[u'oauth_version'] != u'1.0')):
        raise ValueError('Invalid    OAuth    version.')
    if (not (signature_method in SIGNATURE_METHODS)):
        raise ValueError('Invalid    signature    method.')
    if (not self.check_client_key(client_key)):
        return False
    if (not self.check_resource_owner_key(client_key, resource_owner_key)):
        return False
    if (not self.check_timestamp_and_nonce(timestamp, nonce)):
        return False
    if (signature_method == SIGNATURE_RSA):
        oauth_client = Client(client_key, resource_owner_key=resource_owner_key, callback_uri=callback_uri, signature_method=signature_method, signature_type=signature_type, rsa_key=self.rsa_key, verifier=verifier)
    else:
        client_secret = self.get_client_secret(client_key)
        resource_owner_secret = self.get_resource_owner_secret(resource_owner_key)
        oauth_client = Client(client_key, client_secret=client_secret, resource_owner_key=resource_owner_key, resource_owner_secret=resource_owner_secret, callback_uri=callback_uri, signature_method=signature_method, signature_type=signature_type, verifier=verifier)
    request = Request(uri, http_method, body, headers)
    request.oauth_params = params
    client_signature = oauth_client.get_oauth_signature(request)
    return (client_signature == request_signature)
