| 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 "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 security, | 674 security, |
| 675 GetPassphrase(), | 675 GetPassphrase(), |
| 676 NULL, | 676 NULL, |
| 677 GetSaveCredentials(), | 677 GetSaveCredentials(), |
| 678 GetShareNetwork(share_default)); | 678 GetShareNetwork(share_default)); |
| 679 } else { | 679 } else { |
| 680 // Hidden 802.1X EAP Wi-Fi connection. | 680 // Hidden 802.1X EAP Wi-Fi connection. |
| 681 chromeos::NetworkLibrary::EAPConfigData config_data; | 681 chromeos::NetworkLibrary::EAPConfigData config_data; |
| 682 config_data.method = GetEapMethod(); | 682 config_data.method = GetEapMethod(); |
| 683 config_data.auth = GetEapPhase2Auth(); | 683 config_data.auth = GetEapPhase2Auth(); |
| 684 config_data.server_ca_cert_nss_nickname = GetEapServerCaCertNssNickname(); | 684 config_data.server_ca_cert_pem = GetEapServerCaCertPEM(); |
| 685 config_data.use_system_cas = GetEapUseSystemCas(); | 685 config_data.use_system_cas = GetEapUseSystemCas(); |
| 686 config_data.client_cert_pkcs11_id = GetEapClientCertPkcs11Id(); | 686 config_data.client_cert_pkcs11_id = GetEapClientCertPkcs11Id(); |
| 687 config_data.identity = GetEapIdentity(); | 687 config_data.identity = GetEapIdentity(); |
| 688 config_data.anonymous_identity = GetEapAnonymousIdentity(); | 688 config_data.anonymous_identity = GetEapAnonymousIdentity(); |
| 689 cros->ConnectToUnconfiguredWifiNetwork( | 689 cros->ConnectToUnconfiguredWifiNetwork( |
| 690 GetSsid(), | 690 GetSsid(), |
| 691 SECURITY_8021X, | 691 SECURITY_8021X, |
| 692 GetPassphrase(), | 692 GetPassphrase(), |
| 693 &config_data, | 693 &config_data, |
| 694 GetSaveCredentials(), | 694 GetSaveCredentials(), |
| 695 GetShareNetwork(share_default)); | 695 GetShareNetwork(share_default)); |
| 696 } | 696 } |
| 697 } else { | 697 } else { |
| 698 WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); | 698 WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); |
| 699 if (!wifi) { | 699 if (!wifi) { |
| 700 // Shill no longer knows about this wifi network (edge case). | 700 // Shill no longer knows about this wifi network (edge case). |
| 701 // TODO(stevenjb): Add a notification (chromium-os13225). | 701 // TODO(stevenjb): Add a notification (chromium-os13225). |
| 702 LOG(WARNING) << "Wifi network: " << service_path_ << " no longer exists."; | 702 LOG(WARNING) << "Wifi network: " << service_path_ << " no longer exists."; |
| 703 return true; | 703 return true; |
| 704 } | 704 } |
| 705 if (eap_method_combobox_) { | 705 if (eap_method_combobox_) { |
| 706 // Visible 802.1X EAP Wi-Fi connection. | 706 // Visible 802.1X EAP Wi-Fi connection. |
| 707 EAPMethod method = GetEapMethod(); | 707 EAPMethod method = GetEapMethod(); |
| 708 DCHECK(method != EAP_METHOD_UNKNOWN); | 708 DCHECK(method != EAP_METHOD_UNKNOWN); |
| 709 wifi->SetEAPMethod(method); | 709 wifi->SetEAPMethod(method); |
| 710 wifi->SetEAPPhase2Auth(GetEapPhase2Auth()); | 710 wifi->SetEAPPhase2Auth(GetEapPhase2Auth()); |
| 711 wifi->SetEAPServerCaCertNssNickname(GetEapServerCaCertNssNickname()); | 711 wifi->SetEAPServerCaCertPEM(GetEapServerCaCertPEM()); |
| 712 wifi->SetEAPUseSystemCAs(GetEapUseSystemCas()); | 712 wifi->SetEAPUseSystemCAs(GetEapUseSystemCas()); |
| 713 wifi->SetEAPClientCertPkcs11Id(GetEapClientCertPkcs11Id()); | 713 wifi->SetEAPClientCertPkcs11Id(GetEapClientCertPkcs11Id()); |
| 714 wifi->SetEAPIdentity(GetEapIdentity()); | 714 wifi->SetEAPIdentity(GetEapIdentity()); |
| 715 wifi->SetEAPAnonymousIdentity(GetEapAnonymousIdentity()); | 715 wifi->SetEAPAnonymousIdentity(GetEapAnonymousIdentity()); |
| 716 wifi->SetEAPPassphrase(GetPassphrase()); | 716 wifi->SetEAPPassphrase(GetPassphrase()); |
| 717 wifi->SetSaveCredentials(GetSaveCredentials()); | 717 wifi->SetSaveCredentials(GetSaveCredentials()); |
| 718 } else { | 718 } else { |
| 719 // Visible ordinary Wi-Fi connection. | 719 // Visible ordinary Wi-Fi connection. |
| 720 const std::string passphrase = GetPassphrase(); | 720 const std::string passphrase = GetPassphrase(); |
| 721 if (passphrase != wifi->passphrase()) | 721 if (passphrase != wifi->passphrase()) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 return EAP_PHASE_2_AUTH_MSCHAP; | 792 return EAP_PHASE_2_AUTH_MSCHAP; |
| 793 case PHASE_2_AUTH_INDEX_PAP: | 793 case PHASE_2_AUTH_INDEX_PAP: |
| 794 return EAP_PHASE_2_AUTH_PAP; | 794 return EAP_PHASE_2_AUTH_PAP; |
| 795 case PHASE_2_AUTH_INDEX_CHAP: | 795 case PHASE_2_AUTH_INDEX_CHAP: |
| 796 return EAP_PHASE_2_AUTH_CHAP; | 796 return EAP_PHASE_2_AUTH_CHAP; |
| 797 default: | 797 default: |
| 798 return EAP_PHASE_2_AUTH_AUTO; | 798 return EAP_PHASE_2_AUTH_AUTO; |
| 799 } | 799 } |
| 800 } | 800 } |
| 801 | 801 |
| 802 std::string WifiConfigView::GetEapServerCaCertNssNickname() const { | 802 std::string WifiConfigView::GetEapServerCaCertPEM() const { |
| 803 DCHECK(server_ca_cert_combobox_); | 803 DCHECK(server_ca_cert_combobox_); |
| 804 int index = server_ca_cert_combobox_->selected_index(); | 804 int index = server_ca_cert_combobox_->selected_index(); |
| 805 if (index == 0) { | 805 if (index == 0) { |
| 806 // First item is "Default". | 806 // First item is "Default". |
| 807 return std::string(); | 807 return std::string(); |
| 808 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { | 808 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { |
| 809 // Last item is "Do not check". | 809 // Last item is "Do not check". |
| 810 return std::string(); | 810 return std::string(); |
| 811 } else { | 811 } else { |
| 812 int cert_index = index - 1; | 812 int cert_index = index - 1; |
| 813 return CertLibrary::Get()->GetCertNicknameAt( | 813 return CertLibrary::Get()->GetCertPEMAt( |
| 814 CertLibrary::CERT_TYPE_SERVER_CA, cert_index); | 814 CertLibrary::CERT_TYPE_SERVER_CA, cert_index); |
| 815 } | 815 } |
| 816 } | 816 } |
| 817 | 817 |
| 818 bool WifiConfigView::GetEapUseSystemCas() const { | 818 bool WifiConfigView::GetEapUseSystemCas() const { |
| 819 DCHECK(server_ca_cert_combobox_); | 819 DCHECK(server_ca_cert_combobox_); |
| 820 // Only use system CAs if the first item ("Default") is selected. | 820 // Only use system CAs if the first item ("Default") is selected. |
| 821 return server_ca_cert_combobox_->selected_index() == 0; | 821 return server_ca_cert_combobox_->selected_index() == 0; |
| 822 } | 822 } |
| 823 | 823 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 } | 1173 } |
| 1174 | 1174 |
| 1175 const std::string& eap_anonymous_identity = | 1175 const std::string& eap_anonymous_identity = |
| 1176 (wifi ? wifi->eap_anonymous_identity() : std::string()); | 1176 (wifi ? wifi->eap_anonymous_identity() : std::string()); |
| 1177 identity_anonymous_textfield_->SetText( | 1177 identity_anonymous_textfield_->SetText( |
| 1178 UTF8ToUTF16(eap_anonymous_identity)); | 1178 UTF8ToUTF16(eap_anonymous_identity)); |
| 1179 } | 1179 } |
| 1180 | 1180 |
| 1181 // Server CA certificate. | 1181 // Server CA certificate. |
| 1182 if (CaCertActive()) { | 1182 if (CaCertActive()) { |
| 1183 const std::string& nss_nickname = | 1183 const std::string& ca_cert_pem = |
| 1184 (wifi ? wifi->eap_server_ca_cert_nss_nickname() : std::string()); | 1184 (wifi ? wifi->eap_server_ca_cert_pem() : std::string()); |
| 1185 if (nss_nickname.empty()) { | 1185 if (ca_cert_pem.empty()) { |
| 1186 if (wifi->eap_use_system_cas()) { | 1186 if (wifi->eap_use_system_cas()) { |
| 1187 // "Default". | 1187 // "Default". |
| 1188 server_ca_cert_combobox_->SetSelectedIndex(0); | 1188 server_ca_cert_combobox_->SetSelectedIndex(0); |
| 1189 } else { | 1189 } else { |
| 1190 // "Do not check". | 1190 // "Do not check". |
| 1191 server_ca_cert_combobox_->SetSelectedIndex( | 1191 server_ca_cert_combobox_->SetSelectedIndex( |
| 1192 server_ca_cert_combobox_->model()->GetItemCount() - 1); | 1192 server_ca_cert_combobox_->model()->GetItemCount() - 1); |
| 1193 } | 1193 } |
| 1194 } else { | 1194 } else { |
| 1195 // Select the certificate if available. | 1195 // Select the certificate if available. |
| 1196 int cert_index = CertLibrary::Get()->GetCertIndexByNickname( | 1196 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( |
| 1197 CertLibrary::CERT_TYPE_SERVER_CA, nss_nickname); | 1197 CertLibrary::CERT_TYPE_SERVER_CA, ca_cert_pem); |
| 1198 if (cert_index >= 0) { | 1198 if (cert_index >= 0) { |
| 1199 // Skip item for "Default". | 1199 // Skip item for "Default". |
| 1200 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); | 1200 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); |
| 1201 } | 1201 } |
| 1202 } | 1202 } |
| 1203 } | 1203 } |
| 1204 | 1204 |
| 1205 // User certificate. | 1205 // User certificate. |
| 1206 if (UserCertActive()) { | 1206 if (UserCertActive()) { |
| 1207 const std::string& pkcs11_id = | 1207 const std::string& pkcs11_id = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 void WifiConfigView::ParseWiFiEAPUIProperty( | 1258 void WifiConfigView::ParseWiFiEAPUIProperty( |
| 1259 NetworkPropertyUIData* property_ui_data, | 1259 NetworkPropertyUIData* property_ui_data, |
| 1260 Network* network, | 1260 Network* network, |
| 1261 const std::string& key) { | 1261 const std::string& key) { |
| 1262 ParseWiFiUIProperty( | 1262 ParseWiFiUIProperty( |
| 1263 property_ui_data, network, | 1263 property_ui_data, network, |
| 1264 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); | 1264 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 } // namespace chromeos | 1267 } // namespace chromeos |
| OLD | NEW |