OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_ | 5 #ifndef CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_ |
6 #define CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_ | 6 #define CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 const std::string& token_secret, | 65 const std::string& token_secret, |
66 std::string* signed_result); | 66 std::string* signed_result); |
67 | 67 |
68 // Signs a request specified as the combination of a base URL string, with | 68 // Signs a request specified as the combination of a base URL string, with |
69 // parameters included in a separate map data structure. NOTE: The base URL | 69 // parameters included in a separate map data structure. NOTE: The base URL |
70 // string must not contain a question mark (?) character. If it does, | 70 // string must not contain a question mark (?) character. If it does, |
71 // you can use ParseAndSign() instead. | 71 // you can use ParseAndSign() instead. |
72 // | 72 // |
73 // If HttpMethod is GET_METHOD, the signed result is the full URL, otherwise | 73 // If HttpMethod is GET_METHOD, the signed result is the full URL, otherwise |
74 // it is the request parameters, including the oauth_signature field. | 74 // it is the request parameters, including the oauth_signature field. |
75 static bool SignURL(const GURL& request_base_url, | 75 static bool Sign(const GURL& request_base_url, |
76 const Parameters& parameters, | 76 const Parameters& parameters, |
77 SignatureMethod signature_method, | 77 SignatureMethod signature_method, |
78 HttpMethod http_method, | 78 HttpMethod http_method, |
79 const std::string& consumer_key, | 79 const std::string& consumer_key, |
80 const std::string& consumer_secret, | 80 const std::string& consumer_secret, |
81 const std::string& token_key, | 81 const std::string& token_key, |
82 const std::string& token_secret, | 82 const std::string& token_secret, |
83 std::string* signed_result); | 83 std::string* signed_result); |
84 | |
85 // Similar to SignURL(), but the returned string is not a URL, but the payload | |
86 // to for an HTTP Authorization header. | |
87 static bool SignAuthHeader(const GURL& request_base_url, | |
88 const Parameters& parameters, | |
89 SignatureMethod signature_method, | |
90 HttpMethod http_method, | |
91 const std::string& consumer_key, | |
92 const std::string& consumer_secret, | |
93 const std::string& token_key, | |
94 const std::string& token_secret, | |
95 std::string* signed_result); | |
96 | 84 |
97 private: | 85 private: |
98 DISALLOW_IMPLICIT_CONSTRUCTORS(OAuthRequestSigner); | 86 DISALLOW_IMPLICIT_CONSTRUCTORS(OAuthRequestSigner); |
99 }; | 87 }; |
100 | 88 |
101 #endif // CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_ | 89 #endif // CHROME_COMMON_NET_GAIA_OAUTH_REQUEST_SIGNER_H_ |
OLD | NEW |