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

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: Addressed comments. 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void DevicePolicyCache::Load() { 160 void DevicePolicyCache::Load() {
161 signed_settings_helper_->StartRetrievePolicyOp( 161 signed_settings_helper_->StartRetrievePolicyOp(
162 base::Bind(&DevicePolicyCache::OnRetrievePolicyCompleted, 162 base::Bind(&DevicePolicyCache::OnRetrievePolicyCompleted,
163 weak_ptr_factory_.GetWeakPtr())); 163 weak_ptr_factory_.GetWeakPtr()));
164 } 164 }
165 165
166 bool DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { 166 bool DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) {
167 DCHECK(IsReady()); 167 DCHECK(IsReady());
168 168
169 // Make sure we have an enterprise device. 169 // Make sure we have an enterprise device.
170 std::string registration_user(install_attributes_->GetRegistrationUser()); 170 std::string registration_domain(install_attributes_->GetDomain());
171 if (registration_user.empty()) { 171 if (registration_domain.empty()) {
172 LOG(WARNING) << "Refusing to accept policy on non-enterprise device."; 172 LOG(WARNING) << "Refusing to accept policy on non-enterprise device.";
173 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, 173 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy,
174 kMetricPolicyFetchNonEnterpriseDevice, 174 kMetricPolicyFetchNonEnterpriseDevice,
175 kMetricPolicySize); 175 kMetricPolicySize);
176 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 176 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
177 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 177 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
178 return false; 178 return false;
179 } 179 }
180 180
181 // Check the user this policy is for against the device-locked name. 181 // Check the user this policy is for against the device-locked name.
182 em::PolicyData policy_data; 182 em::PolicyData policy_data;
183 if (!policy_data.ParseFromString(policy.policy_data())) { 183 if (!policy_data.ParseFromString(policy.policy_data())) {
184 LOG(WARNING) << "Invalid policy protobuf"; 184 LOG(WARNING) << "Invalid policy protobuf";
185 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy, 185 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy,
186 kMetricPolicySize); 186 kMetricPolicySize);
187 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 187 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
188 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 188 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
189 return false; 189 return false;
190 } 190 }
191 191
192 // Existing installations may not have a canonicalized version of the 192 // Existing installations may not have a canonicalized version of the
193 // registration user name in install attributes, so re-canonicalize here. 193 // registration domain in install attributes, so lower-case the data here.
194 if (chromeos::Authenticator::Canonicalize(registration_user) != 194 if (registration_domain !=
195 chromeos::Authenticator::Canonicalize(policy_data.username())) { 195 chromeos::Authenticator::ExtractDomainName(policy_data.username())) {
196 LOG(WARNING) << "Refusing policy blob for " << policy_data.username() 196 LOG(WARNING) << "Refusing policy blob for " << policy_data.username()
197 << " which doesn't match " << registration_user; 197 << " which doesn't match domain " << registration_domain;
198 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch, 198 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch,
199 kMetricPolicySize); 199 kMetricPolicySize);
200 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 200 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
201 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 201 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
202 return false; 202 return false;
203 } 203 }
204 204
205 set_last_policy_refresh_time(base::Time::NowFromSystemTime()); 205 set_last_policy_refresh_time(base::Time::NowFromSystemTime());
206 206
207 // Start a store operation. 207 // Start a store operation.
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 718 }
719 policies->Set(key::kDeviceStartUpUrls, 719 policies->Set(key::kDeviceStartUpUrls,
720 POLICY_LEVEL_MANDATORY, 720 POLICY_LEVEL_MANDATORY,
721 POLICY_SCOPE_MACHINE, 721 POLICY_SCOPE_MACHINE,
722 urls); 722 urls);
723 } 723 }
724 } 724 }
725 } 725 }
726 726
727 } // namespace policy 727 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/existing_user_controller.cc ('k') | chrome/browser/policy/device_policy_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698