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/cros/network_library.h" | 5 #include "chrome/browser/chromeos/cros/network_library.h" |
6 | 6 |
7 #include "base/i18n/icu_encoding_detection.h" | 7 #include "base/i18n/icu_encoding_detection.h" |
8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/json/json_writer.h" // for debug output only. | 10 #include "base/json/json_writer.h" // for debug output only. |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversion_utils.h" | 12 #include "base/strings/utf_string_conversion_utils.h" |
13 #include "chrome/browser/chromeos/cros/cros_library.h" | 13 #include "chrome/browser/chromeos/cros/cros_library.h" |
14 #include "chrome/browser/chromeos/cros/native_network_constants.h" | 14 #include "chrome/browser/chromeos/cros/native_network_constants.h" |
15 #include "chrome/browser/chromeos/cros/native_network_parser.h" | 15 #include "chrome/browser/chromeos/cros/native_network_parser.h" |
16 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h" | 16 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h" |
17 #include "chrome/browser/chromeos/cros/network_library_impl_stub.h" | 17 #include "chrome/browser/chromeos/cros/network_library_impl_stub.h" |
18 #include "chrome/common/net/x509_certificate_model.h" | 18 #include "chrome/common/net/x509_certificate_model.h" |
| 19 #include "chromeos/network/cert_loader.h" |
19 #include "chromeos/network/certificate_pattern.h" | 20 #include "chromeos/network/certificate_pattern.h" |
20 #include "chromeos/network/certificate_pattern_matcher.h" | 21 #include "chromeos/network/certificate_pattern_matcher.h" |
21 #include "chromeos/network/cros_network_functions.h" | 22 #include "chromeos/network/cros_network_functions.h" |
22 #include "chromeos/network/network_state_handler.h" | 23 #include "chromeos/network/network_state_handler.h" |
| 24 #include "chromeos/network/onc/onc_utils.h" |
23 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
24 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
25 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
26 #include "net/base/url_util.h" | 28 #include "net/base/url_util.h" |
27 #include "third_party/cros_system_api/dbus/service_constants.h" | 29 #include "third_party/cros_system_api/dbus/service_constants.h" |
28 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
29 | 31 |
30 using content::BrowserThread; | 32 using content::BrowserThread; |
31 | 33 |
32 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 provider_type_(PROVIDER_TYPE_L2TP_IPSEC_PSK), | 586 provider_type_(PROVIDER_TYPE_L2TP_IPSEC_PSK), |
585 // Assume PSK and user passphrase are not available initially | 587 // Assume PSK and user passphrase are not available initially |
586 psk_passphrase_required_(true), | 588 psk_passphrase_required_(true), |
587 user_passphrase_required_(true), | 589 user_passphrase_required_(true), |
588 weak_pointer_factory_(this) { | 590 weak_pointer_factory_(this) { |
589 } | 591 } |
590 | 592 |
591 VirtualNetwork::~VirtualNetwork() {} | 593 VirtualNetwork::~VirtualNetwork() {} |
592 | 594 |
593 void VirtualNetwork::EraseCredentials() { | 595 void VirtualNetwork::EraseCredentials() { |
594 WipeString(&ca_cert_nss_); | 596 WipeString(&ca_cert_pem_); |
595 WipeString(&psk_passphrase_); | 597 WipeString(&psk_passphrase_); |
596 WipeString(&client_cert_id_); | 598 WipeString(&client_cert_id_); |
597 WipeString(&user_passphrase_); | 599 WipeString(&user_passphrase_); |
598 } | 600 } |
599 | 601 |
600 void VirtualNetwork::CalculateUniqueId() { | 602 void VirtualNetwork::CalculateUniqueId() { |
601 std::string provider_type(ProviderTypeToString(provider_type_)); | 603 std::string provider_type(ProviderTypeToString(provider_type_)); |
602 set_unique_id(provider_type + "|" + server_hostname_); | 604 set_unique_id(provider_type + "|" + server_hostname_); |
603 } | 605 } |
604 | 606 |
605 bool VirtualNetwork::RequiresUserProfile() const { | 607 bool VirtualNetwork::RequiresUserProfile() const { |
606 return true; | 608 return true; |
607 } | 609 } |
608 | 610 |
609 void VirtualNetwork::AttemptConnection(const base::Closure& connect) { | 611 void VirtualNetwork::AttemptConnection(const base::Closure& connect) { |
610 if (client_cert_type() == CLIENT_CERT_TYPE_PATTERN) { | 612 if (client_cert_type() == CLIENT_CERT_TYPE_PATTERN) { |
611 MatchCertificatePattern(true, connect); | 613 MatchCertificatePattern(true, connect); |
612 } else { | 614 } else { |
613 connect.Run(); | 615 connect.Run(); |
614 } | 616 } |
615 } | 617 } |
616 | 618 |
617 void VirtualNetwork::CopyCredentialsFromRemembered(Network* remembered) { | 619 void VirtualNetwork::CopyCredentialsFromRemembered(Network* remembered) { |
618 CHECK_EQ(remembered->type(), TYPE_VPN); | 620 CHECK_EQ(remembered->type(), TYPE_VPN); |
619 VirtualNetwork* remembered_vpn = static_cast<VirtualNetwork*>(remembered); | 621 VirtualNetwork* remembered_vpn = static_cast<VirtualNetwork*>(remembered); |
620 VLOG(1) << "Copy VPN credentials: " << name() | 622 VLOG(1) << "Copy VPN credentials: " << name() |
621 << " username: " << remembered_vpn->username(); | 623 << " username: " << remembered_vpn->username(); |
622 if (ca_cert_nss_.empty()) | 624 if (ca_cert_pem_.empty()) |
623 ca_cert_nss_ = remembered_vpn->ca_cert_nss(); | 625 ca_cert_pem_ = remembered_vpn->ca_cert_pem(); |
624 if (psk_passphrase_.empty()) | 626 if (psk_passphrase_.empty()) |
625 psk_passphrase_ = remembered_vpn->psk_passphrase(); | 627 psk_passphrase_ = remembered_vpn->psk_passphrase(); |
626 if (client_cert_id_.empty()) | 628 if (client_cert_id_.empty()) |
627 client_cert_id_ = remembered_vpn->client_cert_id(); | 629 client_cert_id_ = remembered_vpn->client_cert_id(); |
628 if (username_.empty()) | 630 if (username_.empty()) |
629 username_ = remembered_vpn->username(); | 631 username_ = remembered_vpn->username(); |
630 if (user_passphrase_.empty()) | 632 if (user_passphrase_.empty()) |
631 user_passphrase_ = remembered_vpn->user_passphrase(); | 633 user_passphrase_ = remembered_vpn->user_passphrase(); |
632 } | 634 } |
633 | 635 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 } | 706 } |
705 | 707 |
706 bool VirtualNetwork::IsPSKPassphraseRequired() const { | 708 bool VirtualNetwork::IsPSKPassphraseRequired() const { |
707 return psk_passphrase_required_ && psk_passphrase_.empty(); | 709 return psk_passphrase_required_ && psk_passphrase_.empty(); |
708 } | 710 } |
709 | 711 |
710 bool VirtualNetwork::IsUserPassphraseRequired() const { | 712 bool VirtualNetwork::IsUserPassphraseRequired() const { |
711 return user_passphrase_required_ && user_passphrase_.empty(); | 713 return user_passphrase_required_ && user_passphrase_.empty(); |
712 } | 714 } |
713 | 715 |
714 void VirtualNetwork::SetCACertNSS(const std::string& ca_cert_nss) { | 716 void VirtualNetwork::SetCACertPEM(const std::string& ca_cert_pem) { |
| 717 VLOG(1) << "SetCACertPEM " << ca_cert_pem; |
715 if (provider_type_ == PROVIDER_TYPE_OPEN_VPN) { | 718 if (provider_type_ == PROVIDER_TYPE_OPEN_VPN) { |
716 SetStringProperty( | 719 ca_cert_pem_ = ca_cert_pem; |
717 flimflam::kOpenVPNCaCertNSSProperty, ca_cert_nss, &ca_cert_nss_); | 720 base::ListValue pem_list; |
| 721 pem_list.AppendString(ca_cert_pem_); |
| 722 SetValueProperty(shill::kOpenVPNCaCertPemProperty, pem_list); |
718 } else { | 723 } else { |
719 SetStringProperty( | 724 SetStringProperty( |
720 flimflam::kL2tpIpsecCaCertNssProperty, ca_cert_nss, &ca_cert_nss_); | 725 shill::kL2tpIpsecCaCertPemProperty, ca_cert_pem, &ca_cert_pem_); |
721 } | 726 } |
722 } | 727 } |
723 | 728 |
724 void VirtualNetwork::SetL2TPIPsecPSKCredentials( | 729 void VirtualNetwork::SetL2TPIPsecPSKCredentials( |
725 const std::string& psk_passphrase, | 730 const std::string& psk_passphrase, |
726 const std::string& username, | 731 const std::string& username, |
727 const std::string& user_passphrase, | 732 const std::string& user_passphrase, |
728 const std::string& group_name) { | 733 const std::string& group_name) { |
729 if (!psk_passphrase.empty()) { | 734 if (!psk_passphrase.empty()) { |
730 SetStringProperty(flimflam::kL2tpIpsecPskProperty, | 735 SetStringProperty(flimflam::kL2tpIpsecPskProperty, |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 // Send the change to shill. If the format is valid, it will propagate to | 1107 // Send the change to shill. If the format is valid, it will propagate to |
1103 // passphrase_ with a service update. | 1108 // passphrase_ with a service update. |
1104 SetOrClearStringProperty(flimflam::kPassphraseProperty, passphrase, NULL); | 1109 SetOrClearStringProperty(flimflam::kPassphraseProperty, passphrase, NULL); |
1105 } | 1110 } |
1106 | 1111 |
1107 // See src/third_party/shill/doc/service-api.txt for properties that | 1112 // See src/third_party/shill/doc/service-api.txt for properties that |
1108 // shill will forget when SaveCredentials is false. | 1113 // shill will forget when SaveCredentials is false. |
1109 void WifiNetwork::EraseCredentials() { | 1114 void WifiNetwork::EraseCredentials() { |
1110 WipeString(&passphrase_); | 1115 WipeString(&passphrase_); |
1111 WipeString(&user_passphrase_); | 1116 WipeString(&user_passphrase_); |
| 1117 WipeString(&eap_server_ca_cert_pem_); |
1112 WipeString(&eap_client_cert_pkcs11_id_); | 1118 WipeString(&eap_client_cert_pkcs11_id_); |
1113 WipeString(&eap_identity_); | 1119 WipeString(&eap_identity_); |
1114 WipeString(&eap_anonymous_identity_); | 1120 WipeString(&eap_anonymous_identity_); |
1115 WipeString(&eap_passphrase_); | 1121 WipeString(&eap_passphrase_); |
1116 } | 1122 } |
1117 | 1123 |
1118 void WifiNetwork::SetIdentity(const std::string& identity) { | 1124 void WifiNetwork::SetIdentity(const std::string& identity) { |
1119 SetStringProperty(flimflam::kIdentityProperty, identity, &identity_); | 1125 SetStringProperty(flimflam::kIdentityProperty, identity, &identity_); |
1120 } | 1126 } |
1121 | 1127 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 SetStringProperty(flimflam::kEapPhase2AuthProperty, | 1181 SetStringProperty(flimflam::kEapPhase2AuthProperty, |
1176 flimflam::kEapPhase2AuthTTLSPAP, NULL); | 1182 flimflam::kEapPhase2AuthTTLSPAP, NULL); |
1177 break; | 1183 break; |
1178 case EAP_PHASE_2_AUTH_CHAP: | 1184 case EAP_PHASE_2_AUTH_CHAP: |
1179 SetStringProperty(flimflam::kEapPhase2AuthProperty, | 1185 SetStringProperty(flimflam::kEapPhase2AuthProperty, |
1180 flimflam::kEapPhase2AuthTTLSCHAP, NULL); | 1186 flimflam::kEapPhase2AuthTTLSCHAP, NULL); |
1181 break; | 1187 break; |
1182 } | 1188 } |
1183 } | 1189 } |
1184 | 1190 |
1185 void WifiNetwork::SetEAPServerCaCertNssNickname( | 1191 void WifiNetwork::SetEAPServerCaCertPEM( |
1186 const std::string& nss_nickname) { | 1192 const std::string& ca_cert_pem) { |
1187 VLOG(1) << "SetEAPServerCaCertNssNickname " << nss_nickname; | 1193 VLOG(1) << "SetEAPServerCaCertPEM " << ca_cert_pem; |
1188 SetOrClearStringProperty(flimflam::kEapCaCertNssProperty, | 1194 eap_server_ca_cert_pem_ = ca_cert_pem; |
1189 nss_nickname, &eap_server_ca_cert_nss_nickname_); | 1195 base::ListValue pem_list; |
| 1196 pem_list.AppendString(ca_cert_pem); |
| 1197 SetValueProperty(shill::kEapCaCertPemProperty, pem_list); |
1190 } | 1198 } |
1191 | 1199 |
1192 void WifiNetwork::SetEAPClientCertPkcs11Id(const std::string& pkcs11_id) { | 1200 void WifiNetwork::SetEAPClientCertPkcs11Id(const std::string& pkcs11_id) { |
1193 VLOG(1) << "SetEAPClientCertPkcs11Id " << pkcs11_id; | 1201 VLOG(1) << "SetEAPClientCertPkcs11Id " << pkcs11_id; |
1194 SetOrClearStringProperty( | 1202 SetOrClearStringProperty( |
1195 flimflam::kEapCertIdProperty, pkcs11_id, &eap_client_cert_pkcs11_id_); | 1203 flimflam::kEapCertIdProperty, pkcs11_id, &eap_client_cert_pkcs11_id_); |
1196 // shill requires both CertID and KeyID for TLS connections, despite | 1204 // shill requires both CertID and KeyID for TLS connections, despite |
1197 // the fact that by convention they are the same ID. | 1205 // the fact that by convention they are the same ID. |
1198 SetOrClearStringProperty(flimflam::kEapKeyIdProperty, pkcs11_id, NULL); | 1206 SetOrClearStringProperty(flimflam::kEapKeyIdProperty, pkcs11_id, NULL); |
1199 } | 1207 } |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 NetworkLibrary* impl; | 1406 NetworkLibrary* impl; |
1399 if (stub) | 1407 if (stub) |
1400 impl = new NetworkLibraryImplStub(); | 1408 impl = new NetworkLibraryImplStub(); |
1401 else | 1409 else |
1402 impl = new NetworkLibraryImplCros(); | 1410 impl = new NetworkLibraryImplCros(); |
1403 impl->Init(); | 1411 impl->Init(); |
1404 return impl; | 1412 return impl; |
1405 } | 1413 } |
1406 | 1414 |
1407 } // namespace chromeos | 1415 } // namespace chromeos |
OLD | NEW |