| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/login/supervised/supervised_user_creation_cont
roller_new.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_cont
roller_new.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" | 17 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" |
| 18 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" | 18 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" |
| 19 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 19 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 20 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 20 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 22 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/application_lifetime.h" |
| 23 #include "chrome/browser/sync/profile_sync_service.h" | 23 #include "chrome/browser/sync/profile_sync_service.h" |
| 24 #include "chrome/browser/sync/profile_sync_service_factory.h" | 24 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 25 #include "chromeos/cryptohome/cryptohome_parameters.h" | 25 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 26 #include "chromeos/dbus/dbus_thread_manager.h" | 26 #include "chromeos/dbus/dbus_thread_manager.h" |
| 27 #include "chromeos/dbus/session_manager_client.h" | 27 #include "chromeos/dbus/session_manager_client.h" |
| 28 #include "chromeos/login/auth/key.h" | 28 #include "chromeos/login/auth/key.h" |
| 29 #include "chromeos/login/auth/user_context.h" | 29 #include "chromeos/login/auth/user_context.h" |
| 30 #include "components/signin/core/account_id/account_id.h" | |
| 31 #include "components/user_manager/user.h" | 30 #include "components/user_manager/user.h" |
| 32 #include "components/user_manager/user_manager.h" | 31 #include "components/user_manager/user_manager.h" |
| 33 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
| 35 #include "crypto/random.h" | 34 #include "crypto/random.h" |
| 36 #include "google_apis/gaia/google_service_auth_error.h" | 35 #include "google_apis/gaia/google_service_auth_error.h" |
| 37 | 36 |
| 38 namespace chromeos { | 37 namespace chromeos { |
| 39 | 38 |
| 40 namespace { | 39 namespace { |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 base::Base64Decode(creation_context_->signature_key, &signature_key); | 280 base::Base64Decode(creation_context_->signature_key, &signature_key); |
| 282 password_key.authorization_data.push_back( | 281 password_key.authorization_data.push_back( |
| 283 cryptohome::KeyDefinition::AuthorizationData(false /* encrypt */, | 282 cryptohome::KeyDefinition::AuthorizationData(false /* encrypt */, |
| 284 true /* sign */, | 283 true /* sign */, |
| 285 signature_key)); | 284 signature_key)); |
| 286 | 285 |
| 287 Key key(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, | 286 Key key(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, |
| 288 std::string(), // The salt is stored elsewhere. | 287 std::string(), // The salt is stored elsewhere. |
| 289 creation_context_->salted_master_key); | 288 creation_context_->salted_master_key); |
| 290 key.SetLabel(kCryptohomeMasterKeyLabel); | 289 key.SetLabel(kCryptohomeMasterKeyLabel); |
| 291 UserContext context( | 290 UserContext context(creation_context_->local_user_id); |
| 292 AccountId::FromUserEmail(creation_context_->local_user_id)); | |
| 293 context.SetKey(key); | 291 context.SetKey(key); |
| 294 context.SetIsUsingOAuth(false); | 292 context.SetIsUsingOAuth(false); |
| 295 | 293 |
| 296 authenticator_->AddKey( | 294 authenticator_->AddKey( |
| 297 context, | 295 context, |
| 298 password_key, | 296 password_key, |
| 299 true, | 297 true, |
| 300 base::Bind(&SupervisedUserCreationControllerNew::OnAddKeySuccess, | 298 base::Bind(&SupervisedUserCreationControllerNew::OnAddKeySuccess, |
| 301 weak_factory_.GetWeakPtr())); | 299 weak_factory_.GetWeakPtr())); |
| 302 } | 300 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 374 |
| 377 if (!success) { | 375 if (!success) { |
| 378 stage_ = STAGE_ERROR; | 376 stage_ = STAGE_ERROR; |
| 379 if (consumer_) | 377 if (consumer_) |
| 380 consumer_->OnCreationError(TOKEN_WRITE_FAILED); | 378 consumer_->OnCreationError(TOKEN_WRITE_FAILED); |
| 381 return; | 379 return; |
| 382 } | 380 } |
| 383 // Assume that new token is valid. It will be automatically invalidated if | 381 // Assume that new token is valid. It will be automatically invalidated if |
| 384 // sync service fails to use it. | 382 // sync service fails to use it. |
| 385 user_manager::UserManager::Get()->SaveUserOAuthStatus( | 383 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
| 386 AccountId::FromUserEmail(creation_context_->local_user_id), | 384 creation_context_->local_user_id, |
| 387 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 385 user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
| 388 | 386 |
| 389 stage_ = TOKEN_WRITTEN; | 387 stage_ = TOKEN_WRITTEN; |
| 390 | 388 |
| 391 timeout_timer_.Stop(); | 389 timeout_timer_.Stop(); |
| 392 ChromeUserManager::Get() | 390 ChromeUserManager::Get() |
| 393 ->GetSupervisedUserManager() | 391 ->GetSupervisedUserManager() |
| 394 ->CommitCreationTransaction(); | 392 ->CommitCreationTransaction(); |
| 395 content::RecordAction( | 393 content::RecordAction( |
| 396 base::UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); | 394 base::UserMetricsAction("ManagedMode_LocallyManagedUserCreated")); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 415 creation_context_->registration_utility.reset(); | 413 creation_context_->registration_utility.reset(); |
| 416 chrome::AttemptUserExit(); | 414 chrome::AttemptUserExit(); |
| 417 } | 415 } |
| 418 | 416 |
| 419 std::string SupervisedUserCreationControllerNew::GetSupervisedUserId() { | 417 std::string SupervisedUserCreationControllerNew::GetSupervisedUserId() { |
| 420 DCHECK(creation_context_); | 418 DCHECK(creation_context_); |
| 421 return creation_context_->local_user_id; | 419 return creation_context_->local_user_id; |
| 422 } | 420 } |
| 423 | 421 |
| 424 } // namespace chromeos | 422 } // namespace chromeos |
| OLD | NEW |