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

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

Issue 101283003: Add first implemenation for SU password sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years 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 (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/login/managed/locally_managed_user_creation_co ntroller.h" 5 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_co ntroller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/sys_info.h" 12 #include "base/sys_info.h"
13 #include "base/task_runner_util.h" 13 #include "base/task_runner_util.h"
14 #include "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h " 16 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h "
17 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h "
17 #include "chrome/browser/chromeos/login/mount_manager.h" 18 #include "chrome/browser/chromeos/login/mount_manager.h"
18 #include "chrome/browser/chromeos/login/supervised_user_manager.h" 19 #include "chrome/browser/chromeos/login/supervised_user_manager.h"
19 #include "chrome/browser/chromeos/login/user.h" 20 #include "chrome/browser/chromeos/login/user.h"
20 #include "chrome/browser/chromeos/login/user_manager.h" 21 #include "chrome/browser/chromeos/login/user_manager.h"
21 #include "chrome/browser/lifetime/application_lifetime.h" 22 #include "chrome/browser/lifetime/application_lifetime.h"
22 #include "chrome/browser/sync/profile_sync_service.h" 23 #include "chrome/browser/sync/profile_sync_service.h"
23 #include "chrome/browser/sync/profile_sync_service_factory.h" 24 #include "chrome/browser/sync/profile_sync_service_factory.h"
24 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
25 #include "chromeos/dbus/session_manager_client.h" 26 #include "chromeos/dbus/session_manager_client.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 ManagedUserRegistrationUtility::GenerateNewManagedUserId(); 143 ManagedUserRegistrationUtility::GenerateNewManagedUserId();
143 } 144 }
144 145
145 manager->CreateUserRecord( 146 manager->CreateUserRecord(
146 creation_context_->manager_id, 147 creation_context_->manager_id,
147 creation_context_->local_user_id, 148 creation_context_->local_user_id,
148 creation_context_->sync_user_id, 149 creation_context_->sync_user_id,
149 creation_context_->display_name); 150 creation_context_->display_name);
150 151
151 manager->SetCreationTransactionUserId(creation_context_->local_user_id); 152 manager->SetCreationTransactionUserId(creation_context_->local_user_id);
153 SupervisedUserAuthentication* authentication =
154 manager->GetSupervisedUserAuthentication();
155 if (authentication->FillDataForNewUser(
156 creation_context_->local_user_id,
Nikita (slow) 2013/12/09 16:42:16 nit: Please move parameter to prev line and align
Denis Kuznetsov (DE-MUC) 2013/12/12 19:45:24 Done.
157 creation_context_->password,
158 &creation_context_->password_data)) {
159 authentication->StorePasswordData(creation_context_->local_user_id,
160 creation_context_->password_data);
161 }
152 VLOG(1) << "Creating cryptohome"; 162 VLOG(1) << "Creating cryptohome";
153 authenticator_ = new ManagedUserAuthenticator(this); 163 authenticator_ = new ManagedUserAuthenticator(this);
154 authenticator_->AuthenticateToCreate(creation_context_->local_user_id, 164 authenticator_->AuthenticateToCreate(
Nikita (slow) 2013/12/09 16:42:16 nit: Can you please change alignment in the same w
Denis Kuznetsov (DE-MUC) 2013/12/12 19:45:24 Done.
155 creation_context_->password); 165 creation_context_->local_user_id,
166 authentication->TransformPassword(
167 creation_context_->local_user_id,
168 creation_context_->password));
156 } 169 }
157 170
158 void LocallyManagedUserCreationController::OnAuthenticationFailure( 171 void LocallyManagedUserCreationController::OnAuthenticationFailure(
159 ManagedUserAuthenticator::AuthState error) { 172 ManagedUserAuthenticator::AuthState error) {
160 timeout_timer_.Stop(); 173 timeout_timer_.Stop();
161 ErrorCode code = NO_ERROR; 174 ErrorCode code = NO_ERROR;
162 switch (error) { 175 switch (error) {
163 case ManagedUserAuthenticator::NO_MOUNT: 176 case ManagedUserAuthenticator::NO_MOUNT:
164 code = CRYPTOHOME_NO_MOUNT; 177 code = CRYPTOHOME_NO_MOUNT;
165 break; 178 break;
(...skipping 17 matching lines...) Expand all
183 if (creation_context_->creation_type == NEW_USER) { 196 if (creation_context_->creation_type == NEW_USER) {
184 // Generate master password. 197 // Generate master password.
185 char master_key_bytes[kMasterKeySize]; 198 char master_key_bytes[kMasterKeySize];
186 crypto::RandBytes(&master_key_bytes, sizeof(master_key_bytes)); 199 crypto::RandBytes(&master_key_bytes, sizeof(master_key_bytes));
187 creation_context_->master_key = StringToLowerASCII(base::HexEncode( 200 creation_context_->master_key = StringToLowerASCII(base::HexEncode(
188 reinterpret_cast<const void*>(master_key_bytes), 201 reinterpret_cast<const void*>(master_key_bytes),
189 sizeof(master_key_bytes))); 202 sizeof(master_key_bytes)));
190 } 203 }
191 204
192 VLOG(1) << "Adding master key"; 205 VLOG(1) << "Adding master key";
193 authenticator_->AddMasterKey(creation_context_->local_user_id, 206 SupervisedUserAuthentication* authentication = UserManager::Get()->
194 creation_context_->password, 207 GetSupervisedUserManager()->GetSupervisedUserAuthentication();
195 creation_context_->master_key); 208
209 authenticator_->AddMasterKey(
Nikita (slow) 2013/12/09 16:42:16 nit: Can you please change alignment in the same w
Denis Kuznetsov (DE-MUC) 2013/12/12 19:45:24 Done.
210 creation_context_->local_user_id,
211 authentication->TransformPassword(
212 creation_context_->local_user_id,
213 creation_context_->password),
214 creation_context_->master_key);
196 } 215 }
197 216
198 void LocallyManagedUserCreationController::OnAddKeySuccess() { 217 void LocallyManagedUserCreationController::OnAddKeySuccess() {
199 creation_context_->registration_utility = 218 creation_context_->registration_utility =
200 ManagedUserRegistrationUtility::Create( 219 ManagedUserRegistrationUtility::Create(
201 creation_context_->manager_profile); 220 creation_context_->manager_profile);
202 221
203 VLOG(1) << "Creating user on server"; 222 VLOG(1) << "Creating user on server";
223 // TODO(antrim) : add password data to sync once API is ready.
Nikita (slow) 2013/12/09 16:42:16 nit: Bug # is missing. Just to make sure that we'r
Denis Kuznetsov (DE-MUC) 2013/12/12 19:45:24 Done.
204 ManagedUserRegistrationInfo info(creation_context_->display_name, 224 ManagedUserRegistrationInfo info(creation_context_->display_name,
205 creation_context_->avatar_index); 225 creation_context_->avatar_index);
206 info.master_key = creation_context_->master_key; 226 info.master_key = creation_context_->master_key;
207 timeout_timer_.Stop(); 227 timeout_timer_.Stop();
208 creation_context_->registration_utility->Register( 228 creation_context_->registration_utility->Register(
209 creation_context_->sync_user_id, 229 creation_context_->sync_user_id,
210 info, 230 info,
211 base::Bind(&LocallyManagedUserCreationController::RegistrationCallback, 231 base::Bind(&LocallyManagedUserCreationController::RegistrationCallback,
212 weak_factory_.GetWeakPtr())); 232 weak_factory_.GetWeakPtr()));
213 } 233 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // sync service fails to use it. 300 // sync service fails to use it.
281 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, 301 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id,
282 User::OAUTH2_TOKEN_STATUS_VALID); 302 User::OAUTH2_TOKEN_STATUS_VALID);
283 UserManager::Get()->GetSupervisedUserManager()-> 303 UserManager::Get()->GetSupervisedUserManager()->
284 CommitCreationTransaction(); 304 CommitCreationTransaction();
285 if (consumer_) 305 if (consumer_)
286 consumer_->OnCreationSuccess(); 306 consumer_->OnCreationSuccess();
287 } 307 }
288 308
289 } // namespace chromeos 309 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698