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 "chrome/browser/chromeos/cros/onc_network_parser.h" | 5 #include "chrome/browser/chromeos/cros/onc_network_parser.h" |
6 | 6 |
7 #include <keyhi.h> | 7 #include <keyhi.h> |
8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/json/json_string_value_serializer.h" | 11 #include "base/json/json_string_value_serializer.h" |
12 #include "chrome/browser/chromeos/login/user_manager.h" | |
13 #include "base/json/json_writer.h" // for debug output only. | 12 #include "base/json/json_writer.h" // for debug output only. |
14 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
15 #include "base/values.h" | 14 #include "base/values.h" |
16 #include "chrome/browser/chromeos/cros/certificate_pattern.h" | 15 #include "chrome/browser/chromeos/cros/certificate_pattern.h" |
17 #include "chrome/browser/chromeos/cros/cros_library.h" | 16 #include "chrome/browser/chromeos/cros/cros_library.h" |
18 #include "chrome/browser/chromeos/cros/native_network_constants.h" | 17 #include "chrome/browser/chromeos/cros/native_network_constants.h" |
19 #include "chrome/browser/chromeos/cros/native_network_parser.h" | 18 #include "chrome/browser/chromeos/cros/native_network_parser.h" |
20 #include "chrome/browser/chromeos/cros/network_library.h" | 19 #include "chrome/browser/chromeos/cros/network_library.h" |
21 #include "chrome/browser/chromeos/cros/onc_constants.h" | 20 #include "chrome/browser/chromeos/login/user_manager.h" |
22 #include "chrome/browser/chromeos/network_settings/onc_certificate_importer.h" | |
23 #include "chrome/browser/chromeos/network_settings/onc_signature.h" | |
24 #include "chrome/browser/chromeos/network_settings/onc_validator.h" | |
25 #include "chrome/browser/chromeos/proxy_config_service_impl.h" | 21 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
26 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 22 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
27 #include "chrome/common/net/x509_certificate_model.h" | 23 #include "chrome/common/net/x509_certificate_model.h" |
| 24 #include "chromeos/network/onc/onc_certificate_importer.h" |
| 25 #include "chromeos/network/onc/onc_constants.h" |
| 26 #include "chromeos/network/onc/onc_signature.h" |
| 27 #include "chromeos/network/onc/onc_validator.h" |
28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
29 #include "crypto/encryptor.h" | 29 #include "crypto/encryptor.h" |
30 #include "crypto/hmac.h" | 30 #include "crypto/hmac.h" |
31 #include "crypto/scoped_nss_types.h" | 31 #include "crypto/scoped_nss_types.h" |
32 #include "crypto/symmetric_key.h" | 32 #include "crypto/symmetric_key.h" |
33 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
34 #include "net/base/crypto_module.h" | 34 #include "net/base/crypto_module.h" |
35 #include "net/base/net_errors.h" | 35 #include "net/base/net_errors.h" |
36 #include "net/base/nss_cert_database.h" | 36 #include "net/base/nss_cert_database.h" |
37 #include "net/base/pem_tokenizer.h" | 37 #include "net/base/pem_tokenizer.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 result->push_back(item); | 274 result->push_back(item); |
275 } | 275 } |
276 return true; | 276 return true; |
277 } | 277 } |
278 | 278 |
279 } // namespace | 279 } // namespace |
280 | 280 |
281 // -------------------- OncNetworkParser -------------------- | 281 // -------------------- OncNetworkParser -------------------- |
282 | 282 |
283 OncNetworkParser::OncNetworkParser(const base::ListValue& network_configs, | 283 OncNetworkParser::OncNetworkParser(const base::ListValue& network_configs, |
284 NetworkUIData::ONCSource onc_source) | 284 onc::ONCSource onc_source) |
285 : NetworkParser(get_onc_mapper()), | 285 : NetworkParser(get_onc_mapper()), |
286 onc_source_(onc_source), | 286 onc_source_(onc_source), |
287 network_configs_(network_configs.DeepCopy()) { | 287 network_configs_(network_configs.DeepCopy()) { |
288 } | 288 } |
289 | 289 |
290 OncNetworkParser::OncNetworkParser() | 290 OncNetworkParser::OncNetworkParser() |
291 : NetworkParser(get_onc_mapper()), | 291 : NetworkParser(get_onc_mapper()), |
292 network_configs_(NULL) { | 292 network_configs_(NULL) { |
293 } | 293 } |
294 | 294 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 if (any_errors) { | 451 if (any_errors) { |
452 parse_error_ = l10n_util::GetStringUTF8( | 452 parse_error_ = l10n_util::GetStringUTF8( |
453 IDS_NETWORK_CONFIG_ERROR_NETWORK_PROP_DICT_MALFORMED); | 453 IDS_NETWORK_CONFIG_ERROR_NETWORK_PROP_DICT_MALFORMED); |
454 } | 454 } |
455 return !any_errors; | 455 return !any_errors; |
456 } | 456 } |
457 | 457 |
458 // static | 458 // static |
459 std::string OncNetworkParser::GetUserExpandedValue( | 459 std::string OncNetworkParser::GetUserExpandedValue( |
460 const base::Value& value, | 460 const base::Value& value, |
461 NetworkUIData::ONCSource source) { | 461 onc::ONCSource source) { |
462 std::string string_value; | 462 std::string string_value; |
463 if (!value.GetAsString(&string_value)) | 463 if (!value.GetAsString(&string_value)) |
464 return string_value; | 464 return string_value; |
465 | 465 |
466 // If running unit test, just return the original value. | 466 // If running unit test, just return the original value. |
467 if (!content::BrowserThread::IsMessageLoopValid(content::BrowserThread::UI)) | 467 if (!content::BrowserThread::IsMessageLoopValid(content::BrowserThread::UI)) |
468 return string_value; | 468 return string_value; |
469 | 469 |
470 if (source != NetworkUIData::ONC_SOURCE_USER_POLICY && | 470 if (source != onc::ONC_SOURCE_USER_POLICY && |
471 source != NetworkUIData::ONC_SOURCE_USER_IMPORT) { | 471 source != onc::ONC_SOURCE_USER_IMPORT) { |
472 return string_value; | 472 return string_value; |
473 } | 473 } |
474 | 474 |
475 if (!UserManager::Get()->IsUserLoggedIn()) | 475 if (!UserManager::Get()->IsUserLoggedIn()) |
476 return string_value; | 476 return string_value; |
477 | 477 |
478 const User* logged_in_user = UserManager::Get()->GetLoggedInUser(); | 478 const User* logged_in_user = UserManager::Get()->GetLoggedInUser(); |
479 ReplaceSubstringsAfterOffset(&string_value, 0, | 479 ReplaceSubstringsAfterOffset(&string_value, 0, |
480 onc::substitutes::kLoginIDField, | 480 onc::substitutes::kLoginIDField, |
481 logged_in_user->GetAccountName(false)); | 481 logged_in_user->GetAccountName(false)); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 return net::ProxyServer(scheme, host_port); | 850 return net::ProxyServer(scheme, host_port); |
851 } | 851 } |
852 | 852 |
853 // static | 853 // static |
854 bool OncNetworkParser::ParseClientCertPattern(OncNetworkParser* parser, | 854 bool OncNetworkParser::ParseClientCertPattern(OncNetworkParser* parser, |
855 PropertyIndex index, | 855 PropertyIndex index, |
856 const base::Value& value, | 856 const base::Value& value, |
857 Network* network) { | 857 Network* network) { |
858 // Ignore certificate patterns for device policy ONC so that an unmanaged user | 858 // Ignore certificate patterns for device policy ONC so that an unmanaged user |
859 // won't have a certificate presented for them involuntarily. | 859 // won't have a certificate presented for them involuntarily. |
860 if (parser->onc_source() == NetworkUIData::ONC_SOURCE_DEVICE_POLICY) | 860 if (parser->onc_source() == onc::ONC_SOURCE_DEVICE_POLICY) |
861 return false; | 861 return false; |
862 | 862 |
863 // Only WiFi and VPN have this type. | 863 // Only WiFi and VPN have this type. |
864 if (network->type() != TYPE_WIFI && | 864 if (network->type() != TYPE_WIFI && |
865 network->type() != TYPE_VPN) { | 865 network->type() != TYPE_VPN) { |
866 LOG(WARNING) << "Tried to parse a ClientCertPattern from something " | 866 LOG(WARNING) << "Tried to parse a ClientCertPattern from something " |
867 << "that wasn't a WiFi or VPN network."; | 867 << "that wasn't a WiFi or VPN network."; |
868 return false; | 868 return false; |
869 } | 869 } |
870 | 870 |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 // on the value of AuthenticationType. | 1506 // on the value of AuthenticationType. |
1507 { "L2TP-IPsec", PROVIDER_TYPE_L2TP_IPSEC_PSK }, | 1507 { "L2TP-IPsec", PROVIDER_TYPE_L2TP_IPSEC_PSK }, |
1508 { "OpenVPN", PROVIDER_TYPE_OPEN_VPN }, | 1508 { "OpenVPN", PROVIDER_TYPE_OPEN_VPN }, |
1509 }; | 1509 }; |
1510 CR_DEFINE_STATIC_LOCAL(EnumMapper<ProviderType>, parser, | 1510 CR_DEFINE_STATIC_LOCAL(EnumMapper<ProviderType>, parser, |
1511 (table, arraysize(table), PROVIDER_TYPE_MAX)); | 1511 (table, arraysize(table), PROVIDER_TYPE_MAX)); |
1512 return parser.Get(type); | 1512 return parser.Get(type); |
1513 } | 1513 } |
1514 | 1514 |
1515 } // namespace chromeos | 1515 } // namespace chromeos |
OLD | NEW |