| 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_impl_base.h" | 5 #include "chrome/browser/chromeos/cros/network_library_impl_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 return wimax_networks_; | 297 return wimax_networks_; |
| 298 } | 298 } |
| 299 const VirtualNetworkVector& NetworkLibraryImplBase::virtual_networks() const { | 299 const VirtualNetworkVector& NetworkLibraryImplBase::virtual_networks() const { |
| 300 return virtual_networks_; | 300 return virtual_networks_; |
| 301 } | 301 } |
| 302 const VirtualNetworkVector& | 302 const VirtualNetworkVector& |
| 303 NetworkLibraryImplBase::remembered_virtual_networks() const { | 303 NetworkLibraryImplBase::remembered_virtual_networks() const { |
| 304 return remembered_virtual_networks_; | 304 return remembered_virtual_networks_; |
| 305 } | 305 } |
| 306 | 306 |
| 307 namespace { |
| 308 |
| 307 // Use shill's ordering of the services to determine which type of | 309 // Use shill's ordering of the services to determine which type of |
| 308 // network to return (i.e. don't assume priority of network types). | 310 // network to return (i.e. don't assume priority of network types). |
| 309 // Note: This does not include any virtual networks. | 311 // Note: This does not include any virtual networks. |
| 310 namespace { | |
| 311 const Network* highest_priority(const Network* a, const Network*b) { | 312 const Network* highest_priority(const Network* a, const Network*b) { |
| 312 if (!a) | 313 if (!a) |
| 313 return b; | 314 return b; |
| 314 if (!b) | 315 if (!b) |
| 315 return a; | 316 return a; |
| 316 if (b->priority_order() < a->priority_order()) | 317 if (b->priority_order() < a->priority_order()) |
| 317 return b; | 318 return b; |
| 318 return a; | 319 return a; |
| 319 } | 320 } |
| 320 } | 321 |
| 322 } // namespace |
| 321 | 323 |
| 322 const Network* NetworkLibraryImplBase::active_network() const { | 324 const Network* NetworkLibraryImplBase::active_network() const { |
| 323 const Network* result = active_nonvirtual_network(); | 325 const Network* result = active_nonvirtual_network(); |
| 324 if (active_virtual_ && active_virtual_->is_active()) | 326 if (active_virtual_ && active_virtual_->is_active()) |
| 325 result = highest_priority(result, active_virtual_); | 327 result = highest_priority(result, active_virtual_); |
| 326 return result; | 328 return result; |
| 327 } | 329 } |
| 328 | 330 |
| 329 const Network* NetworkLibraryImplBase::active_nonvirtual_network() const { | 331 const Network* NetworkLibraryImplBase::active_nonvirtual_network() const { |
| 330 const Network* result = NULL; | 332 const Network* result = NULL; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 connect_data_.security = security; | 801 connect_data_.security = security; |
| 800 connect_data_.service_name = ssid; | 802 connect_data_.service_name = ssid; |
| 801 connect_data_.passphrase = passphrase; | 803 connect_data_.passphrase = passphrase; |
| 802 connect_data_.save_credentials = save_credentials; | 804 connect_data_.save_credentials = save_credentials; |
| 803 connect_data_.profile_type = shared ? PROFILE_SHARED : PROFILE_USER; | 805 connect_data_.profile_type = shared ? PROFILE_SHARED : PROFILE_USER; |
| 804 if (security == SECURITY_8021X) { | 806 if (security == SECURITY_8021X) { |
| 805 DCHECK(eap_config); | 807 DCHECK(eap_config); |
| 806 connect_data_.service_name = ssid; | 808 connect_data_.service_name = ssid; |
| 807 connect_data_.eap_method = eap_config->method; | 809 connect_data_.eap_method = eap_config->method; |
| 808 connect_data_.eap_auth = eap_config->auth; | 810 connect_data_.eap_auth = eap_config->auth; |
| 809 connect_data_.server_ca_cert_nss_nickname = | 811 connect_data_.server_ca_cert_pem = eap_config->server_ca_cert_pem; |
| 810 eap_config->server_ca_cert_nss_nickname; | |
| 811 connect_data_.eap_use_system_cas = eap_config->use_system_cas; | 812 connect_data_.eap_use_system_cas = eap_config->use_system_cas; |
| 812 connect_data_.client_cert_pkcs11_id = | 813 connect_data_.client_cert_pkcs11_id = |
| 813 eap_config->client_cert_pkcs11_id; | 814 eap_config->client_cert_pkcs11_id; |
| 814 connect_data_.eap_identity = eap_config->identity; | 815 connect_data_.eap_identity = eap_config->identity; |
| 815 connect_data_.eap_anonymous_identity = eap_config->anonymous_identity; | 816 connect_data_.eap_anonymous_identity = eap_config->anonymous_identity; |
| 816 } | 817 } |
| 817 | 818 |
| 818 CallRequestWifiNetworkAndConnect(ssid, security); | 819 CallRequestWifiNetworkAndConnect(ssid, security); |
| 819 } | 820 } |
| 820 | 821 |
| 821 // 1. Connect to a virtual network with a PSK. | 822 // 1. Connect to a virtual network with a PSK. |
| 822 void NetworkLibraryImplBase::ConnectToUnconfiguredVirtualNetwork( | 823 void NetworkLibraryImplBase::ConnectToUnconfiguredVirtualNetwork( |
| 823 const std::string& service_name, | 824 const std::string& service_name, |
| 824 const std::string& server_hostname, | 825 const std::string& server_hostname, |
| 825 ProviderType provider_type, | 826 ProviderType provider_type, |
| 826 const VPNConfigData& config) { | 827 const VPNConfigData& config) { |
| 827 // Store the connection data to be used by the callback. | 828 // Store the connection data to be used by the callback. |
| 828 connect_data_.service_name = service_name; | 829 connect_data_.service_name = service_name; |
| 829 connect_data_.server_hostname = server_hostname; | 830 connect_data_.server_hostname = server_hostname; |
| 830 connect_data_.psk_key = config.psk; | 831 connect_data_.psk_key = config.psk; |
| 831 connect_data_.server_ca_cert_nss_nickname = | 832 connect_data_.server_ca_cert_pem = config.server_ca_cert_pem; |
| 832 config.server_ca_cert_nss_nickname; | |
| 833 connect_data_.client_cert_pkcs11_id = config.client_cert_pkcs11_id; | 833 connect_data_.client_cert_pkcs11_id = config.client_cert_pkcs11_id; |
| 834 connect_data_.username = config.username; | 834 connect_data_.username = config.username; |
| 835 connect_data_.passphrase = config.user_passphrase; | 835 connect_data_.passphrase = config.user_passphrase; |
| 836 connect_data_.otp = config.otp; | 836 connect_data_.otp = config.otp; |
| 837 connect_data_.group_name = config.group_name; | 837 connect_data_.group_name = config.group_name; |
| 838 connect_data_.save_credentials = config.save_credentials; | 838 connect_data_.save_credentials = config.save_credentials; |
| 839 CallRequestVirtualNetworkAndConnect( | 839 CallRequestVirtualNetworkAndConnect( |
| 840 service_name, server_hostname, provider_type); | 840 service_name, server_hostname, provider_type); |
| 841 } | 841 } |
| 842 | 842 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 860 if (wifi->name() != data.service_name) { | 860 if (wifi->name() != data.service_name) { |
| 861 LOG(WARNING) << "WiFi network name does not match ConnectData: " | 861 LOG(WARNING) << "WiFi network name does not match ConnectData: " |
| 862 << wifi->name() << " != " << data.service_name; | 862 << wifi->name() << " != " << data.service_name; |
| 863 return; | 863 return; |
| 864 } | 864 } |
| 865 wifi->set_added(true); | 865 wifi->set_added(true); |
| 866 if (data.security == SECURITY_8021X) { | 866 if (data.security == SECURITY_8021X) { |
| 867 // Enterprise 802.1X EAP network. | 867 // Enterprise 802.1X EAP network. |
| 868 wifi->SetEAPMethod(data.eap_method); | 868 wifi->SetEAPMethod(data.eap_method); |
| 869 wifi->SetEAPPhase2Auth(data.eap_auth); | 869 wifi->SetEAPPhase2Auth(data.eap_auth); |
| 870 wifi->SetEAPServerCaCertNssNickname(data.server_ca_cert_nss_nickname); | 870 wifi->SetEAPServerCaCertPEM(data.server_ca_cert_pem); |
| 871 wifi->SetEAPUseSystemCAs(data.eap_use_system_cas); | 871 wifi->SetEAPUseSystemCAs(data.eap_use_system_cas); |
| 872 wifi->SetEAPClientCertPkcs11Id(data.client_cert_pkcs11_id); | 872 wifi->SetEAPClientCertPkcs11Id(data.client_cert_pkcs11_id); |
| 873 wifi->SetEAPIdentity(data.eap_identity); | 873 wifi->SetEAPIdentity(data.eap_identity); |
| 874 wifi->SetEAPAnonymousIdentity(data.eap_anonymous_identity); | 874 wifi->SetEAPAnonymousIdentity(data.eap_anonymous_identity); |
| 875 wifi->SetEAPPassphrase(data.passphrase); | 875 wifi->SetEAPPassphrase(data.passphrase); |
| 876 wifi->SetSaveCredentials(data.save_credentials); | 876 wifi->SetSaveCredentials(data.save_credentials); |
| 877 } else { | 877 } else { |
| 878 // Ordinary, non-802.1X network. | 878 // Ordinary, non-802.1X network. |
| 879 wifi->SetPassphrase(data.passphrase); | 879 wifi->SetPassphrase(data.passphrase); |
| 880 } | 880 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 906 // the code to make the flow more straightforward. See crosbug.com/24636 | 906 // the code to make the flow more straightforward. See crosbug.com/24636 |
| 907 if (vpn->provider_type() == PROVIDER_TYPE_L2TP_IPSEC_PSK && | 907 if (vpn->provider_type() == PROVIDER_TYPE_L2TP_IPSEC_PSK && |
| 908 !connect_data_.client_cert_pkcs11_id.empty()) { | 908 !connect_data_.client_cert_pkcs11_id.empty()) { |
| 909 vpn->set_provider_type(PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); | 909 vpn->set_provider_type(PROVIDER_TYPE_L2TP_IPSEC_USER_CERT); |
| 910 } | 910 } |
| 911 | 911 |
| 912 vpn->set_added(true); | 912 vpn->set_added(true); |
| 913 if (!data.server_hostname.empty()) | 913 if (!data.server_hostname.empty()) |
| 914 vpn->set_server_hostname(data.server_hostname); | 914 vpn->set_server_hostname(data.server_hostname); |
| 915 | 915 |
| 916 vpn->SetCACertNSS(data.server_ca_cert_nss_nickname); | 916 vpn->SetCACertPEM(data.server_ca_cert_pem); |
| 917 switch (vpn->provider_type()) { | 917 switch (vpn->provider_type()) { |
| 918 case PROVIDER_TYPE_L2TP_IPSEC_PSK: | 918 case PROVIDER_TYPE_L2TP_IPSEC_PSK: |
| 919 vpn->SetL2TPIPsecPSKCredentials( | 919 vpn->SetL2TPIPsecPSKCredentials( |
| 920 data.psk_key, data.username, data.passphrase, data.group_name); | 920 data.psk_key, data.username, data.passphrase, data.group_name); |
| 921 break; | 921 break; |
| 922 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: { | 922 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: { |
| 923 vpn->SetL2TPIPsecCertCredentials( | 923 vpn->SetL2TPIPsecCertCredentials( |
| 924 data.client_cert_pkcs11_id, | 924 data.client_cert_pkcs11_id, |
| 925 data.username, data.passphrase, data.group_name); | 925 data.username, data.passphrase, data.group_name); |
| 926 break; | 926 break; |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 GetTpmInfo(); | 1679 GetTpmInfo(); |
| 1680 return tpm_slot_; | 1680 return tpm_slot_; |
| 1681 } | 1681 } |
| 1682 | 1682 |
| 1683 const std::string& NetworkLibraryImplBase::GetTpmPin() { | 1683 const std::string& NetworkLibraryImplBase::GetTpmPin() { |
| 1684 GetTpmInfo(); | 1684 GetTpmInfo(); |
| 1685 return tpm_pin_; | 1685 return tpm_pin_; |
| 1686 } | 1686 } |
| 1687 | 1687 |
| 1688 } // namespace chromeos | 1688 } // namespace chromeos |
| OLD | NEW |