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

Side by Side Diff: chrome/browser/chromeos/policy/enrollment_handler_chromeos.h

Issue 2677563005: Chromad: Use DM server reply to determine enrollment type (Closed)
Patch Set: comments+create ActiveDirectoryJoinDelegate Created 3 years, 10 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
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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_HANDLER_CHROMEOS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_HANDLER_CHROMEOS_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_HANDLER_CHROMEOS_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_HANDLER_CHROMEOS_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" 15 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h"
16 #include "chrome/browser/chromeos/policy/device_cloud_policy_validator.h" 16 #include "chrome/browser/chromeos/policy/device_cloud_policy_validator.h"
17 #include "chrome/browser/chromeos/policy/enrollment_config.h" 17 #include "chrome/browser/chromeos/policy/enrollment_config.h"
18 #include "chrome/browser/chromeos/settings/install_attributes.h" 18 #include "chrome/browser/chromeos/settings/install_attributes.h"
19 #include "components/policy/core/common/cloud/cloud_policy_client.h" 19 #include "components/policy/core/common/cloud/cloud_policy_client.h"
20 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 20 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
21 #include "components/policy/core/common/cloud/cloud_policy_store.h" 21 #include "components/policy/core/common/cloud/cloud_policy_store.h"
22 #include "components/policy/proto/device_management_backend.pb.h" 22 #include "components/policy/proto/device_management_backend.pb.h"
23 #include "google_apis/gaia/gaia_oauth_client.h" 23 #include "google_apis/gaia/gaia_oauth_client.h"
24 24
25 namespace base { 25 namespace base {
26 class SequencedTaskRunner; 26 class SequencedTaskRunner;
27 } 27 }
28 28
29 namespace chromeos { 29 namespace chromeos {
30
31 class ActiveDirectoryJoinDelegate;
32
30 namespace attestation { 33 namespace attestation {
31 class AttestationFlow; 34 class AttestationFlow;
32 } 35 }
33 } 36 }
34 37
35 namespace policy { 38 namespace policy {
36 39
37 class DeviceCloudPolicyStoreChromeOS; 40 class DeviceCloudPolicyStoreChromeOS;
38 class DMTokenStorage; 41 class DMTokenStorage;
39 class ServerBackedStateKeysBroker; 42 class ServerBackedStateKeysBroker;
(...skipping 18 matching lines...) Expand all
58 61
59 // |store| and |install_attributes| must remain valid for the life time of the 62 // |store| and |install_attributes| must remain valid for the life time of the
60 // enrollment handler. 63 // enrollment handler.
61 EnrollmentHandlerChromeOS( 64 EnrollmentHandlerChromeOS(
62 DeviceCloudPolicyStoreChromeOS* store, 65 DeviceCloudPolicyStoreChromeOS* store,
63 chromeos::InstallAttributes* install_attributes, 66 chromeos::InstallAttributes* install_attributes,
64 ServerBackedStateKeysBroker* state_keys_broker, 67 ServerBackedStateKeysBroker* state_keys_broker,
65 chromeos::attestation::AttestationFlow* attestation_flow, 68 chromeos::attestation::AttestationFlow* attestation_flow,
66 std::unique_ptr<CloudPolicyClient> client, 69 std::unique_ptr<CloudPolicyClient> client,
67 scoped_refptr<base::SequencedTaskRunner> background_task_runner, 70 scoped_refptr<base::SequencedTaskRunner> background_task_runner,
71 chromeos::ActiveDirectoryJoinDelegate* join_delegate,
68 const EnrollmentConfig& enrollment_config, 72 const EnrollmentConfig& enrollment_config,
69 const std::string& auth_token, 73 const std::string& auth_token,
70 const std::string& client_id, 74 const std::string& client_id,
71 const std::string& requisition, 75 const std::string& requisition,
72 const EnrollmentCallback& completion_callback); 76 const EnrollmentCallback& completion_callback);
73 ~EnrollmentHandlerChromeOS() override; 77 ~EnrollmentHandlerChromeOS() override;
74 78
75 // Starts the enrollment process and reports the result to 79 // Starts the enrollment process and reports the result to
76 // |completion_callback_|. 80 // |completion_callback_|.
77 void StartEnrollment(); 81 void StartEnrollment();
(...skipping 26 matching lines...) Expand all
104 // explicitly to make it easier to read debug logs.) 108 // explicitly to make it easier to read debug logs.)
105 enum EnrollmentStep { 109 enum EnrollmentStep {
106 STEP_PENDING = 0, // Not started yet. 110 STEP_PENDING = 0, // Not started yet.
107 STEP_STATE_KEYS = 1, // Waiting for state keys to become available. 111 STEP_STATE_KEYS = 1, // Waiting for state keys to become available.
108 STEP_LOADING_STORE = 2, // Waiting for |store_| to initialize. 112 STEP_LOADING_STORE = 2, // Waiting for |store_| to initialize.
109 STEP_REGISTRATION = 3, // Currently registering the client. 113 STEP_REGISTRATION = 3, // Currently registering the client.
110 STEP_POLICY_FETCH = 4, // Fetching policy. 114 STEP_POLICY_FETCH = 4, // Fetching policy.
111 STEP_VALIDATION = 5, // Policy validation. 115 STEP_VALIDATION = 5, // Policy validation.
112 STEP_ROBOT_AUTH_FETCH = 6, // Fetching device API auth code. 116 STEP_ROBOT_AUTH_FETCH = 6, // Fetching device API auth code.
113 STEP_ROBOT_AUTH_REFRESH = 7, // Fetching device API refresh token. 117 STEP_ROBOT_AUTH_REFRESH = 7, // Fetching device API refresh token.
114 STEP_LOCK_DEVICE = 8, // Writing installation-time attributes. 118 STEP_AD_DOMAIN_JOIN = 8, // Joining Active Directory domain.
115 STEP_STORE_TOKEN = 9, // Encrypting and storing DM token. 119 STEP_LOCK_DEVICE = 9, // Writing installation-time attributes.
116 STEP_STORE_ROBOT_AUTH = 10, // Encrypting & writing robot refresh token. 120 STEP_STORE_TOKEN = 10, // Encrypting and storing DM token.
117 STEP_STORE_POLICY = 11, // Storing policy and API refresh token. For 121 STEP_STORE_ROBOT_AUTH = 11, // Encrypting & writing robot refresh token.
122 STEP_STORE_POLICY = 12, // Storing policy and API refresh token. For
118 // AD, includes policy fetch via authpolicyd. 123 // AD, includes policy fetch via authpolicyd.
119 STEP_FINISHED = 12, // Enrollment process done, no further action. 124 STEP_FINISHED = 13, // Enrollment process done, no further action.
120 }; 125 };
121 126
122 // Handles the response to a request for server-backed state keys. 127 // Handles the response to a request for server-backed state keys.
123 void HandleStateKeysResult(const std::vector<std::string>& state_keys); 128 void HandleStateKeysResult(const std::vector<std::string>& state_keys);
124 129
125 // Starts attestation based enrollment flow. 130 // Starts attestation based enrollment flow.
126 void StartAttestationBasedEnrollmentFlow(); 131 void StartAttestationBasedEnrollmentFlow();
127 132
128 // Handles the response to a request for a registration certificate. 133 // Handles the response to a request for a registration certificate.
129 void HandleRegistrationCertificateResult( 134 void HandleRegistrationCertificateResult(
130 bool success, 135 bool success,
131 const std::string& pem_certificate_chain); 136 const std::string& pem_certificate_chain);
132 137
133 // Starts registration if the store is initialized. 138 // Starts registration if the store is initialized.
134 void StartRegistration(); 139 void StartRegistration();
135 140
136 // Handles the policy validation result, proceeding with device lock if 141 // Handles the policy validation result, proceeding with device lock if
137 // successful. 142 // successful.
138 void HandlePolicyValidationResult(DeviceCloudPolicyValidator* validator); 143 void HandlePolicyValidationResult(DeviceCloudPolicyValidator* validator);
139 144
145 // Start joining the Active Directory domain in case the device is enrolling
146 // into Active Directory management mode.
147 void StartJoinAdDomain();
148
149 // Handles successful Active Directory domain join.
150 void OnAdDomainJoined(const std::string& realm);
151
140 // Calls InstallAttributes::LockDevice() for enterprise enrollment and 152 // Calls InstallAttributes::LockDevice() for enterprise enrollment and
141 // DeviceSettingsService::SetManagementSettings() for consumer 153 // DeviceSettingsService::SetManagementSettings() for consumer
142 // enrollment. 154 // enrollment.
143 void StartLockDevice(); 155 void StartLockDevice();
144 156
145 // Handle callback from InstallAttributes::LockDevice() and retry on failure. 157 // Handle callback from InstallAttributes::LockDevice() and retry on failure.
146 void HandleLockDeviceResult( 158 void HandleLockDeviceResult(
147 chromeos::InstallAttributes::LockResult lock_result); 159 chromeos::InstallAttributes::LockResult lock_result);
148 160
149 // Initiates storing DM token. For Active Directory devices only. 161 // Initiates storing DM token. For Active Directory devices only.
(...skipping 19 matching lines...) Expand all
169 181
170 // Set |enrollment_step_| to |step|. 182 // Set |enrollment_step_| to |step|.
171 void SetStep(EnrollmentStep step); 183 void SetStep(EnrollmentStep step);
172 184
173 DeviceCloudPolicyStoreChromeOS* store_; 185 DeviceCloudPolicyStoreChromeOS* store_;
174 chromeos::InstallAttributes* install_attributes_; 186 chromeos::InstallAttributes* install_attributes_;
175 ServerBackedStateKeysBroker* state_keys_broker_; 187 ServerBackedStateKeysBroker* state_keys_broker_;
176 chromeos::attestation::AttestationFlow* attestation_flow_; 188 chromeos::attestation::AttestationFlow* attestation_flow_;
177 std::unique_ptr<CloudPolicyClient> client_; 189 std::unique_ptr<CloudPolicyClient> client_;
178 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; 190 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
191 chromeos::ActiveDirectoryJoinDelegate* join_delegate_;
achuithb 2017/02/13 13:39:03 ad_join_delegate_ = nullptr
Roman Sorokin (ftl) 2017/02/14 12:47:10 Done.
179 std::unique_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; 192 std::unique_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_;
180 std::unique_ptr<policy::DMTokenStorage> dm_token_storage_; 193 std::unique_ptr<policy::DMTokenStorage> dm_token_storage_;
181 194
182 EnrollmentConfig enrollment_config_; 195 EnrollmentConfig enrollment_config_;
183 std::string auth_token_; 196 std::string auth_token_;
184 std::string client_id_; 197 std::string client_id_;
185 std::string requisition_; 198 std::string requisition_;
186 EnrollmentCallback completion_callback_; 199 EnrollmentCallback completion_callback_;
187 200
188 // The current state key provided by |state_keys_broker_|. 201 // The current state key provided by |state_keys_broker_|.
189 std::string current_state_key_; 202 std::string current_state_key_;
190 203
191 // The device mode as received in the registration request. 204 // The device mode as received in the registration request.
192 DeviceMode device_mode_; 205 DeviceMode device_mode_ = DEVICE_MODE_NOT_SET;
193 206
194 // Whether the server signaled to skip robot auth setup. 207 // Whether the server signaled to skip robot auth setup.
195 bool skip_robot_auth_; 208 bool skip_robot_auth_ = false;
196 209
197 // The robot account refresh token. 210 // The robot account refresh token.
198 std::string robot_refresh_token_; 211 std::string robot_refresh_token_;
199 212
200 // The validated policy response info to be installed in the store. 213 // The validated policy response info to be installed in the store.
201 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy_; 214 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy_;
202 std::string domain_; 215 std::string domain_;
216 std::string realm_;
203 std::string device_id_; 217 std::string device_id_;
204 218
205 // Current enrollment step. 219 // Current enrollment step.
206 EnrollmentStep enrollment_step_; 220 EnrollmentStep enrollment_step_;
207 221
208 // Total amount of time in milliseconds spent waiting for lockbox 222 // Total amount of time in milliseconds spent waiting for lockbox
209 // initialization. 223 // initialization.
210 int lockbox_init_duration_; 224 int lockbox_init_duration_ = 0;
211 225
212 base::WeakPtrFactory<EnrollmentHandlerChromeOS> weak_ptr_factory_; 226 base::WeakPtrFactory<EnrollmentHandlerChromeOS> weak_ptr_factory_;
213 227
214 DISALLOW_COPY_AND_ASSIGN(EnrollmentHandlerChromeOS); 228 DISALLOW_COPY_AND_ASSIGN(EnrollmentHandlerChromeOS);
215 }; 229 };
216 230
217 } // namespace policy 231 } // namespace policy
218 232
219 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_HANDLER_CHROMEOS_H_ 233 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_HANDLER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698