diff options
7 files changed, 94 insertions, 2 deletions
diff --git a/chromeos/network/onc/onc_translation_tables.cc b/chromeos/network/onc/onc_translation_tables.cc index a71f441..27feecb 100644 --- a/chromeos/network/onc/onc_translation_tables.cc +++ b/chromeos/network/onc/onc_translation_tables.cc @@ -296,6 +296,7 @@ const StringTranslationEntry kWiFiSecurityTable[] = { {::onc::wifi::kWEP_PSK, shill::kSecurityWep}, {::onc::wifi::kWPA_PSK, shill::kSecurityPsk}, {::onc::wifi::kWPA_EAP, shill::kSecurity8021x}, + {::onc::wifi::kWEP_8021X, shill::kSecurityWep}, {NULL}}; const StringTranslationEntry kEAPOuterTable[] = { diff --git a/chromeos/network/onc/onc_translator_onc_to_shill.cc b/chromeos/network/onc/onc_translator_onc_to_shill.cc index f399d8b..0e84300 100644 --- a/chromeos/network/onc/onc_translator_onc_to_shill.cc +++ b/chromeos/network/onc/onc_translator_onc_to_shill.cc @@ -29,6 +29,9 @@ namespace onc { namespace { +// TODO(pstew): Remove once crosreview.com/310644 lands and merges to Chrome. +const char kKeyManagementIEEE8021X[] = "IEEE8021X"; + scoped_ptr<base::StringValue> ConvertValueToString(const base::Value& value) { std::string str; if (!value.GetAsString(&str)) @@ -220,6 +223,10 @@ void LocalTranslator::TranslateWiFi() { &security)) { TranslateWithTableAndSet(security, kWiFiSecurityTable, shill::kSecurityClassProperty); + if (security == ::onc::wifi::kWEP_8021X) { + shill_dictionary_->SetStringWithoutPathExpansion( + shill::kEapKeyMgmtProperty, kKeyManagementIEEE8021X); + } } // We currently only support managed and no adhoc networks. diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc index f91950f..e76f5e6 100644 --- a/chromeos/network/onc/onc_translator_shill_to_onc.cc +++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc @@ -27,6 +27,9 @@ namespace onc { namespace { +// TODO(pstew): Remove once crosreview.com/310644 lands and merges to Chrome. +const char kKeyManagementIEEE8021X[] = "IEEE8021X"; + // Converts |str| to a base::Value of the given |type|. If the conversion fails, // returns NULL. scoped_ptr<base::Value> ConvertStringToValue(const std::string& str, @@ -329,8 +332,21 @@ void ShillToONCTranslator::TranslateVPN() { } void ShillToONCTranslator::TranslateWiFiWithState() { - TranslateWithTableAndSet(shill::kSecurityClassProperty, kWiFiSecurityTable, - ::onc::wifi::kSecurity); + std::string shill_security; + std::string shill_key_mgmt; + if (shill_dictionary_->GetStringWithoutPathExpansion( + shill::kSecurityClassProperty, &shill_security) && + shill_security == shill::kSecurityWep && + shill_dictionary_->GetStringWithoutPathExpansion( + shill::kEapKeyMgmtProperty, &shill_key_mgmt) && + shill_key_mgmt == kKeyManagementIEEE8021X) { + onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSecurity, + ::onc::wifi::kWEP_8021X); + } else { + TranslateWithTableAndSet(shill::kSecurityClassProperty, kWiFiSecurityTable, + ::onc::wifi::kSecurity); + } + bool unknown_encoding = true; std::string ssid = shill_property_util::GetSSIDFromProperties( *shill_dictionary_, false /* verbose_logging */, &unknown_encoding); diff --git a/chromeos/network/onc/onc_translator_unittest.cc b/chromeos/network/onc/onc_translator_unittest.cc index 72ceae1..7de265a 100644 --- a/chromeos/network/onc/onc_translator_unittest.cc +++ b/chromeos/network/onc/onc_translator_unittest.cc @@ -51,6 +51,8 @@ INSTANTIATE_TEST_CASE_P( std::make_pair("valid_wifi_psk.onc", "shill_wifi_psk.json"), std::make_pair("wifi_clientcert_with_cert_pems.onc", "shill_wifi_clientcert.json"), + std::make_pair("wifi_wep_8021x_clientcert_with_cert_pems.onc", + "shill_wifi_wep_8021x_clientcert.json"), std::make_pair("valid_wifi_clientref.onc", "shill_wifi_clientref.json"), std::make_pair("valid_l2tpipsec.onc", "shill_l2tpipsec.json"), std::make_pair("wifi_dhcp.onc", "shill_wifi_dhcp.json"), @@ -106,6 +108,8 @@ INSTANTIATE_TEST_CASE_P( "translation_of_shill_wifi_clientcert.onc"), std::make_pair("shill_wifi_non_utf8_ssid.json", "translation_of_shill_wifi_non_utf8_ssid.onc"), + std::make_pair("shill_wifi_wep_8021x_clientcert.json", + "translation_of_shill_wifi_wep_8021x_clientcert.onc"), std::make_pair("shill_output_l2tpipsec.json", "translation_of_shill_l2tpipsec.onc"), std::make_pair("shill_output_openvpn.json", diff --git a/chromeos/test/data/network/shill_wifi_wep_8021x_clientcert.json b/chromeos/test/data/network/shill_wifi_wep_8021x_clientcert.json new file mode 100644 index 0000000..e4aadb4 --- /dev/null +++ b/chromeos/test/data/network/shill_wifi_wep_8021x_clientcert.json @@ -0,0 +1,14 @@ +{ + "EAP.EAP": "TLS", + "EAP.Identity": "abc ${LOGIN_ID}@my.domain.com", + "EAP.UseProactiveKeyCaching": true, + "EAP.UseSystemCAs": true, + "GUID": "{77db0089-0bc8-4358-929c-123xcv}", + "EAP.KeyMgmt": "IEEE8021X", + "Mode": "managed", + "ProxyConfig": "{\"mode\":\"pac_script\",\"pac_mandatory\":false,\"pac_url\":\"https://proxycfg.my.domain.com/proxy.dat\"}", + "SaveCredentials": true, + "SecurityClass": "wep", + "Type": "wifi", + "WiFi.HexSSID": "4F70656E577274" // "OpenWrt" +} diff --git a/chromeos/test/data/network/translation_of_shill_wifi_wep_8021x_clientcert.onc b/chromeos/test/data/network/translation_of_shill_wifi_wep_8021x_clientcert.onc new file mode 100644 index 0000000..ee6c5f4 --- /dev/null +++ b/chromeos/test/data/network/translation_of_shill_wifi_wep_8021x_clientcert.onc @@ -0,0 +1,20 @@ +{ + "GUID":"{77db0089-0bc8-4358-929c-123xcv}", + "Name":"", + "ProxySettings": { + "Type": "PAC", + "PAC": "https://proxycfg.my.domain.com/proxy.dat" + }, + "Type":"WiFi", + "WiFi":{ + "EAP": { + "Identity": "abc ${LOGIN_ID}@my.domain.com", + "SaveCredentials": true, + "UseProactiveKeyCaching": true, + "UseSystemCAs": true + }, + "HexSSID":"4F70656E577274", // "OpenWrt" + "SSID":"OpenWrt", + "Security":"WEP-8021X" + } +} diff --git a/chromeos/test/data/network/wifi_wep_8021x_clientcert_with_cert_pems.onc b/chromeos/test/data/network/wifi_wep_8021x_clientcert_with_cert_pems.onc new file mode 100644 index 0000000..1bf4a16 --- /dev/null +++ b/chromeos/test/data/network/wifi_wep_8021x_clientcert_with_cert_pems.onc @@ -0,0 +1,30 @@ +{ + "GUID": "{77db0089-0bc8-4358-929c-123xcv}", + "Type": "WiFi", + "Name": "SomeWifi-XY", + "WiFi": { + "HexSSID": "4F70656E577274", // Hex of "OpenWrt" + "Security": "WEP-8021X", + "Recommended": [ "AutoConnect" ], + "EAP": { + "Outer": "EAP-TLS", + "Identity": "abc ${LOGIN_ID}@my.domain.com", + "UseProactiveKeyCaching": true, + "UseSystemCAs": true, + "ClientCertType": "Pattern", + "ClientCertPattern": { + "IssuerCAPEMs": [ + "pem1", + "pem2" + ], + "EnrollmentURI": [ "chrome-extension://delkjfjibodjclmdijflfnimdmgdagfk/generate-cert.html" ] + }, + "Recommended": [ "Identity" ], + "SaveCredentials": true + } + }, + "ProxySettings": { + "Type": "PAC", + "PAC": "https://proxycfg.my.domain.com/proxy.dat" + } +} |