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

Side by Side Diff: chromeos/network/client_cert_resolver.h

Issue 1443043002: Execute ClientCertResolver on network disconnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed SimpleTestClock ownership Created 5 years, 1 month 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
« no previous file with comments | « no previous file | chromeos/network/client_cert_resolver.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROMEOS_NETWORK_CLIENT_CERT_RESOLVER_H_ 5 #ifndef CHROMEOS_NETWORK_CLIENT_CERT_RESOLVER_H_
6 #define CHROMEOS_NETWORK_CLIENT_CERT_RESOLVER_H_ 6 #define CHROMEOS_NETWORK_CLIENT_CERT_RESOLVER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
17 #include "base/observer_list.h" 16 #include "base/observer_list.h"
17 #include "base/time/time.h"
18 #include "chromeos/cert_loader.h" 18 #include "chromeos/cert_loader.h"
19 #include "chromeos/chromeos_export.h" 19 #include "chromeos/chromeos_export.h"
20 #include "chromeos/network/client_cert_util.h" 20 #include "chromeos/network/client_cert_util.h"
21 #include "chromeos/network/network_policy_observer.h" 21 #include "chromeos/network/network_policy_observer.h"
22 #include "chromeos/network/network_state_handler.h" 22 #include "chromeos/network/network_state_handler.h"
23 #include "chromeos/network/network_state_handler_observer.h" 23 #include "chromeos/network/network_state_handler_observer.h"
24 24
25 namespace base { 25 namespace base {
26 class Clock;
26 class TaskRunner; 27 class TaskRunner;
27 } 28 }
28 29
29 namespace chromeos { 30 namespace chromeos {
30 31
31 class NetworkState; 32 class NetworkState;
32 class ManagedNetworkConfigurationHandler; 33 class ManagedNetworkConfigurationHandler;
33 34
34 // Observes the known networks. If a network is configured with a client 35 // Observes the known networks. If a network is configured with a client
35 // certificate pattern, this class searches for a matching client certificate. 36 // certificate pattern, this class searches for a matching client certificate.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 const scoped_refptr<base::TaskRunner>& task_runner); 68 const scoped_refptr<base::TaskRunner>& task_runner);
68 69
69 void AddObserver(Observer* observer); 70 void AddObserver(Observer* observer);
70 void RemoveObserver(Observer* observer); 71 void RemoveObserver(Observer* observer);
71 72
72 // Returns true if any resolve tasks are running. Every time a task finishes 73 // Returns true if any resolve tasks are running. Every time a task finishes
73 // and no further requests are pending, a notification is sent, see 74 // and no further requests are pending, a notification is sent, see
74 // |Observer|. 75 // |Observer|.
75 bool IsAnyResolveTaskRunning() const; 76 bool IsAnyResolveTaskRunning() const;
76 77
78 // Sets the clock for testing. This clock is used when checking the
79 // certificates for expiration.
80 void SetClockForTesting(base::Clock* clock);
81
77 // Returns true and sets the Shill properties that have to be configured in 82 // Returns true and sets the Shill properties that have to be configured in
78 // |shill_properties| if the certificate pattern |pattern| could be resolved. 83 // |shill_properties| if the certificate pattern |pattern| could be resolved.
79 // Returns false otherwise and sets empty Shill properties to clear the 84 // Returns false otherwise and sets empty Shill properties to clear the
80 // certificate configuration. 85 // certificate configuration.
86 // Note that it uses the global clock when checking the certificates for
87 // expiration.
81 static bool ResolveCertificatePatternSync( 88 static bool ResolveCertificatePatternSync(
82 const client_cert::ConfigType client_cert_type, 89 const client_cert::ConfigType client_cert_type,
83 const CertificatePattern& pattern, 90 const CertificatePattern& pattern,
84 base::DictionaryValue* shill_properties); 91 base::DictionaryValue* shill_properties);
85 92
86 private: 93 private:
87 // NetworkStateHandlerObserver overrides 94 // NetworkStateHandlerObserver overrides
88 void NetworkListChanged() override; 95 void NetworkListChanged() override;
96 void NetworkConnectionStateChanged(const NetworkState* network) override;
89 97
90 // CertLoader::Observer overrides 98 // CertLoader::Observer overrides
91 void OnCertificatesLoaded(const net::CertificateList& cert_list, 99 void OnCertificatesLoaded(const net::CertificateList& cert_list,
92 bool initial_load) override; 100 bool initial_load) override;
93 101
94 // NetworkPolicyObserver overrides 102 // NetworkPolicyObserver overrides
95 void PolicyAppliedToNetwork(const std::string& service_path) override; 103 void PolicyAppliedToNetwork(const std::string& service_path) override;
96 104
97 // Check which networks of |networks| are configured with a client certificate 105 // Check which networks of |networks| are configured with a client certificate
98 // pattern. Search for certificates, on the worker thread, and configure the 106 // pattern. Search for certificates, on the worker thread, and configure the
99 // networks for which a matching cert is found (see ConfigureCertificates). 107 // networks for which a matching cert is found (see ConfigureCertificates).
100 void ResolveNetworks(const NetworkStateHandler::NetworkStateList& networks); 108 void ResolveNetworks(const NetworkStateHandler::NetworkStateList& networks);
101 109
102 // Resolves certificates for the pending networks. This will always trigger a 110 // Resolves certificates for the pending networks. This will always trigger a
103 // ResolveRequestCompleted notification, even if the queue is empty. 111 // ResolveRequestCompleted notification, even if the queue is empty.
104 void ResolvePendingNetworks(); 112 void ResolvePendingNetworks();
105 113
106 // |matches| contains networks for which a matching certificate was found. 114 // |matches| contains networks for which a matching certificate was found.
107 // Configures these networks. 115 // Configures these networks.
108 void ConfigureCertificates(std::vector<NetworkAndMatchingCert>* matches); 116 void ConfigureCertificates(std::vector<NetworkAndMatchingCert>* matches);
109 117
110 // Trigger a ResolveRequestCompleted event on all observers. 118 // Trigger a ResolveRequestCompleted event on all observers.
111 void NotifyResolveRequestCompleted(); 119 void NotifyResolveRequestCompleted();
112 120
121 // Returns Time::Now() unless a mock clock has been installed with
122 // SetClockForTesting, in which case the time according to that clock is used
123 // instead.
124 base::Time Now() const;
125
113 base::ObserverList<Observer> observers_; 126 base::ObserverList<Observer> observers_;
114 127
115 // The set of networks that were checked/resolved in previous passes. These 128 // The set of networks that were checked/resolved in previous passes. These
116 // networks are skipped in the NetworkListChanged notification. 129 // networks are skipped in the NetworkListChanged notification.
117 std::set<std::string> resolved_networks_; 130 std::set<std::string> resolved_networks_;
118 131
119 // The list of network paths that still have to be resolved. 132 // The list of network paths that still have to be resolved.
120 std::set<std::string> queued_networks_to_resolve_; 133 std::set<std::string> queued_networks_to_resolve_;
121 134
122 // True if currently a resolve task is running. 135 // True if currently a resolve task is running.
123 bool resolve_task_running_; 136 bool resolve_task_running_;
124 137
125 // True if any network properties were changed since the last notification to 138 // True if any network properties were changed since the last notification to
126 // observers. 139 // observers.
127 bool network_properties_changed_; 140 bool network_properties_changed_;
128 141
129 // Unowned associated (global or test) instance. 142 // Unowned associated (global or test) instance.
130 NetworkStateHandler* network_state_handler_; 143 NetworkStateHandler* network_state_handler_;
131 144
132 // Unowned associated (global or test) instance. 145 // Unowned associated (global or test) instance.
133 ManagedNetworkConfigurationHandler* managed_network_config_handler_; 146 ManagedNetworkConfigurationHandler* managed_network_config_handler_;
134 147
135 // TaskRunner for slow tasks. 148 // TaskRunner for slow tasks.
136 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_; 149 scoped_refptr<base::TaskRunner> slow_task_runner_for_test_;
137 150
151 // Can be set for testing.
152 base::Clock* testing_clock_;
153
138 base::WeakPtrFactory<ClientCertResolver> weak_ptr_factory_; 154 base::WeakPtrFactory<ClientCertResolver> weak_ptr_factory_;
139 155
140 DISALLOW_COPY_AND_ASSIGN(ClientCertResolver); 156 DISALLOW_COPY_AND_ASSIGN(ClientCertResolver);
141 }; 157 };
142 158
143 } // namespace chromeos 159 } // namespace chromeos
144 160
145 #endif // CHROMEOS_NETWORK_CLIENT_CERT_RESOLVER_H_ 161 #endif // CHROMEOS_NETWORK_CLIENT_CERT_RESOLVER_H_
OLDNEW
« no previous file with comments | « no previous file | chromeos/network/client_cert_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698