| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 NET_HTTP_TRANSPORT_SECURITY_STATE_H_ | 5 #ifndef NET_HTTP_TRANSPORT_SECURITY_STATE_H_ |
| 6 #define NET_HTTP_TRANSPORT_SECURITY_STATE_H_ | 6 #define NET_HTTP_TRANSPORT_SECURITY_STATE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 std::string domain; | 209 std::string domain; |
| 210 | 210 |
| 211 // The URI reports are sent to if a valid OCSP response is not stapled | 211 // The URI reports are sent to if a valid OCSP response is not stapled |
| 212 GURL report_uri; | 212 GURL report_uri; |
| 213 | 213 |
| 214 // True if subdomains are subject to this policy | 214 // True if subdomains are subject to this policy |
| 215 bool include_subdomains; | 215 bool include_subdomains; |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 // An interface for asynchronously sending HPKP violation reports. | 218 // An interface for asynchronously sending HPKP violation reports. |
| 219 class NET_EXPORT ReportSender { | 219 class NET_EXPORT ReportSenderInterface { |
| 220 public: | 220 public: |
| 221 // Sends the given serialized |report| to |report_uri|. | 221 // Sends the given serialized |report| to |report_uri|. |
| 222 virtual void Send(const GURL& report_uri, const std::string& report) = 0; | 222 virtual void Send(const GURL& report_uri, const std::string& report) = 0; |
| 223 | 223 |
| 224 // Sets a callback to be called when report sending fails. | 224 // Sets a callback to be called when report sending fails. |
| 225 virtual void SetErrorCallback( | 225 virtual void SetErrorCallback( |
| 226 const base::Callback<void(const GURL&, int)>& error_callback) = 0; | 226 const base::Callback<void(const GURL&, int)>& error_callback) = 0; |
| 227 | 227 |
| 228 protected: | 228 protected: |
| 229 virtual ~ReportSender() {} | 229 virtual ~ReportSenderInterface() {} |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 // An interface for building and asynchronously sending reports when a | 232 // An interface for building and asynchronously sending reports when a |
| 233 // site expects valid Certificate Transparency information but it | 233 // site expects valid Certificate Transparency information but it |
| 234 // wasn't supplied. | 234 // wasn't supplied. |
| 235 class NET_EXPORT ExpectCTReporter { | 235 class NET_EXPORT ExpectCTReporter { |
| 236 public: | 236 public: |
| 237 // Called when the host in |host_port_pair| has opted in to have | 237 // Called when the host in |host_port_pair| has opted in to have |
| 238 // reports about Expect CT policy violations sent to |report_uri|, | 238 // reports about Expect CT policy violations sent to |report_uri|, |
| 239 // and such a violation has occurred. | 239 // and such a violation has occurred. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 267 std::string* failure_log); | 267 std::string* failure_log); |
| 268 bool HasPublicKeyPins(const std::string& host); | 268 bool HasPublicKeyPins(const std::string& host); |
| 269 | 269 |
| 270 // Assign a |Delegate| for persisting the transport security state. If | 270 // Assign a |Delegate| for persisting the transport security state. If |
| 271 // |NULL|, state will not be persisted. The caller retains | 271 // |NULL|, state will not be persisted. The caller retains |
| 272 // ownership of |delegate|. | 272 // ownership of |delegate|. |
| 273 // Note: This is only used for serializing/deserializing the | 273 // Note: This is only used for serializing/deserializing the |
| 274 // TransportSecurityState. | 274 // TransportSecurityState. |
| 275 void SetDelegate(Delegate* delegate); | 275 void SetDelegate(Delegate* delegate); |
| 276 | 276 |
| 277 void SetReportSender(ReportSender* report_sender); | 277 void SetReportSender(ReportSenderInterface* report_sender); |
| 278 | 278 |
| 279 void SetExpectCTReporter(ExpectCTReporter* expect_ct_reporter); | 279 void SetExpectCTReporter(ExpectCTReporter* expect_ct_reporter); |
| 280 | 280 |
| 281 // Clears all dynamic data (e.g. HSTS and HPKP data). | 281 // Clears all dynamic data (e.g. HSTS and HPKP data). |
| 282 // | 282 // |
| 283 // Does NOT persist changes using the Delegate, as this function is only | 283 // Does NOT persist changes using the Delegate, as this function is only |
| 284 // used to clear any dynamic data prior to re-loading it from a file. | 284 // used to clear any dynamic data prior to re-loading it from a file. |
| 285 // Note: This is only used for serializing/deserializing the | 285 // Note: This is only used for serializing/deserializing the |
| 286 // TransportSecurityState. | 286 // TransportSecurityState. |
| 287 void ClearDynamicData(); | 287 void ClearDynamicData(); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // The sets of hosts that have enabled TransportSecurity. |domain| will always | 475 // The sets of hosts that have enabled TransportSecurity. |domain| will always |
| 476 // be empty for a STSState or PKPState in these maps; the domain | 476 // be empty for a STSState or PKPState in these maps; the domain |
| 477 // comes from the map keys instead. In addition, |upgrade_mode| in the | 477 // comes from the map keys instead. In addition, |upgrade_mode| in the |
| 478 // STSState is never MODE_DEFAULT and |HasPublicKeyPins| in the PKPState | 478 // STSState is never MODE_DEFAULT and |HasPublicKeyPins| in the PKPState |
| 479 // always returns true. | 479 // always returns true. |
| 480 STSStateMap enabled_sts_hosts_; | 480 STSStateMap enabled_sts_hosts_; |
| 481 PKPStateMap enabled_pkp_hosts_; | 481 PKPStateMap enabled_pkp_hosts_; |
| 482 | 482 |
| 483 Delegate* delegate_; | 483 Delegate* delegate_; |
| 484 | 484 |
| 485 ReportSender* report_sender_; | 485 ReportSenderInterface* report_sender_; |
| 486 | 486 |
| 487 // True if static pins should be used. | 487 // True if static pins should be used. |
| 488 bool enable_static_pins_; | 488 bool enable_static_pins_; |
| 489 | 489 |
| 490 // True if static expect-CT state should be used. | 490 // True if static expect-CT state should be used. |
| 491 bool enable_static_expect_ct_; | 491 bool enable_static_expect_ct_; |
| 492 | 492 |
| 493 // True if static expect-staple state should be used. | 493 // True if static expect-staple state should be used. |
| 494 bool enable_static_expect_staple_; | 494 bool enable_static_expect_staple_; |
| 495 | 495 |
| 496 ExpectCTReporter* expect_ct_reporter_; | 496 ExpectCTReporter* expect_ct_reporter_; |
| 497 | 497 |
| 498 // Keeps track of reports that have been sent recently for | 498 // Keeps track of reports that have been sent recently for |
| 499 // rate-limiting. | 499 // rate-limiting. |
| 500 ExpiringCache<std::string, bool, base::TimeTicks, std::less<base::TimeTicks>> | 500 ExpiringCache<std::string, bool, base::TimeTicks, std::less<base::TimeTicks>> |
| 501 sent_reports_cache_; | 501 sent_reports_cache_; |
| 502 | 502 |
| 503 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); | 503 DISALLOW_COPY_AND_ASSIGN(TransportSecurityState); |
| 504 }; | 504 }; |
| 505 | 505 |
| 506 } // namespace net | 506 } // namespace net |
| 507 | 507 |
| 508 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ | 508 #endif // NET_HTTP_TRANSPORT_SECURITY_STATE_H_ |
| OLD | NEW |