| Index: chromeos/network/onc/onc_validator.cc
|
| diff --git a/chromeos/network/onc/onc_validator.cc b/chromeos/network/onc/onc_validator.cc
|
| index a57aeca2d6e77608b5532f9f853e2a33c7f4f2fa..178343c371909213724e3f5278567bf32aa25f15 100644
|
| --- a/chromeos/network/onc/onc_validator.cc
|
| +++ b/chromeos/network/onc/onc_validator.cc
|
| @@ -386,23 +386,28 @@ bool Validator::ValidateToplevelConfiguration(
|
| }
|
|
|
| static const char* kValidTypes[] =
|
| - { kUnencryptedConfiguration, kEncryptedConfiguration, NULL };
|
| - if (FieldExistsAndHasNoValidValue(*result, kType, kValidTypes))
|
| + { toplevel_config::kUnencryptedConfiguration,
|
| + toplevel_config::kEncryptedConfiguration,
|
| + NULL };
|
| + if (FieldExistsAndHasNoValidValue(*result,
|
| + network_config::kType,
|
| + kValidTypes))
|
| return false;
|
|
|
| bool allRequiredExist = true;
|
|
|
| // Not part of the ONC spec yet:
|
| // We don't require the type field and default to UnencryptedConfiguration.
|
| - std::string type = kUnencryptedConfiguration;
|
| - result->GetStringWithoutPathExpansion(kType, &type);
|
| - if (type == kUnencryptedConfiguration &&
|
| - !result->HasKey(kNetworkConfigurations) &&
|
| - !result->HasKey(kCertificates)) {
|
| + std::string type = toplevel_config::kUnencryptedConfiguration;
|
| + result->GetStringWithoutPathExpansion(network_config::kType, &type);
|
| + if (type == toplevel_config::kUnencryptedConfiguration &&
|
| + !result->HasKey(toplevel_config::kNetworkConfigurations) &&
|
| + !result->HasKey(toplevel_config::kCertificates)) {
|
| error_or_warning_found_ = true;
|
| std::string message = MessageHeader(error_on_missing_field_) +
|
| - "Neither the field '" + kNetworkConfigurations + "' nor '" +
|
| - kCertificates + "is present, but at least one is required.";
|
| + "Neither the field '" + toplevel_config::kNetworkConfigurations +
|
| + "' nor '" + toplevel_config::kCertificates +
|
| + "is present, but at least one is required.";
|
| if (error_on_missing_field_)
|
| LOG(ERROR) << message;
|
| else
|
| @@ -421,26 +426,31 @@ bool Validator::ValidateNetworkConfiguration(
|
| return false;
|
| }
|
|
|
| - static const char* kValidTypes[] = { kEthernet, kVPN, kWiFi, NULL };
|
| - if (FieldExistsAndHasNoValidValue(*result, kType, kValidTypes))
|
| + static const char* kValidTypes[] = { network_type::kEthernet,
|
| + network_type::kVPN,
|
| + network_type::kWiFi,
|
| + NULL };
|
| + if (FieldExistsAndHasNoValidValue(*result,
|
| + network_config::kType,
|
| + kValidTypes))
|
| return false;
|
|
|
| - bool allRequiredExist = RequireField(*result, kGUID);
|
| + bool allRequiredExist = RequireField(*result, network_config::kGUID);
|
|
|
| bool remove = false;
|
| result->GetBooleanWithoutPathExpansion(kRemove, &remove);
|
| if (!remove) {
|
| - allRequiredExist &= RequireField(*result, kName);
|
| - allRequiredExist &= RequireField(*result, kType);
|
| + allRequiredExist &= RequireField(*result, network_config::kName);
|
| + allRequiredExist &= RequireField(*result, network_config::kType);
|
|
|
| std::string type;
|
| - result->GetStringWithoutPathExpansion(kType, &type);
|
| + result->GetStringWithoutPathExpansion(network_config::kType, &type);
|
|
|
| // Prohibit anything but WiFi and Ethernet for device-level policy (which
|
| // corresponds to shared networks). See also http://crosbug.com/28741.
|
| if (onc_source_ == ONC_SOURCE_DEVICE_POLICY &&
|
| - type != kWiFi &&
|
| - type != kEthernet) {
|
| + type != network_type::kWiFi &&
|
| + type != network_type::kEthernet) {
|
| error_or_warning_found_ = true;
|
| LOG(ERROR) << ErrorHeader() << "Networks of type '"
|
| << type << "' are prohibited in ONC device policies.";
|
| @@ -739,7 +749,7 @@ bool Validator::ValidateCertificate(
|
| if (FieldExistsAndHasNoValidValue(*result, certificate::kType, kValidTypes))
|
| return false;
|
|
|
| - bool allRequiredExist = RequireField(*result, kGUID);
|
| + bool allRequiredExist = RequireField(*result, certificate::kGUID);
|
|
|
| bool remove = false;
|
| result->GetBooleanWithoutPathExpansion(kRemove, &remove);
|
|
|