OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_ | 5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_ |
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_ | 6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQUES T_HANDLER_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 const net::ProxyServer& proxy_server, | 53 const net::ProxyServer& proxy_server, |
54 net::HttpRequestHeaders* request_headers); | 54 net::HttpRequestHeaders* request_headers); |
55 | 55 |
56 // Sets a new authentication key. This must be called for platforms that do | 56 // Sets a new authentication key. This must be called for platforms that do |
57 // not have a default key defined. See the constructor implementation for | 57 // not have a default key defined. See the constructor implementation for |
58 // those platforms. Must be called on the UI thread. | 58 // those platforms. Must be called on the UI thread. |
59 void SetKeyOnUI(const std::string& key); | 59 void SetKeyOnUI(const std::string& key); |
60 | 60 |
61 protected: | 61 protected: |
62 void Init(); | 62 void Init(); |
63 void InitAuthenticationOnUI(const std::string& key); | 63 void InitAuthenticationOnUI(const std::string& key); |
marq (ping after 24h)
2014/08/12 19:04:39
To match other CLs, this should be "OnUIThread".
bengr
2014/08/13 01:39:15
I'm trying to move over to OnUI and OnIO as I like
| |
64 | 64 |
65 void AddAuthorizationHeader(net::HttpRequestHeaders* headers); | 65 void AddAuthorizationHeader(net::HttpRequestHeaders* headers); |
66 | 66 |
67 // Returns a UTF16 string that's the hash of the configured authentication | 67 // Returns a UTF16 string that's the hash of the configured authentication |
68 // |key| and |salt|. Returns an empty UTF16 string if no key is configured or | 68 // |key| and |salt|. Returns an empty UTF16 string if no key is configured or |
69 // the data reduction proxy feature isn't available. | 69 // the data reduction proxy feature isn't available. |
70 static base::string16 AuthHashForSalt(int64 salt, | 70 static base::string16 AuthHashForSalt(int64 salt, |
71 const std::string& key); | 71 const std::string& key); |
72 // Visible for testing. | 72 // Visible for testing. |
73 virtual base::Time Now() const; | 73 virtual base::Time Now() const; |
74 virtual void RandBytes(void* output, size_t length); | 74 virtual void RandBytes(void* output, size_t length); |
75 | 75 |
76 // Visible for testing. | 76 // Visible for testing. |
77 virtual std::string GetDefaultKey() const; | 77 virtual std::string GetDefaultKey() const; |
78 | 78 |
79 private: | 79 private: |
80 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, | 80 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, |
81 Authorization); | 81 Authorization); |
82 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, | 82 FRIEND_TEST_ALL_PREFIXES(DataReductionProxyAuthRequestHandlerTest, |
83 AuthHashForSalt); | 83 AuthHashForSalt); |
84 | 84 |
85 void InitAuthentication( | 85 // Stores the supplied key and sets up credentials suitable for authenticating |
86 const std::string& session, | 86 // with the data reduction proxy. |
87 const std::string& credentials); | 87 void InitAuthentication(const std::string& key); |
88 | |
89 // Generates a session ID and credentials suitable for authenticating with | |
90 // the data reduction proxy. | |
91 void ComputeCredentials(const base::Time& now, | |
92 std::string* session, | |
93 std::string* credentials); | |
88 | 94 |
89 // Authentication state. | 95 // Authentication state. |
90 std::string key_; | 96 std::string key_; |
91 | 97 |
92 // Lives on the IO thread. | 98 // Lives on the IO thread. |
93 std::string session_; | 99 std::string session_; |
94 std::string credentials_; | 100 std::string credentials_; |
95 | 101 |
96 // Name of the client and version of the data reduction proxy protocol to use. | 102 // Name of the client and version of the data reduction proxy protocol to use. |
97 // Both live on the IO thread. | 103 // Both live on the IO thread. |
98 std::string client_; | 104 std::string client_; |
99 std::string version_; | 105 std::string version_; |
100 | 106 |
107 // The last time the session was updated. Used to ensure that a session is | |
108 // never used for more than twenty-four hours. | |
109 base::Time last_update_time_; | |
110 | |
101 DataReductionProxyParams* data_reduction_proxy_params_; | 111 DataReductionProxyParams* data_reduction_proxy_params_; |
102 | 112 |
103 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; | 113 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_; |
104 | 114 |
105 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); | 115 DISALLOW_COPY_AND_ASSIGN(DataReductionProxyAuthRequestHandler); |
106 }; | 116 }; |
107 | 117 |
108 } // namespace data_reduction_proxy | 118 } // namespace data_reduction_proxy |
109 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ UEST_HANDLER_H_ | 119 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_AUTH_REQ UEST_HANDLER_H_ |
OLD | NEW |