Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/chromeos/options/vpn_config_view.cc

Issue 421113002: Use correct slot id for client certs in network config. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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"
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 server_ca_cert_combobox_->selected_index() : 0; 446 server_ca_cert_combobox_->selected_index() : 0;
447 if (index == 0) { 447 if (index == 0) {
448 // First item is "Default". 448 // First item is "Default".
449 return std::string(); 449 return std::string();
450 } else { 450 } else {
451 int cert_index = index - 1; 451 int cert_index = index - 1;
452 return CertLibrary::Get()->GetServerCACertPEMAt(cert_index); 452 return CertLibrary::Get()->GetServerCACertPEMAt(cert_index);
453 } 453 }
454 } 454 }
455 455
456 const std::string VPNConfigView::GetUserCertID() const { 456 void VPNConfigView::SetUserCertProperties(
457 chromeos::client_cert::ConfigType client_cert_type,
458 base::DictionaryValue* properties) const {
457 if (!HaveUserCerts()) { 459 if (!HaveUserCerts()) {
458 return std::string(); // "None installed" 460 // No certificate selected or not required.
461 chromeos::client_cert::SetEmptyShillProperties(
462 chromeos::client_cert::CONFIG_TYPE_EAP, properties);
459 } else { 463 } else {
460 // Certificates are listed in the order they appear in the model. 464 // Certificates are listed in the order they appear in the model.
461 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0; 465 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0;
462 return CertLibrary::Get()->GetUserCertPkcs11IdAt(index); 466 int slot_id = -1;
467 const std::string pkcs11_id =
468 CertLibrary::Get()->GetUserCertPkcs11IdAt(index, &slot_id);
469 chromeos::client_cert::SetShillProperties(
470 client_cert_type, slot_id, pkcs11_id, properties);
463 } 471 }
464 } 472 }
465 473
466 bool VPNConfigView::GetSaveCredentials() const { 474 bool VPNConfigView::GetSaveCredentials() const {
467 return save_credentials_checkbox_->checked(); 475 return save_credentials_checkbox_->checked();
468 } 476 }
469 477
470 int VPNConfigView::GetProviderTypeIndex() const { 478 int VPNConfigView::GetProviderTypeIndex() const {
471 if (provider_type_combobox_) 479 if (provider_type_combobox_)
472 return provider_type_combobox_->selected_index(); 480 return provider_type_combobox_->selected_index();
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 break; 838 break;
831 } 839 }
832 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT: { 840 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT: {
833 std::string ca_cert_pem = GetServerCACertPEM(); 841 std::string ca_cert_pem = GetServerCACertPEM();
834 if (!ca_cert_pem.empty()) { 842 if (!ca_cert_pem.empty()) {
835 base::ListValue* pem_list = new base::ListValue; 843 base::ListValue* pem_list = new base::ListValue;
836 pem_list->AppendString(ca_cert_pem); 844 pem_list->AppendString(ca_cert_pem);
837 properties->SetWithoutPathExpansion( 845 properties->SetWithoutPathExpansion(
838 shill::kL2tpIpsecCaCertPemProperty, pem_list); 846 shill::kL2tpIpsecCaCertPemProperty, pem_list);
839 } 847 }
840 properties->SetStringWithoutPathExpansion( 848 SetUserCertProperties(client_cert::CONFIG_TYPE_IPSEC, properties);
841 shill::kL2tpIpsecClientCertIdProperty, GetUserCertID());
842 if (!group_name.empty()) { 849 if (!group_name.empty()) {
843 properties->SetStringWithoutPathExpansion( 850 properties->SetStringWithoutPathExpansion(
844 shill::kL2tpIpsecTunnelGroupProperty, GetGroupName()); 851 shill::kL2tpIpsecTunnelGroupProperty, GetGroupName());
845 } 852 }
846 if (!user_name.empty()) { 853 if (!user_name.empty()) {
847 properties->SetStringWithoutPathExpansion( 854 properties->SetStringWithoutPathExpansion(
848 shill::kL2tpIpsecUserProperty, user_name); 855 shill::kL2tpIpsecUserProperty, user_name);
849 } 856 }
850 if (!user_passphrase.empty()) { 857 if (!user_passphrase.empty()) {
851 properties->SetStringWithoutPathExpansion( 858 properties->SetStringWithoutPathExpansion(
852 shill::kL2tpIpsecPasswordProperty, user_passphrase); 859 shill::kL2tpIpsecPasswordProperty, user_passphrase);
853 } 860 }
854 break; 861 break;
855 } 862 }
856 case PROVIDER_TYPE_INDEX_OPEN_VPN: { 863 case PROVIDER_TYPE_INDEX_OPEN_VPN: {
857 std::string ca_cert_pem = GetServerCACertPEM(); 864 std::string ca_cert_pem = GetServerCACertPEM();
858 if (!ca_cert_pem.empty()) { 865 if (!ca_cert_pem.empty()) {
859 base::ListValue* pem_list = new base::ListValue; 866 base::ListValue* pem_list = new base::ListValue;
860 pem_list->AppendString(ca_cert_pem); 867 pem_list->AppendString(ca_cert_pem);
861 properties->SetWithoutPathExpansion( 868 properties->SetWithoutPathExpansion(
862 shill::kOpenVPNCaCertPemProperty, pem_list); 869 shill::kOpenVPNCaCertPemProperty, pem_list);
863 } 870 }
864 properties->SetStringWithoutPathExpansion( 871 SetUserCertProperties(client_cert::CONFIG_TYPE_OPENVPN, properties);
865 shill::kOpenVPNClientCertIdProperty, GetUserCertID());
866 properties->SetStringWithoutPathExpansion( 872 properties->SetStringWithoutPathExpansion(
867 shill::kOpenVPNUserProperty, GetUsername()); 873 shill::kOpenVPNUserProperty, GetUsername());
868 if (!user_passphrase.empty()) { 874 if (!user_passphrase.empty()) {
869 properties->SetStringWithoutPathExpansion( 875 properties->SetStringWithoutPathExpansion(
870 shill::kOpenVPNPasswordProperty, user_passphrase); 876 shill::kOpenVPNPasswordProperty, user_passphrase);
871 } 877 }
872 std::string otp = GetOTP(); 878 std::string otp = GetOTP();
873 if (!otp.empty()) { 879 if (!otp.empty()) {
874 properties->SetStringWithoutPathExpansion( 880 properties->SetStringWithoutPathExpansion(
875 shill::kOpenVPNOTPProperty, otp); 881 shill::kOpenVPNOTPProperty, otp);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 property_ui_data->ParseOncProperty( 1066 property_ui_data->ParseOncProperty(
1061 onc_source, 1067 onc_source,
1062 onc, 1068 onc,
1063 base::StringPrintf("%s.%s.%s", 1069 base::StringPrintf("%s.%s.%s",
1064 ::onc::network_config::kVPN, 1070 ::onc::network_config::kVPN,
1065 dict_key.c_str(), 1071 dict_key.c_str(),
1066 key.c_str())); 1072 key.c_str()));
1067 } 1073 }
1068 1074
1069 } // namespace chromeos 1075 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/options/vpn_config_view.h ('k') | chrome/browser/chromeos/options/wifi_config_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698