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

Side by Side Diff: chromeos/network/network_cert_migrator.cc

Issue 2858113003: Enable device-wide EAP-TLS networks (Closed)
Patch Set: Addressed comments and fixed weak_ptr access from wrong thread. Created 3 years, 7 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
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 #include "chromeos/network/network_cert_migrator.h" 5 #include "chromeos/network/network_cert_migrator.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/dbus/shill_service_client.h" 14 #include "chromeos/dbus/shill_service_client.h"
15 #include "chromeos/network/client_cert_util.h" 15 #include "chromeos/network/client_cert_util.h"
16 #include "chromeos/network/network_handler_callbacks.h" 16 #include "chromeos/network/network_handler_callbacks.h"
17 #include "chromeos/network/network_state.h" 17 #include "chromeos/network/network_state.h"
18 #include "chromeos/network/network_state_handler.h" 18 #include "chromeos/network/network_state_handler.h"
19 #include "dbus/object_path.h" 19 #include "dbus/object_path.h"
20 #include "net/cert/x509_certificate.h"
20 #include "third_party/cros_system_api/dbus/service_constants.h" 21 #include "third_party/cros_system_api/dbus/service_constants.h"
21 22
22 namespace chromeos { 23 namespace chromeos {
23 24
24 // Migrates each network of |networks| with an invalid or missing slot ID in 25 // Migrates each network of |networks| with an invalid or missing slot ID in
25 // their client certificate configuration. 26 // their client certificate configuration.
26 // 27 //
27 // If a network with a client certificate configuration (i.e. a PKCS11 ID) is 28 // If a network with a client certificate configuration (i.e. a PKCS11 ID) is
28 // found, the configured client certificate is looked up. 29 // found, the configured client certificate is looked up.
29 // If the certificate is found, the currently configured slot ID (if any) is 30 // If the certificate is found, the currently configured slot ID (if any) is
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void NetworkCertMigrator::Init(NetworkStateHandler* network_state_handler) { 173 void NetworkCertMigrator::Init(NetworkStateHandler* network_state_handler) {
173 DCHECK(network_state_handler); 174 DCHECK(network_state_handler);
174 network_state_handler_ = network_state_handler; 175 network_state_handler_ = network_state_handler;
175 network_state_handler_->AddObserver(this, FROM_HERE); 176 network_state_handler_->AddObserver(this, FROM_HERE);
176 177
177 DCHECK(CertLoader::IsInitialized()); 178 DCHECK(CertLoader::IsInitialized());
178 CertLoader::Get()->AddObserver(this); 179 CertLoader::Get()->AddObserver(this);
179 } 180 }
180 181
181 void NetworkCertMigrator::NetworkListChanged() { 182 void NetworkCertMigrator::NetworkListChanged() {
182 if (!CertLoader::Get()->certificates_loaded()) { 183 if (!CertLoader::Get()->initial_load_finished()) {
183 VLOG(2) << "Certs not loaded yet."; 184 VLOG(2) << "Certs not loaded yet.";
184 return; 185 return;
185 } 186 }
186 // Run the migration process to fix missing or incorrect slot ids of client 187 // Run the migration process to fix missing or incorrect slot ids of client
187 // certificates. 188 // certificates.
188 VLOG(2) << "Start certificate migration of network configurations."; 189 VLOG(2) << "Start certificate migration of network configurations.";
189 scoped_refptr<MigrationTask> helper(new MigrationTask( 190 scoped_refptr<MigrationTask> helper(new MigrationTask(
190 CertLoader::Get()->all_certs(), weak_ptr_factory_.GetWeakPtr())); 191 CertLoader::Get()->all_certs(), weak_ptr_factory_.GetWeakPtr()));
191 NetworkStateHandler::NetworkStateList networks; 192 NetworkStateHandler::NetworkStateList networks;
192 network_state_handler_->GetNetworkListByType( 193 network_state_handler_->GetNetworkListByType(
193 NetworkTypePattern::Default(), 194 NetworkTypePattern::Default(),
194 true, // only configured networks 195 true, // only configured networks
195 false, // visible and not visible networks 196 false, // visible and not visible networks
196 0, // no count limit 197 0, // no count limit
197 &networks); 198 &networks);
198 helper->Run(networks); 199 helper->Run(networks);
199 } 200 }
200 201
201 void NetworkCertMigrator::OnCertificatesLoaded( 202 void NetworkCertMigrator::OnCertificatesLoaded(
202 const net::CertificateList& cert_list, 203 const net::CertificateList& cert_list,
203 bool initial_load) { 204 bool initial_load) {
204 if (initial_load) 205 if (initial_load)
205 NetworkListChanged(); 206 NetworkListChanged();
206 } 207 }
207 208
208 } // namespace chromeos 209 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/client_cert_resolver_unittest.cc ('k') | chromeos/network/network_cert_migrator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698