diff options
author | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 17:40:05 +0000 |
---|---|---|
committer | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-17 17:40:05 +0000 |
commit | e93217a6cf8a5aae265d4b82b7a50edeec456f41 (patch) | |
tree | 0b2e83d369f4ac7139356758290786a60b5eb4fb /chromeos | |
parent | 503aa8b1cbfe39c92ea3bf430d51eaed9b87e658 (diff) | |
download | chromium_src-e93217a6cf8a5aae265d4b82b7a50edeec456f41.zip chromium_src-e93217a6cf8a5aae265d4b82b7a50edeec456f41.tar.gz chromium_src-e93217a6cf8a5aae265d4b82b7a50edeec456f41.tar.bz2 |
Add ethernet to ONC validation and Shill translation.
BUG=126870
(for networking_private_api_nonchromeos.cc)
TBR=gspencer@chromium.org
Review URL: https://chromiumcodereview.appspot.com/23506040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223630 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/network/onc/onc_signature.cc | 1 | ||||
-rw-r--r-- | chromeos/network/onc/onc_translation_tables.cc | 4 | ||||
-rw-r--r-- | chromeos/network/onc/onc_translator_onc_to_shill.cc | 26 | ||||
-rw-r--r-- | chromeos/network/onc/onc_translator_shill_to_onc.cc | 33 | ||||
-rw-r--r-- | chromeos/network/onc/onc_translator_unittest.cc | 8 | ||||
-rw-r--r-- | chromeos/network/onc/onc_validator_unittest.cc | 5 | ||||
-rw-r--r-- | chromeos/test/data/network/ethernet.onc (renamed from chromeos/test/data/network/managed_ethernet.onc) | 0 | ||||
-rw-r--r-- | chromeos/test/data/network/ethernet_with_eap.onc | 24 | ||||
-rw-r--r-- | chromeos/test/data/network/ethernet_with_eap_and_cert_pems.onc | 24 | ||||
-rw-r--r-- | chromeos/test/data/network/shill_ethernet_with_eap.json | 8 | ||||
-rw-r--r-- | chromeos/test/data/network/translation_of_shill_ethernet.onc | 8 | ||||
-rw-r--r-- | chromeos/test/data/network/translation_of_shill_ethernet_with_eap.onc | 8 |
12 files changed, 136 insertions, 13 deletions
diff --git a/chromeos/network/onc/onc_signature.cc b/chromeos/network/onc/onc_signature.cc index f3e000b..afed3a8 100644 --- a/chromeos/network/onc/onc_signature.cc +++ b/chromeos/network/onc/onc_signature.cc @@ -144,7 +144,6 @@ const OncFieldSignature vpn_fields[] = { const OncFieldSignature ethernet_fields[] = { { kRecommended, &kRecommendedSignature }, - // Not supported, yet. { ethernet::kAuthentication, &kStringSignature }, { ethernet::kEAP, &kEAPSignature }, { NULL } diff --git a/chromeos/network/onc/onc_translation_tables.cc b/chromeos/network/onc/onc_translation_tables.cc index 8a1b29d..0cc2b6b 100644 --- a/chromeos/network/onc/onc_translation_tables.cc +++ b/chromeos/network/onc/onc_translation_tables.cc @@ -212,7 +212,9 @@ const NestedShillDictionaryEntry nested_shill_dictionaries[] = { } // namespace const StringTranslationEntry kNetworkTypeTable[] = { - { network_type::kEthernet, flimflam::kTypeEthernet }, + // This mapping is ensured in the translation code. + // { network_type::kEthernet, flimflam::kTypeEthernet }, + // { network_type::kEthernet, shill::kTypeEthernetEap }, { network_type::kWiFi, flimflam::kTypeWifi }, { network_type::kCellular, flimflam::kTypeCellular }, { network_type::kVPN, flimflam::kTypeVPN }, diff --git a/chromeos/network/onc/onc_translator_onc_to_shill.cc b/chromeos/network/onc/onc_translator_onc_to_shill.cc index 9afae32..8af78d5 100644 --- a/chromeos/network/onc/onc_translator_onc_to_shill.cc +++ b/chromeos/network/onc/onc_translator_onc_to_shill.cc @@ -52,6 +52,7 @@ class LocalTranslator { void TranslateFields(); private: + void TranslateEthernet(); void TranslateOpenVPN(); void TranslateVPN(); void TranslateWiFi(); @@ -86,6 +87,8 @@ class LocalTranslator { void LocalTranslator::TranslateFields() { if (onc_signature_ == &kNetworkConfigurationSignature) TranslateNetworkConfiguration(); + else if (onc_signature_ == &kEthernetSignature) + TranslateEthernet(); else if (onc_signature_ == &kVPNSignature) TranslateVPN(); else if (onc_signature_ == &kOpenVPNSignature) @@ -98,6 +101,20 @@ void LocalTranslator::TranslateFields() { CopyFieldsAccordingToSignature(); } +void LocalTranslator::TranslateEthernet() { + std::string authentication; + onc_object_->GetStringWithoutPathExpansion(ethernet::kAuthentication, + &authentication); + + const char* shill_type = flimflam::kTypeEthernet; + if (authentication == ethernet::k8021X) + shill_type = shill::kTypeEthernetEap; + shill_dictionary_->SetStringWithoutPathExpansion(flimflam::kTypeProperty, + shill_type); + + CopyFieldsAccordingToSignature(); +} + void LocalTranslator::TranslateOpenVPN() { // Shill supports only one RemoteCertKU but ONC a list. // Copy only the first entry if existing. @@ -171,14 +188,17 @@ void LocalTranslator::TranslateEAP() { void LocalTranslator::TranslateNetworkConfiguration() { std::string type; onc_object_->GetStringWithoutPathExpansion(network_config::kType, &type); - TranslateWithTableAndSet(type, kNetworkTypeTable, flimflam::kTypeProperty); + + // Set the type except for Ethernet which is set in TranslateEthernet. + if (type != network_type::kEthernet) + TranslateWithTableAndSet(type, kNetworkTypeTable, flimflam::kTypeProperty); // Shill doesn't allow setting the name for non-VPN networks. if (type == network_type::kVPN) { std::string name; onc_object_->GetStringWithoutPathExpansion(network_config::kName, &name); - shill_dictionary_->SetStringWithoutPathExpansion( - flimflam::kNameProperty, name); + shill_dictionary_->SetStringWithoutPathExpansion(flimflam::kNameProperty, + name); } CopyFieldsAccordingToSignature(); diff --git a/chromeos/network/onc/onc_translator_shill_to_onc.cc b/chromeos/network/onc/onc_translator_shill_to_onc.cc index 0bd82ea..80e00ba 100644 --- a/chromeos/network/onc/onc_translator_shill_to_onc.cc +++ b/chromeos/network/onc/onc_translator_shill_to_onc.cc @@ -58,6 +58,7 @@ class ShillToONCTranslator { scoped_ptr<base::DictionaryValue> CreateTranslatedONCObject(); private: + void TranslateEthernet(); void TranslateOpenVPN(); void TranslateVPN(); void TranslateWiFiWithState(); @@ -109,6 +110,8 @@ ShillToONCTranslator::CreateTranslatedONCObject() { onc_object_.reset(new base::DictionaryValue); if (onc_signature_ == &kNetworkWithStateSignature) { TranslateNetworkWithState(); + } else if (onc_signature_ == &kEthernetSignature) { + TranslateEthernet(); } else if (onc_signature_ == &kVPNSignature) { TranslateVPN(); } else if (onc_signature_ == &kOpenVPNSignature) { @@ -123,6 +126,17 @@ ShillToONCTranslator::CreateTranslatedONCObject() { return onc_object_.Pass(); } +void ShillToONCTranslator::TranslateEthernet() { + std::string shill_network_type; + shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kTypeProperty, + &shill_network_type); + const char* onc_auth = ethernet::kNone; + if (shill_network_type == shill::kTypeEthernetEap) + onc_auth = ethernet::k8021X; + onc_object_->SetStringWithoutPathExpansion(ethernet::kAuthentication, + onc_auth); +} + void ShillToONCTranslator::TranslateOpenVPN() { // Shill supports only one RemoteCertKU but ONC requires a list. If existing, // wraps the value into a list. @@ -219,14 +233,21 @@ void ShillToONCTranslator::TranslateCellularWithState() { } void ShillToONCTranslator::TranslateNetworkWithState() { - TranslateWithTableAndSet(flimflam::kTypeProperty, kNetworkTypeTable, - network_config::kType); CopyPropertiesAccordingToSignature(); - std::string network_type; - if (onc_object_->GetStringWithoutPathExpansion(network_config::kType, - &network_type)) { - TranslateAndAddNestedObject(network_type); + std::string shill_network_type; + shill_dictionary_->GetStringWithoutPathExpansion(flimflam::kTypeProperty, + &shill_network_type); + std::string onc_network_type = network_type::kEthernet; + if (shill_network_type != flimflam::kTypeEthernet && + shill_network_type != shill::kTypeEthernetEap) { + TranslateStringToONC( + kNetworkTypeTable, shill_network_type, &onc_network_type); + } + if (!onc_network_type.empty()) { + onc_object_->SetStringWithoutPathExpansion(network_config::kType, + onc_network_type); + TranslateAndAddNestedObject(onc_network_type); } // Since Name is a read only field in Shill unless it's a VPN, it is copied diff --git a/chromeos/network/onc/onc_translator_unittest.cc b/chromeos/network/onc/onc_translator_unittest.cc index 6bc7b6a..12f952f 100644 --- a/chromeos/network/onc/onc_translator_unittest.cc +++ b/chromeos/network/onc/onc_translator_unittest.cc @@ -42,7 +42,9 @@ INSTANTIATE_TEST_CASE_P( ONCTranslatorOncToShillTest, ONCTranslatorOncToShillTest, ::testing::Values( - std::make_pair("managed_ethernet.onc", "shill_ethernet.json"), + std::make_pair("ethernet.onc", "shill_ethernet.json"), + std::make_pair("ethernet_with_eap_and_cert_pems.onc", + "shill_ethernet_with_eap.json"), std::make_pair("valid_wifi_psk.onc", "shill_wifi_psk.json"), std::make_pair("wifi_clientcert_with_cert_pems.onc", "shill_wifi_clientcert.json"), @@ -86,6 +88,10 @@ INSTANTIATE_TEST_CASE_P( ONCTranslatorShillToOncTest, ONCTranslatorShillToOncTest, ::testing::Values( + std::make_pair("shill_ethernet.json", + "translation_of_shill_ethernet.onc"), + std::make_pair("shill_ethernet_with_eap.json", + "translation_of_shill_ethernet_with_eap.onc"), std::make_pair("shill_wifi_clientcert.json", "translation_of_shill_wifi_clientcert.onc"), std::make_pair("shill_wifi_wpa1.json", diff --git a/chromeos/network/onc/onc_validator_unittest.cc b/chromeos/network/onc/onc_validator_unittest.cc index d839466..3ddd679 100644 --- a/chromeos/network/onc/onc_validator_unittest.cc +++ b/chromeos/network/onc/onc_validator_unittest.cc @@ -154,7 +154,10 @@ INSTANTIATE_TEST_CASE_P( OncParams("managed_vpn.onc", &kNetworkConfigurationSignature, true), - OncParams("managed_ethernet.onc", + OncParams("ethernet.onc", + &kNetworkConfigurationSignature, + true), + OncParams("ethernet_with_eap.onc", &kNetworkConfigurationSignature, true), OncParams("translation_of_shill_wifi_with_state.onc", diff --git a/chromeos/test/data/network/managed_ethernet.onc b/chromeos/test/data/network/ethernet.onc index 56828bc..56828bc 100644 --- a/chromeos/test/data/network/managed_ethernet.onc +++ b/chromeos/test/data/network/ethernet.onc diff --git a/chromeos/test/data/network/ethernet_with_eap.onc b/chromeos/test/data/network/ethernet_with_eap.onc new file mode 100644 index 0000000..e12b3d0 --- /dev/null +++ b/chromeos/test/data/network/ethernet_with_eap.onc @@ -0,0 +1,24 @@ +{ + "Ethernet":{ + "Authentication":"None", + "EAP":{ + "ClientCertPattern":{ + "EnrollmentURI":[ + "chrome-extension://delkjfjibodjclmdijflfnimdmgdagfk/generate-cert.html" + ], + "IssuerCARef":[ + "{58ac1967-a0e7-49e9-be68-123abc}", + "{42cb13cd-140c-4941-9fb6-456def}" + ] + }, + "ClientCertType":"Pattern", + "Identity":"abc ${LOGIN_ID}@my.domain.com", + "Outer":"EAP-TLS", + "SaveCredentials":true, + "UseSystemCAs":true + } + }, + "GUID":"guid", + "Name":"name", + "Type":"Ethernet" +} diff --git a/chromeos/test/data/network/ethernet_with_eap_and_cert_pems.onc b/chromeos/test/data/network/ethernet_with_eap_and_cert_pems.onc new file mode 100644 index 0000000..7ec2bd0 --- /dev/null +++ b/chromeos/test/data/network/ethernet_with_eap_and_cert_pems.onc @@ -0,0 +1,24 @@ +{ + "Ethernet":{ + "Authentication":"8021X", + "EAP":{ + "ClientCertPattern":{ + "EnrollmentURI":[ + "chrome-extension://delkjfjibodjclmdijflfnimdmgdagfk/generate-cert.html" + ], + "IssuerCAPEMs":[ + "pem1", + "pem2" + ] + }, + "ClientCertType":"Pattern", + "Identity":"abc ${LOGIN_ID}@my.domain.com", + "Outer":"EAP-TLS", + "SaveCredentials":true, + "UseSystemCAs":true + } + }, + "GUID":"guid", + "Name":"name", + "Type":"Ethernet" +} diff --git a/chromeos/test/data/network/shill_ethernet_with_eap.json b/chromeos/test/data/network/shill_ethernet_with_eap.json new file mode 100644 index 0000000..e5d44be --- /dev/null +++ b/chromeos/test/data/network/shill_ethernet_with_eap.json @@ -0,0 +1,8 @@ +{ + "EAP.EAP":"TLS", + "EAP.Identity":"abc ${LOGIN_ID}@my.domain.com", + "EAP.UseSystemCAs":true, + "GUID":"guid", + "SaveCredentials":true, + "Type":"etherneteap" +} diff --git a/chromeos/test/data/network/translation_of_shill_ethernet.onc b/chromeos/test/data/network/translation_of_shill_ethernet.onc new file mode 100644 index 0000000..8b568bf --- /dev/null +++ b/chromeos/test/data/network/translation_of_shill_ethernet.onc @@ -0,0 +1,8 @@ +{ + "Ethernet":{ + "Authentication":"None" + }, + "GUID":"guid", + "Name":"", + "Type":"Ethernet" +} diff --git a/chromeos/test/data/network/translation_of_shill_ethernet_with_eap.onc b/chromeos/test/data/network/translation_of_shill_ethernet_with_eap.onc new file mode 100644 index 0000000..bfb1a29 --- /dev/null +++ b/chromeos/test/data/network/translation_of_shill_ethernet_with_eap.onc @@ -0,0 +1,8 @@ +{ + "Ethernet":{ + "Authentication":"8021X" + }, + "GUID":"guid", + "Name":"", + "Type":"Ethernet" +} |