OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/onc/onc_signature.h" | 5 #include "chromeos/network/onc/onc_signature.h" |
6 | 6 |
7 #include "components/onc/onc_constants.h" | 7 #include "components/onc/onc_constants.h" |
8 #include "third_party/cros_system_api/dbus/service_constants.h" | 8 #include "third_party/cros_system_api/dbus/service_constants.h" |
9 | 9 |
10 using base::Value; | 10 using base::Value; |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 namespace onc { | 13 namespace onc { |
14 namespace { | 14 namespace { |
15 | 15 |
16 const OncValueSignature kBoolSignature = { | 16 const OncValueSignature kBoolSignature = { |
17 Value::TYPE_BOOLEAN, NULL | 17 base::Value::TYPE_BOOLEAN, NULL |
18 }; | 18 }; |
19 const OncValueSignature kStringSignature = { | 19 const OncValueSignature kStringSignature = { |
20 Value::TYPE_STRING, NULL | 20 base::Value::TYPE_STRING, NULL |
21 }; | 21 }; |
22 const OncValueSignature kIntegerSignature = { | 22 const OncValueSignature kIntegerSignature = { |
23 Value::TYPE_INTEGER, NULL | 23 base::Value::TYPE_INTEGER, NULL |
24 }; | 24 }; |
25 const OncValueSignature kStringListSignature = { | 25 const OncValueSignature kStringListSignature = { |
26 Value::TYPE_LIST, NULL, &kStringSignature | 26 base::Value::TYPE_LIST, NULL, &kStringSignature |
27 }; | 27 }; |
28 const OncValueSignature kIntegerListSignature = { | 28 const OncValueSignature kIntegerListSignature = { |
29 Value::TYPE_LIST, NULL, &kIntegerSignature | 29 base::Value::TYPE_LIST, NULL, &kIntegerSignature |
30 }; | 30 }; |
31 const OncValueSignature kIPConfigListSignature = { | 31 const OncValueSignature kIPConfigListSignature = { |
32 Value::TYPE_LIST, NULL, &kIPConfigSignature | 32 base::Value::TYPE_LIST, NULL, &kIPConfigSignature |
33 }; | 33 }; |
34 const OncValueSignature kCellularApnListSignature = { | 34 const OncValueSignature kCellularApnListSignature = { |
35 Value::TYPE_LIST, NULL, &kCellularApnSignature | 35 base::Value::TYPE_LIST, NULL, &kCellularApnSignature |
36 }; | 36 }; |
37 | 37 |
38 const OncFieldSignature issuer_subject_pattern_fields[] = { | 38 const OncFieldSignature issuer_subject_pattern_fields[] = { |
39 { ::onc::certificate::kCommonName, &kStringSignature}, | 39 { ::onc::certificate::kCommonName, &kStringSignature}, |
40 { ::onc::certificate::kLocality, &kStringSignature}, | 40 { ::onc::certificate::kLocality, &kStringSignature}, |
41 { ::onc::certificate::kOrganization, &kStringSignature}, | 41 { ::onc::certificate::kOrganization, &kStringSignature}, |
42 { ::onc::certificate::kOrganizationalUnit, &kStringSignature}, | 42 { ::onc::certificate::kOrganizationalUnit, &kStringSignature}, |
43 {NULL}}; | 43 {NULL}}; |
44 | 44 |
45 const OncFieldSignature certificate_pattern_fields[] = { | 45 const OncFieldSignature certificate_pattern_fields[] = { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 { ::onc::encrypted::kHMAC, &kStringSignature}, | 303 { ::onc::encrypted::kHMAC, &kStringSignature}, |
304 { ::onc::encrypted::kHMACMethod, &kStringSignature}, | 304 { ::onc::encrypted::kHMACMethod, &kStringSignature}, |
305 { ::onc::encrypted::kIV, &kStringSignature}, | 305 { ::onc::encrypted::kIV, &kStringSignature}, |
306 { ::onc::encrypted::kIterations, &kIntegerSignature}, | 306 { ::onc::encrypted::kIterations, &kIntegerSignature}, |
307 { ::onc::encrypted::kSalt, &kStringSignature}, | 307 { ::onc::encrypted::kSalt, &kStringSignature}, |
308 { ::onc::encrypted::kStretch, &kStringSignature}, {NULL}}; | 308 { ::onc::encrypted::kStretch, &kStringSignature}, {NULL}}; |
309 | 309 |
310 } // namespace | 310 } // namespace |
311 | 311 |
312 const OncValueSignature kRecommendedSignature = { | 312 const OncValueSignature kRecommendedSignature = { |
313 Value::TYPE_LIST, NULL, &kStringSignature | 313 base::Value::TYPE_LIST, NULL, &kStringSignature |
314 }; | 314 }; |
315 const OncValueSignature kEAPSignature = { | 315 const OncValueSignature kEAPSignature = { |
316 Value::TYPE_DICTIONARY, eap_fields, NULL | 316 base::Value::TYPE_DICTIONARY, eap_fields, NULL |
317 }; | 317 }; |
318 const OncValueSignature kIssuerSubjectPatternSignature = { | 318 const OncValueSignature kIssuerSubjectPatternSignature = { |
319 Value::TYPE_DICTIONARY, issuer_subject_pattern_fields, NULL | 319 base::Value::TYPE_DICTIONARY, issuer_subject_pattern_fields, NULL |
320 }; | 320 }; |
321 const OncValueSignature kCertificatePatternSignature = { | 321 const OncValueSignature kCertificatePatternSignature = { |
322 Value::TYPE_DICTIONARY, certificate_pattern_fields, NULL | 322 base::Value::TYPE_DICTIONARY, certificate_pattern_fields, NULL |
323 }; | 323 }; |
324 const OncValueSignature kIPsecSignature = { | 324 const OncValueSignature kIPsecSignature = { |
325 Value::TYPE_DICTIONARY, ipsec_fields, NULL | 325 base::Value::TYPE_DICTIONARY, ipsec_fields, NULL |
326 }; | 326 }; |
327 const OncValueSignature kL2TPSignature = { | 327 const OncValueSignature kL2TPSignature = { |
328 Value::TYPE_DICTIONARY, l2tp_fields, NULL | 328 base::Value::TYPE_DICTIONARY, l2tp_fields, NULL |
329 }; | 329 }; |
330 const OncValueSignature kOpenVPNSignature = { | 330 const OncValueSignature kOpenVPNSignature = { |
331 Value::TYPE_DICTIONARY, openvpn_fields, NULL | 331 base::Value::TYPE_DICTIONARY, openvpn_fields, NULL |
332 }; | 332 }; |
333 const OncValueSignature kVerifyX509Signature = { | 333 const OncValueSignature kVerifyX509Signature = { |
334 Value::TYPE_DICTIONARY, verify_x509_fields, NULL | 334 base::Value::TYPE_DICTIONARY, verify_x509_fields, NULL |
335 }; | 335 }; |
336 const OncValueSignature kVPNSignature = { | 336 const OncValueSignature kVPNSignature = { |
337 Value::TYPE_DICTIONARY, vpn_fields, NULL | 337 base::Value::TYPE_DICTIONARY, vpn_fields, NULL |
338 }; | 338 }; |
339 const OncValueSignature kEthernetSignature = { | 339 const OncValueSignature kEthernetSignature = { |
340 Value::TYPE_DICTIONARY, ethernet_fields, NULL | 340 base::Value::TYPE_DICTIONARY, ethernet_fields, NULL |
341 }; | 341 }; |
342 const OncValueSignature kIPConfigSignature = { | 342 const OncValueSignature kIPConfigSignature = { |
343 Value::TYPE_DICTIONARY, ipconfig_fields, NULL | 343 base::Value::TYPE_DICTIONARY, ipconfig_fields, NULL |
344 }; | 344 }; |
345 const OncValueSignature kProxyLocationSignature = { | 345 const OncValueSignature kProxyLocationSignature = { |
346 Value::TYPE_DICTIONARY, proxy_location_fields, NULL | 346 base::Value::TYPE_DICTIONARY, proxy_location_fields, NULL |
347 }; | 347 }; |
348 const OncValueSignature kProxyManualSignature = { | 348 const OncValueSignature kProxyManualSignature = { |
349 Value::TYPE_DICTIONARY, proxy_manual_fields, NULL | 349 base::Value::TYPE_DICTIONARY, proxy_manual_fields, NULL |
350 }; | 350 }; |
351 const OncValueSignature kProxySettingsSignature = { | 351 const OncValueSignature kProxySettingsSignature = { |
352 Value::TYPE_DICTIONARY, proxy_settings_fields, NULL | 352 base::Value::TYPE_DICTIONARY, proxy_settings_fields, NULL |
353 }; | 353 }; |
354 const OncValueSignature kWiFiSignature = { | 354 const OncValueSignature kWiFiSignature = { |
355 Value::TYPE_DICTIONARY, wifi_fields, NULL | 355 base::Value::TYPE_DICTIONARY, wifi_fields, NULL |
356 }; | 356 }; |
357 const OncValueSignature kCertificateSignature = { | 357 const OncValueSignature kCertificateSignature = { |
358 Value::TYPE_DICTIONARY, certificate_fields, NULL | 358 base::Value::TYPE_DICTIONARY, certificate_fields, NULL |
359 }; | 359 }; |
360 const OncValueSignature kNetworkConfigurationSignature = { | 360 const OncValueSignature kNetworkConfigurationSignature = { |
361 Value::TYPE_DICTIONARY, network_configuration_fields, NULL | 361 base::Value::TYPE_DICTIONARY, network_configuration_fields, NULL |
362 }; | 362 }; |
363 const OncValueSignature kGlobalNetworkConfigurationSignature = { | 363 const OncValueSignature kGlobalNetworkConfigurationSignature = { |
364 Value::TYPE_DICTIONARY, global_network_configuration_fields, NULL | 364 base::Value::TYPE_DICTIONARY, global_network_configuration_fields, NULL |
365 }; | 365 }; |
366 const OncValueSignature kCertificateListSignature = { | 366 const OncValueSignature kCertificateListSignature = { |
367 Value::TYPE_LIST, NULL, &kCertificateSignature | 367 base::Value::TYPE_LIST, NULL, &kCertificateSignature |
368 }; | 368 }; |
369 const OncValueSignature kNetworkConfigurationListSignature = { | 369 const OncValueSignature kNetworkConfigurationListSignature = { |
370 Value::TYPE_LIST, NULL, &kNetworkConfigurationSignature | 370 base::Value::TYPE_LIST, NULL, &kNetworkConfigurationSignature |
371 }; | 371 }; |
372 const OncValueSignature kToplevelConfigurationSignature = { | 372 const OncValueSignature kToplevelConfigurationSignature = { |
373 Value::TYPE_DICTIONARY, toplevel_configuration_fields, NULL | 373 base::Value::TYPE_DICTIONARY, toplevel_configuration_fields, NULL |
374 }; | 374 }; |
375 | 375 |
376 // Derived "ONC with State" signatures. | 376 // Derived "ONC with State" signatures. |
377 const OncValueSignature kNetworkWithStateSignature = { | 377 const OncValueSignature kNetworkWithStateSignature = { |
378 Value::TYPE_DICTIONARY, network_with_state_fields, NULL, | 378 base::Value::TYPE_DICTIONARY, network_with_state_fields, NULL, |
379 &kNetworkConfigurationSignature | 379 &kNetworkConfigurationSignature |
380 }; | 380 }; |
381 const OncValueSignature kWiFiWithStateSignature = { | 381 const OncValueSignature kWiFiWithStateSignature = { |
382 Value::TYPE_DICTIONARY, wifi_with_state_fields, NULL, &kWiFiSignature | 382 base::Value::TYPE_DICTIONARY, wifi_with_state_fields, NULL, &kWiFiSignature |
383 }; | 383 }; |
384 const OncValueSignature kCellularSignature = { | 384 const OncValueSignature kCellularSignature = { |
385 Value::TYPE_DICTIONARY, cellular_fields, NULL | 385 base::Value::TYPE_DICTIONARY, cellular_fields, NULL |
386 }; | 386 }; |
387 const OncValueSignature kCellularWithStateSignature = { | 387 const OncValueSignature kCellularWithStateSignature = { |
388 Value::TYPE_DICTIONARY, cellular_with_state_fields, NULL, &kCellularSignature | 388 base::Value::TYPE_DICTIONARY, cellular_with_state_fields, NULL, |
| 389 &kCellularSignature |
389 }; | 390 }; |
390 const OncValueSignature kCellularProviderSignature = { | 391 const OncValueSignature kCellularProviderSignature = { |
391 Value::TYPE_DICTIONARY, cellular_provider_fields, NULL | 392 base::Value::TYPE_DICTIONARY, cellular_provider_fields, NULL |
392 }; | 393 }; |
393 const OncValueSignature kCellularApnSignature = { | 394 const OncValueSignature kCellularApnSignature = { |
394 Value::TYPE_DICTIONARY, cellular_apn_fields, NULL | 395 base::Value::TYPE_DICTIONARY, cellular_apn_fields, NULL |
395 }; | 396 }; |
396 | 397 |
397 const OncFieldSignature* GetFieldSignature(const OncValueSignature& signature, | 398 const OncFieldSignature* GetFieldSignature(const OncValueSignature& signature, |
398 const std::string& onc_field_name) { | 399 const std::string& onc_field_name) { |
399 if (!signature.fields) | 400 if (!signature.fields) |
400 return NULL; | 401 return NULL; |
401 for (const OncFieldSignature* field_signature = signature.fields; | 402 for (const OncFieldSignature* field_signature = signature.fields; |
402 field_signature->onc_field_name != NULL; ++field_signature) { | 403 field_signature->onc_field_name != NULL; ++field_signature) { |
403 if (onc_field_name == field_signature->onc_field_name) | 404 if (onc_field_name == field_signature->onc_field_name) |
404 return field_signature; | 405 return field_signature; |
(...skipping 29 matching lines...) Expand all Loading... |
434 if (&signature == entry->value_signature && | 435 if (&signature == entry->value_signature && |
435 onc_field_name == entry->field_name) { | 436 onc_field_name == entry->field_name) { |
436 return true; | 437 return true; |
437 } | 438 } |
438 } | 439 } |
439 return false; | 440 return false; |
440 } | 441 } |
441 | 442 |
442 } // namespace onc | 443 } // namespace onc |
443 } // namespace chromeos | 444 } // namespace chromeos |
OLD | NEW |