Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(393)

Side by Side Diff: chrome/common/net/gaia/oauth_request_signer.h

Issue 7171023: Adds the OAuthRequestSigner class to facilitate OAuth integration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Using PRId64 formatter in preference to static_cast of the value. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/common/net/gaia/oauth_request_signer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_
6 #define CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_
7 #pragma once
8
9 #include <map>
10 #include <string>
11
12 #include "base/basictypes.h"
13
14 class GURL;
15
16 // Implements the OAuth request signing process as described here:
17 // http://oauth.net/core/1.0/#signing_process
18 //
19 // NOTE: Currently the only supported SignatureMethod is HMAC_SHA1_SIGNATURE
20 class OAuthRequestSigner {
21 public:
22 enum SignatureMethod {
23 HMAC_SHA1_SIGNATURE,
24 RSA_SHA1_SIGNATURE,
25 PLAINTEXT_SIGNATURE
26 };
27
28 enum HttpMethod {
29 GET_METHOD,
30 POST_METHOD
31 };
32
33 typedef std::map<std::string,std::string> Parameters;
34
35 // Signs a request specified as URL string, complete with parameters.
36 //
37 // If HttpMethod is GET_METHOD, the signed result is the full URL, otherwise
38 // it is the request parameters, including the oauth_signature field.
39 static bool ParseAndSign(const GURL& request_url_with_parameters,
40 SignatureMethod signature_method,
41 HttpMethod http_method,
42 const std::string& consumer_key,
43 const std::string& consumer_secret,
44 const std::string& token_key,
45 const std::string& token_secret,
46 std::string* signed_result);
47
48 // Signs a request specified as the combination of a base URL string, with
49 // parameters included in a separate map data structure. NOTE: The base URL
50 // string must not contain a question mark (?) character. If it does,
51 // you can use ParseAndSign() instead.
52 //
53 // If HttpMethod is GET_METHOD, the signed result is the full URL, otherwise
54 // it is the request parameters, including the oauth_signature field.
55 static bool Sign(const GURL& request_base_url,
56 const Parameters& parameters,
57 SignatureMethod signature_method,
58 HttpMethod http_method,
59 const std::string& consumer_key,
60 const std::string& consumer_secret,
61 const std::string& token_key,
62 const std::string& token_secret,
63 std::string* signed_result);
64
65 private:
66 DISALLOW_IMPLICIT_CONSTRUCTORS(OAuthRequestSigner);
67 };
68
69 #endif // CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | chrome/common/net/gaia/oauth_request_signer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698