| 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 #include "chrome/browser/chromeos/options/wifi_config_view.h" | 5 #include "chrome/browser/chromeos/options/wifi_config_view.h" |
| 6 | 6 |
| 7 #include "ash/system/chromeos/network/network_connect.h" | 7 #include "ash/system/chromeos/network/network_connect.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 12 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| 13 #include "chrome/browser/chromeos/net/onc_utils.h" | 13 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 14 #include "chrome/browser/chromeos/options/passphrase_textfield.h" | 14 #include "chrome/browser/chromeos/options/passphrase_textfield.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chromeos/login/login_state.h" | 16 #include "chromeos/login/login_state.h" |
| 17 #include "chromeos/network/client_cert_util.h" | 17 #include "chromeos/network/client_cert_util.h" |
| 18 #include "chromeos/network/network_configuration_handler.h" | 18 #include "chromeos/network/network_configuration_handler.h" |
| 19 #include "chromeos/network/network_event_log.h" | 19 #include "chromeos/network/network_event_log.h" |
| 20 #include "chromeos/network/network_handler.h" | 20 #include "chromeos/network/network_handler.h" |
| 21 #include "chromeos/network/network_state.h" | 21 #include "chromeos/network/network_state.h" |
| 22 #include "chromeos/network/network_state_handler.h" | 22 #include "chromeos/network/network_state_handler.h" |
| 23 #include "chromeos/network/network_ui_data.h" | 23 #include "chromeos/network/network_ui_data.h" |
| 24 #include "chromeos/network/shill_property_util.h" | 24 #include "chromeos/network/shill_property_util.h" |
| 25 #include "chromeos/tpm_token_loader.h" | |
| 26 #include "components/onc/onc_constants.h" | 25 #include "components/onc/onc_constants.h" |
| 27 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
| 28 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 29 #include "grit/locale_settings.h" | 28 #include "grit/locale_settings.h" |
| 30 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 31 #include "third_party/cros_system_api/dbus/service_constants.h" | 30 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/events/event.h" | 33 #include "ui/events/event.h" |
| 35 #include "ui/views/controls/button/checkbox.h" | 34 #include "ui/views/controls/button/checkbox.h" |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 shill::kPassphraseProperty, passphrase); | 727 shill::kPassphraseProperty, passphrase); |
| 729 } | 728 } |
| 730 } | 729 } |
| 731 if (network->type() == shill::kTypeEthernet) { | 730 if (network->type() == shill::kTypeEthernet) { |
| 732 // When configuring an ethernet service, we actually configure the | 731 // When configuring an ethernet service, we actually configure the |
| 733 // EthernetEap service, which exists in the Profile only. | 732 // EthernetEap service, which exists in the Profile only. |
| 734 // See crbug.com/126870 for more info. | 733 // See crbug.com/126870 for more info. |
| 735 properties.SetStringWithoutPathExpansion(shill::kTypeProperty, | 734 properties.SetStringWithoutPathExpansion(shill::kTypeProperty, |
| 736 shill::kTypeEthernetEap); | 735 shill::kTypeEthernetEap); |
| 737 share_network = false; | 736 share_network = false; |
| 738 // Set the TPM PIN. | |
| 739 properties.SetStringWithoutPathExpansion( | |
| 740 shill::kEapPinProperty, TPMTokenLoader::Get()->tpm_user_pin()); | |
| 741 ash::network_connect::CreateConfiguration(&properties, share_network); | 737 ash::network_connect::CreateConfiguration(&properties, share_network); |
| 742 } else { | 738 } else { |
| 743 ash::network_connect::ConfigureNetworkAndConnect( | 739 ash::network_connect::ConfigureNetworkAndConnect( |
| 744 service_path_, properties, share_network); | 740 service_path_, properties, share_network); |
| 745 } | 741 } |
| 746 } | 742 } |
| 747 return true; // dialog will be closed | 743 return true; // dialog will be closed |
| 748 } | 744 } |
| 749 | 745 |
| 750 std::string WifiConfigView::GetSsid() const { | 746 std::string WifiConfigView::GetSsid() const { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 DCHECK(server_ca_cert_combobox_); | 829 DCHECK(server_ca_cert_combobox_); |
| 834 // Only use system CAs if the first item ("Default") is selected. | 830 // Only use system CAs if the first item ("Default") is selected. |
| 835 return server_ca_cert_combobox_->selected_index() == 0; | 831 return server_ca_cert_combobox_->selected_index() == 0; |
| 836 } | 832 } |
| 837 | 833 |
| 838 std::string WifiConfigView::GetEapSubjectMatch() const { | 834 std::string WifiConfigView::GetEapSubjectMatch() const { |
| 839 DCHECK(subject_match_textfield_); | 835 DCHECK(subject_match_textfield_); |
| 840 return base::UTF16ToUTF8(subject_match_textfield_->text()); | 836 return base::UTF16ToUTF8(subject_match_textfield_->text()); |
| 841 } | 837 } |
| 842 | 838 |
| 843 std::string WifiConfigView::GetEapClientCertPkcs11Id() const { | 839 void WifiConfigView::SetEapClientCertProperties( |
| 840 base::DictionaryValue* properties) const { |
| 844 DCHECK(user_cert_combobox_); | 841 DCHECK(user_cert_combobox_); |
| 845 if (!HaveUserCerts() || !UserCertActive()) { | 842 if (!HaveUserCerts() || !UserCertActive()) { |
| 846 return std::string(); // No certificate selected or not required. | 843 // No certificate selected or not required. |
| 844 client_cert::SetEmptyShillProperties(client_cert::CONFIG_TYPE_EAP, |
| 845 properties); |
| 847 } else { | 846 } else { |
| 848 // Certificates are listed in the order they appear in the model. | 847 // Certificates are listed in the order they appear in the model. |
| 849 int index = user_cert_combobox_->selected_index(); | 848 int index = user_cert_combobox_->selected_index(); |
| 850 return CertLibrary::Get()->GetUserCertPkcs11IdAt(index); | 849 int slot_id = -1; |
| 850 const std::string pkcs11_id = |
| 851 CertLibrary::Get()->GetUserCertPkcs11IdAt(index, &slot_id); |
| 852 client_cert::SetShillProperties( |
| 853 client_cert::CONFIG_TYPE_EAP, slot_id, pkcs11_id, properties); |
| 851 } | 854 } |
| 852 } | 855 } |
| 853 | 856 |
| 854 std::string WifiConfigView::GetEapIdentity() const { | 857 std::string WifiConfigView::GetEapIdentity() const { |
| 855 DCHECK(identity_textfield_); | 858 DCHECK(identity_textfield_); |
| 856 return base::UTF16ToUTF8(identity_textfield_->text()); | 859 return base::UTF16ToUTF8(identity_textfield_->text()); |
| 857 } | 860 } |
| 858 | 861 |
| 859 std::string WifiConfigView::GetEapAnonymousIdentity() const { | 862 std::string WifiConfigView::GetEapAnonymousIdentity() const { |
| 860 DCHECK(identity_anonymous_textfield_); | 863 DCHECK(identity_anonymous_textfield_); |
| 861 return base::UTF16ToUTF8(identity_anonymous_textfield_->text()); | 864 return base::UTF16ToUTF8(identity_anonymous_textfield_->text()); |
| 862 } | 865 } |
| 863 | 866 |
| 864 void WifiConfigView::SetEapProperties(base::DictionaryValue* properties) { | 867 void WifiConfigView::SetEapProperties(base::DictionaryValue* properties) { |
| 865 properties->SetStringWithoutPathExpansion( | 868 properties->SetStringWithoutPathExpansion( |
| 866 shill::kEapIdentityProperty, GetEapIdentity()); | 869 shill::kEapIdentityProperty, GetEapIdentity()); |
| 867 properties->SetStringWithoutPathExpansion( | 870 properties->SetStringWithoutPathExpansion( |
| 868 shill::kEapMethodProperty, GetEapMethod()); | 871 shill::kEapMethodProperty, GetEapMethod()); |
| 869 properties->SetStringWithoutPathExpansion( | 872 properties->SetStringWithoutPathExpansion( |
| 870 shill::kEapPhase2AuthProperty, GetEapPhase2Auth()); | 873 shill::kEapPhase2AuthProperty, GetEapPhase2Auth()); |
| 871 properties->SetStringWithoutPathExpansion( | 874 properties->SetStringWithoutPathExpansion( |
| 872 shill::kEapAnonymousIdentityProperty, GetEapAnonymousIdentity()); | 875 shill::kEapAnonymousIdentityProperty, GetEapAnonymousIdentity()); |
| 873 properties->SetStringWithoutPathExpansion( | 876 properties->SetStringWithoutPathExpansion( |
| 874 shill::kEapSubjectMatchProperty, GetEapSubjectMatch()); | 877 shill::kEapSubjectMatchProperty, GetEapSubjectMatch()); |
| 875 | 878 |
| 876 const std::string pkcs11id = GetEapClientCertPkcs11Id(); | 879 SetEapClientCertProperties(properties); |
| 877 client_cert::SetShillProperties(client_cert::CONFIG_TYPE_EAP, | |
| 878 CertLibrary::Get()->GetTPMSlotID(), | |
| 879 TPMTokenLoader::Get()->tpm_user_pin(), | |
| 880 &pkcs11id, | |
| 881 properties); | |
| 882 | 880 |
| 883 properties->SetBooleanWithoutPathExpansion( | 881 properties->SetBooleanWithoutPathExpansion( |
| 884 shill::kEapUseSystemCasProperty, GetEapUseSystemCas()); | 882 shill::kEapUseSystemCasProperty, GetEapUseSystemCas()); |
| 885 properties->SetStringWithoutPathExpansion( | 883 properties->SetStringWithoutPathExpansion( |
| 886 shill::kEapPasswordProperty, GetPassphrase()); | 884 shill::kEapPasswordProperty, GetPassphrase()); |
| 887 | 885 |
| 888 base::ListValue* pem_list = new base::ListValue; | 886 base::ListValue* pem_list = new base::ListValue; |
| 889 pem_list->AppendString(GetEapServerCaCertPEM()); | 887 pem_list->AppendString(GetEapServerCaCertPEM()); |
| 890 properties->SetWithoutPathExpansion( | 888 properties->SetWithoutPathExpansion( |
| 891 shill::kEapCaCertPemProperty, pem_list); | 889 shill::kEapCaCertPemProperty, pem_list); |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 void WifiConfigView::ParseEAPUIProperty(NetworkPropertyUIData* property_ui_data, | 1374 void WifiConfigView::ParseEAPUIProperty(NetworkPropertyUIData* property_ui_data, |
| 1377 const NetworkState* network, | 1375 const NetworkState* network, |
| 1378 const std::string& key) { | 1376 const std::string& key) { |
| 1379 std::string onc_tag = network->type() == shill::kTypeEthernet | 1377 std::string onc_tag = network->type() == shill::kTypeEthernet |
| 1380 ? ::onc::ethernet::kEAP | 1378 ? ::onc::ethernet::kEAP |
| 1381 : ::onc::wifi::kEAP; | 1379 : ::onc::wifi::kEAP; |
| 1382 ParseUIProperty(property_ui_data, network, onc_tag + '.' + key); | 1380 ParseUIProperty(property_ui_data, network, onc_tag + '.' + key); |
| 1383 } | 1381 } |
| 1384 | 1382 |
| 1385 } // namespace chromeos | 1383 } // namespace chromeos |
| OLD | NEW |