'Verify grade request from LTI provider using OAuth body signing.
Uses http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html::
This specification extends the OAuth signature to include integrity checks on HTTP request bodies
with content types other than application/x-www-form-urlencoded.
Arguments:
request: DjangoWebobRequest.
Raises:
LTIError if request is incorrect.'

def verify_oauth_body_sign(self, request, content_type='application/x-www-form-urlencoded'):

    (client_key, client_secret) = self.get_client_key_secret()
    headers = {'Authorization': unicode(request.headers.get('Authorization')), 'Content-Type': content_type}
    sha1 = hashlib.sha1()
    sha1.update(request.body)
    oauth_body_hash = base64.b64encode(sha1.digest())
    oauth_params = signature.collect_parameters(headers=headers, exclude_oauth_signature=False)
    oauth_headers = dict(oauth_params)
    oauth_signature = oauth_headers.pop('oauth_signature')
    mock_request_lti_1 = mock.Mock(uri=unicode(urllib.unquote(self.get_outcome_service_url())), http_method=unicode(request.method), params=oauth_headers.items(), signature=oauth_signature)
    mock_request_lti_2 = mock.Mock(uri=unicode(urllib.unquote(request.url)), http_method=unicode(request.method), params=oauth_headers.items(), signature=oauth_signature)
    if (oauth_body_hash != oauth_headers.get('oauth_body_hash')):
        log.error('OAuth    body    hash    verification    failed,    provided:    {},    calculated:    {},    for    url:    {},    body    is:    {}'.format(oauth_headers.get('oauth_body_hash'), oauth_body_hash, self.get_outcome_service_url(), request.body))
        raise LTIError('OAuth    body    hash    verification    is    failed.')
    if ((not signature.verify_hmac_sha1(mock_request_lti_1, client_secret)) and (not signature.verify_hmac_sha1(mock_request_lti_2, client_secret))):
        log.error('OAuth    signature    verification    failed,    for    headers:{}    url:{}    method:{}'.format(oauth_headers, self.get_outcome_service_url(), unicode(request.method)))
        raise LTIError('OAuth    signature    verification    has    failed.')
