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/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 Loading... | |
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 = manager->GetAuthentication(); | |
154 if (authentication->FillDataForNewUser(creation_context_->local_user_id, | |
155 creation_context_->password, | |
156 &creation_context_->password_data)) { | |
157 authentication->StorePasswordData(creation_context_->local_user_id, | |
158 creation_context_->password_data); | |
159 } | |
152 VLOG(1) << "Creating cryptohome"; | 160 VLOG(1) << "Creating cryptohome"; |
153 authenticator_ = new ManagedUserAuthenticator(this); | 161 authenticator_ = new ManagedUserAuthenticator(this); |
154 authenticator_->AuthenticateToCreate(creation_context_->local_user_id, | 162 authenticator_->AuthenticateToCreate(creation_context_->local_user_id, |
155 creation_context_->password); | 163 authentication->TransformPassword( |
164 creation_context_->local_user_id, | |
165 creation_context_->password)); | |
156 } | 166 } |
157 | 167 |
158 void LocallyManagedUserCreationController::OnAuthenticationFailure( | 168 void LocallyManagedUserCreationController::OnAuthenticationFailure( |
159 ManagedUserAuthenticator::AuthState error) { | 169 ManagedUserAuthenticator::AuthState error) { |
160 timeout_timer_.Stop(); | 170 timeout_timer_.Stop(); |
161 ErrorCode code = NO_ERROR; | 171 ErrorCode code = NO_ERROR; |
162 switch (error) { | 172 switch (error) { |
163 case ManagedUserAuthenticator::NO_MOUNT: | 173 case ManagedUserAuthenticator::NO_MOUNT: |
164 code = CRYPTOHOME_NO_MOUNT; | 174 code = CRYPTOHOME_NO_MOUNT; |
165 break; | 175 break; |
(...skipping 17 matching lines...) Expand all Loading... | |
183 if (creation_context_->creation_type == NEW_USER) { | 193 if (creation_context_->creation_type == NEW_USER) { |
184 // Generate master password. | 194 // Generate master password. |
185 char master_key_bytes[kMasterKeySize]; | 195 char master_key_bytes[kMasterKeySize]; |
186 crypto::RandBytes(&master_key_bytes, sizeof(master_key_bytes)); | 196 crypto::RandBytes(&master_key_bytes, sizeof(master_key_bytes)); |
187 creation_context_->master_key = StringToLowerASCII(base::HexEncode( | 197 creation_context_->master_key = StringToLowerASCII(base::HexEncode( |
188 reinterpret_cast<const void*>(master_key_bytes), | 198 reinterpret_cast<const void*>(master_key_bytes), |
189 sizeof(master_key_bytes))); | 199 sizeof(master_key_bytes))); |
190 } | 200 } |
191 | 201 |
192 VLOG(1) << "Adding master key"; | 202 VLOG(1) << "Adding master key"; |
203 SupervisedUserAuthentication* authentication = UserManager::Get()-> | |
204 GetSupervisedUserManager()->GetAuthentication(); | |
205 | |
193 authenticator_->AddMasterKey(creation_context_->local_user_id, | 206 authenticator_->AddMasterKey(creation_context_->local_user_id, |
194 creation_context_->password, | 207 authentication->TransformPassword( |
208 creation_context_->local_user_id, | |
209 creation_context_->password), | |
195 creation_context_->master_key); | 210 creation_context_->master_key); |
196 } | 211 } |
197 | 212 |
198 void LocallyManagedUserCreationController::OnAddKeySuccess() { | 213 void LocallyManagedUserCreationController::OnAddKeySuccess() { |
199 creation_context_->registration_utility = | 214 creation_context_->registration_utility = |
200 ManagedUserRegistrationUtility::Create( | 215 ManagedUserRegistrationUtility::Create( |
201 creation_context_->manager_profile); | 216 creation_context_->manager_profile); |
202 | 217 |
203 VLOG(1) << "Creating user on server"; | 218 VLOG(1) << "Creating user on server"; |
219 // TODO(antrim) : add password data to sync once API is ready (crbug/316168). | |
Bernhard Bauer
2013/12/19 18:09:58
Nit: If you write it as crbug.com/316168, it's eas
| |
204 ManagedUserRegistrationInfo info(creation_context_->display_name, | 220 ManagedUserRegistrationInfo info(creation_context_->display_name, |
205 creation_context_->avatar_index); | 221 creation_context_->avatar_index); |
206 info.master_key = creation_context_->master_key; | 222 info.master_key = creation_context_->master_key; |
207 timeout_timer_.Stop(); | 223 timeout_timer_.Stop(); |
208 creation_context_->registration_utility->Register( | 224 creation_context_->registration_utility->Register( |
209 creation_context_->sync_user_id, | 225 creation_context_->sync_user_id, |
210 info, | 226 info, |
211 base::Bind(&LocallyManagedUserCreationController::RegistrationCallback, | 227 base::Bind(&LocallyManagedUserCreationController::RegistrationCallback, |
212 weak_factory_.GetWeakPtr())); | 228 weak_factory_.GetWeakPtr())); |
213 } | 229 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 // sync service fails to use it. | 296 // sync service fails to use it. |
281 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, | 297 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, |
282 User::OAUTH2_TOKEN_STATUS_VALID); | 298 User::OAUTH2_TOKEN_STATUS_VALID); |
283 UserManager::Get()->GetSupervisedUserManager()-> | 299 UserManager::Get()->GetSupervisedUserManager()-> |
284 CommitCreationTransaction(); | 300 CommitCreationTransaction(); |
285 if (consumer_) | 301 if (consumer_) |
286 consumer_->OnCreationSuccess(); | 302 consumer_->OnCreationSuccess(); |
287 } | 303 } |
288 | 304 |
289 } // namespace chromeos | 305 } // namespace chromeos |
OLD | NEW |