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

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: Moved the domain extraction to Authenticator and added custom error message. 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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/string_util.h"
17 #include "base/values.h" 18 #include "base/values.h"
18 #include "chrome/browser/chromeos/cros_settings.h" 19 #include "chrome/browser/chromeos/cros_settings.h"
19 #include "chrome/browser/chromeos/login/authenticator.h" 20 #include "chrome/browser/chromeos/login/authenticator.h"
20 #include "chrome/browser/chromeos/login/ownership_service.h" 21 #include "chrome/browser/chromeos/login/ownership_service.h"
21 #include "chrome/browser/chromeos/login/signed_settings_helper.h" 22 #include "chrome/browser/chromeos/login/signed_settings_helper.h"
22 #include "chrome/browser/policy/app_pack_updater.h" 23 #include "chrome/browser/policy/app_pack_updater.h"
23 #include "chrome/browser/policy/cloud_policy_data_store.h" 24 #include "chrome/browser/policy/cloud_policy_data_store.h"
24 #include "chrome/browser/policy/enterprise_install_attributes.h" 25 #include "chrome/browser/policy/enterprise_install_attributes.h"
25 #include "chrome/browser/policy/enterprise_metrics.h" 26 #include "chrome/browser/policy/enterprise_metrics.h"
26 #include "chrome/browser/policy/policy_map.h" 27 #include "chrome/browser/policy/policy_map.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 void DevicePolicyCache::Load() { 161 void DevicePolicyCache::Load() {
161 signed_settings_helper_->StartRetrievePolicyOp( 162 signed_settings_helper_->StartRetrievePolicyOp(
162 base::Bind(&DevicePolicyCache::OnRetrievePolicyCompleted, 163 base::Bind(&DevicePolicyCache::OnRetrievePolicyCompleted,
163 weak_ptr_factory_.GetWeakPtr())); 164 weak_ptr_factory_.GetWeakPtr()));
164 } 165 }
165 166
166 bool DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) { 167 bool DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) {
167 DCHECK(IsReady()); 168 DCHECK(IsReady());
168 169
169 // Make sure we have an enterprise device. 170 // Make sure we have an enterprise device.
170 std::string registration_user(install_attributes_->GetRegistrationUser()); 171 std::string registration_domain(
171 if (registration_user.empty()) { 172 StringToLowerASCII(install_attributes_->GetDomain()));
Mattias Nissler (ping if slow) 2012/06/08 13:13:44 It would be nice if we could call the canonicaliza
pastarmovj 2012/06/08 15:07:12 Done.
173 if (registration_domain.empty()) {
172 LOG(WARNING) << "Refusing to accept policy on non-enterprise device."; 174 LOG(WARNING) << "Refusing to accept policy on non-enterprise device.";
173 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, 175 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy,
174 kMetricPolicyFetchNonEnterpriseDevice, 176 kMetricPolicyFetchNonEnterpriseDevice,
175 kMetricPolicySize); 177 kMetricPolicySize);
176 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 178 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
177 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 179 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
178 return false; 180 return false;
179 } 181 }
180 182
181 // Check the user this policy is for against the device-locked name. 183 // Check the user this policy is for against the device-locked name.
182 em::PolicyData policy_data; 184 em::PolicyData policy_data;
183 if (!policy_data.ParseFromString(policy.policy_data())) { 185 if (!policy_data.ParseFromString(policy.policy_data())) {
184 LOG(WARNING) << "Invalid policy protobuf"; 186 LOG(WARNING) << "Invalid policy protobuf";
185 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy, 187 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy,
186 kMetricPolicySize); 188 kMetricPolicySize);
187 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 189 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
188 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 190 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
189 return false; 191 return false;
190 } 192 }
191 193
192 // Existing installations may not have a canonicalized version of the 194 // Existing installations may not have a canonicalized version of the
193 // registration user name in install attributes, so re-canonicalize here. 195 // registration domain in install attributes, so lower-case the data here.
194 if (chromeos::Authenticator::Canonicalize(registration_user) != 196 if (registration_domain !=
195 chromeos::Authenticator::Canonicalize(policy_data.username())) { 197 chromeos::Authenticator::ExtractDomainName(policy_data.username())) {
196 LOG(WARNING) << "Refusing policy blob for " << policy_data.username() 198 LOG(WARNING) << "Refusing policy blob for " << policy_data.username()
197 << " which doesn't match " << registration_user; 199 << " which doesn't match domain " << registration_domain;
198 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch, 200 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch,
199 kMetricPolicySize); 201 kMetricPolicySize);
200 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, 202 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
201 CloudPolicySubsystem::POLICY_LOCAL_ERROR); 203 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
202 return false; 204 return false;
203 } 205 }
204 206
205 set_last_policy_refresh_time(base::Time::NowFromSystemTime()); 207 set_last_policy_refresh_time(base::Time::NowFromSystemTime());
206 208
207 // Start a store operation. 209 // Start a store operation.
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 720 }
719 policies->Set(key::kDeviceStartUpUrls, 721 policies->Set(key::kDeviceStartUpUrls,
720 POLICY_LEVEL_MANDATORY, 722 POLICY_LEVEL_MANDATORY,
721 POLICY_SCOPE_MACHINE, 723 POLICY_SCOPE_MACHINE,
722 urls); 724 urls);
723 } 725 }
724 } 726 }
725 } 727 }
726 728
727 } // namespace policy 729 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698