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