Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: chromeos/network/managed_network_configuration_handler_impl.cc

Issue 510123004: Apply global auto connect ONC policy in GetManagedProperties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chromeos/network/managed_network_configuration_handler_impl.h" 5 #include "chromeos/network/managed_network_configuration_handler_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 &profile_path); 142 &profile_path);
143 const NetworkProfile* profile = 143 const NetworkProfile* profile =
144 network_profile_handler_->GetProfileForPath(profile_path); 144 network_profile_handler_->GetProfileForPath(profile_path);
145 if (!profile) 145 if (!profile)
146 NET_LOG_ERROR("No profile for service: " + profile_path, service_path); 146 NET_LOG_ERROR("No profile for service: " + profile_path, service_path);
147 147
148 scoped_ptr<NetworkUIData> ui_data = 148 scoped_ptr<NetworkUIData> ui_data =
149 shill_property_util::GetUIDataFromProperties(*shill_properties); 149 shill_property_util::GetUIDataFromProperties(*shill_properties);
150 150
151 const base::DictionaryValue* user_settings = NULL; 151 const base::DictionaryValue* user_settings = NULL;
152 const base::DictionaryValue* shared_settings = NULL;
153 152
154 if (ui_data && profile) { 153 if (ui_data && profile) {
155 if (profile->type() == NetworkProfile::TYPE_SHARED) 154 user_settings = ui_data->user_settings();
pneubeck (no reviews) 2014/08/28 16:09:49 move to policy_util::CreateManagedONC
156 shared_settings = ui_data->user_settings();
157 else if (profile->type() == NetworkProfile::TYPE_USER)
158 user_settings = ui_data->user_settings();
159 else
160 NOTREACHED();
161 } else if (profile) { 155 } else if (profile) {
162 NET_LOG_ERROR("Service contains empty or invalid UIData", service_path); 156 NET_LOG_ERROR("Service contains empty or invalid UIData", service_path);
163 // TODO(pneubeck): add a conversion of user configured entries of old 157 // TODO(pneubeck): add a conversion of user configured entries of old
164 // ChromeOS versions. We will have to use a heuristic to determine which 158 // ChromeOS versions. We will have to use a heuristic to determine which
165 // properties _might_ be user configured. 159 // properties _might_ be user configured.
166 } 160 }
167 161
168 scoped_ptr<base::DictionaryValue> active_settings( 162 scoped_ptr<base::DictionaryValue> active_settings(
169 onc::TranslateShillServiceToONCPart( 163 onc::TranslateShillServiceToONCPart(
170 *shill_properties, 164 *shill_properties,
171 &onc::kNetworkWithStateSignature)); 165 &onc::kNetworkWithStateSignature));
172 166
173 std::string guid; 167 std::string guid;
174 active_settings->GetStringWithoutPathExpansion(::onc::network_config::kGUID, 168 active_settings->GetStringWithoutPathExpansion(::onc::network_config::kGUID,
175 &guid); 169 &guid);
176 170
177 const base::DictionaryValue* user_policy = NULL; 171 const base::DictionaryValue* network_policy = NULL;
178 const base::DictionaryValue* device_policy = NULL; 172 const base::DictionaryValue* global_policy = NULL;
179 if (!guid.empty() && profile) { 173 if (!guid.empty() && profile) {
180 const Policies* policies = GetPoliciesForProfile(*profile); 174 const Policies* policies = GetPoliciesForProfile(*profile);
181 if (!policies) { 175 if (!policies) {
182 InvokeErrorCallback( 176 InvokeErrorCallback(
183 service_path, error_callback, kPoliciesNotInitialized); 177 service_path, error_callback, kPoliciesNotInitialized);
184 return; 178 return;
185 } 179 }
186 const base::DictionaryValue* policy = 180 network_policy = GetByGUID(policies->per_network_config, guid);
187 GetByGUID(policies->per_network_config, guid); 181 global_policy = &policies->global_network_config;
188 if (profile->type() == NetworkProfile::TYPE_SHARED)
189 device_policy = policy;
190 else if (profile->type() == NetworkProfile::TYPE_USER)
191 user_policy = policy;
192 else
193 NOTREACHED();
194 } 182 }
195 183
196 // This call also removes credentials from policies. 184 scoped_ptr<base::DictionaryValue> augmented_properties(
197 scoped_ptr<base::DictionaryValue> augmented_properties = 185 policy_util::CreateManagedONC(global_policy,
198 onc::MergeSettingsAndPoliciesToAugmented( 186 network_policy,
199 onc::kNetworkConfigurationSignature, 187 user_settings,
200 user_policy, 188 active_settings.get(),
201 device_policy, 189 profile));
202 user_settings,
203 shared_settings,
204 active_settings.get());
205 callback.Run(service_path, *augmented_properties); 190 callback.Run(service_path, *augmented_properties);
206 } 191 }
207 192
208 // GetProperties 193 // GetProperties
209 194
210 void ManagedNetworkConfigurationHandlerImpl::GetProperties( 195 void ManagedNetworkConfigurationHandlerImpl::GetProperties(
211 const std::string& service_path, 196 const std::string& service_path,
212 const network_handler::DictionaryResultCallback& callback, 197 const network_handler::DictionaryResultCallback& callback,
213 const network_handler::ErrorCallback& error_callback) { 198 const network_handler::ErrorCallback& error_callback) {
214 network_configuration_handler_->GetProperties( 199 network_configuration_handler_->GetProperties(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 user_settings, 275 user_settings,
291 &validation_result); 276 &validation_result);
292 277
293 if (validation_result == onc::Validator::INVALID) { 278 if (validation_result == onc::Validator::INVALID) {
294 InvokeErrorCallback(service_path, error_callback, kInvalidUserSettings); 279 InvokeErrorCallback(service_path, error_callback, kInvalidUserSettings);
295 return; 280 return;
296 } 281 }
297 if (validation_result == onc::Validator::VALID_WITH_WARNINGS) 282 if (validation_result == onc::Validator::VALID_WITH_WARNINGS)
298 LOG(WARNING) << "Validation of ONC user settings produced warnings."; 283 LOG(WARNING) << "Validation of ONC user settings produced warnings.";
299 284
300 const base::DictionaryValue* policy = 285 const base::DictionaryValue* network_policy =
301 GetByGUID(policies->per_network_config, guid); 286 GetByGUID(policies->per_network_config, guid);
302 VLOG(2) << "This configuration is " << (policy ? "" : "not ") << "managed."; 287 VLOG(2) << "This configuration is " << (network_policy ? "" : "not ")
288 << "managed.";
303 289
304 scoped_ptr<base::DictionaryValue> shill_dictionary( 290 scoped_ptr<base::DictionaryValue> shill_dictionary(
305 policy_util::CreateShillConfiguration( 291 policy_util::CreateShillConfiguration(*profile,
306 *profile, guid, policy, validated_user_settings.get())); 292 guid,
293 &policies->global_network_config,
294 network_policy,
295 validated_user_settings.get()));
307 296
308 network_configuration_handler_->SetProperties( 297 network_configuration_handler_->SetProperties(
309 service_path, *shill_dictionary, callback, error_callback); 298 service_path, *shill_dictionary, callback, error_callback);
310 } 299 }
311 300
312 void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration( 301 void ManagedNetworkConfigurationHandlerImpl::CreateConfiguration(
313 const std::string& userhash, 302 const std::string& userhash,
314 const base::DictionaryValue& properties, 303 const base::DictionaryValue& properties,
315 const network_handler::StringResultCallback& callback, 304 const network_handler::StringResultCallback& callback,
316 const network_handler::ErrorCallback& error_callback) const { 305 const network_handler::ErrorCallback& error_callback) const {
(...skipping 17 matching lines...) Expand all
334 } 323 }
335 324
336 // TODO(pneubeck): In case of WiFi, check that no other configuration for the 325 // TODO(pneubeck): In case of WiFi, check that no other configuration for the
337 // same {SSID, mode, security} exists. We don't support such multiple 326 // same {SSID, mode, security} exists. We don't support such multiple
338 // configurations, yet. 327 // configurations, yet.
339 328
340 // Generate a new GUID for this configuration. Ignore the maybe provided GUID 329 // Generate a new GUID for this configuration. Ignore the maybe provided GUID
341 // in |properties| as it is not our own and from an untrusted source. 330 // in |properties| as it is not our own and from an untrusted source.
342 std::string guid = base::GenerateGUID(); 331 std::string guid = base::GenerateGUID();
343 scoped_ptr<base::DictionaryValue> shill_dictionary( 332 scoped_ptr<base::DictionaryValue> shill_dictionary(
344 policy_util::CreateShillConfiguration( 333 policy_util::CreateShillConfiguration(*profile,
345 *profile, guid, NULL /*no policy*/, &properties)); 334 guid,
335 NULL, // no global policy
336 NULL, // no network policy
337 &properties));
346 338
347 network_configuration_handler_->CreateConfiguration( 339 network_configuration_handler_->CreateConfiguration(
348 *shill_dictionary, callback, error_callback); 340 *shill_dictionary, callback, error_callback);
349 } 341 }
350 342
351 void ManagedNetworkConfigurationHandlerImpl::RemoveConfiguration( 343 void ManagedNetworkConfigurationHandlerImpl::RemoveConfiguration(
352 const std::string& service_path, 344 const std::string& service_path,
353 const base::Closure& callback, 345 const base::Closure& callback,
354 const network_handler::ErrorCallback& error_callback) const { 346 const network_handler::ErrorCallback& error_callback) const {
355 network_configuration_handler_->RemoveConfiguration( 347 network_configuration_handler_->RemoveConfiguration(
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 scoped_ptr<base::DictionaryValue> network_properties, 709 scoped_ptr<base::DictionaryValue> network_properties,
718 GetDevicePropertiesCallback send_callback, 710 GetDevicePropertiesCallback send_callback,
719 const std::string& error_name, 711 const std::string& error_name,
720 scoped_ptr<base::DictionaryValue> error_data) { 712 scoped_ptr<base::DictionaryValue> error_data) {
721 NET_LOG_ERROR("Error getting device properties", service_path); 713 NET_LOG_ERROR("Error getting device properties", service_path);
722 send_callback.Run(service_path, network_properties.Pass()); 714 send_callback.Run(service_path, network_properties.Pass());
723 } 715 }
724 716
725 717
726 } // namespace chromeos 718 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/network/policy_applicator.h » ('j') | chromeos/network/policy_applicator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698