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

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

Issue 23451044: Add an Ethernet EAP policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed remaining comments. # Created 7 years, 2 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 | Annotate | Revision Log
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/policy_util.h" 5 #include "chromeos/network/policy_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/values.h"
8 #include "chromeos/network/network_profile.h" 9 #include "chromeos/network/network_profile.h"
9 #include "chromeos/network/network_ui_data.h" 10 #include "chromeos/network/network_ui_data.h"
10 #include "chromeos/network/onc/onc_constants.h" 11 #include "chromeos/network/onc/onc_constants.h"
11 #include "chromeos/network/onc/onc_merger.h" 12 #include "chromeos/network/onc/onc_merger.h"
12 #include "chromeos/network/onc/onc_normalizer.h" 13 #include "chromeos/network/onc/onc_normalizer.h"
13 #include "chromeos/network/onc/onc_signature.h" 14 #include "chromeos/network/onc/onc_signature.h"
14 #include "chromeos/network/onc/onc_translator.h" 15 #include "chromeos/network/onc/onc_translator.h"
15 #include "chromeos/network/onc/onc_utils.h" 16 #include "chromeos/network/onc/onc_utils.h"
16 #include "chromeos/network/shill_property_util.h" 17 #include "chromeos/network/shill_property_util.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Returns true if |policy| matches |actual_network|, which must be part of a 73 // Returns true if |policy| matches |actual_network|, which must be part of a
73 // ONC NetworkConfiguration. This should be the only such matching function 74 // ONC NetworkConfiguration. This should be the only such matching function
74 // within Chrome. Shill does such matching in several functions for network 75 // within Chrome. Shill does such matching in several functions for network
75 // identification. For compatibility, we currently should stick to Shill's 76 // identification. For compatibility, we currently should stick to Shill's
76 // matching behavior. 77 // matching behavior.
77 bool IsPolicyMatching(const base::DictionaryValue& policy, 78 bool IsPolicyMatching(const base::DictionaryValue& policy,
78 const base::DictionaryValue& actual_network) { 79 const base::DictionaryValue& actual_network) {
79 std::string policy_type; 80 std::string policy_type;
80 policy.GetStringWithoutPathExpansion(onc::network_config::kType, 81 policy.GetStringWithoutPathExpansion(onc::network_config::kType,
81 &policy_type); 82 &policy_type);
82 std::string network_type; 83 std::string actual_network_type;
83 actual_network.GetStringWithoutPathExpansion(onc::network_config::kType, 84 actual_network.GetStringWithoutPathExpansion(onc::network_config::kType,
84 &network_type); 85 &actual_network_type);
85 if (policy_type != network_type) 86 if (policy_type != actual_network_type)
86 return false; 87 return false;
87 88
88 if (network_type != onc::network_type::kWiFi) 89 if (actual_network_type == onc::network_type::kEthernet) {
89 return false; 90 const base::DictionaryValue* policy_ethernet = NULL;
91 policy.GetDictionaryWithoutPathExpansion(onc::network_config::kEthernet,
92 &policy_ethernet);
93 const base::DictionaryValue* actual_ethernet = NULL;
94 actual_network.GetDictionaryWithoutPathExpansion(
95 onc::network_config::kEthernet, &actual_ethernet);
96 if (!policy_ethernet || !actual_ethernet)
97 return false;
90 98
91 const base::DictionaryValue* policy_wifi = NULL; 99 std::string policy_auth;
92 policy.GetDictionaryWithoutPathExpansion(onc::network_config::kWiFi, 100 policy_ethernet->GetStringWithoutPathExpansion(
93 &policy_wifi); 101 onc::ethernet::kAuthentication, &policy_auth);
94 const base::DictionaryValue* actual_wifi = NULL; 102 std::string actual_auth;
95 actual_network.GetDictionaryWithoutPathExpansion(onc::network_config::kWiFi, 103 actual_ethernet->GetStringWithoutPathExpansion(
96 &actual_wifi); 104 onc::ethernet::kAuthentication, &actual_auth);
97 if (!policy_wifi || !actual_wifi) 105 return policy_auth == actual_auth;
98 return false; 106 } else if (actual_network_type == onc::network_type::kWiFi) {
107 const base::DictionaryValue* policy_wifi = NULL;
108 policy.GetDictionaryWithoutPathExpansion(onc::network_config::kWiFi,
109 &policy_wifi);
110 const base::DictionaryValue* actual_wifi = NULL;
111 actual_network.GetDictionaryWithoutPathExpansion(onc::network_config::kWiFi,
112 &actual_wifi);
113 if (!policy_wifi || !actual_wifi)
114 return false;
99 115
100 std::string policy_ssid; 116 std::string policy_ssid;
101 policy_wifi->GetStringWithoutPathExpansion(onc::wifi::kSSID, &policy_ssid); 117 policy_wifi->GetStringWithoutPathExpansion(onc::wifi::kSSID, &policy_ssid);
102 std::string actual_ssid; 118 std::string actual_ssid;
103 actual_wifi->GetStringWithoutPathExpansion(onc::wifi::kSSID, &actual_ssid); 119 actual_wifi->GetStringWithoutPathExpansion(onc::wifi::kSSID, &actual_ssid);
104 return (policy_ssid == actual_ssid); 120 return (policy_ssid == actual_ssid);
121 }
122 return false;
105 } 123 }
106 124
107 } // namespace 125 } // namespace
108 126
109 scoped_ptr<base::DictionaryValue> CreateShillConfiguration( 127 scoped_ptr<base::DictionaryValue> CreateShillConfiguration(
110 const NetworkProfile& profile, 128 const NetworkProfile& profile,
111 const std::string& guid, 129 const std::string& guid,
112 const base::DictionaryValue* policy, 130 const base::DictionaryValue* policy,
113 const base::DictionaryValue* settings) { 131 const base::DictionaryValue* settings) {
114 scoped_ptr<base::DictionaryValue> effective; 132 scoped_ptr<base::DictionaryValue> effective;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 it != policies.end(); ++it) { 210 it != policies.end(); ++it) {
193 if (IsPolicyMatching(*it->second, actual_network)) 211 if (IsPolicyMatching(*it->second, actual_network))
194 return it->second; 212 return it->second;
195 } 213 }
196 return NULL; 214 return NULL;
197 } 215 }
198 216
199 } // namespace policy_util 217 } // namespace policy_util
200 218
201 } // namespace chromeos 219 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/policy_applicator.cc ('k') | chromeos/test/data/network/policy/policy_ethernet_eap.onc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698