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
},
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
},
88 // { ipsec::kEAP, &kEAPSignature },
91 const OncFieldSignature xauth_fields
[] = {
92 {::onc::vpn::kPassword
, &kStringSignature
},
93 {::onc::vpn::kUsername
, &kStringSignature
},
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
},
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
},
148 const OncFieldSignature third_party_vpn_fields
[] = {
149 {::onc::kRecommended
, &kRecommendedSignature
},
150 {::onc::third_party_vpn::kExtensionID
, &kStringSignature
},
153 const OncFieldSignature verify_x509_fields
[] = {
154 {::onc::verify_x509::kName
, &kStringSignature
},
155 {::onc::verify_x509::kType
, &kStringSignature
},
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
},
169 const OncFieldSignature ethernet_fields
[] = {
170 {::onc::kRecommended
, &kRecommendedSignature
},
171 {::onc::ethernet::kAuthentication
, &kStringSignature
},
172 {::onc::ethernet::kEAP
, &kEAPSignature
},
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
},
185 const OncFieldSignature proxy_location_fields
[] = {
186 {::onc::proxy::kHost
, &kStringSignature
},
187 {::onc::proxy::kPort
, &kIntegerSignature
},
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
},
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
},
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
},
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
},
224 const OncFieldSignature wimax_fields
[] = {
225 {::onc::kRecommended
, &kRecommendedSignature
},
226 {::onc::wimax::kAutoConnect
, &kBoolSignature
},
227 {::onc::wimax::kEAP
, &kEAPSignature
},
230 const OncFieldSignature wimax_with_state_fields
[] = {
231 {::onc::wimax::kSignalStrength
, &kIntegerSignature
},
234 const OncFieldSignature cellular_provider_fields
[] = {
235 {::onc::cellular_provider::kCode
, &kStringSignature
},
236 {::onc::cellular_provider::kCountry
, &kStringSignature
},
237 {::onc::cellular_provider::kName
, &kStringSignature
},
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
},
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
},
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
},
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
},
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
},
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
},
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
},
333 const OncFieldSignature global_network_configuration_fields
[] = {
334 {::onc::global_network_config::kAllowOnlyPolicyNetworksToAutoconnect
,
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
},
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
},
366 const OncValueSignature kRecommendedSignature
= {base::Value::TYPE_LIST
,
369 const OncValueSignature kEAPSignature
= {base::Value::TYPE_DICTIONARY
,
372 const OncValueSignature kIssuerSubjectPatternSignature
= {
373 base::Value::TYPE_DICTIONARY
,
374 issuer_subject_pattern_fields
,
376 const OncValueSignature kCertificatePatternSignature
= {
377 base::Value::TYPE_DICTIONARY
,
378 certificate_pattern_fields
,
380 const OncValueSignature kIPsecSignature
= {base::Value::TYPE_DICTIONARY
,
383 const OncValueSignature kXAUTHSignature
= {base::Value::TYPE_DICTIONARY
,
386 const OncValueSignature kL2TPSignature
= {base::Value::TYPE_DICTIONARY
,
389 const OncValueSignature kOpenVPNSignature
= {base::Value::TYPE_DICTIONARY
,
392 const OncValueSignature kThirdPartyVPNSignature
= {base::Value::TYPE_DICTIONARY
,
393 third_party_vpn_fields
,
395 const OncValueSignature kVerifyX509Signature
= {base::Value::TYPE_DICTIONARY
,
398 const OncValueSignature kVPNSignature
= {base::Value::TYPE_DICTIONARY
,
401 const OncValueSignature kEthernetSignature
= {base::Value::TYPE_DICTIONARY
,
404 const OncValueSignature kIPConfigSignature
= {base::Value::TYPE_DICTIONARY
,
407 const OncValueSignature kSavedIPConfigSignature
= {base::Value::TYPE_DICTIONARY
,
410 const OncValueSignature kStaticIPConfigSignature
= {
411 base::Value::TYPE_DICTIONARY
,
414 const OncValueSignature kProxyLocationSignature
= {base::Value::TYPE_DICTIONARY
,
415 proxy_location_fields
,
417 const OncValueSignature kProxyManualSignature
= {base::Value::TYPE_DICTIONARY
,
420 const OncValueSignature kProxySettingsSignature
= {base::Value::TYPE_DICTIONARY
,
421 proxy_settings_fields
,
423 const OncValueSignature kWiFiSignature
= {base::Value::TYPE_DICTIONARY
,
426 const OncValueSignature kWiMAXSignature
= {base::Value::TYPE_DICTIONARY
,
429 const OncValueSignature kCertificateSignature
= {base::Value::TYPE_DICTIONARY
,
432 const OncValueSignature kNetworkConfigurationSignature
= {
433 base::Value::TYPE_DICTIONARY
,
434 network_configuration_fields
,
436 const OncValueSignature kGlobalNetworkConfigurationSignature
= {
437 base::Value::TYPE_DICTIONARY
,
438 global_network_configuration_fields
,
440 const OncValueSignature kCertificateListSignature
= {base::Value::TYPE_LIST
,
442 &kCertificateSignature
};
443 const OncValueSignature kNetworkConfigurationListSignature
= {
444 base::Value::TYPE_LIST
,
446 &kNetworkConfigurationSignature
};
447 const OncValueSignature kToplevelConfigurationSignature
= {
448 base::Value::TYPE_DICTIONARY
,
449 toplevel_configuration_fields
,
452 // Derived "ONC with State" signatures.
453 const OncValueSignature kNetworkWithStateSignature
= {
454 base::Value::TYPE_DICTIONARY
,
455 network_with_state_fields
,
457 &kNetworkConfigurationSignature
};
458 const OncValueSignature kWiFiWithStateSignature
= {base::Value::TYPE_DICTIONARY
,
459 wifi_with_state_fields
,
462 const OncValueSignature kWiMAXWithStateSignature
= {
463 base::Value::TYPE_DICTIONARY
,
464 wimax_with_state_fields
,
467 const OncValueSignature kCellularSignature
= {base::Value::TYPE_DICTIONARY
,
470 const OncValueSignature kCellularWithStateSignature
= {
471 base::Value::TYPE_DICTIONARY
,
472 cellular_with_state_fields
,
474 &kCellularSignature
};
475 const OncValueSignature kCellularProviderSignature
= {
476 base::Value::TYPE_DICTIONARY
,
477 cellular_provider_fields
,
479 const OncValueSignature kCellularApnSignature
= {base::Value::TYPE_DICTIONARY
,
482 const OncValueSignature kCellularFoundNetworkSignature
= {
483 base::Value::TYPE_DICTIONARY
,
484 cellular_found_network_fields
,
486 const OncValueSignature kSIMLockStatusSignature
= {base::Value::TYPE_DICTIONARY
,
487 sim_lock_status_fields
,
490 const OncFieldSignature
* GetFieldSignature(const OncValueSignature
& signature
,
491 const std::string
& onc_field_name
) {
492 if (!signature
.fields
)
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
);
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
},
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
) {
537 } // namespace chromeos