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/stub_authenticator.h" | 5 #include "chromeos/login/auth/stub_authenticator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 if (expected_user_context_ != user_context) | 31 if (expected_user_context_ != user_context) |
| 32 NOTREACHED(); | 32 NOTREACHED(); |
| 33 OnAuthSuccess(); | 33 OnAuthSuccess(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void StubAuthenticator::AuthenticateToLogin(content::BrowserContext* context, | 36 void StubAuthenticator::AuthenticateToLogin(content::BrowserContext* context, |
| 37 const UserContext& user_context) { | 37 const UserContext& user_context) { |
| 38 authentication_context_ = context; | 38 authentication_context_ = context; |
| 39 // Don't compare the entire |expected_user_context_| to |user_context| because | 39 // Don't compare the entire |expected_user_context_| to |user_context| because |
| 40 // during non-online re-auth |user_context| does not have a gaia id. | 40 // during non-online re-auth |user_context| does not have a gaia id. |
| 41 if (expected_user_context_.GetUserID() == user_context.GetUserID() && | 41 if (expected_user_context_.GetAccountId() == user_context.GetAccountId() && |
| 42 *expected_user_context_.GetKey() == *user_context.GetKey()) { | 42 *expected_user_context_.GetKey() == *user_context.GetKey()) { |
| 43 task_runner_->PostTask(FROM_HERE, | 43 task_runner_->PostTask(FROM_HERE, |
| 44 base::Bind(&StubAuthenticator::OnAuthSuccess, this)); | 44 base::Bind(&StubAuthenticator::OnAuthSuccess, this)); |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 GoogleServiceAuthError error( | 47 GoogleServiceAuthError error( |
| 48 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 48 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 49 task_runner_->PostTask( | 49 task_runner_->PostTask( |
| 50 FROM_HERE, base::Bind(&StubAuthenticator::OnAuthFailure, this, | 50 FROM_HERE, base::Bind(&StubAuthenticator::OnAuthFailure, this, |
| 51 AuthFailure::FromNetworkAuthFailure(error))); | 51 AuthFailure::FromNetworkAuthFailure(error))); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void StubAuthenticator::AuthenticateToUnlock(const UserContext& user_context) { | 54 void StubAuthenticator::AuthenticateToUnlock(const UserContext& user_context) { |
| 55 AuthenticateToLogin(NULL /* not used */, user_context); | 55 AuthenticateToLogin(NULL /* not used */, user_context); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void StubAuthenticator::LoginAsSupervisedUser(const UserContext& user_context) { | 58 void StubAuthenticator::LoginAsSupervisedUser(const UserContext& user_context) { |
| 59 UserContext new_user_context = user_context; | 59 UserContext new_user_context = user_context; |
| 60 new_user_context.SetUserIDHash(user_context.GetUserID() + kUserIdHashSuffix); | 60 new_user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail() + |
| 61 kUserIdHashSuffix); | |
| 61 consumer_->OnAuthSuccess(new_user_context); | 62 consumer_->OnAuthSuccess(new_user_context); |
| 62 } | 63 } |
| 63 | 64 |
| 64 void StubAuthenticator::LoginOffTheRecord() { | 65 void StubAuthenticator::LoginOffTheRecord() { |
| 65 consumer_->OnOffTheRecordAuthSuccess(); | 66 consumer_->OnOffTheRecordAuthSuccess(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void StubAuthenticator::LoginAsPublicSession(const UserContext& user_context) { | 69 void StubAuthenticator::LoginAsPublicSession(const UserContext& user_context) { |
| 69 UserContext logged_in_user_context = user_context; | 70 UserContext logged_in_user_context = user_context; |
| 70 logged_in_user_context.SetIsUsingOAuth(false); | 71 logged_in_user_context.SetIsUsingOAuth(false); |
| 71 logged_in_user_context.SetUserIDHash(logged_in_user_context.GetUserID() + | 72 logged_in_user_context.SetUserIDHash( |
| 72 kUserIdHashSuffix); | 73 logged_in_user_context.GetAccountId().GetUserEmail() + kUserIdHashSuffix); |
| 73 consumer_->OnAuthSuccess(logged_in_user_context); | 74 consumer_->OnAuthSuccess(logged_in_user_context); |
| 74 } | 75 } |
| 75 | 76 |
| 76 void StubAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, | 77 void StubAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, |
|
achuithb
2015/10/28 23:11:46
/* app_user_id */ since you are here
Alexander Alekseev
2015/10/29 02:00:42
Done.
| |
| 77 bool use_guest_mount) { | 78 bool use_guest_mount) { |
| 78 UserContext user_context(expected_user_context_.GetUserID()); | 79 UserContext user_context(expected_user_context_.GetAccountId()); |
| 79 user_context.SetIsUsingOAuth(false); | 80 user_context.SetIsUsingOAuth(false); |
| 80 user_context.SetUserIDHash(expected_user_context_.GetUserID() + | 81 user_context.SetUserIDHash( |
| 81 kUserIdHashSuffix); | 82 expected_user_context_.GetAccountId().GetUserEmail() + kUserIdHashSuffix); |
| 82 consumer_->OnAuthSuccess(user_context); | 83 consumer_->OnAuthSuccess(user_context); |
| 83 } | 84 } |
| 84 | 85 |
| 85 void StubAuthenticator::OnAuthSuccess() { | 86 void StubAuthenticator::OnAuthSuccess() { |
| 86 // If we want to be more like the real thing, we could save the user ID | 87 // If we want to be more like the real thing, we could save the user ID |
| 87 // in AuthenticateToLogin, but there's not much of a point. | 88 // in AuthenticateToLogin, but there's not much of a point. |
| 88 UserContext user_context(expected_user_context_); | 89 UserContext user_context(expected_user_context_); |
| 89 user_context.SetUserIDHash(expected_user_context_.GetUserID() + | 90 user_context.SetUserIDHash( |
| 90 kUserIdHashSuffix); | 91 expected_user_context_.GetAccountId().GetUserEmail() + kUserIdHashSuffix); |
| 91 consumer_->OnAuthSuccess(user_context); | 92 consumer_->OnAuthSuccess(user_context); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void StubAuthenticator::OnAuthFailure(const AuthFailure& failure) { | 95 void StubAuthenticator::OnAuthFailure(const AuthFailure& failure) { |
| 95 consumer_->OnAuthFailure(failure); | 96 consumer_->OnAuthFailure(failure); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void StubAuthenticator::RecoverEncryptedData(const std::string& old_password) { | 99 void StubAuthenticator::RecoverEncryptedData(const std::string& old_password) { |
| 99 } | 100 } |
| 100 | 101 |
| 101 void StubAuthenticator::ResyncEncryptedData() { | 102 void StubAuthenticator::ResyncEncryptedData() { |
| 102 } | 103 } |
| 103 | 104 |
| 104 void StubAuthenticator::SetExpectedCredentials( | 105 void StubAuthenticator::SetExpectedCredentials( |
| 105 const UserContext& user_context) { | 106 const UserContext& user_context) { |
| 106 expected_user_context_ = user_context; | 107 expected_user_context_ = user_context; |
| 107 } | 108 } |
| 108 | 109 |
| 109 StubAuthenticator::~StubAuthenticator() { | 110 StubAuthenticator::~StubAuthenticator() { |
| 110 } | 111 } |
| 111 | 112 |
| 112 } // namespace chromeos | 113 } // namespace chromeos |
| OLD | NEW |