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"
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
,
23 const OncValueSignature kIntegerListSignature
= {base::Value::TYPE_LIST
,
26 const OncValueSignature kIPConfigListSignature
= {base::Value::TYPE_LIST
,
29 const OncValueSignature kCellularApnListSignature
= {base::Value::TYPE_LIST
,
31 &kCellularApnSignature
};
32 const OncValueSignature kCellularFoundNetworkListSignature
= {
33 base::Value::TYPE_LIST
,
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
},
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
},
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 {::onc::eap::kUseProactiveKeyCaching
, &kBoolSignature
},
73 const OncFieldSignature ipsec_fields
[] = {
74 {::onc::kRecommended
, &kRecommendedSignature
},
75 {::onc::ipsec::kAuthenticationType
, &kStringSignature
},
76 {::onc::client_cert::kClientCertPattern
, &kCertificatePatternSignature
},
77 {::onc::client_cert::kClientCertRef
, &kStringSignature
},
78 {::onc::client_cert::kClientCertType
, &kStringSignature
},
79 {::onc::ipsec::kGroup
, &kStringSignature
},
80 {::onc::ipsec::kIKEVersion
, &kIntegerSignature
},
81 {::onc::ipsec::kPSK
, &kStringSignature
},
82 {::onc::vpn::kSaveCredentials
, &kBoolSignature
},
83 // Used internally. Not officially supported.
84 {::onc::ipsec::kServerCAPEMs
, &kStringListSignature
},
85 {::onc::ipsec::kServerCARef
, &kStringSignature
},
86 {::onc::ipsec::kServerCARefs
, &kStringListSignature
},
87 {::onc::ipsec::kXAUTH
, &kXAUTHSignature
},
89 // { ipsec::kEAP, &kEAPSignature },
92 const OncFieldSignature xauth_fields
[] = {
93 {::onc::vpn::kPassword
, &kStringSignature
},
94 {::onc::vpn::kUsername
, &kStringSignature
},
97 const OncFieldSignature l2tp_fields
[] = {
98 {::onc::kRecommended
, &kRecommendedSignature
},
99 {::onc::l2tp::kPassword
, &kStringSignature
},
100 {::onc::l2tp::kSaveCredentials
, &kBoolSignature
},
101 {::onc::l2tp::kUsername
, &kStringSignature
},
102 {::onc::l2tp::kLcpEchoDisabled
, &kBoolSignature
},
105 const OncFieldSignature openvpn_fields
[] = {
106 {::onc::kRecommended
, &kRecommendedSignature
},
107 {::onc::openvpn::kAuth
, &kStringSignature
},
108 {::onc::openvpn::kAuthNoCache
, &kBoolSignature
},
109 {::onc::openvpn::kAuthRetry
, &kStringSignature
},
110 {::onc::openvpn::kCipher
, &kStringSignature
},
111 {::onc::client_cert::kClientCertPattern
, &kCertificatePatternSignature
},
112 {::onc::client_cert::kClientCertRef
, &kStringSignature
},
113 {::onc::client_cert::kClientCertType
, &kStringSignature
},
114 {::onc::openvpn::kCompLZO
, &kStringSignature
},
115 {::onc::openvpn::kCompNoAdapt
, &kBoolSignature
},
116 {::onc::openvpn::kIgnoreDefaultRoute
, &kBoolSignature
},
117 {::onc::openvpn::kKeyDirection
, &kStringSignature
},
118 {::onc::openvpn::kNsCertType
, &kStringSignature
},
119 {::onc::openvpn::kOTP
, &kStringSignature
},
120 {::onc::openvpn::kPassword
, &kStringSignature
},
121 {::onc::openvpn::kPort
, &kIntegerSignature
},
122 {::onc::openvpn::kProto
, &kStringSignature
},
123 {::onc::openvpn::kPushPeerInfo
, &kBoolSignature
},
124 {::onc::openvpn::kRemoteCertEKU
, &kStringSignature
},
125 {::onc::openvpn::kRemoteCertKU
, &kStringListSignature
},
126 {::onc::openvpn::kRemoteCertTLS
, &kStringSignature
},
127 {::onc::openvpn::kRenegSec
, &kIntegerSignature
},
128 {::onc::vpn::kSaveCredentials
, &kBoolSignature
},
129 // Used internally. Not officially supported.
130 {::onc::openvpn::kServerCAPEMs
, &kStringListSignature
},
131 {::onc::openvpn::kServerCARef
, &kStringSignature
},
132 {::onc::openvpn::kServerCARefs
, &kStringListSignature
},
133 // Not supported, yet.
134 {::onc::openvpn::kServerCertPEM
, &kStringSignature
},
135 {::onc::openvpn::kServerCertRef
, &kStringSignature
},
136 {::onc::openvpn::kServerPollTimeout
, &kIntegerSignature
},
137 {::onc::openvpn::kShaper
, &kIntegerSignature
},
138 {::onc::openvpn::kStaticChallenge
, &kStringSignature
},
139 {::onc::openvpn::kTLSAuthContents
, &kStringSignature
},
140 {::onc::openvpn::kTLSRemote
, &kStringSignature
},
141 {::onc::openvpn::kUserAuthenticationType
, &kStringSignature
},
142 {::onc::vpn::kUsername
, &kStringSignature
},
143 // Not supported, yet.
144 {::onc::openvpn::kVerb
, &kStringSignature
},
145 {::onc::openvpn::kVerifyHash
, &kStringSignature
},
146 {::onc::openvpn::kVerifyX509
, &kVerifyX509Signature
},
149 const OncFieldSignature third_party_vpn_fields
[] = {
150 {::onc::kRecommended
, &kRecommendedSignature
},
151 {::onc::third_party_vpn::kExtensionID
, &kStringSignature
},
154 const OncFieldSignature verify_x509_fields
[] = {
155 {::onc::verify_x509::kName
, &kStringSignature
},
156 {::onc::verify_x509::kType
, &kStringSignature
},
159 const OncFieldSignature vpn_fields
[] = {
160 {::onc::kRecommended
, &kRecommendedSignature
},
161 {::onc::vpn::kAutoConnect
, &kBoolSignature
},
162 {::onc::vpn::kHost
, &kStringSignature
},
163 {::onc::vpn::kIPsec
, &kIPsecSignature
},
164 {::onc::vpn::kL2TP
, &kL2TPSignature
},
165 {::onc::vpn::kOpenVPN
, &kOpenVPNSignature
},
166 {::onc::vpn::kThirdPartyVpn
, &kThirdPartyVPNSignature
},
167 {::onc::vpn::kType
, &kStringSignature
},
170 const OncFieldSignature ethernet_fields
[] = {
171 {::onc::kRecommended
, &kRecommendedSignature
},
172 {::onc::ethernet::kAuthentication
, &kStringSignature
},
173 {::onc::ethernet::kEAP
, &kEAPSignature
},
176 const OncFieldSignature ipconfig_fields
[] = {
177 {::onc::ipconfig::kGateway
, &kStringSignature
},
178 {::onc::ipconfig::kIPAddress
, &kStringSignature
},
179 {::onc::ipconfig::kNameServers
, &kStringListSignature
},
180 {::onc::ipconfig::kRoutingPrefix
, &kIntegerSignature
},
181 {::onc::ipconfig::kSearchDomains
, &kStringListSignature
},
182 {::onc::ipconfig::kType
, &kStringSignature
},
183 {::onc::ipconfig::kWebProxyAutoDiscoveryUrl
, &kStringSignature
},
186 const OncFieldSignature proxy_location_fields
[] = {
187 {::onc::proxy::kHost
, &kStringSignature
},
188 {::onc::proxy::kPort
, &kIntegerSignature
},
191 const OncFieldSignature proxy_manual_fields
[] = {
192 {::onc::proxy::kFtp
, &kProxyLocationSignature
},
193 {::onc::proxy::kHttp
, &kProxyLocationSignature
},
194 {::onc::proxy::kHttps
, &kProxyLocationSignature
},
195 {::onc::proxy::kSocks
, &kProxyLocationSignature
},
198 const OncFieldSignature proxy_settings_fields
[] = {
199 {::onc::kRecommended
, &kRecommendedSignature
},
200 {::onc::proxy::kExcludeDomains
, &kStringListSignature
},
201 {::onc::proxy::kManual
, &kProxyManualSignature
},
202 {::onc::proxy::kPAC
, &kStringSignature
},
203 {::onc::proxy::kType
, &kStringSignature
},
206 const OncFieldSignature wifi_fields
[] = {
207 {::onc::kRecommended
, &kRecommendedSignature
},
208 {::onc::wifi::kAllowGatewayARPPolling
, &kBoolSignature
},
209 {::onc::wifi::kAutoConnect
, &kBoolSignature
},
210 {::onc::wifi::kEAP
, &kEAPSignature
},
211 {::onc::wifi::kHexSSID
, &kStringSignature
},
212 {::onc::wifi::kHiddenSSID
, &kBoolSignature
},
213 {::onc::wifi::kPassphrase
, &kStringSignature
},
214 {::onc::wifi::kRoamThreshold
, &kIntegerSignature
},
215 {::onc::wifi::kSSID
, &kStringSignature
},
216 {::onc::wifi::kSecurity
, &kStringSignature
},
219 const OncFieldSignature wifi_with_state_fields
[] = {
220 {::onc::wifi::kBSSID
, &kStringSignature
},
221 {::onc::wifi::kFrequency
, &kIntegerSignature
},
222 {::onc::wifi::kFrequencyList
, &kIntegerListSignature
},
223 {::onc::wifi::kSignalStrength
, &kIntegerSignature
},
226 const OncFieldSignature wimax_fields
[] = {
227 {::onc::kRecommended
, &kRecommendedSignature
},
228 {::onc::wimax::kAutoConnect
, &kBoolSignature
},
229 {::onc::wimax::kEAP
, &kEAPSignature
},
232 const OncFieldSignature wimax_with_state_fields
[] = {
233 {::onc::wimax::kSignalStrength
, &kIntegerSignature
},
236 const OncFieldSignature cellular_payment_portal_fields
[] = {
237 {::onc::cellular_payment_portal::kMethod
, &kStringSignature
},
238 {::onc::cellular_payment_portal::kPostData
, &kStringSignature
},
239 {::onc::cellular_payment_portal::kUrl
, &kStringSignature
},
242 const OncFieldSignature cellular_provider_fields
[] = {
243 {::onc::cellular_provider::kCode
, &kStringSignature
},
244 {::onc::cellular_provider::kCountry
, &kStringSignature
},
245 {::onc::cellular_provider::kName
, &kStringSignature
},
248 const OncFieldSignature cellular_apn_fields
[] = {
249 {::onc::cellular_apn::kAccessPointName
, &kStringSignature
},
250 {::onc::cellular_apn::kName
, &kStringSignature
},
251 {::onc::cellular_apn::kUsername
, &kStringSignature
},
252 {::onc::cellular_apn::kPassword
, &kStringSignature
},
253 {::onc::cellular_apn::kLocalizedName
, &kStringSignature
},
254 {::onc::cellular_apn::kLanguage
, &kStringSignature
},
257 const OncFieldSignature cellular_found_network_fields
[] = {
258 {::onc::cellular_found_network::kStatus
, &kStringSignature
},
259 {::onc::cellular_found_network::kNetworkId
, &kStringSignature
},
260 {::onc::cellular_found_network::kShortName
, &kStringSignature
},
261 {::onc::cellular_found_network::kLongName
, &kStringSignature
},
262 {::onc::cellular_found_network::kTechnology
, &kStringSignature
},
265 const OncFieldSignature sim_lock_status_fields
[] = {
266 {::onc::sim_lock_status::kLockEnabled
, &kBoolSignature
},
267 {::onc::sim_lock_status::kLockType
, &kStringSignature
},
268 {::onc::sim_lock_status::kRetriesLeft
, &kDoubleSignature
},
271 const OncFieldSignature cellular_fields
[] = {
272 {::onc::kRecommended
, &kRecommendedSignature
},
273 {::onc::cellular::kAPN
, &kCellularApnSignature
},
274 {::onc::cellular::kAPNList
, &kCellularApnListSignature
},
275 {::onc::cellular::kCarrier
, &kStringSignature
},
276 {::onc::cellular::kAutoConnect
, &kBoolSignature
},
279 const OncFieldSignature cellular_with_state_fields
[] = {
280 {::onc::cellular::kActivationType
, &kStringSignature
},
281 {::onc::cellular::kActivationState
, &kStringSignature
},
282 {::onc::cellular::kAllowRoaming
, &kBoolSignature
},
283 {::onc::cellular::kESN
, &kStringSignature
},
284 {::onc::cellular::kFamily
, &kStringSignature
},
285 {::onc::cellular::kFirmwareRevision
, &kStringSignature
},
286 {::onc::cellular::kFoundNetworks
, &kCellularFoundNetworkListSignature
},
287 {::onc::cellular::kHardwareRevision
, &kStringSignature
},
288 {::onc::cellular::kHomeProvider
, &kCellularProviderSignature
},
289 {::onc::cellular::kICCID
, &kStringSignature
},
290 {::onc::cellular::kIMEI
, &kStringSignature
},
291 {::onc::cellular::kIMSI
, &kStringSignature
},
292 {::onc::cellular::kLastGoodAPN
, &kCellularApnSignature
},
293 {::onc::cellular::kManufacturer
, &kStringSignature
},
294 {::onc::cellular::kMDN
, &kStringSignature
},
295 {::onc::cellular::kMEID
, &kStringSignature
},
296 {::onc::cellular::kMIN
, &kStringSignature
},
297 {::onc::cellular::kModelID
, &kStringSignature
},
298 {::onc::cellular::kNetworkTechnology
, &kStringSignature
},
299 {::onc::cellular::kPaymentPortal
, &kCellularPaymentPortalSignature
},
300 {::onc::cellular::kPRLVersion
, &kIntegerSignature
},
301 {::onc::cellular::kRoamingState
, &kStringSignature
},
302 {::onc::cellular::kServingOperator
, &kCellularProviderSignature
},
303 {::onc::cellular::kSignalStrength
, &kIntegerSignature
},
304 {::onc::cellular::kSIMLockStatus
, &kSIMLockStatusSignature
},
305 {::onc::cellular::kSIMPresent
, &kBoolSignature
},
306 {::onc::cellular::kSupportNetworkScan
, &kBoolSignature
},
307 {::onc::cellular::kSupportedCarriers
, &kStringListSignature
},
310 const OncFieldSignature network_configuration_fields
[] = {
311 {::onc::network_config::kCellular
, &kCellularSignature
},
312 {::onc::network_config::kEthernet
, &kEthernetSignature
},
313 {::onc::network_config::kGUID
, &kStringSignature
},
314 {::onc::network_config::kIPAddressConfigType
, &kStringSignature
},
315 {::onc::network_config::kName
, &kStringSignature
},
316 {::onc::network_config::kNameServersConfigType
, &kStringSignature
},
317 {::onc::network_config::kPriority
, &kIntegerSignature
},
318 {::onc::network_config::kProxySettings
, &kProxySettingsSignature
},
319 {::onc::kRecommended
, &kRecommendedSignature
},
320 {::onc::kRemove
, &kBoolSignature
},
321 {::onc::network_config::kStaticIPConfig
, &kStaticIPConfigSignature
},
322 {::onc::network_config::kType
, &kStringSignature
},
323 {::onc::network_config::kVPN
, &kVPNSignature
},
324 {::onc::network_config::kWiFi
, &kWiFiSignature
},
325 {::onc::network_config::kWimax
, &kWiMAXSignature
},
328 const OncFieldSignature network_with_state_fields
[] = {
329 {::onc::network_config::kCellular
, &kCellularWithStateSignature
},
330 {::onc::network_config::kConnectionState
, &kStringSignature
},
331 {::onc::network_config::kConnectable
, &kBoolSignature
},
332 {::onc::network_config::kErrorState
, &kStringSignature
},
333 {::onc::network_config::kIPConfigs
, &kIPConfigListSignature
},
334 {::onc::network_config::kMacAddress
, &kStringSignature
},
335 {::onc::network_config::kRestrictedConnectivity
, &kBoolSignature
},
336 {::onc::network_config::kSavedIPConfig
, &kSavedIPConfigSignature
},
337 {::onc::network_config::kSource
, &kStringSignature
},
338 {::onc::network_config::kWiFi
, &kWiFiWithStateSignature
},
339 {::onc::network_config::kWimax
, &kWiMAXWithStateSignature
},
342 const OncFieldSignature global_network_configuration_fields
[] = {
343 {::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect
,
347 const OncFieldSignature certificate_fields
[] = {
348 {::onc::certificate::kGUID
, &kStringSignature
},
349 {::onc::certificate::kPKCS12
, &kStringSignature
},
350 {::onc::kRemove
, &kBoolSignature
},
351 {::onc::certificate::kTrustBits
, &kStringListSignature
},
352 {::onc::certificate::kType
, &kStringSignature
},
353 {::onc::certificate::kX509
, &kStringSignature
},
356 const OncFieldSignature toplevel_configuration_fields
[] = {
357 {::onc::toplevel_config::kCertificates
, &kCertificateListSignature
},
358 {::onc::toplevel_config::kNetworkConfigurations
,
359 &kNetworkConfigurationListSignature
},
360 {::onc::toplevel_config::kGlobalNetworkConfiguration
,
361 &kGlobalNetworkConfigurationSignature
},
362 {::onc::toplevel_config::kType
, &kStringSignature
},
363 {::onc::encrypted::kCipher
, &kStringSignature
},
364 {::onc::encrypted::kCiphertext
, &kStringSignature
},
365 {::onc::encrypted::kHMAC
, &kStringSignature
},
366 {::onc::encrypted::kHMACMethod
, &kStringSignature
},
367 {::onc::encrypted::kIV
, &kStringSignature
},
368 {::onc::encrypted::kIterations
, &kIntegerSignature
},
369 {::onc::encrypted::kSalt
, &kStringSignature
},
370 {::onc::encrypted::kStretch
, &kStringSignature
},
375 const OncValueSignature kRecommendedSignature
= {base::Value::TYPE_LIST
,
378 const OncValueSignature kEAPSignature
= {base::Value::TYPE_DICTIONARY
,
381 const OncValueSignature kIssuerSubjectPatternSignature
= {
382 base::Value::TYPE_DICTIONARY
,
383 issuer_subject_pattern_fields
,
385 const OncValueSignature kCertificatePatternSignature
= {
386 base::Value::TYPE_DICTIONARY
,
387 certificate_pattern_fields
,
389 const OncValueSignature kIPsecSignature
= {base::Value::TYPE_DICTIONARY
,
392 const OncValueSignature kXAUTHSignature
= {base::Value::TYPE_DICTIONARY
,
395 const OncValueSignature kL2TPSignature
= {base::Value::TYPE_DICTIONARY
,
398 const OncValueSignature kOpenVPNSignature
= {base::Value::TYPE_DICTIONARY
,
401 const OncValueSignature kThirdPartyVPNSignature
= {base::Value::TYPE_DICTIONARY
,
402 third_party_vpn_fields
,
404 const OncValueSignature kVerifyX509Signature
= {base::Value::TYPE_DICTIONARY
,
407 const OncValueSignature kVPNSignature
= {base::Value::TYPE_DICTIONARY
,
410 const OncValueSignature kEthernetSignature
= {base::Value::TYPE_DICTIONARY
,
413 const OncValueSignature kIPConfigSignature
= {base::Value::TYPE_DICTIONARY
,
416 const OncValueSignature kSavedIPConfigSignature
= {base::Value::TYPE_DICTIONARY
,
419 const OncValueSignature kStaticIPConfigSignature
= {
420 base::Value::TYPE_DICTIONARY
,
423 const OncValueSignature kProxyLocationSignature
= {base::Value::TYPE_DICTIONARY
,
424 proxy_location_fields
,
426 const OncValueSignature kProxyManualSignature
= {base::Value::TYPE_DICTIONARY
,
429 const OncValueSignature kProxySettingsSignature
= {base::Value::TYPE_DICTIONARY
,
430 proxy_settings_fields
,
432 const OncValueSignature kWiFiSignature
= {base::Value::TYPE_DICTIONARY
,
435 const OncValueSignature kWiMAXSignature
= {base::Value::TYPE_DICTIONARY
,
438 const OncValueSignature kCertificateSignature
= {base::Value::TYPE_DICTIONARY
,
441 const OncValueSignature kNetworkConfigurationSignature
= {
442 base::Value::TYPE_DICTIONARY
,
443 network_configuration_fields
,
445 const OncValueSignature kGlobalNetworkConfigurationSignature
= {
446 base::Value::TYPE_DICTIONARY
,
447 global_network_configuration_fields
,
449 const OncValueSignature kCertificateListSignature
= {base::Value::TYPE_LIST
,
451 &kCertificateSignature
};
452 const OncValueSignature kNetworkConfigurationListSignature
= {
453 base::Value::TYPE_LIST
,
455 &kNetworkConfigurationSignature
};
456 const OncValueSignature kToplevelConfigurationSignature
= {
457 base::Value::TYPE_DICTIONARY
,
458 toplevel_configuration_fields
,
461 // Derived "ONC with State" signatures.
462 const OncValueSignature kNetworkWithStateSignature
= {
463 base::Value::TYPE_DICTIONARY
,
464 network_with_state_fields
,
466 &kNetworkConfigurationSignature
};
467 const OncValueSignature kWiFiWithStateSignature
= {base::Value::TYPE_DICTIONARY
,
468 wifi_with_state_fields
,
471 const OncValueSignature kWiMAXWithStateSignature
= {
472 base::Value::TYPE_DICTIONARY
,
473 wimax_with_state_fields
,
476 const OncValueSignature kCellularSignature
= {base::Value::TYPE_DICTIONARY
,
479 const OncValueSignature kCellularWithStateSignature
= {
480 base::Value::TYPE_DICTIONARY
,
481 cellular_with_state_fields
,
483 &kCellularSignature
};
484 const OncValueSignature kCellularPaymentPortalSignature
= {
485 base::Value::TYPE_DICTIONARY
,
486 cellular_payment_portal_fields
,
488 const OncValueSignature kCellularProviderSignature
= {
489 base::Value::TYPE_DICTIONARY
,
490 cellular_provider_fields
,
492 const OncValueSignature kCellularApnSignature
= {base::Value::TYPE_DICTIONARY
,
495 const OncValueSignature kCellularFoundNetworkSignature
= {
496 base::Value::TYPE_DICTIONARY
,
497 cellular_found_network_fields
,
499 const OncValueSignature kSIMLockStatusSignature
= {base::Value::TYPE_DICTIONARY
,
500 sim_lock_status_fields
,
503 const OncFieldSignature
* GetFieldSignature(const OncValueSignature
& signature
,
504 const std::string
& onc_field_name
) {
505 if (!signature
.fields
)
507 for (const OncFieldSignature
* field_signature
= signature
.fields
;
508 field_signature
->onc_field_name
!= NULL
; ++field_signature
) {
509 if (onc_field_name
== field_signature
->onc_field_name
)
510 return field_signature
;
512 if (signature
.base_signature
)
513 return GetFieldSignature(*signature
.base_signature
, onc_field_name
);
519 struct CredentialEntry
{
520 const OncValueSignature
* value_signature
;
521 const char* field_name
;
524 const CredentialEntry credentials
[] = {
525 {&kEAPSignature
, ::onc::eap::kPassword
},
526 {&kIPsecSignature
, ::onc::ipsec::kPSK
},
527 {&kXAUTHSignature
, ::onc::vpn::kPassword
},
528 {&kL2TPSignature
, ::onc::vpn::kPassword
},
529 {&kOpenVPNSignature
, ::onc::vpn::kPassword
},
530 {&kOpenVPNSignature
, ::onc::openvpn::kTLSAuthContents
},
531 {&kWiFiSignature
, ::onc::wifi::kPassphrase
},
532 {&kCellularApnSignature
, ::onc::cellular_apn::kPassword
},
537 bool FieldIsCredential(const OncValueSignature
& signature
,
538 const std::string
& onc_field_name
) {
539 for (const CredentialEntry
* entry
= credentials
;
540 entry
->value_signature
!= NULL
; ++entry
) {
541 if (&signature
== entry
->value_signature
&&
542 onc_field_name
== entry
->field_name
) {
550 } // namespace chromeos