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

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

Issue 296773002: Add a Key class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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 _old.h" 5 #include "chrome/browser/chromeos/login/managed/managed_user_creation_controller _old.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/auth/key.h"
16 #include "chrome/browser/chromeos/login/auth/mount_manager.h" 17 #include "chrome/browser/chromeos/login/auth/mount_manager.h"
18 #include "chrome/browser/chromeos/login/auth/user_context.h"
17 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h " 19 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h "
18 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h " 20 #include "chrome/browser/chromeos/login/managed/supervised_user_authentication.h "
19 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 21 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
20 #include "chrome/browser/chromeos/login/users/user.h" 22 #include "chrome/browser/chromeos/login/users/user.h"
21 #include "chrome/browser/chromeos/login/users/user_manager.h" 23 #include "chrome/browser/chromeos/login/users/user_manager.h"
22 #include "chrome/browser/lifetime/application_lifetime.h" 24 #include "chrome/browser/lifetime/application_lifetime.h"
23 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
24 #include "chrome/browser/sync/profile_sync_service_factory.h" 26 #include "chrome/browser/sync/profile_sync_service_factory.h"
25 #include "chromeos/dbus/dbus_thread_manager.h" 27 #include "chromeos/dbus/dbus_thread_manager.h"
26 #include "chromeos/dbus/session_manager_client.h" 28 #include "chromeos/dbus/session_manager_client.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 manager->SetCreationTransactionUserId(creation_context_->local_user_id); 154 manager->SetCreationTransactionUserId(creation_context_->local_user_id);
153 SupervisedUserAuthentication* authentication = manager->GetAuthentication(); 155 SupervisedUserAuthentication* authentication = manager->GetAuthentication();
154 base::DictionaryValue extra; 156 base::DictionaryValue extra;
155 if (authentication->FillDataForNewUser(creation_context_->local_user_id, 157 if (authentication->FillDataForNewUser(creation_context_->local_user_id,
156 creation_context_->password, 158 creation_context_->password,
157 &creation_context_->password_data, 159 &creation_context_->password_data,
158 &extra)) { 160 &extra)) {
159 authentication->StorePasswordData(creation_context_->local_user_id, 161 authentication->StorePasswordData(creation_context_->local_user_id,
160 creation_context_->password_data); 162 creation_context_->password_data);
161 } 163 }
164
162 VLOG(1) << "Creating cryptohome"; 165 VLOG(1) << "Creating cryptohome";
166
167 UserContext context(creation_context_->local_user_id);
168 context.SetKey(Key(creation_context_->password));
163 authenticator_ = new ManagedUserAuthenticator(this); 169 authenticator_ = new ManagedUserAuthenticator(this);
164 authenticator_->AuthenticateToCreate( 170 authenticator_->AuthenticateToCreate(
165 creation_context_->local_user_id, 171 context.GetUserID(),
166 authentication->TransformPassword(creation_context_->local_user_id, 172 authentication->TransformKey(context).GetKey()->GetSecret());
167 creation_context_->password));
168 } 173 }
169 174
170 void ManagedUserCreationControllerOld::OnAuthenticationFailure( 175 void ManagedUserCreationControllerOld::OnAuthenticationFailure(
171 ManagedUserAuthenticator::AuthState error) { 176 ManagedUserAuthenticator::AuthState error) {
172 timeout_timer_.Stop(); 177 timeout_timer_.Stop();
173 ErrorCode code = NO_ERROR; 178 ErrorCode code = NO_ERROR;
174 switch (error) { 179 switch (error) {
175 case ManagedUserAuthenticator::NO_MOUNT: 180 case ManagedUserAuthenticator::NO_MOUNT:
176 code = CRYPTOHOME_NO_MOUNT; 181 code = CRYPTOHOME_NO_MOUNT;
177 break; 182 break;
(...skipping 17 matching lines...) Expand all
195 SupervisedUserAuthentication* authentication = 200 SupervisedUserAuthentication* authentication =
196 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); 201 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication();
197 202
198 if (creation_context_->creation_type == NEW_USER) { 203 if (creation_context_->creation_type == NEW_USER) {
199 // Generate master password. 204 // Generate master password.
200 creation_context_->master_key = authentication->GenerateMasterKey(); 205 creation_context_->master_key = authentication->GenerateMasterKey();
201 } 206 }
202 207
203 VLOG(1) << "Adding master key"; 208 VLOG(1) << "Adding master key";
204 209
210 UserContext context(creation_context_->local_user_id);
211 context.SetKey(Key(creation_context_->password));
205 authenticator_->AddMasterKey( 212 authenticator_->AddMasterKey(
206 creation_context_->local_user_id, 213 creation_context_->local_user_id,
207 authentication->TransformPassword(creation_context_->local_user_id, 214 authentication->TransformKey(context).GetKey()->GetSecret(),
208 creation_context_->password),
209 creation_context_->master_key); 215 creation_context_->master_key);
210 } 216 }
211 217
212 void ManagedUserCreationControllerOld::OnAddKeySuccess() { 218 void ManagedUserCreationControllerOld::OnAddKeySuccess() {
213 creation_context_->registration_utility = 219 creation_context_->registration_utility =
214 ManagedUserRegistrationUtility::Create( 220 ManagedUserRegistrationUtility::Create(
215 creation_context_->manager_profile); 221 creation_context_->manager_profile);
216 222
217 VLOG(1) << "Creating user on server"; 223 VLOG(1) << "Creating user on server";
218 // TODO(antrim) : add password data to sync once API is ready. 224 // TODO(antrim) : add password data to sync once API is ready.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 // Assume that new token is valid. It will be automatically invalidated if 299 // Assume that new token is valid. It will be automatically invalidated if
294 // sync service fails to use it. 300 // sync service fails to use it.
295 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, 301 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id,
296 User::OAUTH2_TOKEN_STATUS_VALID); 302 User::OAUTH2_TOKEN_STATUS_VALID);
297 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction(); 303 UserManager::Get()->GetSupervisedUserManager()->CommitCreationTransaction();
298 if (consumer_) 304 if (consumer_)
299 consumer_->OnCreationSuccess(); 305 consumer_->OnCreationSuccess();
300 } 306 }
301 307
302 } // namespace chromeos 308 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698