Update broken references to image assets
[chromium-blink-merge.git] / chromeos / network / onc / onc_signature.cc
blob65df3966c3cb526c2d0564807ff941c0618fb82a
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 kStringListSignature = {base::Value::TYPE_LIST,
20 NULL,
21 &kStringSignature};
22 const OncValueSignature kIntegerListSignature = {base::Value::TYPE_LIST,
23 NULL,
24 &kIntegerSignature};
25 const OncValueSignature kIPConfigListSignature = {base::Value::TYPE_LIST,
26 NULL,
27 &kIPConfigSignature};
28 const OncValueSignature kCellularApnListSignature = {base::Value::TYPE_LIST,
29 NULL,
30 &kCellularApnSignature};
31 const OncValueSignature kCellularFoundNetworkListSignature = {
32 base::Value::TYPE_LIST,
33 NULL,
34 &kCellularFoundNetworkSignature};
36 const OncFieldSignature issuer_subject_pattern_fields[] = {
37 {::onc::client_cert::kCommonName, &kStringSignature},
38 {::onc::client_cert::kLocality, &kStringSignature},
39 {::onc::client_cert::kOrganization, &kStringSignature},
40 {::onc::client_cert::kOrganizationalUnit, &kStringSignature},
41 {NULL}};
43 const OncFieldSignature certificate_pattern_fields[] = {
44 {::onc::kRecommended, &kRecommendedSignature},
45 {::onc::client_cert::kEnrollmentURI, &kStringListSignature},
46 {::onc::client_cert::kIssuer, &kIssuerSubjectPatternSignature},
47 {::onc::client_cert::kIssuerCARef, &kStringListSignature},
48 // Used internally. Not officially supported.
49 {::onc::client_cert::kIssuerCAPEMs, &kStringListSignature},
50 {::onc::client_cert::kSubject, &kIssuerSubjectPatternSignature},
51 {NULL}};
53 const OncFieldSignature eap_fields[] = {
54 {::onc::kRecommended, &kRecommendedSignature},
55 {::onc::eap::kAnonymousIdentity, &kStringSignature},
56 {::onc::client_cert::kClientCertPattern, &kCertificatePatternSignature},
57 {::onc::client_cert::kClientCertRef, &kStringSignature},
58 {::onc::client_cert::kClientCertType, &kStringSignature},
59 {::onc::eap::kIdentity, &kStringSignature},
60 {::onc::eap::kInner, &kStringSignature},
61 {::onc::eap::kOuter, &kStringSignature},
62 {::onc::eap::kPassword, &kStringSignature},
63 {::onc::eap::kSaveCredentials, &kBoolSignature},
64 // Used internally. Not officially supported.
65 {::onc::eap::kServerCAPEMs, &kStringListSignature},
66 {::onc::eap::kServerCARef, &kStringSignature},
67 {::onc::eap::kServerCARefs, &kStringListSignature},
68 {::onc::eap::kUseSystemCAs, &kBoolSignature},
69 {::onc::eap::kUseProactiveKeyCaching, &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::kRoamThreshold, &kIntegerSignature},
214 {::onc::wifi::kSSID, &kStringSignature},
215 {::onc::wifi::kSecurity, &kStringSignature},
216 {NULL}};
218 const OncFieldSignature wifi_with_state_fields[] = {
219 {::onc::wifi::kBSSID, &kStringSignature},
220 {::onc::wifi::kFrequency, &kIntegerSignature},
221 {::onc::wifi::kFrequencyList, &kIntegerListSignature},
222 {::onc::wifi::kSignalStrength, &kIntegerSignature},
223 {NULL}};
225 const OncFieldSignature wimax_fields[] = {
226 {::onc::kRecommended, &kRecommendedSignature},
227 {::onc::wimax::kAutoConnect, &kBoolSignature},
228 {::onc::wimax::kEAP, &kEAPSignature},
229 {NULL}};
231 const OncFieldSignature wimax_with_state_fields[] = {
232 {::onc::wimax::kSignalStrength, &kIntegerSignature},
233 {NULL}};
235 const OncFieldSignature cellular_payment_portal_fields[] = {
236 {::onc::cellular_payment_portal::kMethod, &kStringSignature},
237 {::onc::cellular_payment_portal::kPostData, &kStringSignature},
238 {::onc::cellular_payment_portal::kUrl, &kStringSignature},
239 {NULL}};
241 const OncFieldSignature cellular_provider_fields[] = {
242 {::onc::cellular_provider::kCode, &kStringSignature},
243 {::onc::cellular_provider::kCountry, &kStringSignature},
244 {::onc::cellular_provider::kName, &kStringSignature},
245 {NULL}};
247 const OncFieldSignature cellular_apn_fields[] = {
248 {::onc::cellular_apn::kAccessPointName, &kStringSignature},
249 {::onc::cellular_apn::kName, &kStringSignature},
250 {::onc::cellular_apn::kUsername, &kStringSignature},
251 {::onc::cellular_apn::kPassword, &kStringSignature},
252 {::onc::cellular_apn::kLocalizedName, &kStringSignature},
253 {::onc::cellular_apn::kLanguage, &kStringSignature},
254 {NULL}};
256 const OncFieldSignature cellular_found_network_fields[] = {
257 {::onc::cellular_found_network::kStatus, &kStringSignature},
258 {::onc::cellular_found_network::kNetworkId, &kStringSignature},
259 {::onc::cellular_found_network::kShortName, &kStringSignature},
260 {::onc::cellular_found_network::kLongName, &kStringSignature},
261 {::onc::cellular_found_network::kTechnology, &kStringSignature},
262 {NULL}};
264 const OncFieldSignature sim_lock_status_fields[] = {
265 {::onc::sim_lock_status::kLockEnabled, &kBoolSignature},
266 {::onc::sim_lock_status::kLockType, &kStringSignature},
267 {::onc::sim_lock_status::kRetriesLeft, &kIntegerSignature},
268 {NULL}};
270 const OncFieldSignature cellular_fields[] = {
271 {::onc::kRecommended, &kRecommendedSignature},
272 {::onc::cellular::kAPN, &kCellularApnSignature},
273 {::onc::cellular::kAPNList, &kCellularApnListSignature},
274 {::onc::cellular::kCarrier, &kStringSignature},
275 {::onc::cellular::kAutoConnect, &kBoolSignature},
276 {NULL}};
278 const OncFieldSignature cellular_with_state_fields[] = {
279 {::onc::cellular::kActivationType, &kStringSignature},
280 {::onc::cellular::kActivationState, &kStringSignature},
281 {::onc::cellular::kAllowRoaming, &kBoolSignature},
282 {::onc::cellular::kESN, &kStringSignature},
283 {::onc::cellular::kFamily, &kStringSignature},
284 {::onc::cellular::kFirmwareRevision, &kStringSignature},
285 {::onc::cellular::kFoundNetworks, &kCellularFoundNetworkListSignature},
286 {::onc::cellular::kHardwareRevision, &kStringSignature},
287 {::onc::cellular::kHomeProvider, &kCellularProviderSignature},
288 {::onc::cellular::kICCID, &kStringSignature},
289 {::onc::cellular::kIMEI, &kStringSignature},
290 {::onc::cellular::kIMSI, &kStringSignature},
291 {::onc::cellular::kLastGoodAPN, &kCellularApnSignature},
292 {::onc::cellular::kManufacturer, &kStringSignature},
293 {::onc::cellular::kMDN, &kStringSignature},
294 {::onc::cellular::kMEID, &kStringSignature},
295 {::onc::cellular::kMIN, &kStringSignature},
296 {::onc::cellular::kModelID, &kStringSignature},
297 {::onc::cellular::kNetworkTechnology, &kStringSignature},
298 {::onc::cellular::kPaymentPortal, &kCellularPaymentPortalSignature},
299 {::onc::cellular::kPRLVersion, &kIntegerSignature},
300 {::onc::cellular::kRoamingState, &kStringSignature},
301 {::onc::cellular::kServingOperator, &kCellularProviderSignature},
302 {::onc::cellular::kSignalStrength, &kIntegerSignature},
303 {::onc::cellular::kSIMLockStatus, &kSIMLockStatusSignature},
304 {::onc::cellular::kSIMPresent, &kBoolSignature},
305 {::onc::cellular::kSupportNetworkScan, &kBoolSignature},
306 {::onc::cellular::kSupportedCarriers, &kStringListSignature},
307 {NULL}};
309 const OncFieldSignature network_configuration_fields[] = {
310 {::onc::network_config::kCellular, &kCellularSignature},
311 {::onc::network_config::kEthernet, &kEthernetSignature},
312 {::onc::network_config::kGUID, &kStringSignature},
313 {::onc::network_config::kIPAddressConfigType, &kStringSignature},
314 {::onc::network_config::kName, &kStringSignature},
315 {::onc::network_config::kNameServersConfigType, &kStringSignature},
316 {::onc::network_config::kPriority, &kIntegerSignature},
317 {::onc::network_config::kProxySettings, &kProxySettingsSignature},
318 {::onc::kRecommended, &kRecommendedSignature},
319 {::onc::kRemove, &kBoolSignature},
320 {::onc::network_config::kStaticIPConfig, &kStaticIPConfigSignature},
321 {::onc::network_config::kType, &kStringSignature},
322 {::onc::network_config::kVPN, &kVPNSignature},
323 {::onc::network_config::kWiFi, &kWiFiSignature},
324 {::onc::network_config::kWimax, &kWiMAXSignature},
325 {NULL}};
327 const OncFieldSignature network_with_state_fields[] = {
328 {::onc::network_config::kCellular, &kCellularWithStateSignature},
329 {::onc::network_config::kConnectionState, &kStringSignature},
330 {::onc::network_config::kConnectable, &kBoolSignature},
331 {::onc::network_config::kErrorState, &kStringSignature},
332 {::onc::network_config::kIPConfigs, &kIPConfigListSignature},
333 {::onc::network_config::kMacAddress, &kStringSignature},
334 {::onc::network_config::kRestrictedConnectivity, &kBoolSignature},
335 {::onc::network_config::kSavedIPConfig, &kSavedIPConfigSignature},
336 {::onc::network_config::kSource, &kStringSignature},
337 {::onc::network_config::kWiFi, &kWiFiWithStateSignature},
338 {::onc::network_config::kWimax, &kWiMAXWithStateSignature},
339 {NULL}};
341 const OncFieldSignature global_network_configuration_fields[] = {
342 {::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect,
343 &kBoolSignature},
344 {NULL}};
346 const OncFieldSignature certificate_fields[] = {
347 {::onc::certificate::kGUID, &kStringSignature},
348 {::onc::certificate::kPKCS12, &kStringSignature},
349 {::onc::kRemove, &kBoolSignature},
350 {::onc::certificate::kTrustBits, &kStringListSignature},
351 {::onc::certificate::kType, &kStringSignature},
352 {::onc::certificate::kX509, &kStringSignature},
353 {NULL}};
355 const OncFieldSignature toplevel_configuration_fields[] = {
356 {::onc::toplevel_config::kCertificates, &kCertificateListSignature},
357 {::onc::toplevel_config::kNetworkConfigurations,
358 &kNetworkConfigurationListSignature},
359 {::onc::toplevel_config::kGlobalNetworkConfiguration,
360 &kGlobalNetworkConfigurationSignature},
361 {::onc::toplevel_config::kType, &kStringSignature},
362 {::onc::encrypted::kCipher, &kStringSignature},
363 {::onc::encrypted::kCiphertext, &kStringSignature},
364 {::onc::encrypted::kHMAC, &kStringSignature},
365 {::onc::encrypted::kHMACMethod, &kStringSignature},
366 {::onc::encrypted::kIV, &kStringSignature},
367 {::onc::encrypted::kIterations, &kIntegerSignature},
368 {::onc::encrypted::kSalt, &kStringSignature},
369 {::onc::encrypted::kStretch, &kStringSignature},
370 {NULL}};
372 } // namespace
374 const OncValueSignature kRecommendedSignature = {base::Value::TYPE_LIST,
375 NULL,
376 &kStringSignature};
377 const OncValueSignature kEAPSignature = {base::Value::TYPE_DICTIONARY,
378 eap_fields,
379 NULL};
380 const OncValueSignature kIssuerSubjectPatternSignature = {
381 base::Value::TYPE_DICTIONARY,
382 issuer_subject_pattern_fields,
383 NULL};
384 const OncValueSignature kCertificatePatternSignature = {
385 base::Value::TYPE_DICTIONARY,
386 certificate_pattern_fields,
387 NULL};
388 const OncValueSignature kIPsecSignature = {base::Value::TYPE_DICTIONARY,
389 ipsec_fields,
390 NULL};
391 const OncValueSignature kXAUTHSignature = {base::Value::TYPE_DICTIONARY,
392 xauth_fields,
393 NULL};
394 const OncValueSignature kL2TPSignature = {base::Value::TYPE_DICTIONARY,
395 l2tp_fields,
396 NULL};
397 const OncValueSignature kOpenVPNSignature = {base::Value::TYPE_DICTIONARY,
398 openvpn_fields,
399 NULL};
400 const OncValueSignature kThirdPartyVPNSignature = {base::Value::TYPE_DICTIONARY,
401 third_party_vpn_fields,
402 NULL};
403 const OncValueSignature kVerifyX509Signature = {base::Value::TYPE_DICTIONARY,
404 verify_x509_fields,
405 NULL};
406 const OncValueSignature kVPNSignature = {base::Value::TYPE_DICTIONARY,
407 vpn_fields,
408 NULL};
409 const OncValueSignature kEthernetSignature = {base::Value::TYPE_DICTIONARY,
410 ethernet_fields,
411 NULL};
412 const OncValueSignature kIPConfigSignature = {base::Value::TYPE_DICTIONARY,
413 ipconfig_fields,
414 NULL};
415 const OncValueSignature kSavedIPConfigSignature = {base::Value::TYPE_DICTIONARY,
416 ipconfig_fields,
417 NULL};
418 const OncValueSignature kStaticIPConfigSignature = {
419 base::Value::TYPE_DICTIONARY,
420 ipconfig_fields,
421 NULL};
422 const OncValueSignature kProxyLocationSignature = {base::Value::TYPE_DICTIONARY,
423 proxy_location_fields,
424 NULL};
425 const OncValueSignature kProxyManualSignature = {base::Value::TYPE_DICTIONARY,
426 proxy_manual_fields,
427 NULL};
428 const OncValueSignature kProxySettingsSignature = {base::Value::TYPE_DICTIONARY,
429 proxy_settings_fields,
430 NULL};
431 const OncValueSignature kWiFiSignature = {base::Value::TYPE_DICTIONARY,
432 wifi_fields,
433 NULL};
434 const OncValueSignature kWiMAXSignature = {base::Value::TYPE_DICTIONARY,
435 wimax_fields,
436 NULL};
437 const OncValueSignature kCertificateSignature = {base::Value::TYPE_DICTIONARY,
438 certificate_fields,
439 NULL};
440 const OncValueSignature kNetworkConfigurationSignature = {
441 base::Value::TYPE_DICTIONARY,
442 network_configuration_fields,
443 NULL};
444 const OncValueSignature kGlobalNetworkConfigurationSignature = {
445 base::Value::TYPE_DICTIONARY,
446 global_network_configuration_fields,
447 NULL};
448 const OncValueSignature kCertificateListSignature = {base::Value::TYPE_LIST,
449 NULL,
450 &kCertificateSignature};
451 const OncValueSignature kNetworkConfigurationListSignature = {
452 base::Value::TYPE_LIST,
453 NULL,
454 &kNetworkConfigurationSignature};
455 const OncValueSignature kToplevelConfigurationSignature = {
456 base::Value::TYPE_DICTIONARY,
457 toplevel_configuration_fields,
458 NULL};
460 // Derived "ONC with State" signatures.
461 const OncValueSignature kNetworkWithStateSignature = {
462 base::Value::TYPE_DICTIONARY,
463 network_with_state_fields,
464 NULL,
465 &kNetworkConfigurationSignature};
466 const OncValueSignature kWiFiWithStateSignature = {base::Value::TYPE_DICTIONARY,
467 wifi_with_state_fields,
468 NULL,
469 &kWiFiSignature};
470 const OncValueSignature kWiMAXWithStateSignature = {
471 base::Value::TYPE_DICTIONARY,
472 wimax_with_state_fields,
473 NULL,
474 &kWiMAXSignature};
475 const OncValueSignature kCellularSignature = {base::Value::TYPE_DICTIONARY,
476 cellular_fields,
477 NULL};
478 const OncValueSignature kCellularWithStateSignature = {
479 base::Value::TYPE_DICTIONARY,
480 cellular_with_state_fields,
481 NULL,
482 &kCellularSignature};
483 const OncValueSignature kCellularPaymentPortalSignature = {
484 base::Value::TYPE_DICTIONARY,
485 cellular_payment_portal_fields,
486 NULL};
487 const OncValueSignature kCellularProviderSignature = {
488 base::Value::TYPE_DICTIONARY,
489 cellular_provider_fields,
490 NULL};
491 const OncValueSignature kCellularApnSignature = {base::Value::TYPE_DICTIONARY,
492 cellular_apn_fields,
493 NULL};
494 const OncValueSignature kCellularFoundNetworkSignature = {
495 base::Value::TYPE_DICTIONARY,
496 cellular_found_network_fields,
497 NULL};
498 const OncValueSignature kSIMLockStatusSignature = {base::Value::TYPE_DICTIONARY,
499 sim_lock_status_fields,
500 NULL};
502 const OncFieldSignature* GetFieldSignature(const OncValueSignature& signature,
503 const std::string& onc_field_name) {
504 if (!signature.fields)
505 return NULL;
506 for (const OncFieldSignature* field_signature = signature.fields;
507 field_signature->onc_field_name != NULL; ++field_signature) {
508 if (onc_field_name == field_signature->onc_field_name)
509 return field_signature;
511 if (signature.base_signature)
512 return GetFieldSignature(*signature.base_signature, onc_field_name);
513 return NULL;
516 namespace {
518 struct CredentialEntry {
519 const OncValueSignature* value_signature;
520 const char* field_name;
523 const CredentialEntry credentials[] = {
524 {&kEAPSignature, ::onc::eap::kPassword},
525 {&kIPsecSignature, ::onc::ipsec::kPSK},
526 {&kXAUTHSignature, ::onc::vpn::kPassword},
527 {&kL2TPSignature, ::onc::vpn::kPassword},
528 {&kOpenVPNSignature, ::onc::vpn::kPassword},
529 {&kOpenVPNSignature, ::onc::openvpn::kTLSAuthContents},
530 {&kWiFiSignature, ::onc::wifi::kPassphrase},
531 {&kCellularApnSignature, ::onc::cellular_apn::kPassword},
532 {NULL}};
534 } // namespace
536 bool FieldIsCredential(const OncValueSignature& signature,
537 const std::string& onc_field_name) {
538 for (const CredentialEntry* entry = credentials;
539 entry->value_signature != NULL; ++entry) {
540 if (&signature == entry->value_signature &&
541 onc_field_name == entry->field_name) {
542 return true;
545 return false;
548 } // namespace onc
549 } // namespace chromeos