| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/supervised_user_login_flow.h" | 5 #include "chrome/browser/chromeos/login/managed/supervised_user_login_flow.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const std::string& token) { | 63 const std::string& token) { |
| 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 65 ConfigureSync(token); | 65 ConfigureSync(token); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void SupervisedUserLoginFlow::ConfigureSync(const std::string& token) { | 68 void SupervisedUserLoginFlow::ConfigureSync(const std::string& token) { |
| 69 data_loaded_ = true; | 69 data_loaded_ = true; |
| 70 | 70 |
| 71 // TODO(antrim): add error handling (no token loaded). | 71 // TODO(antrim): add error handling (no token loaded). |
| 72 // See also: http://crbug.com/312751 | 72 // See also: http://crbug.com/312751 |
| 73 UserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken( | 73 GetUserManager()->GetSupervisedUserManager()->ConfigureSyncWithToken(profile_, |
| 74 profile_, token); | 74 token); |
| 75 SupervisedUserAuthentication* auth = | 75 SupervisedUserAuthentication* auth = |
| 76 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 76 GetUserManager()->GetSupervisedUserManager()->GetAuthentication(); |
| 77 | 77 |
| 78 if (auth->HasScheduledPasswordUpdate(user_id())) { | 78 if (auth->HasScheduledPasswordUpdate(user_id())) { |
| 79 auth->LoadPasswordUpdateData( | 79 auth->LoadPasswordUpdateData( |
| 80 user_id(), | 80 user_id(), |
| 81 base::Bind(&SupervisedUserLoginFlow::OnPasswordChangeDataLoaded, | 81 base::Bind(&SupervisedUserLoginFlow::OnPasswordChangeDataLoaded, |
| 82 weak_factory_.GetWeakPtr()), | 82 weak_factory_.GetWeakPtr()), |
| 83 base::Bind(&SupervisedUserLoginFlow::OnPasswordChangeDataLoadFailed, | 83 base::Bind(&SupervisedUserLoginFlow::OnPasswordChangeDataLoadFailed, |
| 84 weak_factory_.GetWeakPtr())); | 84 weak_factory_.GetWeakPtr())); |
| 85 return; | 85 return; |
| 86 } | 86 } |
| 87 Finish(); | 87 Finish(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void SupervisedUserLoginFlow::HandleLoginSuccess( | 90 void SupervisedUserLoginFlow::HandleLoginSuccess( |
| 91 const UserContext& login_context) { | 91 const UserContext& login_context) { |
| 92 context_ = login_context; | 92 context_ = login_context; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void SupervisedUserLoginFlow::OnPasswordChangeDataLoaded( | 95 void SupervisedUserLoginFlow::OnPasswordChangeDataLoaded( |
| 96 const base::DictionaryValue* password_data) { | 96 const base::DictionaryValue* password_data) { |
| 97 // Edge case, when manager has signed in and already updated the password. | 97 // Edge case, when manager has signed in and already updated the password. |
| 98 SupervisedUserAuthentication* auth = | 98 SupervisedUserAuthentication* auth = |
| 99 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 99 GetUserManager()->GetSupervisedUserManager()->GetAuthentication(); |
| 100 if (!auth->NeedPasswordChange(user_id(), password_data)) { | 100 if (!auth->NeedPasswordChange(user_id(), password_data)) { |
| 101 VLOG(1) << "Password already changed for " << user_id(); | 101 VLOG(1) << "Password already changed for " << user_id(); |
| 102 auth->ClearScheduledPasswordUpdate(user_id()); | 102 auth->ClearScheduledPasswordUpdate(user_id()); |
| 103 Finish(); | 103 Finish(); |
| 104 return; | 104 return; |
| 105 } | 105 } |
| 106 | 106 |
| 107 // Two cases now - we can currently have either old-style password, or new | 107 // Two cases now - we can currently have either old-style password, or new |
| 108 // password. | 108 // password. |
| 109 std::string base64_signature; | 109 std::string base64_signature; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 Passed(&data_copy))); | 173 Passed(&data_copy))); |
| 174 } else { | 174 } else { |
| 175 NOTREACHED() << "Unsupported password schema"; | 175 NOTREACHED() << "Unsupported password schema"; |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 void SupervisedUserLoginFlow::OnNewKeyAdded( | 179 void SupervisedUserLoginFlow::OnNewKeyAdded( |
| 180 scoped_ptr<base::DictionaryValue> password_data) { | 180 scoped_ptr<base::DictionaryValue> password_data) { |
| 181 VLOG(1) << "New key added"; | 181 VLOG(1) << "New key added"; |
| 182 SupervisedUserAuthentication* auth = | 182 SupervisedUserAuthentication* auth = |
| 183 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 183 GetUserManager()->GetSupervisedUserManager()->GetAuthentication(); |
| 184 auth->StorePasswordData(user_id(), *password_data.get()); | 184 auth->StorePasswordData(user_id(), *password_data.get()); |
| 185 auth->MarkKeyIncomplete(user_id(), true /* incomplete */); | 185 auth->MarkKeyIncomplete(user_id(), true /* incomplete */); |
| 186 authenticator_->RemoveKey( | 186 authenticator_->RemoveKey( |
| 187 context_, | 187 context_, |
| 188 kLegacyCryptohomeSupervisedUserKeyLabel, | 188 kLegacyCryptohomeSupervisedUserKeyLabel, |
| 189 base::Bind(&SupervisedUserLoginFlow::OnOldKeyRemoved, | 189 base::Bind(&SupervisedUserLoginFlow::OnOldKeyRemoved, |
| 190 weak_factory_.GetWeakPtr())); | 190 weak_factory_.GetWeakPtr())); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void SupervisedUserLoginFlow::OnOldKeyRemoved() { | 193 void SupervisedUserLoginFlow::OnOldKeyRemoved() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 218 PASSWORD_CHANGE_FAILED_AUTHENTICATION_FAILURE, | 218 PASSWORD_CHANGE_FAILED_AUTHENTICATION_FAILURE, |
| 219 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); | 219 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); |
| 220 Finish(); | 220 Finish(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void SupervisedUserLoginFlow::OnPasswordUpdated( | 223 void SupervisedUserLoginFlow::OnPasswordUpdated( |
| 224 scoped_ptr<base::DictionaryValue> password_data) { | 224 scoped_ptr<base::DictionaryValue> password_data) { |
| 225 VLOG(1) << "Updated password for supervised user"; | 225 VLOG(1) << "Updated password for supervised user"; |
| 226 | 226 |
| 227 SupervisedUserAuthentication* auth = | 227 SupervisedUserAuthentication* auth = |
| 228 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 228 GetUserManager()->GetSupervisedUserManager()->GetAuthentication(); |
| 229 | 229 |
| 230 // Incomplete state is not there in password_data, carry it from old state. | 230 // Incomplete state is not there in password_data, carry it from old state. |
| 231 bool was_incomplete = auth->HasIncompleteKey(user_id()); | 231 bool was_incomplete = auth->HasIncompleteKey(user_id()); |
| 232 auth->StorePasswordData(user_id(), *password_data.get()); | 232 auth->StorePasswordData(user_id(), *password_data.get()); |
| 233 if (was_incomplete) | 233 if (was_incomplete) |
| 234 auth->MarkKeyIncomplete(user_id(), true /* incomplete */); | 234 auth->MarkKeyIncomplete(user_id(), true /* incomplete */); |
| 235 | 235 |
| 236 UMA_HISTOGRAM_ENUMERATION( | 236 UMA_HISTOGRAM_ENUMERATION( |
| 237 "ManagedUsers.ChromeOS.PasswordChange", | 237 "ManagedUsers.ChromeOS.PasswordChange", |
| 238 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_USER_SESSION, | 238 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_USER_SESSION, |
| 239 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); | 239 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); |
| 240 Finish(); | 240 Finish(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void SupervisedUserLoginFlow::Finish() { | 243 void SupervisedUserLoginFlow::Finish() { |
| 244 LoginUtils::Get()->DoBrowserLaunch(profile_, host()); | 244 LoginUtils::Get()->DoBrowserLaunch(profile_, host()); |
| 245 profile_ = NULL; | 245 profile_ = NULL; |
| 246 UnregisterFlowSoon(); | 246 UnregisterFlowSoon(); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void SupervisedUserLoginFlow::LaunchExtraSteps( | 249 void SupervisedUserLoginFlow::LaunchExtraSteps( |
| 250 Profile* profile) { | 250 Profile* profile) { |
| 251 profile_ = profile; | 251 profile_ = profile; |
| 252 UserManager::Get()->GetSupervisedUserManager()->LoadSupervisedUserToken( | 252 GetUserManager()->GetSupervisedUserManager()->LoadSupervisedUserToken( |
| 253 profile, | 253 profile, |
| 254 base::Bind( | 254 base::Bind(&SupervisedUserLoginFlow::OnSyncSetupDataLoaded, |
| 255 &SupervisedUserLoginFlow::OnSyncSetupDataLoaded, | 255 weak_factory_.GetWeakPtr())); |
| 256 weak_factory_.GetWeakPtr())); | |
| 257 } | 256 } |
| 258 | 257 |
| 259 } // namespace chromeos | 258 } // namespace chromeos |
| OLD | NEW |