| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 false, // unlock | 450 false, // unlock |
| 451 false, // online_complete | 451 false, // online_complete |
| 452 false)); // user_is_new | 452 false)); // user_is_new |
| 453 remove_user_data_on_failure_ = false; | 453 remove_user_data_on_failure_ = false; |
| 454 StartMount(current_state_.get(), | 454 StartMount(current_state_.get(), |
| 455 scoped_refptr<CryptohomeAuthenticator>(this), | 455 scoped_refptr<CryptohomeAuthenticator>(this), |
| 456 false /* ephemeral */, | 456 false /* ephemeral */, |
| 457 false /* create_if_nonexistent */); | 457 false /* create_if_nonexistent */); |
| 458 } | 458 } |
| 459 | 459 |
| 460 void CryptohomeAuthenticator::LoginRetailMode() { | |
| 461 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | |
| 462 // Note: |kRetailModeUserEMail| is used in other places to identify a retail | |
| 463 // mode session. | |
| 464 current_state_.reset( | |
| 465 new AuthAttemptState(UserContext(chromeos::login::kRetailModeUserName), | |
| 466 user_manager::USER_TYPE_RETAIL_MODE, | |
| 467 false, // unlock | |
| 468 false, // online_complete | |
| 469 false)); // user_is_new | |
| 470 remove_user_data_on_failure_ = false; | |
| 471 ephemeral_mount_attempted_ = true; | |
| 472 MountGuestAndGetHash(current_state_.get(), | |
| 473 scoped_refptr<CryptohomeAuthenticator>(this)); | |
| 474 } | |
| 475 | |
| 476 void CryptohomeAuthenticator::LoginOffTheRecord() { | 460 void CryptohomeAuthenticator::LoginOffTheRecord() { |
| 477 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 461 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 478 current_state_.reset( | 462 current_state_.reset( |
| 479 new AuthAttemptState(UserContext(chromeos::login::kGuestUserName), | 463 new AuthAttemptState(UserContext(chromeos::login::kGuestUserName), |
| 480 user_manager::USER_TYPE_GUEST, | 464 user_manager::USER_TYPE_GUEST, |
| 481 false, // unlock | 465 false, // unlock |
| 482 false, // online_complete | 466 false, // online_complete |
| 483 false)); // user_is_new | 467 false)); // user_is_new |
| 484 remove_user_data_on_failure_ = false; | 468 remove_user_data_on_failure_ = false; |
| 485 ephemeral_mount_attempted_ = true; | 469 ephemeral_mount_attempted_ = true; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 MountPublic(current_state_.get(), | 506 MountPublic(current_state_.get(), |
| 523 scoped_refptr<CryptohomeAuthenticator>(this), | 507 scoped_refptr<CryptohomeAuthenticator>(this), |
| 524 cryptohome::CREATE_IF_MISSING); | 508 cryptohome::CREATE_IF_MISSING); |
| 525 } else { | 509 } else { |
| 526 ephemeral_mount_attempted_ = true; | 510 ephemeral_mount_attempted_ = true; |
| 527 MountGuestAndGetHash(current_state_.get(), | 511 MountGuestAndGetHash(current_state_.get(), |
| 528 scoped_refptr<CryptohomeAuthenticator>(this)); | 512 scoped_refptr<CryptohomeAuthenticator>(this)); |
| 529 } | 513 } |
| 530 } | 514 } |
| 531 | 515 |
| 532 void CryptohomeAuthenticator::OnRetailModeAuthSuccess() { | |
| 533 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | |
| 534 VLOG(1) << "Retail mode login success"; | |
| 535 chromeos::LoginEventRecorder::Get()->RecordAuthenticationSuccess(); | |
| 536 if (consumer_) | |
| 537 consumer_->OnRetailModeAuthSuccess(current_state_->user_context); | |
| 538 } | |
| 539 | |
| 540 void CryptohomeAuthenticator::OnAuthSuccess() { | 516 void CryptohomeAuthenticator::OnAuthSuccess() { |
| 541 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 517 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 542 VLOG(1) << "Login success"; | 518 VLOG(1) << "Login success"; |
| 543 // Send notification of success | 519 // Send notification of success |
| 544 chromeos::LoginEventRecorder::Get()->RecordAuthenticationSuccess(); | 520 chromeos::LoginEventRecorder::Get()->RecordAuthenticationSuccess(); |
| 545 { | 521 { |
| 546 base::AutoLock for_this_block(success_lock_); | 522 base::AutoLock for_this_block(success_lock_); |
| 547 already_reported_success_ = true; | 523 already_reported_success_ = true; |
| 548 } | 524 } |
| 549 if (consumer_) | 525 if (consumer_) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 VLOG(2) << "Offline login"; | 699 VLOG(2) << "Offline login"; |
| 724 // Fall through. | 700 // Fall through. |
| 725 case UNLOCK: | 701 case UNLOCK: |
| 726 VLOG(2) << "Unlock"; | 702 VLOG(2) << "Unlock"; |
| 727 // Fall through. | 703 // Fall through. |
| 728 case ONLINE_LOGIN: | 704 case ONLINE_LOGIN: |
| 729 VLOG(2) << "Online login"; | 705 VLOG(2) << "Online login"; |
| 730 task_runner_->PostTask( | 706 task_runner_->PostTask( |
| 731 FROM_HERE, base::Bind(&CryptohomeAuthenticator::OnAuthSuccess, this)); | 707 FROM_HERE, base::Bind(&CryptohomeAuthenticator::OnAuthSuccess, this)); |
| 732 break; | 708 break; |
| 733 case DEMO_LOGIN: | |
| 734 VLOG(2) << "Retail mode login"; | |
| 735 current_state_->user_context.SetIsUsingOAuth(false); | |
| 736 task_runner_->PostTask( | |
| 737 FROM_HERE, | |
| 738 base::Bind(&CryptohomeAuthenticator::OnRetailModeAuthSuccess, this)); | |
| 739 break; | |
| 740 case GUEST_LOGIN: | 709 case GUEST_LOGIN: |
| 741 task_runner_->PostTask( | 710 task_runner_->PostTask( |
| 742 FROM_HERE, | 711 FROM_HERE, |
| 743 base::Bind(&CryptohomeAuthenticator::OnOffTheRecordAuthSuccess, | 712 base::Bind(&CryptohomeAuthenticator::OnOffTheRecordAuthSuccess, |
| 744 this)); | 713 this)); |
| 745 break; | 714 break; |
| 746 case KIOSK_ACCOUNT_LOGIN: | 715 case KIOSK_ACCOUNT_LOGIN: |
| 747 case PUBLIC_ACCOUNT_LOGIN: | 716 case PUBLIC_ACCOUNT_LOGIN: |
| 748 current_state_->user_context.SetIsUsingOAuth(false); | 717 current_state_->user_context.SetIsUsingOAuth(false); |
| 749 task_runner_->PostTask( | 718 task_runner_->PostTask( |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 return CREATE_NEW; | 846 return CREATE_NEW; |
| 878 if (remove_attempted_) | 847 if (remove_attempted_) |
| 879 return REMOVED_DATA_AFTER_FAILURE; | 848 return REMOVED_DATA_AFTER_FAILURE; |
| 880 if (migrate_attempted_) | 849 if (migrate_attempted_) |
| 881 return RECOVER_MOUNT; | 850 return RECOVER_MOUNT; |
| 882 if (check_key_attempted_) | 851 if (check_key_attempted_) |
| 883 return UNLOCK; | 852 return UNLOCK; |
| 884 | 853 |
| 885 if (current_state_->user_type == user_manager::USER_TYPE_GUEST) | 854 if (current_state_->user_type == user_manager::USER_TYPE_GUEST) |
| 886 return GUEST_LOGIN; | 855 return GUEST_LOGIN; |
| 887 if (current_state_->user_type == user_manager::USER_TYPE_RETAIL_MODE) | |
| 888 return DEMO_LOGIN; | |
| 889 if (current_state_->user_type == user_manager::USER_TYPE_PUBLIC_ACCOUNT) | 856 if (current_state_->user_type == user_manager::USER_TYPE_PUBLIC_ACCOUNT) |
| 890 return PUBLIC_ACCOUNT_LOGIN; | 857 return PUBLIC_ACCOUNT_LOGIN; |
| 891 if (current_state_->user_type == user_manager::USER_TYPE_KIOSK_APP) | 858 if (current_state_->user_type == user_manager::USER_TYPE_KIOSK_APP) |
| 892 return KIOSK_ACCOUNT_LOGIN; | 859 return KIOSK_ACCOUNT_LOGIN; |
| 893 if (current_state_->user_type == user_manager::USER_TYPE_SUPERVISED) | 860 if (current_state_->user_type == user_manager::USER_TYPE_SUPERVISED) |
| 894 return SUPERVISED_USER_LOGIN; | 861 return SUPERVISED_USER_LOGIN; |
| 895 | 862 |
| 896 if (!VerifyOwner()) | 863 if (!VerifyOwner()) |
| 897 return CONTINUE; | 864 return CONTINUE; |
| 898 return user_can_login_ ? OFFLINE_LOGIN : OWNER_REQUIRED; | 865 return user_can_login_ ? OFFLINE_LOGIN : OWNER_REQUIRED; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 921 Resolve(); | 888 Resolve(); |
| 922 } | 889 } |
| 923 | 890 |
| 924 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished, | 891 void CryptohomeAuthenticator::SetOwnerState(bool owner_check_finished, |
| 925 bool check_result) { | 892 bool check_result) { |
| 926 owner_is_verified_ = owner_check_finished; | 893 owner_is_verified_ = owner_check_finished; |
| 927 user_can_login_ = check_result; | 894 user_can_login_ = check_result; |
| 928 } | 895 } |
| 929 | 896 |
| 930 } // namespace chromeos | 897 } // namespace chromeos |
| OLD | NEW |