Chromium Code Reviews| 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 "chromeos/login/auth/cryptohome_authenticator.h" | 5 #include "chromeos/login/auth/cryptohome_authenticator.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "chromeos/chromeos_switches.h" | |
| 16 #include "chromeos/cryptohome/async_method_caller.h" | 17 #include "chromeos/cryptohome/async_method_caller.h" |
| 17 #include "chromeos/cryptohome/cryptohome_parameters.h" | 18 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 18 #include "chromeos/cryptohome/homedir_methods.h" | 19 #include "chromeos/cryptohome/homedir_methods.h" |
| 19 #include "chromeos/cryptohome/system_salt_getter.h" | 20 #include "chromeos/cryptohome/system_salt_getter.h" |
| 20 #include "chromeos/dbus/cryptohome_client.h" | 21 #include "chromeos/dbus/cryptohome_client.h" |
| 21 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
| 22 #include "chromeos/login/auth/auth_status_consumer.h" | 23 #include "chromeos/login/auth/auth_status_consumer.h" |
| 23 #include "chromeos/login/auth/key.h" | 24 #include "chromeos/login/auth/key.h" |
| 24 #include "chromeos/login/auth/user_context.h" | 25 #include "chromeos/login/auth/user_context.h" |
| 25 #include "chromeos/login/login_state.h" | 26 #include "chromeos/login/login_state.h" |
| 26 #include "chromeos/login/user_names.h" | 27 #include "chromeos/login/user_names.h" |
| 27 #include "chromeos/login_event_recorder.h" | 28 #include "chromeos/login_event_recorder.h" |
| 28 #include "components/device_event_log/device_event_log.h" | 29 #include "components/device_event_log/device_event_log.h" |
| 29 #include "components/signin/core/account_id/account_id.h" | 30 #include "components/signin/core/account_id/account_id.h" |
| 31 #include "components/user_manager/known_user.h" | |
| 30 #include "components/user_manager/user_type.h" | 32 #include "components/user_manager/user_type.h" |
| 31 #include "third_party/cros_system_api/dbus/service_constants.h" | 33 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 32 | 34 |
| 33 namespace chromeos { | 35 namespace chromeos { |
| 34 | 36 |
| 35 namespace { | 37 namespace { |
| 36 | 38 |
| 37 // The label used for the key derived from the user's GAIA credentials. | 39 // The label used for the key derived from the user's GAIA credentials. |
| 38 const char kCryptohomeGAIAKeyLabel[] = "gaia"; | 40 const char kCryptohomeGAIAKeyLabel[] = "gaia"; |
| 39 | 41 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 cryptohome::PRIV_DEFAULT); | 144 cryptohome::PRIV_DEFAULT); |
| 143 cryptohome::MountParameters mount(ephemeral); | 145 cryptohome::MountParameters mount(ephemeral); |
| 144 if (create_if_nonexistent) { | 146 if (create_if_nonexistent) { |
| 145 mount.create_keys.push_back(cryptohome::KeyDefinition( | 147 mount.create_keys.push_back(cryptohome::KeyDefinition( |
| 146 key->GetSecret(), | 148 key->GetSecret(), |
| 147 kCryptohomeGAIAKeyLabel, | 149 kCryptohomeGAIAKeyLabel, |
| 148 cryptohome::PRIV_DEFAULT)); | 150 cryptohome::PRIV_DEFAULT)); |
| 149 } | 151 } |
| 150 | 152 |
| 151 cryptohome::HomedirMethods::GetInstance()->MountEx( | 153 cryptohome::HomedirMethods::GetInstance()->MountEx( |
| 152 cryptohome::Identification( | 154 cryptohome::Identification(attempt->user_context.GetAccountId()), |
| 153 attempt->user_context.GetAccountId().GetUserEmail()), | |
| 154 cryptohome::Authorization(auth_key), mount, | 155 cryptohome::Authorization(auth_key), mount, |
| 155 base::Bind(&OnMount, attempt, resolver)); | 156 base::Bind(&OnMount, attempt, resolver)); |
| 156 } | 157 } |
| 157 | 158 |
| 159 // Handle cryptohome migration status. | |
| 160 void OnCryptohomeRenamed(const base::WeakPtr<AuthAttemptState>& attempt, | |
| 161 scoped_refptr<CryptohomeAuthenticator> resolver, | |
| 162 bool ephemeral, | |
| 163 bool create_if_nonexistent, | |
| 164 bool success, | |
| 165 cryptohome::MountError return_code) { | |
| 166 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | |
| 167 "CryptohomeRename-End", false); | |
| 168 const AccountId account_id = attempt->user_context.GetAccountId(); | |
| 169 if (success) { | |
| 170 cryptohome::SetGaiaIdMigrationStatusDone(account_id); | |
| 171 } else { | |
| 172 LOG(ERROR) << "Failed to rename cryptohome for account_id='" | |
| 173 << account_id.Serialize() << "' (return_code=" << return_code | |
| 174 << ")"; | |
| 175 } | |
| 176 | |
| 177 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); | |
| 178 } | |
| 179 | |
| 180 // This method migrates cryptohome identifier to gaia id (if needed), | |
| 181 // and then calls Mount. | |
| 182 void EnsureCryptohomeMigratedToGaiaId( | |
| 183 const base::WeakPtr<AuthAttemptState>& attempt, | |
| 184 scoped_refptr<CryptohomeAuthenticator> resolver, | |
| 185 bool ephemeral, | |
| 186 bool create_if_nonexistent) { | |
| 187 const bool is_gaiaid_migration_started = switches::IsGaiaIdMigrationStarted(); | |
| 188 if (!is_gaiaid_migration_started) { | |
| 189 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); | |
| 190 return; | |
| 191 } | |
| 192 const bool already_migrated = cryptohome::GetGaiaIdMigrationStatus( | |
| 193 attempt->user_context.GetAccountId()); | |
| 194 const bool has_gaia_id = | |
| 195 !attempt->user_context.GetAccountId().GetGaiaId().empty(); | |
| 196 | |
| 197 bool need_migration = false; | |
| 198 if (!create_if_nonexistent && !already_migrated) { | |
| 199 if (has_gaia_id) { | |
| 200 need_migration = true; | |
| 201 } else { | |
| 202 LOG(WARNING) << "Account '" | |
| 203 << attempt->user_context.GetAccountId().Serialize() | |
| 204 << "' has no gaia id. Cryptohome migration skipped."; | |
| 205 } | |
| 206 } | |
| 207 if (need_migration) { | |
| 208 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | |
| 209 "CryptohomeRename-Start", false); | |
| 210 const std::string& cryptohome_id_from = | |
| 211 attempt->user_context.GetAccountId().GetUserEmail(); // Migrated | |
| 212 const std::string cryptohome_id_to = | |
| 213 attempt->user_context.GetAccountId().GetGaiaIdKey(); | |
| 214 | |
| 215 cryptohome::HomedirMethods::GetInstance()->RenameCryptohome( | |
| 216 cryptohome::Identification::FromString(cryptohome_id_from), | |
| 217 cryptohome::Identification::FromString(cryptohome_id_to), | |
| 218 base::Bind(&OnCryptohomeRenamed, attempt, resolver, ephemeral, | |
| 219 create_if_nonexistent)); | |
| 220 return; | |
| 221 } | |
| 222 if (!already_migrated && has_gaia_id) { | |
| 223 // Mark new users migrated. | |
| 224 cryptohome::SetGaiaIdMigrationStatusDone( | |
| 225 attempt->user_context.GetAccountId()); | |
| 226 } | |
| 227 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); | |
| 228 } | |
|
stevenjb
2016/02/23 19:27:34
Can these be added separately?
Alexander Alekseev
2016/02/24 09:27:42
What do you mean?
stevenjb
2016/02/24 17:25:43
I was hoping it would be reasonable to add EnsureC
Alexander Alekseev
2016/02/25 07:40:46
Done.
| |
| 229 | |
| 158 // Callback invoked when the system salt has been retrieved. Transforms the key | 230 // Callback invoked when the system salt has been retrieved. Transforms the key |
| 159 // in |attempt->user_context| using Chrome's default hashing algorithm and the | 231 // in |attempt->user_context| using Chrome's default hashing algorithm and the |
| 160 // system salt, then calls MountEx(). | 232 // system salt, then calls MountEx(). |
| 161 void OnGetSystemSalt(const base::WeakPtr<AuthAttemptState>& attempt, | 233 void OnGetSystemSalt(const base::WeakPtr<AuthAttemptState>& attempt, |
| 162 scoped_refptr<CryptohomeAuthenticator> resolver, | 234 scoped_refptr<CryptohomeAuthenticator> resolver, |
| 163 bool ephemeral, | 235 bool ephemeral, |
| 164 bool create_if_nonexistent, | 236 bool create_if_nonexistent, |
| 165 const std::string& system_salt) { | 237 const std::string& system_salt) { |
| 166 DCHECK_EQ(Key::KEY_TYPE_PASSWORD_PLAIN, | 238 DCHECK_EQ(Key::KEY_TYPE_PASSWORD_PLAIN, |
| 167 attempt->user_context.GetKey()->GetKeyType()); | 239 attempt->user_context.GetKey()->GetKeyType()); |
| 168 | 240 |
| 169 attempt->user_context.GetKey()->Transform( | 241 attempt->user_context.GetKey()->Transform( |
| 170 Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, | 242 Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, |
| 171 system_salt); | 243 system_salt); |
| 172 | 244 |
| 173 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); | 245 EnsureCryptohomeMigratedToGaiaId(attempt, resolver, ephemeral, |
| 246 create_if_nonexistent); | |
| 174 } | 247 } |
| 175 | 248 |
| 176 // Callback invoked when cryptohome's GetKeyDataEx() method has finished. | 249 // Callback invoked when cryptohome's GetKeyDataEx() method has finished. |
| 177 // * If GetKeyDataEx() returned metadata indicating the hashing algorithm and | 250 // * If GetKeyDataEx() returned metadata indicating the hashing algorithm and |
| 178 // salt that were used to generate the key for this user's cryptohome, | 251 // salt that were used to generate the key for this user's cryptohome, |
| 179 // transforms the key in |attempt->user_context| with the same parameters. | 252 // transforms the key in |attempt->user_context| with the same parameters. |
| 180 // * Otherwise, starts the retrieval of the system salt so that the key in | 253 // * Otherwise, starts the retrieval of the system salt so that the key in |
| 181 // |attempt->user_context| can be transformed with Chrome's default hashing | 254 // |attempt->user_context| can be transformed with Chrome's default hashing |
| 182 // algorithm and the system salt. | 255 // algorithm and the system salt. |
| 183 // The resulting key is then passed to cryptohome's MountEx(). | 256 // The resulting key is then passed to cryptohome's MountEx(). |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 295 |
| 223 if (!salt) { | 296 if (!salt) { |
| 224 LOGIN_LOG(ERROR) << "Missing salt."; | 297 LOGIN_LOG(ERROR) << "Missing salt."; |
| 225 RecordKeyErrorAndResolve(attempt, resolver); | 298 RecordKeyErrorAndResolve(attempt, resolver); |
| 226 return; | 299 return; |
| 227 } | 300 } |
| 228 | 301 |
| 229 attempt->user_context.GetKey()->Transform( | 302 attempt->user_context.GetKey()->Transform( |
| 230 static_cast<Key::KeyType>(*type), | 303 static_cast<Key::KeyType>(*type), |
| 231 *salt); | 304 *salt); |
| 232 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); | 305 EnsureCryptohomeMigratedToGaiaId(attempt, resolver, ephemeral, |
| 306 create_if_nonexistent); | |
| 233 return; | 307 return; |
| 234 } | 308 } |
| 235 } else { | 309 } else { |
| 236 LOGIN_LOG(EVENT) << "GetKeyDataEx() returned " << key_definitions.size() | 310 LOGIN_LOG(EVENT) << "GetKeyDataEx() returned " << key_definitions.size() |
| 237 << " entries."; | 311 << " entries."; |
| 238 } | 312 } |
| 239 } | 313 } |
| 240 | 314 |
| 241 SystemSaltGetter::Get()->GetSystemSalt(base::Bind(&OnGetSystemSalt, | 315 SystemSaltGetter::Get()->GetSystemSalt(base::Bind(&OnGetSystemSalt, |
| 242 attempt, | 316 attempt, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 255 // transformed accordingly before calling MountEx(). | 329 // transformed accordingly before calling MountEx(). |
| 256 void StartMount(const base::WeakPtr<AuthAttemptState>& attempt, | 330 void StartMount(const base::WeakPtr<AuthAttemptState>& attempt, |
| 257 scoped_refptr<CryptohomeAuthenticator> resolver, | 331 scoped_refptr<CryptohomeAuthenticator> resolver, |
| 258 bool ephemeral, | 332 bool ephemeral, |
| 259 bool create_if_nonexistent) { | 333 bool create_if_nonexistent) { |
| 260 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | 334 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( |
| 261 "CryptohomeMount-Start", false); | 335 "CryptohomeMount-Start", false); |
| 262 | 336 |
| 263 if (attempt->user_context.GetKey()->GetKeyType() != | 337 if (attempt->user_context.GetKey()->GetKeyType() != |
| 264 Key::KEY_TYPE_PASSWORD_PLAIN) { | 338 Key::KEY_TYPE_PASSWORD_PLAIN) { |
| 265 DoMount(attempt, resolver, ephemeral, create_if_nonexistent); | 339 EnsureCryptohomeMigratedToGaiaId(attempt, resolver, ephemeral, |
| 340 create_if_nonexistent); | |
| 266 return; | 341 return; |
| 267 } | 342 } |
| 268 | 343 |
| 269 cryptohome::HomedirMethods::GetInstance()->GetKeyDataEx( | 344 cryptohome::HomedirMethods::GetInstance()->GetKeyDataEx( |
| 270 cryptohome::Identification( | 345 cryptohome::Identification(attempt->user_context.GetAccountId()), |
| 271 attempt->user_context.GetAccountId().GetUserEmail()), | |
| 272 kCryptohomeGAIAKeyLabel, base::Bind(&OnGetKeyDataEx, attempt, resolver, | 346 kCryptohomeGAIAKeyLabel, base::Bind(&OnGetKeyDataEx, attempt, resolver, |
| 273 ephemeral, create_if_nonexistent)); | 347 ephemeral, create_if_nonexistent)); |
| 274 } | 348 } |
| 275 | 349 |
| 276 // Calls cryptohome's mount method for guest and also get the user hash from | 350 // Calls cryptohome's mount method for guest and also get the user hash from |
| 277 // cryptohome. | 351 // cryptohome. |
| 278 void MountGuestAndGetHash(const base::WeakPtr<AuthAttemptState>& attempt, | 352 void MountGuestAndGetHash(const base::WeakPtr<AuthAttemptState>& attempt, |
| 279 scoped_refptr<CryptohomeAuthenticator> resolver) { | 353 scoped_refptr<CryptohomeAuthenticator> resolver) { |
| 280 attempt->UsernameHashRequested(); | 354 attempt->UsernameHashRequested(); |
| 281 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest( | 355 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest( |
| 282 base::Bind(&TriggerResolveWithLoginTimeMarker, | 356 base::Bind(&TriggerResolveWithLoginTimeMarker, |
| 283 "CryptohomeMount-End", | 357 "CryptohomeMount-End", |
| 284 attempt, | 358 attempt, |
| 285 resolver)); | 359 resolver)); |
| 286 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 360 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
| 287 attempt->user_context.GetAccountId().GetUserEmail(), | 361 cryptohome::Identification(attempt->user_context.GetAccountId()), |
| 288 base::Bind(&TriggerResolveHash, attempt, resolver)); | 362 base::Bind(&TriggerResolveHash, attempt, resolver)); |
| 289 } | 363 } |
| 290 | 364 |
| 291 // Calls cryptohome's MountPublic method | 365 // Calls cryptohome's MountPublic method |
| 292 void MountPublic(const base::WeakPtr<AuthAttemptState>& attempt, | 366 void MountPublic(const base::WeakPtr<AuthAttemptState>& attempt, |
| 293 scoped_refptr<CryptohomeAuthenticator> resolver, | 367 scoped_refptr<CryptohomeAuthenticator> resolver, |
| 294 int flags) { | 368 int flags) { |
| 295 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountPublic( | 369 cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountPublic( |
| 296 attempt->user_context.GetAccountId().GetUserEmail(), flags, | 370 cryptohome::Identification(attempt->user_context.GetAccountId()), flags, |
| 297 base::Bind(&TriggerResolveWithLoginTimeMarker, | 371 base::Bind(&TriggerResolveWithLoginTimeMarker, |
| 298 "CryptohomeMountPublic-End", attempt, resolver)); | 372 "CryptohomeMountPublic-End", attempt, resolver)); |
| 299 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( | 373 cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
| 300 attempt->user_context.GetAccountId().GetUserEmail(), | 374 cryptohome::Identification(attempt->user_context.GetAccountId()), |
| 301 base::Bind(&TriggerResolveHash, attempt, resolver)); | 375 base::Bind(&TriggerResolveHash, attempt, resolver)); |
| 302 } | 376 } |
| 303 | 377 |
| 304 // Calls cryptohome's key migration method. | 378 // Calls cryptohome's key migration method. |
| 305 void Migrate(const base::WeakPtr<AuthAttemptState>& attempt, | 379 void Migrate(const base::WeakPtr<AuthAttemptState>& attempt, |
| 306 scoped_refptr<CryptohomeAuthenticator> resolver, | 380 scoped_refptr<CryptohomeAuthenticator> resolver, |
| 307 bool passing_old_hash, | 381 bool passing_old_hash, |
| 308 const std::string& old_password, | 382 const std::string& old_password, |
| 309 const std::string& system_salt) { | 383 const std::string& system_salt) { |
| 310 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | 384 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( |
| 311 "CryptohomeMigrate-Start", false); | 385 "CryptohomeMigrate-Start", false); |
| 312 cryptohome::AsyncMethodCaller* caller = | 386 cryptohome::AsyncMethodCaller* caller = |
| 313 cryptohome::AsyncMethodCaller::GetInstance(); | 387 cryptohome::AsyncMethodCaller::GetInstance(); |
| 314 | 388 |
| 315 // TODO(bartfab): Retrieve the hashing algorithm and salt to use for |old_key| | 389 // TODO(bartfab): Retrieve the hashing algorithm and salt to use for |old_key| |
| 316 // from cryptohomed. | 390 // from cryptohomed. |
| 317 scoped_ptr<Key> old_key = | 391 scoped_ptr<Key> old_key = |
| 318 TransformKeyIfNeeded(Key(old_password), system_salt); | 392 TransformKeyIfNeeded(Key(old_password), system_salt); |
| 319 scoped_ptr<Key> new_key = | 393 scoped_ptr<Key> new_key = |
| 320 TransformKeyIfNeeded(*attempt->user_context.GetKey(), system_salt); | 394 TransformKeyIfNeeded(*attempt->user_context.GetKey(), system_salt); |
| 321 if (passing_old_hash) { | 395 if (passing_old_hash) { |
| 322 caller->AsyncMigrateKey( | 396 caller->AsyncMigrateKey( |
| 323 attempt->user_context.GetAccountId().GetUserEmail(), | 397 cryptohome::Identification(attempt->user_context.GetAccountId()), |
| 324 old_key->GetSecret(), new_key->GetSecret(), | 398 old_key->GetSecret(), new_key->GetSecret(), |
| 325 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-End", | 399 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-End", |
| 326 attempt, resolver)); | 400 attempt, resolver)); |
| 327 } else { | 401 } else { |
| 328 caller->AsyncMigrateKey( | 402 caller->AsyncMigrateKey( |
| 329 attempt->user_context.GetAccountId().GetUserEmail(), | 403 cryptohome::Identification(attempt->user_context.GetAccountId()), |
| 330 new_key->GetSecret(), old_key->GetSecret(), | 404 new_key->GetSecret(), old_key->GetSecret(), |
| 331 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-End", | 405 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeMount-End", |
| 332 attempt, resolver)); | 406 attempt, resolver)); |
| 333 } | 407 } |
| 334 } | 408 } |
| 335 | 409 |
| 336 // Calls cryptohome's remove method. | 410 // Calls cryptohome's remove method. |
| 337 void Remove(const base::WeakPtr<AuthAttemptState>& attempt, | 411 void Remove(const base::WeakPtr<AuthAttemptState>& attempt, |
| 338 scoped_refptr<CryptohomeAuthenticator> resolver) { | 412 scoped_refptr<CryptohomeAuthenticator> resolver) { |
| 339 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( | 413 chromeos::LoginEventRecorder::Get()->AddLoginTimeMarker( |
| 340 "CryptohomeRemove-Start", false); | 414 "CryptohomeRemove-Start", false); |
| 341 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( | 415 cryptohome::AsyncMethodCaller::GetInstance()->AsyncRemove( |
| 342 attempt->user_context.GetAccountId().GetUserEmail(), | 416 cryptohome::Identification(attempt->user_context.GetAccountId()), |
| 343 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeRemove-End", | 417 base::Bind(&TriggerResolveWithLoginTimeMarker, "CryptohomeRemove-End", |
| 344 attempt, resolver)); | 418 attempt, resolver)); |
| 345 } | 419 } |
| 346 | 420 |
| 347 // Calls cryptohome's key check method. | 421 // Calls cryptohome's key check method. |
| 348 void CheckKey(const base::WeakPtr<AuthAttemptState>& attempt, | 422 void CheckKey(const base::WeakPtr<AuthAttemptState>& attempt, |
| 349 scoped_refptr<CryptohomeAuthenticator> resolver, | 423 scoped_refptr<CryptohomeAuthenticator> resolver, |
| 350 const std::string& system_salt) { | 424 const std::string& system_salt) { |
| 351 scoped_ptr<Key> key = | 425 scoped_ptr<Key> key = |
| 352 TransformKeyIfNeeded(*attempt->user_context.GetKey(), system_salt); | 426 TransformKeyIfNeeded(*attempt->user_context.GetKey(), system_salt); |
| 353 cryptohome::AsyncMethodCaller::GetInstance()->AsyncCheckKey( | 427 cryptohome::AsyncMethodCaller::GetInstance()->AsyncCheckKey( |
| 354 attempt->user_context.GetAccountId().GetUserEmail(), key->GetSecret(), | 428 cryptohome::Identification(attempt->user_context.GetAccountId()), |
| 355 base::Bind(&TriggerResolve, attempt, resolver)); | 429 key->GetSecret(), base::Bind(&TriggerResolve, attempt, resolver)); |
| 356 } | 430 } |
| 357 | 431 |
| 358 } // namespace | 432 } // namespace |
| 359 | 433 |
| 360 CryptohomeAuthenticator::CryptohomeAuthenticator( | 434 CryptohomeAuthenticator::CryptohomeAuthenticator( |
| 361 scoped_refptr<base::TaskRunner> task_runner, | 435 scoped_refptr<base::TaskRunner> task_runner, |
| 362 AuthStatusConsumer* consumer) | 436 AuthStatusConsumer* consumer) |
| 363 : Authenticator(consumer), | 437 : Authenticator(consumer), |
| 364 task_runner_(task_runner), | 438 task_runner_(task_runner), |
| 365 migrate_attempted_(false), | 439 migrate_attempted_(false), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 false, // online_complete | 514 false, // online_complete |
| 441 false)); // user_is_new | 515 false)); // user_is_new |
| 442 remove_user_data_on_failure_ = false; | 516 remove_user_data_on_failure_ = false; |
| 443 StartMount(current_state_->AsWeakPtr(), | 517 StartMount(current_state_->AsWeakPtr(), |
| 444 scoped_refptr<CryptohomeAuthenticator>(this), | 518 scoped_refptr<CryptohomeAuthenticator>(this), |
| 445 false /* ephemeral */, false /* create_if_nonexistent */); | 519 false /* ephemeral */, false /* create_if_nonexistent */); |
| 446 } | 520 } |
| 447 | 521 |
| 448 void CryptohomeAuthenticator::LoginOffTheRecord() { | 522 void CryptohomeAuthenticator::LoginOffTheRecord() { |
| 449 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 523 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 450 current_state_.reset( | 524 current_state_.reset(new AuthAttemptState( |
| 451 new AuthAttemptState(UserContext(user_manager::USER_TYPE_GUEST, | 525 UserContext(user_manager::USER_TYPE_GUEST, login::GuestAccountId()), |
| 452 login::GuestAccountId().GetUserEmail()), | 526 false, // unlock |
| 453 false, // unlock | 527 false, // online_complete |
| 454 false, // online_complete | 528 false)); // user_is_new |
| 455 false)); // user_is_new | |
| 456 remove_user_data_on_failure_ = false; | 529 remove_user_data_on_failure_ = false; |
| 457 ephemeral_mount_attempted_ = true; | 530 ephemeral_mount_attempted_ = true; |
| 458 MountGuestAndGetHash(current_state_->AsWeakPtr(), | 531 MountGuestAndGetHash(current_state_->AsWeakPtr(), |
| 459 scoped_refptr<CryptohomeAuthenticator>(this)); | 532 scoped_refptr<CryptohomeAuthenticator>(this)); |
| 460 } | 533 } |
| 461 | 534 |
| 462 void CryptohomeAuthenticator::LoginAsPublicSession( | 535 void CryptohomeAuthenticator::LoginAsPublicSession( |
| 463 const UserContext& user_context) { | 536 const UserContext& user_context) { |
| 464 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 537 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 465 DCHECK_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user_context.GetUserType()); | 538 DCHECK_EQ(user_manager::USER_TYPE_PUBLIC_ACCOUNT, user_context.GetUserType()); |
| 466 | 539 |
| 467 current_state_.reset( | 540 current_state_.reset( |
| 468 new AuthAttemptState(user_context, | 541 new AuthAttemptState(user_context, |
| 469 false, // unlock | 542 false, // unlock |
| 470 false, // online_complete | 543 false, // online_complete |
| 471 false)); // user_is_new | 544 false)); // user_is_new |
| 472 remove_user_data_on_failure_ = false; | 545 remove_user_data_on_failure_ = false; |
| 473 ephemeral_mount_attempted_ = true; | 546 ephemeral_mount_attempted_ = true; |
| 474 StartMount(current_state_->AsWeakPtr(), | 547 StartMount(current_state_->AsWeakPtr(), |
| 475 scoped_refptr<CryptohomeAuthenticator>(this), true /* ephemeral */, | 548 scoped_refptr<CryptohomeAuthenticator>(this), true /* ephemeral */, |
| 476 true /* create_if_nonexistent */); | 549 true /* create_if_nonexistent */); |
| 477 } | 550 } |
| 478 | 551 |
| 479 void CryptohomeAuthenticator::LoginAsKioskAccount( | 552 void CryptohomeAuthenticator::LoginAsKioskAccount( |
| 480 const std::string& app_user_id, | 553 const AccountId& app_account_id, |
| 481 bool use_guest_mount) { | 554 bool use_guest_mount) { |
| 482 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 555 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 483 | 556 |
| 484 const std::string user_id = | 557 const AccountId& account_id = |
| 485 use_guest_mount ? login::GuestAccountId().GetUserEmail() : app_user_id; | 558 use_guest_mount ? login::GuestAccountId() : app_account_id; |
| 486 current_state_.reset(new AuthAttemptState( | 559 current_state_.reset(new AuthAttemptState( |
| 487 UserContext(user_manager::USER_TYPE_KIOSK_APP, user_id), | 560 UserContext(user_manager::USER_TYPE_KIOSK_APP, account_id), |
| 488 false, // unlock | 561 false, // unlock |
| 489 false, // online_complete | 562 false, // online_complete |
| 490 false)); // user_is_new | 563 false)); // user_is_new |
| 491 | 564 |
| 492 remove_user_data_on_failure_ = true; | 565 remove_user_data_on_failure_ = true; |
| 493 if (!use_guest_mount) { | 566 if (!use_guest_mount) { |
| 494 MountPublic(current_state_->AsWeakPtr(), | 567 MountPublic(current_state_->AsWeakPtr(), |
| 495 scoped_refptr<CryptohomeAuthenticator>(this), | 568 scoped_refptr<CryptohomeAuthenticator>(this), |
| 496 cryptohome::CREATE_IF_MISSING); | 569 cryptohome::CREATE_IF_MISSING); |
| 497 } else { | 570 } else { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 873 Resolve(); | 946 Resolve(); |
| 874 } | 947 } |
| 875 | 948 |
| 876 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished, | 949 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished, |
| 877 bool check_result) { | 950 bool check_result) { |
| 878 owner_is_verified_ = owner_check_finished; | 951 owner_is_verified_ = owner_check_finished; |
| 879 user_can_login_ = check_result; | 952 user_can_login_ = check_result; |
| 880 } | 953 } |
| 881 | 954 |
| 882 } // namespace chromeos | 955 } // namespace chromeos |
| OLD | NEW |