| 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 // The implementation of TranslateONCObjectToShill is structured in two parts: | 5 // The implementation of TranslateONCObjectToShill is structured in two parts: |
| 6 // - The recursion through the existing ONC hierarchy | 6 // - The recursion through the existing ONC hierarchy |
| 7 // see TranslateONCHierarchy | 7 // see TranslateONCHierarchy |
| 8 // - The local translation of an object depending on the associated signature | 8 // - The local translation of an object depending on the associated signature |
| 9 // see LocalTranslator::TranslateFields | 9 // see LocalTranslator::TranslateFields |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 TranslateWiFi(); | 94 TranslateWiFi(); |
| 95 else if (onc_signature_ == &kEAPSignature) | 95 else if (onc_signature_ == &kEAPSignature) |
| 96 TranslateEAP(); | 96 TranslateEAP(); |
| 97 else | 97 else |
| 98 CopyFieldsAccordingToSignature(); | 98 CopyFieldsAccordingToSignature(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void LocalTranslator::TranslateOpenVPN() { | 101 void LocalTranslator::TranslateOpenVPN() { |
| 102 // Shill supports only one RemoteCertKU but ONC a list. | 102 // Shill supports only one RemoteCertKU but ONC a list. |
| 103 // Copy only the first entry if existing. | 103 // Copy only the first entry if existing. |
| 104 const base::ListValue* certKUs = NULL; | 104 const base::ListValue* cert_kus = NULL; |
| 105 std::string certKU; | 105 std::string cert_ku; |
| 106 if (onc_object_->GetListWithoutPathExpansion(vpn::kRemoteCertKU, &certKUs) && | 106 if (onc_object_->GetListWithoutPathExpansion(vpn::kRemoteCertKU, &cert_kus) && |
| 107 certKUs->GetString(0, &certKU)) { | 107 cert_kus->GetString(0, &cert_ku)) { |
| 108 shill_dictionary_->SetStringWithoutPathExpansion( | 108 shill_dictionary_->SetStringWithoutPathExpansion( |
| 109 flimflam::kOpenVPNRemoteCertKUProperty, certKU); | 109 flimflam::kOpenVPNRemoteCertKUProperty, cert_ku); |
| 110 } | 110 } |
| 111 | 111 |
| 112 for (base::DictionaryValue::Iterator it(*onc_object_); !it.IsAtEnd(); | 112 for (base::DictionaryValue::Iterator it(*onc_object_); !it.IsAtEnd(); |
| 113 it.Advance()) { | 113 it.Advance()) { |
| 114 scoped_ptr<base::Value> translated; | 114 scoped_ptr<base::Value> translated; |
| 115 if (it.key() == vpn::kSaveCredentials || it.key() == vpn::kRemoteCertKU) { | 115 if (it.key() == vpn::kSaveCredentials || |
| 116 it.key() == vpn::kRemoteCertKU || |
| 117 it.key() == openvpn::kServerCAPEMs) { |
| 116 translated.reset(it.value().DeepCopy()); | 118 translated.reset(it.value().DeepCopy()); |
| 117 } else { | 119 } else { |
| 118 // Shill wants all Provider/VPN fields to be strings. | 120 // Shill wants all Provider/VPN fields to be strings. |
| 119 translated = ConvertValueToString(it.value()); | 121 translated = ConvertValueToString(it.value()); |
| 120 } | 122 } |
| 121 AddValueAccordingToSignature(it.key(), translated.Pass()); | 123 AddValueAccordingToSignature(it.key(), translated.Pass()); |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 | 126 |
| 125 void LocalTranslator::TranslateVPN() { | 127 void LocalTranslator::TranslateVPN() { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 const OncValueSignature* onc_signature, | 256 const OncValueSignature* onc_signature, |
| 255 const base::DictionaryValue& onc_object) { | 257 const base::DictionaryValue& onc_object) { |
| 256 CHECK(onc_signature != NULL); | 258 CHECK(onc_signature != NULL); |
| 257 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); | 259 scoped_ptr<base::DictionaryValue> shill_dictionary(new base::DictionaryValue); |
| 258 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); | 260 TranslateONCHierarchy(*onc_signature, onc_object, shill_dictionary.get()); |
| 259 return shill_dictionary.Pass(); | 261 return shill_dictionary.Pass(); |
| 260 } | 262 } |
| 261 | 263 |
| 262 } // namespace onc | 264 } // namespace onc |
| 263 } // namespace chromeos | 265 } // namespace chromeos |
| OLD | NEW |