| 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/vpn_config_view.h" | 5 #include "chrome/browser/chromeos/options/vpn_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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (service_path_.empty()) { | 306 if (service_path_.empty()) { |
| 307 NetworkLibrary::VPNConfigData config_data; | 307 NetworkLibrary::VPNConfigData config_data; |
| 308 switch (provider_type_) { | 308 switch (provider_type_) { |
| 309 case PROVIDER_TYPE_L2TP_IPSEC_PSK: | 309 case PROVIDER_TYPE_L2TP_IPSEC_PSK: |
| 310 config_data.psk = GetPSKPassphrase(); | 310 config_data.psk = GetPSKPassphrase(); |
| 311 config_data.username = GetUsername(); | 311 config_data.username = GetUsername(); |
| 312 config_data.user_passphrase = GetUserPassphrase(); | 312 config_data.user_passphrase = GetUserPassphrase(); |
| 313 config_data.group_name = GetGroupName(); | 313 config_data.group_name = GetGroupName(); |
| 314 break; | 314 break; |
| 315 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: { | 315 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: { |
| 316 config_data.server_ca_cert_nss_nickname = GetServerCACertNssNickname(); | 316 config_data.server_ca_cert_fingerprint = GetServerCACertFingerprint(); |
| 317 config_data.client_cert_pkcs11_id = GetUserCertID(); | 317 config_data.client_cert_pkcs11_id = GetUserCertID(); |
| 318 config_data.username = GetUsername(); | 318 config_data.username = GetUsername(); |
| 319 config_data.user_passphrase = GetUserPassphrase(); | 319 config_data.user_passphrase = GetUserPassphrase(); |
| 320 config_data.group_name = GetGroupName(); | 320 config_data.group_name = GetGroupName(); |
| 321 break; | 321 break; |
| 322 } | 322 } |
| 323 case PROVIDER_TYPE_OPEN_VPN: | 323 case PROVIDER_TYPE_OPEN_VPN: |
| 324 config_data.server_ca_cert_nss_nickname = GetServerCACertNssNickname(); | 324 config_data.server_ca_cert_fingerprint = GetServerCACertFingerprint(); |
| 325 config_data.client_cert_pkcs11_id = GetUserCertID(); | 325 config_data.client_cert_pkcs11_id = GetUserCertID(); |
| 326 config_data.username = GetUsername(); | 326 config_data.username = GetUsername(); |
| 327 config_data.user_passphrase = GetUserPassphrase(); | 327 config_data.user_passphrase = GetUserPassphrase(); |
| 328 config_data.otp = GetOTP(); | 328 config_data.otp = GetOTP(); |
| 329 break; | 329 break; |
| 330 case PROVIDER_TYPE_MAX: | 330 case PROVIDER_TYPE_MAX: |
| 331 break; | 331 break; |
| 332 } | 332 } |
| 333 config_data.save_credentials = GetSaveCredentials(); | 333 config_data.save_credentials = GetSaveCredentials(); |
| 334 cros->ConnectToUnconfiguredVirtualNetwork( | 334 cros->ConnectToUnconfiguredVirtualNetwork( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 414 } |
| 415 | 415 |
| 416 const std::string VPNConfigView::GetGroupName() const { | 416 const std::string VPNConfigView::GetGroupName() const { |
| 417 return GetTextFromField(group_name_textfield_, false); | 417 return GetTextFromField(group_name_textfield_, false); |
| 418 } | 418 } |
| 419 | 419 |
| 420 const std::string VPNConfigView::GetOTP() const { | 420 const std::string VPNConfigView::GetOTP() const { |
| 421 return GetTextFromField(otp_textfield_, true); | 421 return GetTextFromField(otp_textfield_, true); |
| 422 } | 422 } |
| 423 | 423 |
| 424 const std::string VPNConfigView::GetServerCACertNssNickname() const { | 424 const std::string VPNConfigView::GetServerCACertFingerprint() const { |
| 425 int index = server_ca_cert_combobox_ ? | 425 int index = server_ca_cert_combobox_ ? |
| 426 server_ca_cert_combobox_->selected_index() : 0; | 426 server_ca_cert_combobox_->selected_index() : 0; |
| 427 if (index == 0) { | 427 if (index == 0) { |
| 428 // First item is "Default". | 428 // First item is "Default". |
| 429 return std::string(); | 429 return std::string(); |
| 430 } else { | 430 } else { |
| 431 int cert_index = index - 1; | 431 int cert_index = index - 1; |
| 432 return CertLibrary::Get()->GetCertNicknameAt( | 432 return CertLibrary::Get()->GetCertFingerprintAt( |
| 433 CertLibrary::CERT_TYPE_SERVER_CA, cert_index); | 433 CertLibrary::CERT_TYPE_SERVER_CA, cert_index); |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 | 436 |
| 437 const std::string VPNConfigView::GetUserCertID() const { | 437 const std::string VPNConfigView::GetUserCertID() const { |
| 438 if (!HaveUserCerts()) { | 438 if (!HaveUserCerts()) { |
| 439 return std::string(); // "None installed" | 439 return std::string(); // "None installed" |
| 440 } else { | 440 } else { |
| 441 // Certificates are listed in the order they appear in the model. | 441 // Certificates are listed in the order they appear in the model. |
| 442 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0; | 442 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 void VPNConfigView::Refresh() { | 711 void VPNConfigView::Refresh() { |
| 712 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 712 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 713 | 713 |
| 714 UpdateControls(); | 714 UpdateControls(); |
| 715 | 715 |
| 716 // Set certificate combo boxes. | 716 // Set certificate combo boxes. |
| 717 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); | 717 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); |
| 718 if (server_ca_cert_combobox_) { | 718 if (server_ca_cert_combobox_) { |
| 719 server_ca_cert_combobox_->ModelChanged(); | 719 server_ca_cert_combobox_->ModelChanged(); |
| 720 if (enable_server_ca_cert_ && | 720 if (enable_server_ca_cert_ && |
| 721 (vpn && !vpn->ca_cert_nss().empty())) { | 721 (vpn && !vpn->ca_cert_fingerprint().empty())) { |
| 722 // Select the current server CA certificate in the combobox. | 722 // Select the current server CA certificate in the combobox. |
| 723 int cert_index = CertLibrary::Get()->GetCertIndexByNickname( | 723 int cert_index = CertLibrary::Get()->GetCertIndexByFingerprint( |
| 724 CertLibrary::CERT_TYPE_SERVER_CA, vpn->ca_cert_nss()); | 724 CertLibrary::CERT_TYPE_SERVER_CA, vpn->ca_cert_fingerprint()); |
| 725 if (cert_index >= 0) { | 725 if (cert_index >= 0) { |
| 726 // Skip item for "Default" | 726 // Skip item for "Default" |
| 727 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); | 727 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); |
| 728 } else { | 728 } else { |
| 729 server_ca_cert_combobox_->SetSelectedIndex(0); | 729 server_ca_cert_combobox_->SetSelectedIndex(0); |
| 730 } | 730 } |
| 731 } else { | 731 } else { |
| 732 server_ca_cert_combobox_->SetSelectedIndex(0); | 732 server_ca_cert_combobox_->SetSelectedIndex(0); |
| 733 } | 733 } |
| 734 } | 734 } |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 | 902 |
| 903 property_ui_data->ParseOncProperty( | 903 property_ui_data->ParseOncProperty( |
| 904 network->ui_data().onc_source(), onc, | 904 network->ui_data().onc_source(), onc, |
| 905 base::StringPrintf("%s.%s.%s", | 905 base::StringPrintf("%s.%s.%s", |
| 906 onc::network_config::kVPN, | 906 onc::network_config::kVPN, |
| 907 dict_key.c_str(), | 907 dict_key.c_str(), |
| 908 key.c_str())); | 908 key.c_str())); |
| 909 } | 909 } |
| 910 | 910 |
| 911 } // namespace chromeos | 911 } // namespace chromeos |
| OLD | NEW |