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

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: Fixed indentation of switch cases and defaults. 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
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 #include "base/basictypes.h"
Nicolas Zea 2011/06/16 18:59:27 nit, line between stl and other includes
Rick Campbell 2011/06/17 16:57:54 Done.
12
13 class GURL;
14
15 // Implements the OAuth request signing process as described here:
16 // http://oauth.net/core/1.0/#signing_process
17 //
18 // NOTE: Currently the only supported SignatureMethod is HMAC_SHA1_SIGNATURE
19 class OAuthRequestSigner {
20 public:
21 enum SignatureMethod {
22 HMAC_SHA1_SIGNATURE,
23 RSA_SHA1_SIGNATURE,
24 PLAINTEXT_SIGNATURE
25 };
26
27 enum HttpMethod {
28 GET_METHOD,
29 POST_METHOD
30 };
31
32 typedef std::map<std::string,std::string> Parameters;
33
34 // Signs a request specified as URL string, complete with parameters.
35 //
36 // If HttpMethod is GET_METHOD, the signed result is the full URL, otherwise
37 // it is the request parameters, including the oauth_signature field.
38 static bool ParseAndSign(const GURL& request_url_with_parameters,
39 SignatureMethod signature_method,
40 HttpMethod http_method,
41 const std::string& consumer_key,
42 const std::string& consumer_secret,
43 const std::string& token_key,
44 const std::string& token_secret,
45 std::string* signed_result);
46
47 // Signs a request specified as the combination of a base URL string, with
48 // parameters included in a separate map data structure. NOTE: The base URL
49 // string must not contain a question mark (?) character. If it does,
50 // you can use ParseAndSign() instead.
51 //
52 // If HttpMethod is GET_METHOD, the signed result is the full URL, otherwise
53 // it is the request parameters, including the oauth_signature field.
54 static bool Sign(const GURL& request_base_url,
55 const Parameters& parameters,
56 SignatureMethod signature_method,
57 HttpMethod http_method,
58 const std::string& consumer_key,
59 const std::string& consumer_secret,
60 const std::string& token_key,
61 const std::string& token_secret,
62 std::string* signed_result);
63
64 private:
65 DISALLOW_IMPLICIT_CONSTRUCTORS(OAuthRequestSigner);
66 };
67
68 #endif // CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698