Commit 49d77fc2 authored by pneubeck's avatar pneubeck Committed by Commit bot

ONC: Remove augmentation of unmanaged network properties.

Before read-only properties which cannot be set by the user or policy, were explicitly marked as 'unmanaged' in the augmented dictionary returned by getManagedProperties.

Now, instead these properties are returned as plain values, which simplifies the consumer side, especially of Array typed properties like IPConfigs (compare this with SavedIPConfig).

BUG=410877

Review URL: https://codereview.chromium.org/551753002

Cr-Commit-Position: refs/heads/master@{#293931}
parent 4c2d33ac
...@@ -316,14 +316,8 @@ var availableTests = [ ...@@ -316,14 +316,8 @@ var availableTests = [
"stub_wifi2", "stub_wifi2",
callbackPass(function(result) { callbackPass(function(result) {
assertEq({ assertEq({
"Connectable": { "Connectable": true,
"Active": true, "ConnectionState": "NotConnected",
"Effective": "Unmanaged"
},
"ConnectionState": {
"Active": "NotConnected",
"Effective": "Unmanaged"
},
"GUID": "stub_wifi2", "GUID": "stub_wifi2",
"Name": { "Name": {
"Active": "wifi2_PSK", "Active": "wifi2_PSK",
...@@ -340,14 +334,8 @@ var availableTests = [ ...@@ -340,14 +334,8 @@ var availableTests = [
"Active": false, "Active": false,
"UserEditable": true "UserEditable": true
}, },
"Frequency" : { "Frequency" : 5000,
"Active": 5000, "FrequencyList" : [2400, 5000],
"Effective": "Unmanaged"
},
"FrequencyList" : {
"Active": [2400, 5000],
"Effective": "Unmanaged"
},
"Passphrase": { "Passphrase": {
"Effective": "UserSetting", "Effective": "UserSetting",
"UserEditable": true, "UserEditable": true,
...@@ -363,10 +351,7 @@ var availableTests = [ ...@@ -363,10 +351,7 @@ var availableTests = [
"Effective": "UserPolicy", "Effective": "UserPolicy",
"UserPolicy": "WPA-PSK" "UserPolicy": "WPA-PSK"
}, },
"SignalStrength": { "SignalStrength": 80,
"Active": 80,
"Effective": "Unmanaged"
}
} }
}, result); }, result);
})); }));
......
...@@ -361,80 +361,81 @@ class MergeToAugmented : public MergeToEffective { ...@@ -361,80 +361,81 @@ class MergeToAugmented : public MergeToEffective {
virtual scoped_ptr<base::Value> MergeValues( virtual scoped_ptr<base::Value> MergeValues(
const std::string& key, const std::string& key,
const ValueParams& values) OVERRIDE { const ValueParams& values) OVERRIDE {
const OncFieldSignature* field = NULL;
if (signature_)
field = GetFieldSignature(*signature_, key);
if (!field) {
// This field is not part of the provided ONCSignature, thus it cannot be
// controlled by policy. Return the plain active value instead of an
// augmented dictionary.
return make_scoped_ptr(values.active_setting->DeepCopy());
}
// This field is part of the provided ONCSignature, thus it can be
// controlled by policy.
std::string which_effective;
scoped_ptr<base::Value> effective_value =
MergeToEffective::MergeValues(key, values, &which_effective);
if (IsIdentifierField(*signature_, key)) {
// Don't augment the GUID but write the plain value.
if (!effective_value) {
LOG(ERROR) << "GUID field has no effective value";
return make_scoped_ptr<base::Value>(NULL);
}
// DCHECK that all provided GUIDs are identical.
DCHECK(AllPresentValuesEqual(values, *effective_value));
// Return the un-augmented GUID.
return effective_value.Pass();
}
scoped_ptr<base::DictionaryValue> augmented_value( scoped_ptr<base::DictionaryValue> augmented_value(
new base::DictionaryValue); new base::DictionaryValue);
if (values.active_setting) { if (values.active_setting) {
augmented_value->SetWithoutPathExpansion( augmented_value->SetWithoutPathExpansion(
::onc::kAugmentationActiveSetting, values.active_setting->DeepCopy()); ::onc::kAugmentationActiveSetting, values.active_setting->DeepCopy());
} }
const OncFieldSignature* field = NULL; if (!which_effective.empty()) {
if (signature_) augmented_value->SetStringWithoutPathExpansion(
field = GetFieldSignature(*signature_, key); ::onc::kAugmentationEffectiveSetting, which_effective);
}
if (field) {
// This field is part of the provided ONCSignature, thus it can be
// controlled by policy.
std::string which_effective;
scoped_ptr<base::Value> effective_value =
MergeToEffective::MergeValues(key, values, &which_effective);
if (IsIdentifierField(*signature_, key)) {
// Don't augment the GUID but write the plain value.
if (!effective_value) {
LOG(ERROR) << "GUID field has no effective value";
return make_scoped_ptr<base::Value>(NULL);
}
// DCHECK that all provided GUIDs are identical.
DCHECK(AllPresentValuesEqual(values, *effective_value));
// Return the un-augmented GUID.
return effective_value.Pass();
}
if (!which_effective.empty()) { // Prevent credentials from being forwarded in cleartext to
augmented_value->SetStringWithoutPathExpansion( // UI. User/shared credentials are not stored separately, so they cannot
::onc::kAugmentationEffectiveSetting, which_effective); // leak here.
} bool is_credential = onc::FieldIsCredential(*signature_, key);
bool is_credential = onc::FieldIsCredential(*signature_, key); if (!is_credential) {
if (values.user_policy) {
// Prevent credentials from being forwarded in cleartext to
// UI. User/shared credentials are not stored separately, so they cannot
// leak here.
if (!is_credential) {
if (values.user_policy) {
augmented_value->SetWithoutPathExpansion(
::onc::kAugmentationUserPolicy, values.user_policy->DeepCopy());
}
if (values.device_policy) {
augmented_value->SetWithoutPathExpansion(
::onc::kAugmentationDevicePolicy,
values.device_policy->DeepCopy());
}
}
if (values.user_setting) {
augmented_value->SetWithoutPathExpansion( augmented_value->SetWithoutPathExpansion(
::onc::kAugmentationUserSetting, values.user_setting->DeepCopy()); ::onc::kAugmentationUserPolicy, values.user_policy->DeepCopy());
} }
if (values.shared_setting) { if (values.device_policy) {
augmented_value->SetWithoutPathExpansion( augmented_value->SetWithoutPathExpansion(
::onc::kAugmentationSharedSetting, ::onc::kAugmentationDevicePolicy,
values.shared_setting->DeepCopy()); values.device_policy->DeepCopy());
}
if (HasUserPolicy() && values.user_editable) {
augmented_value->SetBooleanWithoutPathExpansion(
::onc::kAugmentationUserEditable, true);
}
if (HasDevicePolicy() && values.device_editable) {
augmented_value->SetBooleanWithoutPathExpansion(
::onc::kAugmentationDeviceEditable, true);
} }
} else { }
// This field is not part of the provided ONCSignature, thus it cannot be if (values.user_setting) {
// controlled by policy. augmented_value->SetWithoutPathExpansion(
augmented_value->SetStringWithoutPathExpansion( ::onc::kAugmentationUserSetting, values.user_setting->DeepCopy());
::onc::kAugmentationEffectiveSetting, ::onc::kAugmentationUnmanaged); }
if (values.shared_setting) {
augmented_value->SetWithoutPathExpansion(
::onc::kAugmentationSharedSetting,
values.shared_setting->DeepCopy());
}
if (HasUserPolicy() && values.user_editable) {
augmented_value->SetBooleanWithoutPathExpansion(
::onc::kAugmentationUserEditable, true);
}
if (HasDevicePolicy() && values.device_editable) {
augmented_value->SetBooleanWithoutPathExpansion(
::onc::kAugmentationDeviceEditable, true);
} }
if (augmented_value->empty()) if (augmented_value->empty())
augmented_value.reset(); augmented_value.reset();
......
{ {
"ConnectionState": { "ConnectionState": "Connected",
"Active": "Connected",
"Effective": "Unmanaged"
},
"GUID": "123", "GUID": "123",
"IPConfigs": { "IPConfigs": [ {
"Active": [ {
"Gateway": "2001:db8:85a3::7a2e:370:7331", "Gateway": "2001:db8:85a3::7a2e:370:7331",
"IPAddress": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "IPAddress": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"NameServers": [ ], "NameServers": [ ],
"RoutingPrefix": 12, "RoutingPrefix": 12,
"Type": "IPv6" "Type": "IPv6"
} ], } ],
"Effective": "Unmanaged"
},
"SavedIPConfig": { "SavedIPConfig": {
"Gateway": { "Gateway": "1.1.1.4",
"Active": "1.1.1.4", "IPAddress": "124.124.124.124",
"Effective": "Unmanaged" "NameServers": [ "1.1.1.5", "1.1.1.6" ],
}, "RoutingPrefix": 25,
"IPAddress": { "Type": "IPv4",
"Active": "124.124.124.124",
"Effective": "Unmanaged"
},
"NameServers": {
"Active": [ "1.1.1.5", "1.1.1.6" ],
"Effective": "Unmanaged"
},
"RoutingPrefix": {
"Active": 25,
"Effective": "Unmanaged"
},
"Type": {
"Active": "IPv4",
"Effective": "Unmanaged"
}
}, },
"StaticIPConfig": { "StaticIPConfig": {
"IPAddress": { "IPAddress": {
......
...@@ -9,7 +9,6 @@ namespace onc { ...@@ -9,7 +9,6 @@ namespace onc {
const char kAugmentationActiveSetting[] = "Active"; const char kAugmentationActiveSetting[] = "Active";
const char kAugmentationEffectiveSetting[] = "Effective"; const char kAugmentationEffectiveSetting[] = "Effective";
const char kAugmentationUnmanaged[] = "Unmanaged";
const char kAugmentationUserPolicy[] = "UserPolicy"; const char kAugmentationUserPolicy[] = "UserPolicy";
const char kAugmentationDevicePolicy[] = "DevicePolicy"; const char kAugmentationDevicePolicy[] = "DevicePolicy";
const char kAugmentationUserSetting[] = "UserSetting"; const char kAugmentationUserSetting[] = "UserSetting";
......
...@@ -29,7 +29,6 @@ ONC_EXPORT extern const char kAugmentationActiveSetting[]; ...@@ -29,7 +29,6 @@ ONC_EXPORT extern const char kAugmentationActiveSetting[];
// The one of different setting sources (user/device policy, user/shared // The one of different setting sources (user/device policy, user/shared
// settings) that has highest priority over the others. // settings) that has highest priority over the others.
ONC_EXPORT extern const char kAugmentationEffectiveSetting[]; ONC_EXPORT extern const char kAugmentationEffectiveSetting[];
ONC_EXPORT extern const char kAugmentationUnmanaged[];
ONC_EXPORT extern const char kAugmentationUserPolicy[]; ONC_EXPORT extern const char kAugmentationUserPolicy[];
ONC_EXPORT extern const char kAugmentationDevicePolicy[]; ONC_EXPORT extern const char kAugmentationDevicePolicy[];
ONC_EXPORT extern const char kAugmentationUserSetting[]; ONC_EXPORT extern const char kAugmentationUserSetting[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment