OLD | NEW |
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/client_cert_resolver.h" | 5 #include "chromeos/network/client_cert_resolver.h" |
6 | 6 |
7 #include <cert.h> | 7 #include <cert.h> |
8 #include <certt.h> // for (SECCertUsageEnum) certUsageAnyCA | 8 #include <certt.h> // for (SECCertUsageEnum) certUsageAnyCA |
9 #include <pk11pub.h> | 9 #include <pk11pub.h> |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
19 #include "base/threading/worker_pool.h" | 19 #include "base/threading/worker_pool.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "chromeos/cert_loader.h" | 21 #include "chromeos/cert_loader.h" |
22 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
23 #include "chromeos/dbus/shill_service_client.h" | 23 #include "chromeos/dbus/shill_service_client.h" |
24 #include "chromeos/network/certificate_pattern.h" | 24 #include "chromeos/network/certificate_pattern.h" |
25 #include "chromeos/network/client_cert_util.h" | 25 #include "chromeos/network/client_cert_util.h" |
26 #include "chromeos/network/favorite_state.h" | 26 #include "chromeos/network/favorite_state.h" |
27 #include "chromeos/network/managed_network_configuration_handler.h" | 27 #include "chromeos/network/managed_network_configuration_handler.h" |
28 #include "chromeos/network/network_state_handler.h" | 28 #include "chromeos/network/network_state_handler.h" |
29 #include "chromeos/network/network_ui_data.h" | 29 #include "chromeos/network/network_ui_data.h" |
| 30 #include "chromeos/tpm_token_loader.h" |
30 #include "components/onc/onc_constants.h" | 31 #include "components/onc/onc_constants.h" |
31 #include "dbus/object_path.h" | 32 #include "dbus/object_path.h" |
32 #include "net/cert/x509_certificate.h" | 33 #include "net/cert/x509_certificate.h" |
33 | 34 |
34 namespace chromeos { | 35 namespace chromeos { |
35 | 36 |
36 // Describes a network |network_path| for which a matching certificate |cert_id| | 37 // Describes a network |network_path| for which a matching certificate |cert_id| |
37 // was found. | 38 // was found. |
38 struct ClientCertResolver::NetworkAndMatchingCert { | 39 struct ClientCertResolver::NetworkAndMatchingCert { |
39 NetworkAndMatchingCert(const std::string& network_path, | 40 NetworkAndMatchingCert(const std::string& network_path, |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } | 430 } |
430 | 431 |
431 void ClientCertResolver::ConfigureCertificates(NetworkCertMatches* matches) { | 432 void ClientCertResolver::ConfigureCertificates(NetworkCertMatches* matches) { |
432 for (NetworkCertMatches::const_iterator it = matches->begin(); | 433 for (NetworkCertMatches::const_iterator it = matches->begin(); |
433 it != matches->end(); ++it) { | 434 it != matches->end(); ++it) { |
434 VLOG(1) << "Configuring certificate of network " << it->service_path; | 435 VLOG(1) << "Configuring certificate of network " << it->service_path; |
435 CertLoader* cert_loader = CertLoader::Get(); | 436 CertLoader* cert_loader = CertLoader::Get(); |
436 base::DictionaryValue shill_properties; | 437 base::DictionaryValue shill_properties; |
437 client_cert::SetShillProperties( | 438 client_cert::SetShillProperties( |
438 it->cert_config_type, | 439 it->cert_config_type, |
439 base::IntToString(cert_loader->tpm_token_slot_id()), | 440 base::IntToString(cert_loader->TPMTokenSlotID()), |
440 cert_loader->tpm_user_pin(), | 441 TPMTokenLoader::Get()->tpm_user_pin(), |
441 &it->pkcs11_id, | 442 &it->pkcs11_id, |
442 &shill_properties); | 443 &shill_properties); |
443 DBusThreadManager::Get()->GetShillServiceClient()-> | 444 DBusThreadManager::Get()->GetShillServiceClient()-> |
444 SetProperties(dbus::ObjectPath(it->service_path), | 445 SetProperties(dbus::ObjectPath(it->service_path), |
445 shill_properties, | 446 shill_properties, |
446 base::Bind(&base::DoNothing), | 447 base::Bind(&base::DoNothing), |
447 base::Bind(&LogError, it->service_path)); | 448 base::Bind(&LogError, it->service_path)); |
448 network_state_handler_->RequestUpdateForNetwork(it->service_path); | 449 network_state_handler_->RequestUpdateForNetwork(it->service_path); |
449 } | 450 } |
450 } | 451 } |
451 | 452 |
452 } // namespace chromeos | 453 } // namespace chromeos |
OLD | NEW |