Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / chromeos / network / onc / onc_signature.cc
blob378bf2ecc8810ee34edbca1c8b9715a30e3ceaa7
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
3 // found in the LICENSE file.
5 #include "chromeos/network/onc/onc_signature.h"
7 #include "components/onc/onc_constants.h"
8 #include "third_party/cros_system_api/dbus/service_constants.h"
10 using base::Value;
12 namespace chromeos {
13 namespace onc {
14 namespace {
16 const OncValueSignature kBoolSignature = {base::Value::TYPE_BOOLEAN, NULL};
17 const OncValueSignature kStringSignature = {base::Value::TYPE_STRING, NULL};
18 const OncValueSignature kIntegerSignature = {base::Value::TYPE_INTEGER, NULL};
19 const OncValueSignature kDoubleSignature = {base::Value::TYPE_DOUBLE, NULL};
20 const OncValueSignature kStringListSignature = {base::Value::TYPE_LIST,
21 NULL,
22 &kStringSignature};
23 const OncValueSignature kIntegerListSignature = {base::Value::TYPE_LIST,
24 NULL,
25 &kIntegerSignature};
26 const OncValueSignature kIPConfigListSignature = {base::Value::TYPE_LIST,
27 NULL,
28 &kIPConfigSignature};
29 const OncValueSignature kCellularApnListSignature = {base::Value::TYPE_LIST,
30 NULL,
31 &kCellularApnSignature};
32 const OncValueSignature kCellularFoundNetworkListSignature = {
33 base::Value::TYPE_LIST,
34 NULL,
35 &kCellularFoundNetworkSignature};
37 const OncFieldSignature issuer_subject_pattern_fields[] = {
38 {::onc::client_cert::kCommonName, &kStringSignature},
39 {::onc::client_cert::kLocality, &kStringSignature},
40 {::onc::client_cert::kOrganization, &kStringSignature},
41 {::onc::client_cert::kOrganizationalUnit, &kStringSignature},
42 {NULL}};
44 const OncFieldSignature certificate_pattern_fields[] = {
45 {::onc::kRecommended, &kRecommendedSignature},
46 {::onc::client_cert::kEnrollmentURI, &kStringListSignature},
47 {::onc::client_cert::kIssuer, &kIssuerSubjectPatternSignature},
48 {::onc::client_cert::kIssuerCARef, &kStringListSignature},
49 // Used internally. Not officially supported.
50 {::onc::client_cert::kIssuerCAPEMs, &kStringListSignature},
51 {::onc::client_cert::kSubject, &kIssuerSubjectPatternSignature},
52 {NULL}};
54 const OncFieldSignature eap_fields[] = {
55 {::onc::kRecommended, &kRecommendedSignature},
56 {::onc::eap::kAnonymousIdentity, &kStringSignature},
57 {::onc::client_cert::kClientCertPattern, &kCertificatePatternSignature},
58 {::onc::client_cert::kClientCertRef, &kStringSignature},
59 {::onc::client_cert::kClientCertType, &kStringSignature},
60 {::onc::eap::kIdentity, &kStringSignature},
61 {::onc::eap::kInner, &kStringSignature},
62 {::onc::eap::kOuter, &kStringSignature},
63 {::onc::eap::kPassword, &kStringSignature},
64 {::onc::eap::kSaveCredentials, &kBoolSignature},
65 // Used internally. Not officially supported.
66 {::onc::eap::kServerCAPEMs, &kStringListSignature},
67 {::onc::eap::kServerCARef, &kStringSignature},
68 {::onc::eap::kServerCARefs, &kStringListSignature},
69 {::onc::eap::kUseSystemCAs, &kBoolSignature},
70 {NULL}};
72 const OncFieldSignature ipsec_fields[] = {
73 {::onc::kRecommended, &kRecommendedSignature},
74 {::onc::ipsec::kAuthenticationType, &kStringSignature},
75 {::onc::client_cert::kClientCertPattern, &kCertificatePatternSignature},
76 {::onc::client_cert::kClientCertRef, &kStringSignature},
77 {::onc::client_cert::kClientCertType, &kStringSignature},
78 {::onc::ipsec::kGroup, &kStringSignature},
79 {::onc::ipsec::kIKEVersion, &kIntegerSignature},
80 {::onc::ipsec::kPSK, &kStringSignature},
81 {::onc::vpn::kSaveCredentials, &kBoolSignature},
82 // Used internally. Not officially supported.
83 {::onc::ipsec::kServerCAPEMs, &kStringListSignature},
84 {::onc::ipsec::kServerCARef, &kStringSignature},
85 {::onc::ipsec::kServerCARefs, &kStringListSignature},
86 {::onc::ipsec::kXAUTH, &kXAUTHSignature},
87 // Not yet supported.
88 // { ipsec::kEAP, &kEAPSignature },
89 {NULL}};
91 const OncFieldSignature xauth_fields[] = {
92 {::onc::vpn::kPassword, &kStringSignature},
93 {::onc::vpn::kUsername, &kStringSignature},
94 {NULL}};
96 const OncFieldSignature l2tp_fields[] = {
97 {::onc::kRecommended, &kRecommendedSignature},
98 {::onc::l2tp::kPassword, &kStringSignature},
99 {::onc::l2tp::kSaveCredentials, &kBoolSignature},
100 {::onc::l2tp::kUsername, &kStringSignature},
101 {::onc::l2tp::kLcpEchoDisabled, &kBoolSignature},
102 {NULL}};
104 const OncFieldSignature openvpn_fields[] = {
105 {::onc::kRecommended, &kRecommendedSignature},
106 {::onc::openvpn::kAuth, &kStringSignature},
107 {::onc::openvpn::kAuthNoCache, &kBoolSignature},
108 {::onc::openvpn::kAuthRetry, &kStringSignature},
109 {::onc::openvpn::kCipher, &kStringSignature},
110 {::onc::client_cert::kClientCertPattern, &kCertificatePatternSignature},
111 {::onc::client_cert::kClientCertRef, &kStringSignature},
112 {::onc::client_cert::kClientCertType, &kStringSignature},
113 {::onc::openvpn::kCompLZO, &kStringSignature},
114 {::onc::openvpn::kCompNoAdapt, &kBoolSignature},
115 {::onc::openvpn::kIgnoreDefaultRoute, &kBoolSignature},
116 {::onc::openvpn::kKeyDirection, &kStringSignature},
117 {::onc::openvpn::kNsCertType, &kStringSignature},
118 {::onc::openvpn::kOTP, &kStringSignature},
119 {::onc::openvpn::kPassword, &kStringSignature},
120 {::onc::openvpn::kPort, &kIntegerSignature},
121 {::onc::openvpn::kProto, &kStringSignature},
122 {::onc::openvpn::kPushPeerInfo, &kBoolSignature},
123 {::onc::openvpn::kRemoteCertEKU, &kStringSignature},
124 {::onc::openvpn::kRemoteCertKU, &kStringListSignature},
125 {::onc::openvpn::kRemoteCertTLS, &kStringSignature},
126 {::onc::openvpn::kRenegSec, &kIntegerSignature},
127 {::onc::vpn::kSaveCredentials, &kBoolSignature},
128 // Used internally. Not officially supported.
129 {::onc::openvpn::kServerCAPEMs, &kStringListSignature},
130 {::onc::openvpn::kServerCARef, &kStringSignature},
131 {::onc::openvpn::kServerCARefs, &kStringListSignature},
132 // Not supported, yet.
133 {::onc::openvpn::kServerCertPEM, &kStringSignature},
134 {::onc::openvpn::kServerCertRef, &kStringSignature},
135 {::onc::openvpn::kServerPollTimeout, &kIntegerSignature},
136 {::onc::openvpn::kShaper, &kIntegerSignature},
137 {::onc::openvpn::kStaticChallenge, &kStringSignature},
138 {::onc::openvpn::kTLSAuthContents, &kStringSignature},
139 {::onc::openvpn::kTLSRemote, &kStringSignature},
140 {::onc::openvpn::kUserAuthenticationType, &kStringSignature},
141 {::onc::vpn::kUsername, &kStringSignature},
142 // Not supported, yet.
143 {::onc::openvpn::kVerb, &kStringSignature},
144 {::onc::openvpn::kVerifyHash, &kStringSignature},
145 {::onc::openvpn::kVerifyX509, &kVerifyX509Signature},
146 {NULL}};
148 const OncFieldSignature third_party_vpn_fields[] = {
149 {::onc::kRecommended, &kRecommendedSignature},
150 {::onc::third_party_vpn::kExtensionID, &kStringSignature},
151 {NULL}};
153 const OncFieldSignature verify_x509_fields[] = {
154 {::onc::verify_x509::kName, &kStringSignature},
155 {::onc::verify_x509::kType, &kStringSignature},
156 {NULL}};
158 const OncFieldSignature vpn_fields[] = {
159 {::onc::kRecommended, &kRecommendedSignature},
160 {::onc::vpn::kAutoConnect, &kBoolSignature},
161 {::onc::vpn::kHost, &kStringSignature},
162 {::onc::vpn::kIPsec, &kIPsecSignature},
163 {::onc::vpn::kL2TP, &kL2TPSignature},
164 {::onc::vpn::kOpenVPN, &kOpenVPNSignature},
165 {::onc::vpn::kThirdPartyVpn, &kThirdPartyVPNSignature},
166 {::onc::vpn::kType, &kStringSignature},
167 {NULL}};
169 const OncFieldSignature ethernet_fields[] = {
170 {::onc::kRecommended, &kRecommendedSignature},
171 {::onc::ethernet::kAuthentication, &kStringSignature},
172 {::onc::ethernet::kEAP, &kEAPSignature},
173 {NULL}};
175 const OncFieldSignature ipconfig_fields[] = {
176 {::onc::ipconfig::kGateway, &kStringSignature},
177 {::onc::ipconfig::kIPAddress, &kStringSignature},
178 {::onc::ipconfig::kNameServers, &kStringListSignature},
179 {::onc::ipconfig::kRoutingPrefix, &kIntegerSignature},
180 {::onc::ipconfig::kSearchDomains, &kStringListSignature},
181 {::onc::ipconfig::kType, &kStringSignature},
182 {::onc::ipconfig::kWebProxyAutoDiscoveryUrl, &kStringSignature},
183 {NULL}};
185 const OncFieldSignature proxy_location_fields[] = {
186 {::onc::proxy::kHost, &kStringSignature},
187 {::onc::proxy::kPort, &kIntegerSignature},
188 {NULL}};
190 const OncFieldSignature proxy_manual_fields[] = {
191 {::onc::proxy::kFtp, &kProxyLocationSignature},
192 {::onc::proxy::kHttp, &kProxyLocationSignature},
193 {::onc::proxy::kHttps, &kProxyLocationSignature},
194 {::onc::proxy::kSocks, &kProxyLocationSignature},
195 {NULL}};
197 const OncFieldSignature proxy_settings_fields[] = {
198 {::onc::kRecommended, &kRecommendedSignature},
199 {::onc::proxy::kExcludeDomains, &kStringListSignature},
200 {::onc::proxy::kManual, &kProxyManualSignature},
201 {::onc::proxy::kPAC, &kStringSignature},
202 {::onc::proxy::kType, &kStringSignature},
203 {NULL}};
205 const OncFieldSignature wifi_fields[] = {
206 {::onc::kRecommended, &kRecommendedSignature},
207 {::onc::wifi::kAllowGatewayARPPolling, &kBoolSignature},
208 {::onc::wifi::kAutoConnect, &kBoolSignature},
209 {::onc::wifi::kEAP, &kEAPSignature},
210 {::onc::wifi::kHexSSID, &kStringSignature},
211 {::onc::wifi::kHiddenSSID, &kBoolSignature},
212 {::onc::wifi::kPassphrase, &kStringSignature},
213 {::onc::wifi::kSSID, &kStringSignature},
214 {::onc::wifi::kSecurity, &kStringSignature},
215 {NULL}};
217 const OncFieldSignature wifi_with_state_fields[] = {
218 {::onc::wifi::kBSSID, &kStringSignature},
219 {::onc::wifi::kFrequency, &kIntegerSignature},
220 {::onc::wifi::kFrequencyList, &kIntegerListSignature},
221 {::onc::wifi::kSignalStrength, &kIntegerSignature},
222 {NULL}};
224 const OncFieldSignature wimax_fields[] = {
225 {::onc::kRecommended, &kRecommendedSignature},
226 {::onc::wimax::kAutoConnect, &kBoolSignature},
227 {::onc::wimax::kEAP, &kEAPSignature},
228 {NULL}};
230 const OncFieldSignature wimax_with_state_fields[] = {
231 {::onc::wimax::kSignalStrength, &kIntegerSignature},
232 {NULL}};
234 const OncFieldSignature cellular_provider_fields[] = {
235 {::onc::cellular_provider::kCode, &kStringSignature},
236 {::onc::cellular_provider::kCountry, &kStringSignature},
237 {::onc::cellular_provider::kName, &kStringSignature},
238 {NULL}};
240 const OncFieldSignature cellular_apn_fields[] = {
241 {::onc::cellular_apn::kAccessPointName, &kStringSignature},
242 {::onc::cellular_apn::kName, &kStringSignature},
243 {::onc::cellular_apn::kUsername, &kStringSignature},
244 {::onc::cellular_apn::kPassword, &kStringSignature},
245 {::onc::cellular_apn::kLocalizedName, &kStringSignature},
246 {::onc::cellular_apn::kLanguage, &kStringSignature},
247 {NULL}};
249 const OncFieldSignature cellular_found_network_fields[] = {
250 {::onc::cellular_found_network::kStatus, &kStringSignature},
251 {::onc::cellular_found_network::kNetworkId, &kStringSignature},
252 {::onc::cellular_found_network::kShortName, &kStringSignature},
253 {::onc::cellular_found_network::kLongName, &kStringSignature},
254 {::onc::cellular_found_network::kTechnology, &kStringSignature},
255 {NULL}};
257 const OncFieldSignature sim_lock_status_fields[] = {
258 {::onc::sim_lock_status::kLockEnabled, &kBoolSignature},
259 {::onc::sim_lock_status::kLockType, &kStringSignature},
260 {::onc::sim_lock_status::kRetriesLeft, &kDoubleSignature},
261 {NULL}};
263 const OncFieldSignature cellular_fields[] = {
264 {::onc::kRecommended, &kRecommendedSignature},
265 {::onc::cellular::kAPN, &kCellularApnSignature},
266 {::onc::cellular::kAPNList, &kCellularApnListSignature},
267 {::onc::cellular::kCarrier, &kStringSignature},
268 {::onc::cellular::kAutoConnect, &kBoolSignature},
269 {NULL}};
271 const OncFieldSignature cellular_with_state_fields[] = {
272 {::onc::cellular::kActivationType, &kStringSignature},
273 {::onc::cellular::kActivationState, &kStringSignature},
274 {::onc::cellular::kAllowRoaming, &kBoolSignature},
275 {::onc::cellular::kESN, &kStringSignature},
276 {::onc::cellular::kFamily, &kStringSignature},
277 {::onc::cellular::kFirmwareRevision, &kStringSignature},
278 {::onc::cellular::kFoundNetworks, &kCellularFoundNetworkListSignature},
279 {::onc::cellular::kHardwareRevision, &kStringSignature},
280 {::onc::cellular::kHomeProvider, &kCellularProviderSignature},
281 {::onc::cellular::kICCID, &kStringSignature},
282 {::onc::cellular::kIMEI, &kStringSignature},
283 {::onc::cellular::kIMSI, &kStringSignature},
284 {::onc::cellular::kLastGoodAPN, &kCellularApnSignature},
285 {::onc::cellular::kManufacturer, &kStringSignature},
286 {::onc::cellular::kMDN, &kStringSignature},
287 {::onc::cellular::kMEID, &kStringSignature},
288 {::onc::cellular::kMIN, &kStringSignature},
289 {::onc::cellular::kModelID, &kStringSignature},
290 {::onc::cellular::kNetworkTechnology, &kStringSignature},
291 {::onc::cellular::kPRLVersion, &kIntegerSignature},
292 {::onc::cellular::kRoamingState, &kStringSignature},
293 {::onc::cellular::kServingOperator, &kCellularProviderSignature},
294 {::onc::cellular::kSignalStrength, &kIntegerSignature},
295 {::onc::cellular::kSIMLockStatus, &kSIMLockStatusSignature},
296 {::onc::cellular::kSIMPresent, &kBoolSignature},
297 {::onc::cellular::kSupportNetworkScan, &kBoolSignature},
298 {::onc::cellular::kSupportedCarriers, &kStringListSignature},
299 {NULL}};
301 const OncFieldSignature network_configuration_fields[] = {
302 {::onc::network_config::kCellular, &kCellularSignature},
303 {::onc::network_config::kEthernet, &kEthernetSignature},
304 {::onc::network_config::kGUID, &kStringSignature},
305 {::onc::network_config::kIPAddressConfigType, &kStringSignature},
306 {::onc::network_config::kName, &kStringSignature},
307 {::onc::network_config::kNameServersConfigType, &kStringSignature},
308 {::onc::network_config::kPriority, &kIntegerSignature},
309 {::onc::network_config::kProxySettings, &kProxySettingsSignature},
310 {::onc::kRecommended, &kRecommendedSignature},
311 {::onc::kRemove, &kBoolSignature},
312 {::onc::network_config::kStaticIPConfig, &kStaticIPConfigSignature},
313 {::onc::network_config::kType, &kStringSignature},
314 {::onc::network_config::kVPN, &kVPNSignature},
315 {::onc::network_config::kWiFi, &kWiFiSignature},
316 {::onc::network_config::kWimax, &kWiMAXSignature},
317 {NULL}};
319 const OncFieldSignature network_with_state_fields[] = {
320 {::onc::network_config::kCellular, &kCellularWithStateSignature},
321 {::onc::network_config::kConnectionState, &kStringSignature},
322 {::onc::network_config::kConnectable, &kBoolSignature},
323 {::onc::network_config::kErrorState, &kStringSignature},
324 {::onc::network_config::kIPConfigs, &kIPConfigListSignature},
325 {::onc::network_config::kMacAddress, &kStringSignature},
326 {::onc::network_config::kRestrictedConnectivity, &kBoolSignature},
327 {::onc::network_config::kSavedIPConfig, &kSavedIPConfigSignature},
328 {::onc::network_config::kSource, &kStringSignature},
329 {::onc::network_config::kWiFi, &kWiFiWithStateSignature},
330 {::onc::network_config::kWimax, &kWiMAXWithStateSignature},
331 {NULL}};
333 const OncFieldSignature global_network_configuration_fields[] = {
334 {::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect,
335 &kBoolSignature},
336 {NULL}};
338 const OncFieldSignature certificate_fields[] = {
339 {::onc::certificate::kGUID, &kStringSignature},
340 {::onc::certificate::kPKCS12, &kStringSignature},
341 {::onc::kRemove, &kBoolSignature},
342 {::onc::certificate::kTrustBits, &kStringListSignature},
343 {::onc::certificate::kType, &kStringSignature},
344 {::onc::certificate::kX509, &kStringSignature},
345 {NULL}};
347 const OncFieldSignature toplevel_configuration_fields[] = {
348 {::onc::toplevel_config::kCertificates, &kCertificateListSignature},
349 {::onc::toplevel_config::kNetworkConfigurations,
350 &kNetworkConfigurationListSignature},
351 {::onc::toplevel_config::kGlobalNetworkConfiguration,
352 &kGlobalNetworkConfigurationSignature},
353 {::onc::toplevel_config::kType, &kStringSignature},
354 {::onc::encrypted::kCipher, &kStringSignature},
355 {::onc::encrypted::kCiphertext, &kStringSignature},
356 {::onc::encrypted::kHMAC, &kStringSignature},
357 {::onc::encrypted::kHMACMethod, &kStringSignature},
358 {::onc::encrypted::kIV, &kStringSignature},
359 {::onc::encrypted::kIterations, &kIntegerSignature},
360 {::onc::encrypted::kSalt, &kStringSignature},
361 {::onc::encrypted::kStretch, &kStringSignature},
362 {NULL}};
364 } // namespace
366 const OncValueSignature kRecommendedSignature = {base::Value::TYPE_LIST,
367 NULL,
368 &kStringSignature};
369 const OncValueSignature kEAPSignature = {base::Value::TYPE_DICTIONARY,
370 eap_fields,
371 NULL};
372 const OncValueSignature kIssuerSubjectPatternSignature = {
373 base::Value::TYPE_DICTIONARY,
374 issuer_subject_pattern_fields,
375 NULL};
376 const OncValueSignature kCertificatePatternSignature = {
377 base::Value::TYPE_DICTIONARY,
378 certificate_pattern_fields,
379 NULL};
380 const OncValueSignature kIPsecSignature = {base::Value::TYPE_DICTIONARY,
381 ipsec_fields,
382 NULL};
383 const OncValueSignature kXAUTHSignature = {base::Value::TYPE_DICTIONARY,
384 xauth_fields,
385 NULL};
386 const OncValueSignature kL2TPSignature = {base::Value::TYPE_DICTIONARY,
387 l2tp_fields,
388 NULL};
389 const OncValueSignature kOpenVPNSignature = {base::Value::TYPE_DICTIONARY,
390 openvpn_fields,
391 NULL};
392 const OncValueSignature kThirdPartyVPNSignature = {base::Value::TYPE_DICTIONARY,
393 third_party_vpn_fields,
394 NULL};
395 const OncValueSignature kVerifyX509Signature = {base::Value::TYPE_DICTIONARY,
396 verify_x509_fields,
397 NULL};
398 const OncValueSignature kVPNSignature = {base::Value::TYPE_DICTIONARY,
399 vpn_fields,
400 NULL};
401 const OncValueSignature kEthernetSignature = {base::Value::TYPE_DICTIONARY,
402 ethernet_fields,
403 NULL};
404 const OncValueSignature kIPConfigSignature = {base::Value::TYPE_DICTIONARY,
405 ipconfig_fields,
406 NULL};
407 const OncValueSignature kSavedIPConfigSignature = {base::Value::TYPE_DICTIONARY,
408 ipconfig_fields,
409 NULL};
410 const OncValueSignature kStaticIPConfigSignature = {
411 base::Value::TYPE_DICTIONARY,
412 ipconfig_fields,
413 NULL};
414 const OncValueSignature kProxyLocationSignature = {base::Value::TYPE_DICTIONARY,
415 proxy_location_fields,
416 NULL};
417 const OncValueSignature kProxyManualSignature = {base::Value::TYPE_DICTIONARY,
418 proxy_manual_fields,
419 NULL};
420 const OncValueSignature kProxySettingsSignature = {base::Value::TYPE_DICTIONARY,
421 proxy_settings_fields,
422 NULL};
423 const OncValueSignature kWiFiSignature = {base::Value::TYPE_DICTIONARY,
424 wifi_fields,
425 NULL};
426 const OncValueSignature kWiMAXSignature = {base::Value::TYPE_DICTIONARY,
427 wimax_fields,
428 NULL};
429 const OncValueSignature kCertificateSignature = {base::Value::TYPE_DICTIONARY,
430 certificate_fields,
431 NULL};
432 const OncValueSignature kNetworkConfigurationSignature = {
433 base::Value::TYPE_DICTIONARY,
434 network_configuration_fields,
435 NULL};
436 const OncValueSignature kGlobalNetworkConfigurationSignature = {
437 base::Value::TYPE_DICTIONARY,
438 global_network_configuration_fields,
439 NULL};
440 const OncValueSignature kCertificateListSignature = {base::Value::TYPE_LIST,
441 NULL,
442 &kCertificateSignature};
443 const OncValueSignature kNetworkConfigurationListSignature = {
444 base::Value::TYPE_LIST,
445 NULL,
446 &kNetworkConfigurationSignature};
447 const OncValueSignature kToplevelConfigurationSignature = {
448 base::Value::TYPE_DICTIONARY,
449 toplevel_configuration_fields,
450 NULL};
452 // Derived "ONC with State" signatures.
453 const OncValueSignature kNetworkWithStateSignature = {
454 base::Value::TYPE_DICTIONARY,
455 network_with_state_fields,
456 NULL,
457 &kNetworkConfigurationSignature};
458 const OncValueSignature kWiFiWithStateSignature = {base::Value::TYPE_DICTIONARY,
459 wifi_with_state_fields,
460 NULL,
461 &kWiFiSignature};
462 const OncValueSignature kWiMAXWithStateSignature = {
463 base::Value::TYPE_DICTIONARY,
464 wimax_with_state_fields,
465 NULL,
466 &kWiMAXSignature};
467 const OncValueSignature kCellularSignature = {base::Value::TYPE_DICTIONARY,
468 cellular_fields,
469 NULL};
470 const OncValueSignature kCellularWithStateSignature = {
471 base::Value::TYPE_DICTIONARY,
472 cellular_with_state_fields,
473 NULL,
474 &kCellularSignature};
475 const OncValueSignature kCellularProviderSignature = {
476 base::Value::TYPE_DICTIONARY,
477 cellular_provider_fields,
478 NULL};
479 const OncValueSignature kCellularApnSignature = {base::Value::TYPE_DICTIONARY,
480 cellular_apn_fields,
481 NULL};
482 const OncValueSignature kCellularFoundNetworkSignature = {
483 base::Value::TYPE_DICTIONARY,
484 cellular_found_network_fields,
485 NULL};
486 const OncValueSignature kSIMLockStatusSignature = {base::Value::TYPE_DICTIONARY,
487 sim_lock_status_fields,
488 NULL};
490 const OncFieldSignature* GetFieldSignature(const OncValueSignature& signature,
491 const std::string& onc_field_name) {
492 if (!signature.fields)
493 return NULL;
494 for (const OncFieldSignature* field_signature = signature.fields;
495 field_signature->onc_field_name != NULL; ++field_signature) {
496 if (onc_field_name == field_signature->onc_field_name)
497 return field_signature;
499 if (signature.base_signature)
500 return GetFieldSignature(*signature.base_signature, onc_field_name);
501 return NULL;
504 namespace {
506 struct CredentialEntry {
507 const OncValueSignature* value_signature;
508 const char* field_name;
511 const CredentialEntry credentials[] = {
512 {&kEAPSignature, ::onc::eap::kPassword},
513 {&kIPsecSignature, ::onc::ipsec::kPSK},
514 {&kXAUTHSignature, ::onc::vpn::kPassword},
515 {&kL2TPSignature, ::onc::vpn::kPassword},
516 {&kOpenVPNSignature, ::onc::vpn::kPassword},
517 {&kOpenVPNSignature, ::onc::openvpn::kTLSAuthContents},
518 {&kWiFiSignature, ::onc::wifi::kPassphrase},
519 {&kCellularApnSignature, ::onc::cellular_apn::kPassword},
520 {NULL}};
522 } // namespace
524 bool FieldIsCredential(const OncValueSignature& signature,
525 const std::string& onc_field_name) {
526 for (const CredentialEntry* entry = credentials;
527 entry->value_signature != NULL; ++entry) {
528 if (&signature == entry->value_signature &&
529 onc_field_name == entry->field_name) {
530 return true;
533 return false;
536 } // namespace onc
537 } // namespace chromeos