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

Side by Side Diff: chrome/browser/chromeos/login/managed/managed_user_creation_controller_new.cc

Issue 335833003: Rename "managed (mode|user)" to "supervised user" (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments (+ a few other cleanups) Created 6 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 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/managed/managed_user_creation_controller _new.h" 5 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 27 matching lines...) Expand all
38 namespace { 38 namespace {
39 39
40 const int kUserCreationTimeoutSeconds = 30; // 30 seconds. 40 const int kUserCreationTimeoutSeconds = 30; // 30 seconds.
41 41
42 bool StoreManagedUserFiles(const std::string& token, 42 bool StoreManagedUserFiles(const std::string& token,
43 const base::FilePath& base_path) { 43 const base::FilePath& base_path) {
44 if (!base::SysInfo::IsRunningOnChromeOS()) { 44 if (!base::SysInfo::IsRunningOnChromeOS()) {
45 // If running on desktop, cryptohome stub does not create home directory. 45 // If running on desktop, cryptohome stub does not create home directory.
46 base::CreateDirectory(base_path); 46 base::CreateDirectory(base_path);
47 } 47 }
48 base::FilePath token_file = base_path.Append(kManagedUserTokenFilename); 48 base::FilePath token_file = base_path.Append(kSupervisedUserTokenFilename);
49 int bytes = base::WriteFile(token_file, token.c_str(), token.length()); 49 int bytes = base::WriteFile(token_file, token.c_str(), token.length());
50 return bytes >= 0; 50 return bytes >= 0;
51 } 51 }
52 52
53 } // namespace 53 } // namespace
54 54
55 ManagedUserCreationControllerNew::ManagedUserCreationControllerNew( 55 ManagedUserCreationControllerNew::ManagedUserCreationControllerNew(
56 ManagedUserCreationControllerNew::StatusConsumer* consumer, 56 ManagedUserCreationControllerNew::StatusConsumer* consumer,
57 const std::string& manager_id) 57 const std::string& manager_id)
58 : ManagedUserCreationController(consumer), 58 : ManagedUserCreationController(consumer),
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 VLOG(1) << "Starting supervised user creation"; 145 VLOG(1) << "Starting supervised user creation";
146 VLOG(1) << " Phase 1 : Prepare keys"; 146 VLOG(1) << " Phase 1 : Prepare keys";
147 147
148 SupervisedUserManager* manager = 148 SupervisedUserManager* manager =
149 UserManager::Get()->GetSupervisedUserManager(); 149 UserManager::Get()->GetSupervisedUserManager();
150 manager->StartCreationTransaction(creation_context_->display_name); 150 manager->StartCreationTransaction(creation_context_->display_name);
151 151
152 creation_context_->local_user_id = manager->GenerateUserId(); 152 creation_context_->local_user_id = manager->GenerateUserId();
153 if (creation_context_->creation_type == NEW_USER) { 153 if (creation_context_->creation_type == NEW_USER) {
154 creation_context_->sync_user_id = 154 creation_context_->sync_user_id =
155 ManagedUserRegistrationUtility::GenerateNewManagedUserId(); 155 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId();
156 } 156 }
157 157
158 manager->SetCreationTransactionUserId(creation_context_->local_user_id); 158 manager->SetCreationTransactionUserId(creation_context_->local_user_id);
159 159
160 stage_ = TRANSACTION_STARTED; 160 stage_ = TRANSACTION_STARTED;
161 161
162 manager->CreateUserRecord(creation_context_->manager_id, 162 manager->CreateUserRecord(creation_context_->manager_id,
163 creation_context_->local_user_id, 163 creation_context_->local_user_id,
164 creation_context_->sync_user_id, 164 creation_context_->sync_user_id,
165 creation_context_->display_name); 165 creation_context_->display_name);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 void ManagedUserCreationControllerNew::OnMountSuccess( 256 void ManagedUserCreationControllerNew::OnMountSuccess(
257 const std::string& mount_hash) { 257 const std::string& mount_hash) {
258 DCHECK(creation_context_); 258 DCHECK(creation_context_);
259 DCHECK_EQ(KEYS_GENERATED, stage_); 259 DCHECK_EQ(KEYS_GENERATED, stage_);
260 VLOG(1) << " Phase 2.2 : Created home dir with master key"; 260 VLOG(1) << " Phase 2.2 : Created home dir with master key";
261 261
262 creation_context_->mount_hash = mount_hash; 262 creation_context_->mount_hash = mount_hash;
263 263
264 // Plain text password, hashed and salted with individual salt. 264 // Plain text password, hashed and salted with individual salt.
265 // It can be used for mounting homedir, and can be replaced only when signed. 265 // It can be used for mounting homedir, and can be replaced only when signed.
266 cryptohome::KeyDefinition password_key(creation_context_->salted_password, 266 cryptohome::KeyDefinition password_key(
267 kCryptohomeManagedUserKeyLabel, 267 creation_context_->salted_password,
268 kCryptohomeManagedUserKeyPrivileges); 268 kCryptohomeSupervisedUserKeyLabel,
269 kCryptohomeSupervisedUserKeyPrivileges);
269 base::Base64Decode(creation_context_->encryption_key, 270 base::Base64Decode(creation_context_->encryption_key,
270 &password_key.encryption_key); 271 &password_key.encryption_key);
271 base::Base64Decode(creation_context_->signature_key, 272 base::Base64Decode(creation_context_->signature_key,
272 &password_key.signature_key); 273 &password_key.signature_key);
273 274
274 Key key(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, 275 Key key(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234,
275 std::string(), // The salt is stored elsewhere. 276 std::string(), // The salt is stored elsewhere.
276 creation_context_->salted_master_key); 277 creation_context_->salted_master_key);
277 key.SetLabel(kCryptohomeMasterKeyLabel); 278 key.SetLabel(kCryptohomeMasterKeyLabel);
278 UserContext context(creation_context_->local_user_id); 279 UserContext context(creation_context_->local_user_id);
(...skipping 18 matching lines...) Expand all
297 ProfileSyncService* sync_service = 298 ProfileSyncService* sync_service =
298 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 299 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
299 creation_context_->manager_profile); 300 creation_context_->manager_profile);
300 ProfileSyncService::SyncStatusSummary status = 301 ProfileSyncService::SyncStatusSummary status =
301 sync_service->QuerySyncStatusSummary(); 302 sync_service->QuerySyncStatusSummary();
302 303
303 if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED) 304 if (status == ProfileSyncService::DATATYPES_NOT_INITIALIZED)
304 consumer_->OnLongCreationWarning(); 305 consumer_->OnLongCreationWarning();
305 306
306 creation_context_->registration_utility = 307 creation_context_->registration_utility =
307 ManagedUserRegistrationUtility::Create( 308 SupervisedUserRegistrationUtility::Create(
308 creation_context_->manager_profile); 309 creation_context_->manager_profile);
309 310
310 ManagedUserRegistrationInfo info(creation_context_->display_name, 311 SupervisedUserRegistrationInfo info(creation_context_->display_name,
311 creation_context_->avatar_index); 312 creation_context_->avatar_index);
312 info.master_key = creation_context_->master_key; 313 info.master_key = creation_context_->master_key;
313 info.password_signature_key = creation_context_->signature_key; 314 info.password_signature_key = creation_context_->signature_key;
314 info.password_encryption_key = creation_context_->encryption_key; 315 info.password_encryption_key = creation_context_->encryption_key;
315 316
316 info.password_data.MergeDictionary(&creation_context_->password_data); 317 info.password_data.MergeDictionary(&creation_context_->password_data);
317 318
318 // Registration utility will update user data if user already exist. 319 // Registration utility will update user data if user already exist.
319 creation_context_->registration_utility->Register( 320 creation_context_->registration_utility->Register(
320 creation_context_->sync_user_id, 321 creation_context_->sync_user_id,
321 info, 322 info,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 creation_context_->registration_utility.reset(); 393 creation_context_->registration_utility.reset();
393 chrome::AttemptUserExit(); 394 chrome::AttemptUserExit();
394 } 395 }
395 396
396 std::string ManagedUserCreationControllerNew::GetManagedUserId() { 397 std::string ManagedUserCreationControllerNew::GetManagedUserId() {
397 DCHECK(creation_context_); 398 DCHECK(creation_context_);
398 return creation_context_->local_user_id; 399 return creation_context_->local_user_id;
399 } 400 }
400 401
401 } // namespace chromeos 402 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698