Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Side by Side Diff: chrome/browser/policy/device_policy_cache.cc

Issue 10443125: Allow re-enrollment to the same domain in case of policy data loss. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unit tests. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/policy/device_policy_cache.h" 5 #include "chrome/browser/policy/device_policy_cache.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void DevicePolicyCache::Load() { 143 void DevicePolicyCache::Load() {
144 signed_settings_helper_->StartRetrievePolicyOp( 144 signed_settings_helper_->StartRetrievePolicyOp(
145 base::Bind(&DevicePolicyCache::OnRetrievePolicyCompleted, 145 base::Bind(&DevicePolicyCache::OnRetrievePolicyCompleted,
146 weak_ptr_factory_.GetWeakPtr())); 146 weak_ptr_factory_.GetWeakPtr()));
147 } 147 }
148 148
149 bool DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { 149 bool DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) {
150 DCHECK(IsReady()); 150 DCHECK(IsReady());
151 151
152 // Make sure we have an enterprise device. 152 // Make sure we have an enterprise device.
153 std::string registration_user(install_attributes_->GetRegistrationUser()); 153 std::string registration_domain(install_attributes_->GetDomain());
154 if (registration_user.empty()) { 154 if (registration_domain.empty()) {
155 LOG(WARNING) << "Refusing to accept policy on non-enterprise device."; 155 LOG(WARNING) << "Refusing to accept policy on non-enterprise device.";
156 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, 156 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy,
157 kMetricPolicyFetchNonEnterpriseDevice, 157 kMetricPolicyFetchNonEnterpriseDevice,
158 kMetricPolicySize); 158 kMetricPolicySize);
159 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 159 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
160 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 160 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
161 return false; 161 return false;
162 } 162 }
163 163
164 // Check the user this policy is for against the device-locked name. 164 // Check the user this policy is for against the device-locked name.
165 em::PolicyData policy_data; 165 em::PolicyData policy_data;
166 if (!policy_data.ParseFromString(policy.policy_data())) { 166 if (!policy_data.ParseFromString(policy.policy_data())) {
167 LOG(WARNING) << "Invalid policy protobuf"; 167 LOG(WARNING) << "Invalid policy protobuf";
168 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy, 168 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy,
169 kMetricPolicySize); 169 kMetricPolicySize);
170 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 170 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
171 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 171 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
172 return false; 172 return false;
173 } 173 }
174 174
175 // Existing installations may not have a canonicalized version of the 175 // Existing installations may not have a canonicalized version of the
176 // registration user name in install attributes, so re-canonicalize here. 176 // registration user name in install attributes, so re-canonicalize here.
177 if (chromeos::Authenticator::Canonicalize(registration_user) != 177 if (registration_domain !=
178 chromeos::Authenticator::Canonicalize(policy_data.username())) { 178 install_attributes_->ExtractDomainName(policy_data.username())) {
Mattias Nissler (ping if slow) 2012/06/04 10:17:52 Remove the authenticator header as well. Also, don
pastarmovj 2012/06/08 09:54:32 Done.
179 LOG(WARNING) << "Refusing policy blob for " << policy_data.username() 179 LOG(WARNING) << "Refusing policy blob for " << policy_data.username()
180 << " which doesn't match " << registration_user; 180 << " which doesn't match domain " << registration_domain;
181 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch, 181 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch,
182 kMetricPolicySize); 182 kMetricPolicySize);
183 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 183 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
184 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 184 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
185 return false; 185 return false;
186 } 186 }
187 187
188 set_last_policy_refresh_time(base::Time::NowFromSystemTime()); 188 set_last_policy_refresh_time(base::Time::NowFromSystemTime());
189 189
190 // Start a store operation. 190 // Start a store operation.
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 } 666 }
667 policies->Set(key::kDeviceStartUpUrls, 667 policies->Set(key::kDeviceStartUpUrls,
668 POLICY_LEVEL_MANDATORY, 668 POLICY_LEVEL_MANDATORY,
669 POLICY_SCOPE_MACHINE, 669 POLICY_SCOPE_MACHINE,
670 urls); 670 urls);
671 } 671 }
672 } 672 }
673 } 673 }
674 674
675 } // namespace policy 675 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698