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_pem = GetServerCACertPEM(); |
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_pem = GetServerCACertPEM(); |
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::GetServerCACertPEM() 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()->GetCertPEMAt( |
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 void VPNConfigView::Refresh() { | 717 void VPNConfigView::Refresh() { |
718 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 718 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
719 | 719 |
720 UpdateControls(); | 720 UpdateControls(); |
721 | 721 |
722 // Set certificate combo boxes. | 722 // Set certificate combo boxes. |
723 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); | 723 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); |
724 if (server_ca_cert_combobox_) { | 724 if (server_ca_cert_combobox_) { |
725 server_ca_cert_combobox_->ModelChanged(); | 725 server_ca_cert_combobox_->ModelChanged(); |
726 if (enable_server_ca_cert_ && | 726 if (enable_server_ca_cert_ && |
727 (vpn && !vpn->ca_cert_nss().empty())) { | 727 (vpn && !vpn->ca_cert_pem().empty())) { |
728 // Select the current server CA certificate in the combobox. | 728 // Select the current server CA certificate in the combobox. |
729 int cert_index = CertLibrary::Get()->GetCertIndexByNickname( | 729 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( |
730 CertLibrary::CERT_TYPE_SERVER_CA, vpn->ca_cert_nss()); | 730 CertLibrary::CERT_TYPE_SERVER_CA, vpn->ca_cert_pem()); |
731 if (cert_index >= 0) { | 731 if (cert_index >= 0) { |
732 // Skip item for "Default" | 732 // Skip item for "Default" |
733 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); | 733 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); |
734 } else { | 734 } else { |
735 server_ca_cert_combobox_->SetSelectedIndex(0); | 735 server_ca_cert_combobox_->SetSelectedIndex(0); |
736 } | 736 } |
737 } else { | 737 } else { |
738 server_ca_cert_combobox_->SetSelectedIndex(0); | 738 server_ca_cert_combobox_->SetSelectedIndex(0); |
739 } | 739 } |
740 } | 740 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 | 908 |
909 property_ui_data->ParseOncProperty( | 909 property_ui_data->ParseOncProperty( |
910 network->ui_data().onc_source(), onc, | 910 network->ui_data().onc_source(), onc, |
911 base::StringPrintf("%s.%s.%s", | 911 base::StringPrintf("%s.%s.%s", |
912 onc::network_config::kVPN, | 912 onc::network_config::kVPN, |
913 dict_key.c_str(), | 913 dict_key.c_str(), |
914 key.c_str())); | 914 key.c_str())); |
915 } | 915 } |
916 | 916 |
917 } // namespace chromeos | 917 } // namespace chromeos |
OLD | NEW |