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/user_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/location.h" | 14 #include "base/location.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
21 #include "chrome/browser/chromeos/policy/user_policy_token_loader.h" | 21 #include "chrome/browser/chromeos/policy/user_policy_token_loader.h" |
22 #include "chrome/browser/lifetime/application_lifetime.h" | |
22 #include "chromeos/cryptohome/cryptohome_parameters.h" | 23 #include "chromeos/cryptohome/cryptohome_parameters.h" |
23 #include "chromeos/dbus/cryptohome_client.h" | 24 #include "chromeos/dbus/cryptohome_client.h" |
24 #include "chromeos/dbus/session_manager_client.h" | |
25 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 25 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
26 #include "components/policy/proto/cloud_policy.pb.h" | 26 #include "components/policy/proto/cloud_policy.pb.h" |
27 #include "components/policy/proto/device_management_local.pb.h" | 27 #include "components/policy/proto/device_management_local.pb.h" |
28 #include "google_apis/gaia/gaia_auth_util.h" | 28 #include "google_apis/gaia/gaia_auth_util.h" |
29 | 29 |
30 namespace em = enterprise_management; | 30 namespace em = enterprise_management; |
31 | 31 |
32 namespace policy { | 32 namespace policy { |
33 | 33 |
34 namespace { | 34 namespace { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 } else { | 207 } else { |
208 // Load the policy right after storing it, to make sure it was accepted by | 208 // Load the policy right after storing it, to make sure it was accepted by |
209 // the session manager. An additional validation is performed after the | 209 // the session manager. An additional validation is performed after the |
210 // load; reload the key for that validation too, in case it was rotated. | 210 // load; reload the key for that validation too, in case it was rotated. |
211 ReloadPolicyKey(base::Bind(&UserCloudPolicyStoreChromeOS::Load, | 211 ReloadPolicyKey(base::Bind(&UserCloudPolicyStoreChromeOS::Load, |
212 weak_factory_.GetWeakPtr())); | 212 weak_factory_.GetWeakPtr())); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 void UserCloudPolicyStoreChromeOS::OnPolicyRetrieved( | 216 void UserCloudPolicyStoreChromeOS::OnPolicyRetrieved( |
217 const std::string& policy_blob) { | 217 const std::string& policy_blob, |
218 const chromeos::SessionManagerClient::RetrievePolicyResponseType& | |
219 response_type) { | |
220 // Disallow the sign in when the error is dbus_error::kSessionDoesNotExist | |
emaxx
2017/04/18 15:03:17
nit: Please rephrase the comment to be explanatory
igorcov
2017/04/20 14:52:29
Done.
| |
221 // from session manager. | |
222 // TODO(igorcov): crbug/689206. Find the root cause for the behavior that | |
emaxx
2017/04/18 15:03:17
nit: Is this TODO really needed here? I thought th
igorcov
2017/04/20 14:52:29
Done.
| |
223 // makes Chrome request the user policy before the session is started. | |
224 if (response_type == chromeos::SessionManagerClient:: | |
225 RetrievePolicyResponseType::SESSION_DOES_NOT_EXIST) { | |
226 chrome::AttemptUserExit(); | |
227 return; | |
228 } | |
229 | |
218 if (policy_blob.empty()) { | 230 if (policy_blob.empty()) { |
219 // session_manager doesn't have policy. Adjust internal state and notify | 231 // session_manager doesn't have policy. Adjust internal state and notify |
220 // the world about the policy update. | 232 // the world about the policy update. |
221 policy_map_.Clear(); | 233 policy_map_.Clear(); |
222 policy_.reset(); | 234 policy_.reset(); |
223 policy_signature_public_key_.clear(); | 235 policy_signature_public_key_.clear(); |
224 NotifyStoreLoaded(); | 236 NotifyStoreLoaded(); |
225 return; | 237 return; |
226 } | 238 } |
227 | 239 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 validator->ValidateUsername(account_id_.GetUserEmail(), true); | 387 validator->ValidateUsername(account_id_.GetUserEmail(), true); |
376 // The policy loaded from session manager need not be validated using the | 388 // The policy loaded from session manager need not be validated using the |
377 // verification key since it is secure, and since there may be legacy policy | 389 // verification key since it is secure, and since there may be legacy policy |
378 // data that was stored without a verification key. | 390 // data that was stored without a verification key. |
379 validator->ValidateSignature(cached_policy_key_); | 391 validator->ValidateSignature(cached_policy_key_); |
380 } | 392 } |
381 return validator; | 393 return validator; |
382 } | 394 } |
383 | 395 |
384 } // namespace policy | 396 } // namespace policy |
OLD | NEW |