| OLD | NEW |
| 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/chromeos/policy/enrollment_handler_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" |
| 13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" | 17 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
| 17 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 18 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
| 18 #include "chrome/browser/chromeos/policy/active_directory_join_delegate.h" | 19 #include "chrome/browser/chromeos/policy/active_directory_join_delegate.h" |
| 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 20 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 20 #include "chrome/browser/chromeos/policy/dm_token_storage.h" | 21 #include "chrome/browser/chromeos/policy/dm_token_storage.h" |
| 21 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" | 22 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" |
| 22 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 23 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 const em::PolicyFetchResponse* policy = client_->GetPolicyFor( | 189 const em::PolicyFetchResponse* policy = client_->GetPolicyFor( |
| 189 dm_protocol::kChromeDevicePolicyType, std::string()); | 190 dm_protocol::kChromeDevicePolicyType, std::string()); |
| 190 if (!policy) { | 191 if (!policy) { |
| 191 ReportResult(EnrollmentStatus::ForFetchError( | 192 ReportResult(EnrollmentStatus::ForFetchError( |
| 192 DM_STATUS_RESPONSE_DECODING_ERROR)); | 193 DM_STATUS_RESPONSE_DECODING_ERROR)); |
| 193 return; | 194 return; |
| 194 } | 195 } |
| 195 | 196 |
| 196 std::unique_ptr<DeviceCloudPolicyValidator> validator( | 197 std::unique_ptr<DeviceCloudPolicyValidator> validator( |
| 197 DeviceCloudPolicyValidator::Create( | 198 DeviceCloudPolicyValidator::Create( |
| 198 std::unique_ptr<em::PolicyFetchResponse>( | 199 base::MakeUnique<em::PolicyFetchResponse>(*policy), |
| 199 new em::PolicyFetchResponse(*policy)), | |
| 200 background_task_runner_)); | 200 background_task_runner_)); |
| 201 | 201 |
| 202 validator->ValidateTimestamp( | 202 validator->ValidateTimestamp( |
| 203 base::Time(), base::Time::NowFromSystemTime(), | 203 base::Time(), base::Time::NowFromSystemTime(), |
| 204 CloudPolicyValidatorBase::TIMESTAMP_FULLY_VALIDATED); | 204 CloudPolicyValidatorBase::TIMESTAMP_FULLY_VALIDATED); |
| 205 | 205 |
| 206 // If this is re-enrollment, make sure that the new policy matches the | 206 // If this is re-enrollment, make sure that the new policy matches the |
| 207 // previously-enrolled domain. (Currently only implemented for cloud | 207 // previously-enrolled domain. (Currently only implemented for cloud |
| 208 // management.) | 208 // management.) |
| 209 std::string domain; | 209 std::string domain; |
| 210 if (install_attributes_->IsCloudManaged()) { | 210 if (install_attributes_->IsCloudManaged()) { |
| 211 domain = install_attributes_->GetDomain(); | 211 domain = install_attributes_->GetDomain(); |
| 212 validator->ValidateDomain(domain); | 212 validator->ValidateDomain(domain); |
| 213 } | 213 } |
| 214 validator->ValidateDMToken(client->dm_token(), | 214 validator->ValidateDMToken(client->dm_token(), |
| 215 CloudPolicyValidatorBase::DM_TOKEN_REQUIRED); | 215 CloudPolicyValidatorBase::DM_TOKEN_REQUIRED); |
| 216 validator->ValidatePolicyType(dm_protocol::kChromeDevicePolicyType); | 216 validator->ValidatePolicyType(dm_protocol::kChromeDevicePolicyType); |
| 217 validator->ValidatePayload(); | 217 validator->ValidatePayload(); |
| 218 // If |domain| is empty here, the policy validation code will just use the | 218 // If |domain| is empty here, the policy validation code will just use the |
| 219 // domain from the username field in the policy itself to do key validation. | 219 // domain from the username field in the policy itself to do key validation. |
| 220 // TODO(mnissler): Plumb the enrolling user's username into this object so we | 220 // TODO(mnissler): Plumb the enrolling user's username into this object so we |
| 221 // can validate the username on the resulting policy, and use the domain from | 221 // can validate the username on the resulting policy, and use the domain from |
| 222 // that username to validate the key below (http://crbug.com/343074). | 222 // that username to validate the key below (http://crbug.com/343074). |
| 223 validator->ValidateInitialKey(domain); | 223 validator->ValidateInitialKey(domain); |
| 224 validator.release()->StartValidation( | 224 DeviceCloudPolicyValidator::StartValidation( |
| 225 std::move(validator), |
| 225 base::Bind(&EnrollmentHandlerChromeOS::HandlePolicyValidationResult, | 226 base::Bind(&EnrollmentHandlerChromeOS::HandlePolicyValidationResult, |
| 226 weak_ptr_factory_.GetWeakPtr())); | 227 weak_ptr_factory_.GetWeakPtr())); |
| 227 } | 228 } |
| 228 | 229 |
| 229 void EnrollmentHandlerChromeOS::OnRegistrationStateChanged( | 230 void EnrollmentHandlerChromeOS::OnRegistrationStateChanged( |
| 230 CloudPolicyClient* client) { | 231 CloudPolicyClient* client) { |
| 231 DCHECK_EQ(client_.get(), client); | 232 DCHECK_EQ(client_.get(), client); |
| 232 | 233 |
| 233 if (enrollment_step_ == STEP_REGISTRATION && client_->is_registered()) { | 234 if (enrollment_step_ == STEP_REGISTRATION && client_->is_registered()) { |
| 234 device_mode_ = client_->device_mode(); | 235 device_mode_ = client_->device_mode(); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 callback.Run(status); | 662 callback.Run(status); |
| 662 } | 663 } |
| 663 | 664 |
| 664 void EnrollmentHandlerChromeOS::SetStep(EnrollmentStep step) { | 665 void EnrollmentHandlerChromeOS::SetStep(EnrollmentStep step) { |
| 665 DCHECK_LE(enrollment_step_, step); | 666 DCHECK_LE(enrollment_step_, step); |
| 666 VLOG(1) << "Step: " << step; | 667 VLOG(1) << "Step: " << step; |
| 667 enrollment_step_ = step; | 668 enrollment_step_ = step; |
| 668 } | 669 } |
| 669 | 670 |
| 670 } // namespace policy | 671 } // namespace policy |
| OLD | NEW |