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_utils.h" | 5 #include "chromeos/network/onc/onc_utils.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 343 |
344 return certs_by_guid; | 344 return certs_by_guid; |
345 } | 345 } |
346 | 346 |
347 } // namespace | 347 } // namespace |
348 | 348 |
349 bool ParseAndValidateOncForImport(const std::string& onc_blob, | 349 bool ParseAndValidateOncForImport(const std::string& onc_blob, |
350 ONCSource onc_source, | 350 ONCSource onc_source, |
351 const std::string& passphrase, | 351 const std::string& passphrase, |
352 base::ListValue* network_configs, | 352 base::ListValue* network_configs, |
| 353 base::DictionaryValue* global_network_config, |
353 base::ListValue* certificates) { | 354 base::ListValue* certificates) { |
| 355 network_configs->Clear(); |
| 356 global_network_config->Clear(); |
354 certificates->Clear(); | 357 certificates->Clear(); |
355 network_configs->Clear(); | |
356 if (onc_blob.empty()) | 358 if (onc_blob.empty()) |
357 return true; | 359 return true; |
358 | 360 |
359 scoped_ptr<base::DictionaryValue> toplevel_onc = | 361 scoped_ptr<base::DictionaryValue> toplevel_onc = |
360 ReadDictionaryFromJson(onc_blob); | 362 ReadDictionaryFromJson(onc_blob); |
361 if (toplevel_onc.get() == NULL) { | 363 if (toplevel_onc.get() == NULL) { |
362 LOG(ERROR) << "ONC loaded from " << GetSourceAsString(onc_source) | 364 LOG(ERROR) << "ONC loaded from " << GetSourceAsString(onc_source) |
363 << " is not a valid JSON dictionary."; | 365 << " is not a valid JSON dictionary."; |
364 return false; | 366 return false; |
365 } | 367 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 validated_networks)) { | 428 validated_networks)) { |
427 LOG(ERROR) << "Some certificate references in the ONC policy for source " | 429 LOG(ERROR) << "Some certificate references in the ONC policy for source " |
428 << GetSourceAsString(onc_source) << " could not be resolved."; | 430 << GetSourceAsString(onc_source) << " could not be resolved."; |
429 success = false; | 431 success = false; |
430 } | 432 } |
431 | 433 |
432 ResolveServerCertRefsInNetworks(server_and_ca_certs, validated_networks); | 434 ResolveServerCertRefsInNetworks(server_and_ca_certs, validated_networks); |
433 network_configs->Swap(validated_networks); | 435 network_configs->Swap(validated_networks); |
434 } | 436 } |
435 | 437 |
| 438 base::DictionaryValue* validated_global_config = NULL; |
| 439 if (toplevel_onc->GetDictionaryWithoutPathExpansion( |
| 440 toplevel_config::kGlobalNetworkConfiguration, |
| 441 &validated_global_config)) { |
| 442 global_network_config->Swap(validated_global_config); |
| 443 } |
| 444 |
436 return success; | 445 return success; |
437 } | 446 } |
438 | 447 |
439 scoped_refptr<net::X509Certificate> DecodePEMCertificate( | 448 scoped_refptr<net::X509Certificate> DecodePEMCertificate( |
440 const std::string& pem_encoded) { | 449 const std::string& pem_encoded) { |
441 std::string decoded = DecodePEM(pem_encoded); | 450 std::string decoded = DecodePEM(pem_encoded); |
442 scoped_refptr<net::X509Certificate> cert = | 451 scoped_refptr<net::X509Certificate> cert = |
443 net::X509Certificate::CreateFromBytes(decoded.data(), decoded.size()); | 452 net::X509Certificate::CreateFromBytes(decoded.data(), decoded.size()); |
444 LOG_IF(ERROR, !cert.get()) << "Couldn't create certificate from X509 data: " | 453 LOG_IF(ERROR, !cert.get()) << "Couldn't create certificate from X509 data: " |
445 << decoded; | 454 << decoded; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 | 613 |
605 bool ResolveServerCertRefsInNetwork(const CertPEMsByGUIDMap& certs_by_guid, | 614 bool ResolveServerCertRefsInNetwork(const CertPEMsByGUIDMap& certs_by_guid, |
606 base::DictionaryValue* network_config) { | 615 base::DictionaryValue* network_config) { |
607 return ResolveServerCertRefsInObject(certs_by_guid, | 616 return ResolveServerCertRefsInObject(certs_by_guid, |
608 kNetworkConfigurationSignature, | 617 kNetworkConfigurationSignature, |
609 network_config); | 618 network_config); |
610 } | 619 } |
611 | 620 |
612 } // namespace onc | 621 } // namespace onc |
613 } // namespace chromeos | 622 } // namespace chromeos |
OLD | NEW |