OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/cros/onc_network_parser.h" | 5 #include "chrome/browser/chromeos/cros/onc_network_parser.h" |
6 | 6 |
7 #include <pk11pub.h> | 7 #include <pk11pub.h> |
8 #include <keyhi.h> | 8 #include <keyhi.h> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/json/json_value_serializer.h" | 11 #include "base/json/json_value_serializer.h" |
12 #include "base/json/json_writer.h" // for debug output only. | 12 #include "base/json/json_writer.h" // for debug output only. |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/chromeos/cros/native_network_constants.h" | 15 #include "chrome/browser/chromeos/cros/native_network_constants.h" |
16 #include "chrome/browser/chromeos/cros/native_network_parser.h" | 16 #include "chrome/browser/chromeos/cros/native_network_parser.h" |
17 #include "chrome/browser/chromeos/cros/network_library.h" | 17 #include "chrome/browser/chromeos/cros/network_library.h" |
18 #include "chrome/common/net/x509_certificate_model.h" | 18 #include "chrome/common/net/x509_certificate_model.h" |
| 19 #include "grit/generated_resources.h" |
19 #include "net/base/cert_database.h" | 20 #include "net/base/cert_database.h" |
20 #include "net/base/crypto_module.h" | 21 #include "net/base/crypto_module.h" |
21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
22 #include "net/base/x509_certificate.h" | 23 #include "net/base/x509_certificate.h" |
23 #include "third_party/cros_system_api/dbus/service_constants.h" | 24 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 25 #include "ui/base/l10n/l10n_util.h" |
24 | 26 |
25 namespace chromeos { | 27 namespace chromeos { |
26 | 28 |
27 // Local constants. | 29 // Local constants. |
28 namespace { | 30 namespace { |
29 | 31 |
30 const base::Value::Type TYPE_BOOLEAN = base::Value::TYPE_BOOLEAN; | 32 const base::Value::Type TYPE_BOOLEAN = base::Value::TYPE_BOOLEAN; |
31 const base::Value::Type TYPE_DICTIONARY = base::Value::TYPE_DICTIONARY; | 33 const base::Value::Type TYPE_DICTIONARY = base::Value::TYPE_DICTIONARY; |
32 const base::Value::Type TYPE_INTEGER = base::Value::TYPE_INTEGER; | 34 const base::Value::Type TYPE_INTEGER = base::Value::TYPE_INTEGER; |
33 const base::Value::Type TYPE_LIST = base::Value::TYPE_LIST; | 35 const base::Value::Type TYPE_LIST = base::Value::TYPE_LIST; |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 230 } |
229 | 231 |
230 int OncNetworkParser::GetCertificatesSize() const { | 232 int OncNetworkParser::GetCertificatesSize() const { |
231 return certificates_ ? certificates_->GetSize() : 0; | 233 return certificates_ ? certificates_->GetSize() : 0; |
232 } | 234 } |
233 | 235 |
234 scoped_refptr<net::X509Certificate> OncNetworkParser::ParseCertificate( | 236 scoped_refptr<net::X509Certificate> OncNetworkParser::ParseCertificate( |
235 int cert_index) { | 237 int cert_index) { |
236 CHECK(certificates_); | 238 CHECK(certificates_); |
237 CHECK(static_cast<size_t>(cert_index) < certificates_->GetSize()); | 239 CHECK(static_cast<size_t>(cert_index) < certificates_->GetSize()); |
238 CHECK(cert_index >= 0); | 240 CHECK_GE(cert_index, 0); |
239 base::DictionaryValue* certificate = NULL; | 241 base::DictionaryValue* certificate = NULL; |
240 certificates_->GetDictionary(cert_index, &certificate); | 242 if (!certificates_->GetDictionary(cert_index, &certificate)) { |
241 CHECK(certificate); | 243 parse_error_ = l10n_util::GetStringUTF8( |
| 244 IDS_NETWORK_CONFIG_ERROR_CERT_DATA_MALFORMED); |
| 245 return NULL; |
| 246 } |
242 | 247 |
243 if (VLOG_IS_ON(2)) { | 248 if (VLOG_IS_ON(2)) { |
244 std::string certificate_json; | 249 std::string certificate_json; |
245 base::JSONWriter::Write(static_cast<base::Value*>(certificate), | 250 base::JSONWriter::Write(static_cast<base::Value*>(certificate), |
246 true, &certificate_json); | 251 true, &certificate_json); |
247 VLOG(2) << "Parsing certificate at index " << cert_index | 252 VLOG(2) << "Parsing certificate at index " << cert_index |
248 << ": " << certificate_json; | 253 << ": " << certificate_json; |
249 } | 254 } |
250 | 255 |
251 // Get out the attributes of the given certificate. | 256 // Get out the attributes of the given certificate. |
252 std::string guid; | 257 std::string guid; |
253 bool remove = false; | 258 bool remove = false; |
254 if (!certificate->GetString("GUID", &guid) || guid.empty()) { | 259 if (!certificate->GetString("GUID", &guid) || guid.empty()) { |
255 LOG(WARNING) << "ONC File: certificate missing identifier at index" | 260 LOG(WARNING) << "ONC File: certificate missing identifier at index" |
256 << cert_index; | 261 << cert_index; |
| 262 parse_error_ = l10n_util::GetStringUTF8( |
| 263 IDS_NETWORK_CONFIG_ERROR_CERT_GUID_MISSING); |
257 return NULL; | 264 return NULL; |
258 } | 265 } |
259 | 266 |
260 if (!certificate->GetBoolean("Remove", &remove)) | 267 if (!certificate->GetBoolean("Remove", &remove)) |
261 remove = false; | 268 remove = false; |
262 | 269 |
263 net::CertDatabase cert_database; | 270 net::CertDatabase cert_database; |
264 if (remove) { | 271 if (remove) { |
265 bool success = DeleteCertAndKeyByNickname(guid); | 272 if (!DeleteCertAndKeyByNickname(guid)) { |
266 DCHECK(success); | 273 parse_error_ = l10n_util::GetStringUTF8( |
267 // TODO(gspencer): return removed certificate? | 274 IDS_NETWORK_CONFIG_ERROR_CERT_DELETE); |
| 275 } |
268 return NULL; | 276 return NULL; |
269 } | 277 } |
270 | 278 |
271 // Not removing, so let's get the data we need to add this certificate. | 279 // Not removing, so let's get the data we need to add this certificate. |
272 std::string cert_type; | 280 std::string cert_type; |
273 certificate->GetString("Type", &cert_type); | 281 certificate->GetString("Type", &cert_type); |
274 if (cert_type == "Server" || cert_type == "Authority") { | 282 if (cert_type == "Server" || cert_type == "Authority") { |
275 return ParseServerOrCaCertificate(cert_index, cert_type, guid, certificate); | 283 return ParseServerOrCaCertificate(cert_index, cert_type, guid, certificate); |
276 } | 284 } |
277 if (cert_type == "Client") { | 285 if (cert_type == "Client") { |
278 return ParseClientCertificate(cert_index, guid, certificate); | 286 return ParseClientCertificate(cert_index, guid, certificate); |
279 } | 287 } |
280 | 288 |
281 LOG(WARNING) << "ONC File: certificate of unknown type: " << cert_type | 289 LOG(WARNING) << "ONC File: certificate of unknown type: " << cert_type |
282 << " at index " << cert_index; | 290 << " at index " << cert_index; |
| 291 parse_error_ = l10n_util::GetStringUTF8( |
| 292 IDS_NETWORK_CONFIG_ERROR_CERT_TYPE_MISSING); |
283 return NULL; | 293 return NULL; |
284 } | 294 } |
285 | 295 |
286 Network* OncNetworkParser::ParseNetwork(int n) { | 296 Network* OncNetworkParser::ParseNetwork(int n) { |
287 if (!network_configs_) | 297 CHECK(network_configs_); |
| 298 CHECK(static_cast<size_t>(n) < network_configs_->GetSize()); |
| 299 CHECK_GE(n, 0); |
| 300 DictionaryValue* info = NULL; |
| 301 if (!network_configs_->GetDictionary(n, &info)) { |
| 302 parse_error_ = l10n_util::GetStringUTF8( |
| 303 IDS_NETWORK_CONFIG_ERROR_NETWORK_PROP_DICT_MALFORMED); |
288 return NULL; | 304 return NULL; |
289 DictionaryValue* info = NULL; | 305 } |
290 if (!network_configs_->GetDictionary(n, &info)) | 306 |
291 return NULL; | |
292 if (VLOG_IS_ON(2)) { | 307 if (VLOG_IS_ON(2)) { |
293 std::string network_json; | 308 std::string network_json; |
294 base::JSONWriter::Write(static_cast<base::Value*>(info), | 309 base::JSONWriter::Write(static_cast<base::Value*>(info), |
295 true, &network_json); | 310 true, &network_json); |
296 VLOG(2) << "Parsing network at index " << n | 311 VLOG(2) << "Parsing network at index " << n |
297 << ": " << network_json; | 312 << ": " << network_json; |
298 } | 313 } |
299 | 314 |
300 return CreateNetworkFromInfo(std::string(), *info); | 315 return CreateNetworkFromInfo(std::string(), *info); |
301 } | 316 } |
302 | 317 |
303 Network* OncNetworkParser::CreateNetworkFromInfo( | 318 Network* OncNetworkParser::CreateNetworkFromInfo( |
304 const std::string& service_path, | 319 const std::string& service_path, |
305 const DictionaryValue& info) { | 320 const DictionaryValue& info) { |
306 ConnectionType type = ParseTypeFromDictionary(info); | 321 ConnectionType type = ParseTypeFromDictionary(info); |
307 if (type == TYPE_UNKNOWN) // Return NULL if cannot parse network type. | 322 if (type == TYPE_UNKNOWN) { // Return NULL if cannot parse network type. |
| 323 parse_error_ = l10n_util::GetStringUTF8( |
| 324 IDS_NETWORK_CONFIG_ERROR_NETWORK_TYPE_MISSING); |
308 return NULL; | 325 return NULL; |
| 326 } |
309 scoped_ptr<Network> network(CreateNewNetwork(type, service_path)); | 327 scoped_ptr<Network> network(CreateNewNetwork(type, service_path)); |
310 if (!ParseNestedObject(network.get(), | 328 if (!ParseNestedObject(network.get(), |
311 "NetworkConfiguration", | 329 "NetworkConfiguration", |
312 static_cast<const base::Value&>(info), | 330 static_cast<const base::Value&>(info), |
313 network_configuration_signature, | 331 network_configuration_signature, |
314 ParseNetworkConfigurationValue)) { | 332 ParseNetworkConfigurationValue)) { |
315 LOG(WARNING) << "Network " << network->name() << " failed to parse."; | 333 LOG(WARNING) << "Network " << network->name() << " failed to parse."; |
| 334 if (parse_error_.empty()) |
| 335 parse_error_ = l10n_util::GetStringUTF8( |
| 336 IDS_NETWORK_CONFIG_ERROR_NETWORK_PROP_DICT_MALFORMED); |
316 return NULL; | 337 return NULL; |
317 } | 338 } |
318 if (VLOG_IS_ON(2)) { | 339 if (VLOG_IS_ON(2)) { |
319 VLOG(2) << "Created Network '" << network->name() | 340 VLOG(2) << "Created Network '" << network->name() |
320 << "' from info. Path:" << service_path | 341 << "' from info. Path:" << service_path |
321 << " Type:" << ConnectionTypeToString(type); | 342 << " Type:" << ConnectionTypeToString(type); |
322 } | 343 } |
323 return network.release(); | 344 return network.release(); |
324 } | 345 } |
325 | 346 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 base::DictionaryValue* certificate) { | 387 base::DictionaryValue* certificate) { |
367 net::CertDatabase cert_database; | 388 net::CertDatabase cert_database; |
368 bool web_trust = false; | 389 bool web_trust = false; |
369 base::ListValue* trust_list = NULL; | 390 base::ListValue* trust_list = NULL; |
370 if (certificate->GetList("Trust", &trust_list)) { | 391 if (certificate->GetList("Trust", &trust_list)) { |
371 for (size_t i = 0; i < trust_list->GetSize(); ++i) { | 392 for (size_t i = 0; i < trust_list->GetSize(); ++i) { |
372 std::string trust_type; | 393 std::string trust_type; |
373 if (!trust_list->GetString(i, &trust_type)) { | 394 if (!trust_list->GetString(i, &trust_type)) { |
374 LOG(WARNING) << "ONC File: certificate trust is invalid at index " | 395 LOG(WARNING) << "ONC File: certificate trust is invalid at index " |
375 << cert_index; | 396 << cert_index; |
| 397 parse_error_ = l10n_util::GetStringUTF8( |
| 398 IDS_NETWORK_CONFIG_ERROR_CERT_TRUST_INVALID); |
376 return NULL; | 399 return NULL; |
377 } | 400 } |
378 if (trust_type == "Web") { | 401 if (trust_type == "Web") { |
379 web_trust = true; | 402 web_trust = true; |
380 } else { | 403 } else { |
381 LOG(WARNING) << "ONC File: certificate contains unknown " | 404 LOG(WARNING) << "ONC File: certificate contains unknown " |
382 << "trust type: " << trust_type | 405 << "trust type: " << trust_type |
383 << " at index " << cert_index; | 406 << " at index " << cert_index; |
| 407 parse_error_ = l10n_util::GetStringUTF8( |
| 408 IDS_NETWORK_CONFIG_ERROR_CERT_TRUST_UNKNOWN); |
384 return NULL; | 409 return NULL; |
385 } | 410 } |
386 } | 411 } |
387 } | 412 } |
388 | 413 |
389 std::string x509_data; | 414 std::string x509_data; |
390 if (!certificate->GetString("X509", &x509_data) || x509_data.empty()) { | 415 if (!certificate->GetString("X509", &x509_data) || x509_data.empty()) { |
391 LOG(WARNING) << "ONC File: certificate missing appropriate " | 416 LOG(WARNING) << "ONC File: certificate missing appropriate " |
392 << "certificate data for type: " << cert_type | 417 << "certificate data for type: " << cert_type |
393 << " at index " << cert_index; | 418 << " at index " << cert_index; |
| 419 parse_error_ = l10n_util::GetStringUTF8( |
| 420 IDS_NETWORK_CONFIG_ERROR_CERT_DATA_MISSING); |
394 return NULL; | 421 return NULL; |
395 } | 422 } |
396 | 423 |
397 std::string decoded_x509; | 424 std::string decoded_x509; |
398 if (!base::Base64Decode(x509_data, &decoded_x509)) { | 425 if (!base::Base64Decode(x509_data, &decoded_x509)) { |
399 LOG(WARNING) << "Unable to base64 decode X509 data: \"" | 426 LOG(WARNING) << "Unable to base64 decode X509 data: \"" |
400 << x509_data << "\"."; | 427 << x509_data << "\"."; |
| 428 parse_error_ = l10n_util::GetStringUTF8( |
| 429 IDS_NETWORK_CONFIG_ERROR_CERT_DATA_MALFORMED); |
401 return NULL; | 430 return NULL; |
402 } | 431 } |
403 | 432 |
404 scoped_refptr<net::X509Certificate> x509_cert = | 433 scoped_refptr<net::X509Certificate> x509_cert = |
405 net::X509Certificate::CreateFromBytesWithNickname( | 434 net::X509Certificate::CreateFromBytesWithNickname( |
406 decoded_x509.c_str(), | 435 decoded_x509.c_str(), |
407 decoded_x509.size(), | 436 decoded_x509.size(), |
408 guid.c_str()); | 437 guid.c_str()); |
409 if (!x509_cert.get()) { | 438 if (!x509_cert.get()) { |
410 LOG(WARNING) << "Unable to create X509 certificate from bytes."; | 439 LOG(WARNING) << "Unable to create X509 certificate from bytes."; |
| 440 parse_error_ = l10n_util::GetStringUTF8( |
| 441 IDS_NETWORK_CONFIG_ERROR_CERT_DATA_MALFORMED); |
411 return NULL; | 442 return NULL; |
412 } | 443 } |
413 | 444 |
414 net::CertificateList cert_list; | 445 net::CertificateList cert_list; |
415 cert_list.push_back(x509_cert); | 446 cert_list.push_back(x509_cert); |
416 net::CertDatabase::ImportCertFailureList failures; | 447 net::CertDatabase::ImportCertFailureList failures; |
417 bool success = false; | 448 bool success = false; |
418 if (cert_type == "Server") { | 449 if (cert_type == "Server") { |
419 success = cert_database.ImportServerCert(cert_list, &failures); | 450 success = cert_database.ImportServerCert(cert_list, &failures); |
420 } else { // Authority cert | 451 } else { // Authority cert |
421 net::CertDatabase::TrustBits trust = web_trust ? | 452 net::CertDatabase::TrustBits trust = web_trust ? |
422 net::CertDatabase::TRUSTED_SSL : | 453 net::CertDatabase::TRUSTED_SSL : |
423 net::CertDatabase::UNTRUSTED; | 454 net::CertDatabase::UNTRUSTED; |
424 success = cert_database.ImportCACerts(cert_list, trust, &failures); | 455 success = cert_database.ImportCACerts(cert_list, trust, &failures); |
425 } | 456 } |
426 if (!failures.empty()) { | 457 if (!failures.empty()) { |
427 LOG(WARNING) << "ONC File: Error (" | 458 LOG(WARNING) << "ONC File: Error (" |
428 << net::ErrorToString(failures[0].net_error) | 459 << net::ErrorToString(failures[0].net_error) |
429 << ") importing " << cert_type << " certificate at index " | 460 << ") importing " << cert_type << " certificate at index " |
430 << cert_index; | 461 << cert_index; |
| 462 parse_error_ = l10n_util::GetStringUTF8( |
| 463 IDS_NETWORK_CONFIG_ERROR_CERT_IMPORT); |
431 return NULL; | 464 return NULL; |
432 } | 465 } |
433 if (!success) { | 466 if (!success) { |
434 LOG(WARNING) << "ONC File: Unknown error importing " << cert_type | 467 LOG(WARNING) << "ONC File: Unknown error importing " << cert_type |
435 << " certificate at index " << cert_index; | 468 << " certificate at index " << cert_index; |
| 469 parse_error_ = l10n_util::GetStringUTF8( |
| 470 IDS_NETWORK_CONFIG_ERROR_UNKNOWN); |
436 return NULL; | 471 return NULL; |
437 } | 472 } |
438 VLOG(2) << "Successfully imported server/ca certificate at index " | 473 VLOG(2) << "Successfully imported server/ca certificate at index " |
439 << cert_index; | 474 << cert_index; |
440 | 475 |
441 return x509_cert; | 476 return x509_cert; |
442 } | 477 } |
443 | 478 |
444 scoped_refptr<net::X509Certificate> OncNetworkParser::ParseClientCertificate( | 479 scoped_refptr<net::X509Certificate> OncNetworkParser::ParseClientCertificate( |
445 int cert_index, | 480 int cert_index, |
446 const std::string& guid, | 481 const std::string& guid, |
447 base::DictionaryValue* certificate) { | 482 base::DictionaryValue* certificate) { |
448 net::CertDatabase cert_database; | 483 net::CertDatabase cert_database; |
449 std::string pkcs12_data; | 484 std::string pkcs12_data; |
450 if (!certificate->GetString("PKCS12", &pkcs12_data) || | 485 if (!certificate->GetString("PKCS12", &pkcs12_data) || |
451 pkcs12_data.empty()) { | 486 pkcs12_data.empty()) { |
452 LOG(WARNING) << "ONC File: PKCS12 data is missing for Client " | 487 LOG(WARNING) << "ONC File: PKCS12 data is missing for Client " |
453 << "certificate at index " << cert_index; | 488 << "certificate at index " << cert_index; |
| 489 parse_error_ = l10n_util::GetStringUTF8( |
| 490 IDS_NETWORK_CONFIG_ERROR_CERT_DATA_MISSING); |
454 return NULL; | 491 return NULL; |
455 } | 492 } |
456 | 493 |
457 std::string decoded_pkcs12; | 494 std::string decoded_pkcs12; |
458 if (!base::Base64Decode(pkcs12_data, &decoded_pkcs12)) { | 495 if (!base::Base64Decode(pkcs12_data, &decoded_pkcs12)) { |
459 LOG(WARNING) << "Unable to base64 decode PKCS#12 data: \"" | 496 LOG(WARNING) << "Unable to base64 decode PKCS#12 data: \"" |
460 << pkcs12_data << "\"."; | 497 << pkcs12_data << "\"."; |
| 498 parse_error_ = l10n_util::GetStringUTF8( |
| 499 IDS_NETWORK_CONFIG_ERROR_CERT_DATA_MALFORMED); |
461 return NULL; | 500 return NULL; |
462 } | 501 } |
463 | 502 |
464 // Since this has a private key, always use the private module. | 503 // Since this has a private key, always use the private module. |
465 scoped_refptr<net::CryptoModule> module(cert_database.GetPrivateModule()); | 504 scoped_refptr<net::CryptoModule> module(cert_database.GetPrivateModule()); |
466 net::CertificateList imported_certs; | 505 net::CertificateList imported_certs; |
467 | 506 |
468 int result = cert_database.ImportFromPKCS12( | 507 int result = cert_database.ImportFromPKCS12( |
469 module.get(), decoded_pkcs12, string16(), false, &imported_certs); | 508 module.get(), decoded_pkcs12, string16(), false, &imported_certs); |
470 if (result != net::OK) { | 509 if (result != net::OK) { |
471 LOG(WARNING) << "ONC File: Unable to import Client certificate at index " | 510 LOG(WARNING) << "ONC File: Unable to import Client certificate at index " |
472 << cert_index | 511 << cert_index |
473 << " (error " << net::ErrorToString(result) << ")."; | 512 << " (error " << net::ErrorToString(result) << ")."; |
| 513 parse_error_ = l10n_util::GetStringUTF8( |
| 514 IDS_NETWORK_CONFIG_ERROR_CERT_IMPORT); |
474 return NULL; | 515 return NULL; |
475 } | 516 } |
476 | 517 |
477 if (imported_certs.size() == 0) { | 518 if (imported_certs.size() == 0) { |
478 LOG(WARNING) << "ONC File: PKCS12 data contains no importable certificates" | 519 LOG(WARNING) << "ONC File: PKCS12 data contains no importable certificates" |
479 << " at index " << cert_index; | 520 << " at index " << cert_index; |
480 return NULL; | 521 return NULL; |
481 } | 522 } |
482 | 523 |
483 if (imported_certs.size() != 1) { | 524 if (imported_certs.size() != 1) { |
(...skipping 24 matching lines...) Expand all Loading... |
508 } | 549 } |
509 | 550 |
510 bool OncNetworkParser::ParseNestedObject(Network* network, | 551 bool OncNetworkParser::ParseNestedObject(Network* network, |
511 const std::string& onc_type, | 552 const std::string& onc_type, |
512 const base::Value& value, | 553 const base::Value& value, |
513 OncValueSignature* signature, | 554 OncValueSignature* signature, |
514 ParserPointer parser) { | 555 ParserPointer parser) { |
515 bool any_errors = false; | 556 bool any_errors = false; |
516 if (!value.IsType(base::Value::TYPE_DICTIONARY)) { | 557 if (!value.IsType(base::Value::TYPE_DICTIONARY)) { |
517 VLOG(1) << network->name() << ": expected object of type " << onc_type; | 558 VLOG(1) << network->name() << ": expected object of type " << onc_type; |
| 559 parse_error_ = l10n_util::GetStringUTF8( |
| 560 IDS_NETWORK_CONFIG_ERROR_NETWORK_PROP_DICT_MALFORMED); |
518 return false; | 561 return false; |
519 } | 562 } |
520 VLOG(2) << "Parsing nested object of type " << onc_type; | 563 VLOG(2) << "Parsing nested object of type " << onc_type; |
521 const DictionaryValue* dict = NULL; | 564 const DictionaryValue* dict = NULL; |
522 value.GetAsDictionary(&dict); | 565 value.GetAsDictionary(&dict); |
523 for (DictionaryValue::key_iterator iter = dict->begin_keys(); | 566 for (DictionaryValue::key_iterator iter = dict->begin_keys(); |
524 iter != dict->end_keys(); ++iter) { | 567 iter != dict->end_keys(); ++iter) { |
525 const std::string& key = *iter; | 568 const std::string& key = *iter; |
526 base::Value* inner_value = NULL; | 569 base::Value* inner_value = NULL; |
527 dict->GetWithoutPathExpansion(key, &inner_value); | 570 dict->GetWithoutPathExpansion(key, &inner_value); |
(...skipping 25 matching lines...) Expand all Loading... |
553 any_errors = true; | 596 any_errors = true; |
554 continue; | 597 continue; |
555 } | 598 } |
556 if (VLOG_IS_ON(2)) { | 599 if (VLOG_IS_ON(2)) { |
557 std::string value_json; | 600 std::string value_json; |
558 base::JSONWriter::Write(inner_value, true, &value_json); | 601 base::JSONWriter::Write(inner_value, true, &value_json); |
559 VLOG(2) << network->name() << ": Successfully parsed [" << key | 602 VLOG(2) << network->name() << ": Successfully parsed [" << key |
560 << "(" << index << ")] = " << value_json; | 603 << "(" << index << ")] = " << value_json; |
561 } | 604 } |
562 } | 605 } |
| 606 if (any_errors) |
| 607 parse_error_ = l10n_util::GetStringUTF8( |
| 608 IDS_NETWORK_CONFIG_ERROR_NETWORK_PROP_DICT_MALFORMED); |
563 return !any_errors; | 609 return !any_errors; |
564 } | 610 } |
565 | 611 |
566 // static | 612 // static |
567 bool OncNetworkParser::CheckNetworkType(Network* network, | 613 bool OncNetworkParser::CheckNetworkType(Network* network, |
568 ConnectionType expected, | 614 ConnectionType expected, |
569 const std::string& onc_type) { | 615 const std::string& onc_type) { |
570 if (expected != network->type()) { | 616 if (expected != network->type()) { |
571 LOG(WARNING) << network->name() << ": " | 617 LOG(WARNING) << network->name() << ": " |
572 << onc_type << " field unexpected for this type network"; | 618 << onc_type << " field unexpected for this type network"; |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 // on the value of AuthenticationType. | 1226 // on the value of AuthenticationType. |
1181 { "L2TP-IPsec", PROVIDER_TYPE_L2TP_IPSEC_PSK }, | 1227 { "L2TP-IPsec", PROVIDER_TYPE_L2TP_IPSEC_PSK }, |
1182 { "OpenVPN", PROVIDER_TYPE_OPEN_VPN }, | 1228 { "OpenVPN", PROVIDER_TYPE_OPEN_VPN }, |
1183 }; | 1229 }; |
1184 CR_DEFINE_STATIC_LOCAL(EnumMapper<ProviderType>, parser, | 1230 CR_DEFINE_STATIC_LOCAL(EnumMapper<ProviderType>, parser, |
1185 (table, arraysize(table), PROVIDER_TYPE_MAX)); | 1231 (table, arraysize(table), PROVIDER_TYPE_MAX)); |
1186 return parser.Get(type); | 1232 return parser.Get(type); |
1187 } | 1233 } |
1188 | 1234 |
1189 } // namespace chromeos | 1235 } // namespace chromeos |
OLD | NEW |