'Verifies a request ensuring that the following is true:
Per `section 3.2`_ of the spec.
- all mandated OAuth parameters are supplied
- parameters are only supplied in one source which may be the URI
query, the Authorization header or the body
- all parameters are checked and validated, see comments and the
methods and properties of this class for further details.
- the supplied signature is verified against a recalculated one
A ValueError will be raised if any parameter is missing,
supplied twice or invalid. A HTTP 400 Response should be returned
upon catching an exception.
A HTTP 401 Response should be returned if verify_request returns False.
`Timing attacks`_ are prevented through the use of dummy credentials to
create near constant time verification even if an invalid credential
is used. Early exit on invalid credentials would enable attackers
to perform `enumeration attacks`_. Near constant time string comparison
is used to prevent secret key guessing. Note that timing attacks can
only be prevented through near constant time execution, not by adding
a random delay which would only require more samples to be gathered.
.. _`section 3.2`: http://tools.ietf.org/html/rfc5849#section-3.2
.. _`Timing attacks`: http://rdist.root.org/2010/07/19/exploiting-remote-timing-attacks/
.. _`enumeration attacks`: http://www.sans.edu/research/security-laboratory/article/attacks-browsing'

def verify_request(self, uri, http_method=u'GET', body=None, headers=None, require_resource_owner=True, require_verifier=False, require_realm=False, required_realm=None):

    headers = (headers or {})
    if ((u'Content-Type' in headers) and (headers[u'Content-Type'] == CONTENT_TYPE_FORM_URLENCODED)):
        request = Request(uri, http_method, body, headers)
    else:
        request = Request(uri, http_method, u'', headers)
    if (self.enforce_ssl and (not request.uri.lower().startswith('https://'))):
        raise ValueError('Insecure    transport,    only    HTTPS    is    allowed.')
    (signature_type, params, oauth_params) = self.get_signature_type_and_params(request)
    if (len(dict(oauth_params)) != len(oauth_params)):
        raise ValueError('Duplicate    OAuth    entries.')
    oauth_params = dict(oauth_params)
    request_signature = oauth_params.get(u'oauth_signature')
    client_key = oauth_params.get(u'oauth_consumer_key')
    resource_owner_key = oauth_params.get(u'oauth_token')
    nonce = oauth_params.get(u'oauth_nonce')
    timestamp = oauth_params.get(u'oauth_timestamp')
    callback_uri = oauth_params.get(u'oauth_callback')
    verifier = oauth_params.get(u'oauth_verifier')
    signature_method = oauth_params.get(u'oauth_signature_method')
    realm = dict(params).get(u'realm')
    if (not all((request_signature, client_key, nonce, timestamp, signature_method))):
        raise ValueError('Missing    OAuth    parameters.')
    if (not (signature_method in self.allowed_signature_methods)):
        raise ValueError('Invalid    signature    method.')
    if ((u'oauth_version' in oauth_params) and (oauth_params[u'oauth_version'] != u'1.0')):
        raise ValueError('Invalid    OAuth    version.')
    if (len(timestamp) != 10):
        raise ValueError('Invalid    timestamp    size')
    try:
        ts = int(timestamp)
    except ValueError:
        raise ValueError('Timestamp    must    be    an    integer')
    else:
        if ((time.time() - ts) > self.timestamp_lifetime):
            raise ValueError('Request    too    old,    over    10    minutes.')
    if (not self.check_client_key(client_key)):
        raise ValueError('Invalid    client    key.')
    if ((not resource_owner_key) and require_resource_owner):
        raise ValueError('Missing    resource    owner.')
    if (require_resource_owner and (not require_verifier) and (not self.check_access_token(resource_owner_key))):
        raise ValueError('Invalid    resource    owner    key.')
    if (require_resource_owner and require_verifier and (not self.check_request_token(resource_owner_key))):
        raise ValueError('Invalid    resource    owner    key.')
    if (not self.check_nonce(nonce)):
        raise ValueError('Invalid    nonce.')
    if (realm and (not self.check_realm(realm))):
        raise ValueError(('Invalid    realm.    Allowed    are    %s' % self.realms))
    if ((not verifier) and require_verifier):
        raise ValueError('Missing    verifier.')
    if (require_verifier and (not self.check_verifier(verifier))):
        raise ValueError('Invalid    verifier.')
    if require_verifier:
        token = {'request_token': resource_owner_key}
    else:
        token = {'access_token': resource_owner_key}
    if (not self.validate_timestamp_and_nonce(client_key, timestamp, nonce, **token)):
        return False
    valid_client = self.validate_client_key(client_key)
    if (not valid_client):
        client_key = self.dummy_client
    valid_redirect = self.validate_redirect_uri(client_key, callback_uri)
    if resource_owner_key:
        if require_verifier:
            valid_resource_owner = self.validate_request_token(client_key, resource_owner_key)
        else:
            valid_resource_owner = self.validate_access_token(client_key, resource_owner_key)
        if (not valid_resource_owner):
            resource_owner_key = self.dummy_resource_owner
    else:
        valid_resource_owner = True
    if (require_realm and (not resource_owner_key)):
        valid_realm = self.validate_requested_realm(client_key, realm)
    elif require_verifier:
        valid_realm = True
    else:
        valid_realm = self.validate_realm(client_key, resource_owner_key, uri=request.uri, required_realm=required_realm)
    if verifier:
        valid_verifier = self.validate_verifier(client_key, resource_owner_key, verifier)
    else:
        valid_verifier = True
    request.params = filter((lambda x: (x[0] != 'oauth_signature')), params)
    request.signature = request_signature
    if (signature_method == SIGNATURE_RSA):
        rsa_key = self.get_rsa_key(client_key)
        valid_signature = signature.verify_rsa_sha1(request, rsa_key)
    else:
        client_secret = self.get_client_secret(client_key)
        if require_verifier:
            resource_owner_secret = self.get_request_token_secret(client_key, resource_owner_key)
        else:
            resource_owner_secret = self.get_access_token_secret(client_key, resource_owner_key)
        if (signature_method == SIGNATURE_HMAC):
            valid_signature = signature.verify_hmac_sha1(request, client_secret, resource_owner_secret)
        else:
            valid_signature = signature.verify_plaintext(request, client_secret, resource_owner_secret)
    v = all((valid_client, valid_resource_owner, valid_realm, valid_redirect, valid_verifier, valid_signature))
    logger = logging.getLogger('oauthlib')
    if (not v):
        logger.info('[Failure]    OAuthLib    request    verification    failed.')
        logger.info(('Valid    client: DCTB %s' % valid_client))
        logger.info(('Valid    token: DCTB %s DCTB (Required:    %s' % (valid_resource_owner, require_resource_owner)))
        logger.info(('Valid    realm: DCTB %s DCTB (Required:    %s)' % (valid_realm, require_realm)))
        logger.info(('Valid    callback: DCTB %s' % valid_redirect))
        logger.info(('Valid    verifier: DCTB %s DCTB (Required:    %s)' % (valid_verifier, require_verifier)))
        logger.info(('Valid    signature: DCTB %s' % valid_signature))
    return v
