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

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

Issue 135193007: Use user specific NSSDatabase in CertLoader. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_connection_handler.h" 5 #include "chromeos/network/network_connection_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "chromeos/cert_loader.h"
12 #include "chromeos/chromeos_switches.h" 13 #include "chromeos/chromeos_switches.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 14 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "chromeos/dbus/shill_manager_client.h" 15 #include "chromeos/dbus/shill_manager_client.h"
15 #include "chromeos/dbus/shill_service_client.h" 16 #include "chromeos/dbus/shill_service_client.h"
16 #include "chromeos/network/client_cert_util.h" 17 #include "chromeos/network/client_cert_util.h"
17 #include "chromeos/network/network_configuration_handler.h" 18 #include "chromeos/network/network_configuration_handler.h"
18 #include "chromeos/network/network_event_log.h" 19 #include "chromeos/network/network_event_log.h"
19 #include "chromeos/network/network_handler_callbacks.h" 20 #include "chromeos/network/network_handler_callbacks.h"
20 #include "chromeos/network/network_profile_handler.h" 21 #include "chromeos/network/network_profile_handler.h"
21 #include "chromeos/network/network_state.h" 22 #include "chromeos/network/network_state.h"
22 #include "chromeos/network/network_state_handler.h" 23 #include "chromeos/network/network_state_handler.h"
23 #include "chromeos/network/network_ui_data.h" 24 #include "chromeos/network/network_ui_data.h"
24 #include "chromeos/network/shill_property_util.h" 25 #include "chromeos/network/shill_property_util.h"
26 #include "chromeos/tpm_token_loader.h"
25 #include "dbus/object_path.h" 27 #include "dbus/object_path.h"
26 #include "net/cert/x509_certificate.h" 28 #include "net/cert/x509_certificate.h"
27 #include "third_party/cros_system_api/dbus/service_constants.h" 29 #include "third_party/cros_system_api/dbus/service_constants.h"
28 30
29 namespace chromeos { 31 namespace chromeos {
30 32
31 namespace { 33 namespace {
32 34
33 void InvokeErrorCallback(const std::string& service_path, 35 void InvokeErrorCallback(const std::string& service_path,
34 const network_handler::ErrorCallback& error_callback, 36 const network_handler::ErrorCallback& error_callback,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 LoginState::Get()->RemoveObserver(this); 156 LoginState::Get()->RemoveObserver(this);
155 } 157 }
156 158
157 void NetworkConnectionHandler::Init( 159 void NetworkConnectionHandler::Init(
158 NetworkStateHandler* network_state_handler, 160 NetworkStateHandler* network_state_handler,
159 NetworkConfigurationHandler* network_configuration_handler) { 161 NetworkConfigurationHandler* network_configuration_handler) {
160 if (LoginState::IsInitialized()) { 162 if (LoginState::IsInitialized()) {
161 LoginState::Get()->AddObserver(this); 163 LoginState::Get()->AddObserver(this);
162 logged_in_ = LoginState::Get()->IsUserLoggedIn(); 164 logged_in_ = LoginState::Get()->IsUserLoggedIn();
163 } 165 }
166
164 if (CertLoader::IsInitialized()) { 167 if (CertLoader::IsInitialized()) {
165 cert_loader_ = CertLoader::Get(); 168 cert_loader_ = CertLoader::Get();
166 cert_loader_->AddObserver(this); 169 cert_loader_->AddObserver(this);
167 certificates_loaded_ = cert_loader_->certificates_loaded(); 170 certificates_loaded_ = cert_loader_->certificates_loaded();
168 } else { 171 } else {
169 // TODO(stevenjb): Require a mock or stub cert_loader in tests. 172 // TODO(tbarzic): Require a mock or stub cert_loader in tests.
170 certificates_loaded_ = true; 173 certificates_loaded_ = true;
171 } 174 }
175
172 if (network_state_handler) { 176 if (network_state_handler) {
173 network_state_handler_ = network_state_handler; 177 network_state_handler_ = network_state_handler;
174 network_state_handler_->AddObserver(this, FROM_HERE); 178 network_state_handler_->AddObserver(this, FROM_HERE);
175 } 179 }
176 network_configuration_handler_ = network_configuration_handler; 180 network_configuration_handler_ = network_configuration_handler;
177 } 181 }
178 182
179 void NetworkConnectionHandler::LoggedInStateChanged() { 183 void NetworkConnectionHandler::LoggedInStateChanged() {
180 if (LoginState::Get()->IsUserLoggedIn()) { 184 if (LoginState::Get()->IsUserLoggedIn()) {
181 logged_in_ = true; 185 logged_in_ = true;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 return; 448 return;
445 } 449 }
446 450
447 // The network may not be 'Connectable' because the TPM properties are not 451 // The network may not be 'Connectable' because the TPM properties are not
448 // set up, so configure tpm slot/pin before connecting. 452 // set up, so configure tpm slot/pin before connecting.
449 if (cert_loader_ && cert_loader_->IsHardwareBacked()) { 453 if (cert_loader_ && cert_loader_->IsHardwareBacked()) {
450 // Pass NULL if pkcs11_id is empty, so that it doesn't clear any 454 // Pass NULL if pkcs11_id is empty, so that it doesn't clear any
451 // previously configured client cert. 455 // previously configured client cert.
452 client_cert::SetShillProperties( 456 client_cert::SetShillProperties(
453 client_cert_type, 457 client_cert_type,
454 base::IntToString(cert_loader_->tpm_token_slot_id()), 458 base::IntToString(cert_loader_->TPMTokenSlotID()),
455 cert_loader_->tpm_user_pin(), 459 TPMTokenLoader::Get()->tpm_user_pin(),
456 pkcs11_id.empty() ? NULL : &pkcs11_id, 460 pkcs11_id.empty() ? NULL : &pkcs11_id,
457 &config_properties); 461 &config_properties);
458 } 462 }
459 } 463 }
460 464
461 if (type == shill::kTypeVPN) { 465 if (type == shill::kTypeVPN) {
462 // VPN may require a username, and/or passphrase to be set. (Check after 466 // VPN may require a username, and/or passphrase to be set. (Check after
463 // ensuring that any required certificates are configured). 467 // ensuring that any required certificates are configured).
464 DCHECK(provider_properties); 468 DCHECK(provider_properties);
465 if (VPNRequiresCredentials( 469 if (VPNRequiresCredentials(
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 CheckPendingRequest(iter->first); 629 CheckPendingRequest(iter->first);
626 } 630 }
627 } 631 }
628 632
629 std::string NetworkConnectionHandler::CertificateIsConfigured( 633 std::string NetworkConnectionHandler::CertificateIsConfigured(
630 NetworkUIData* ui_data) { 634 NetworkUIData* ui_data) {
631 if (ui_data->certificate_pattern().Empty()) 635 if (ui_data->certificate_pattern().Empty())
632 return std::string(); 636 return std::string();
633 // Find the matching certificate. 637 // Find the matching certificate.
634 scoped_refptr<net::X509Certificate> matching_cert = 638 scoped_refptr<net::X509Certificate> matching_cert =
635 client_cert::GetCertificateMatch(ui_data->certificate_pattern()); 639 client_cert::GetCertificateMatch(ui_data->certificate_pattern(),
640 cert_loader_->cert_list());
636 if (!matching_cert.get()) 641 if (!matching_cert.get())
637 return std::string(); 642 return std::string();
638 return CertLoader::GetPkcs11IdForCert(*matching_cert.get()); 643 return CertLoader::GetPkcs11IdForCert(*matching_cert.get());
639 } 644 }
640 645
641 void NetworkConnectionHandler::ErrorCallbackForPendingRequest( 646 void NetworkConnectionHandler::ErrorCallbackForPendingRequest(
642 const std::string& service_path, 647 const std::string& service_path,
643 const std::string& error_name) { 648 const std::string& error_name) {
644 ConnectRequest* request = GetPendingRequest(service_path); 649 ConnectRequest* request = GetPendingRequest(service_path);
645 if (!request) { 650 if (!request) {
(...skipping 24 matching lines...) Expand all
670 675
671 void NetworkConnectionHandler::HandleShillDisconnectSuccess( 676 void NetworkConnectionHandler::HandleShillDisconnectSuccess(
672 const std::string& service_path, 677 const std::string& service_path,
673 const base::Closure& success_callback) { 678 const base::Closure& success_callback) {
674 NET_LOG_EVENT("Disconnect Request Sent", service_path); 679 NET_LOG_EVENT("Disconnect Request Sent", service_path);
675 if (!success_callback.is_null()) 680 if (!success_callback.is_null())
676 success_callback.Run(); 681 success_callback.Run();
677 } 682 }
678 683
679 } // namespace chromeos 684 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_cert_migrator_unittest.cc ('k') | chromeos/network/network_connection_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698