Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: chrome/browser/chromeos/login/managed/supervised_user_login_flow.cc

Issue 221813006: Various supervised user password fixes - 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upload once again Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 // Two cases now - we can currently have either old-style password, or new 106 // Two cases now - we can currently have either old-style password, or new
107 // password. 107 // password.
108 std::string base64_signature; 108 std::string base64_signature;
109 std::string signature; 109 std::string signature;
110 std::string password; 110 std::string password;
111 int revision = 0; 111 int revision = 0;
112 int schema = 0; 112 int schema = 0;
113 bool success = password_data->GetStringWithoutPathExpansion( 113 bool success = password_data->GetStringWithoutPathExpansion(
114 kPasswordSignatureKey, &base64_signature); 114 kPasswordSignature, &base64_signature);
115 success &= password_data->GetIntegerWithoutPathExpansion(kPasswordRevision, 115 success &= password_data->GetIntegerWithoutPathExpansion(kPasswordRevision,
116 &revision); 116 &revision);
117 success &= 117 success &=
118 password_data->GetIntegerWithoutPathExpansion(kSchemaVersion, &schema); 118 password_data->GetIntegerWithoutPathExpansion(kSchemaVersion, &schema);
119 success &= password_data->GetStringWithoutPathExpansion(kEncryptedPassword, 119 success &= password_data->GetStringWithoutPathExpansion(kEncryptedPassword,
120 &password); 120 &password);
121 if (!success) { 121 if (!success) {
122 LOG(ERROR) << "Incomplete data for password change"; 122 LOG(ERROR) << "Incomplete data for password change";
123 123
124 UMA_HISTOGRAM_ENUMERATION( 124 UMA_HISTOGRAM_ENUMERATION(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 NOTREACHED() << "Unsupported password schema"; 174 NOTREACHED() << "Unsupported password schema";
175 } 175 }
176 } 176 }
177 177
178 void SupervisedUserLoginFlow::OnNewKeyAdded( 178 void SupervisedUserLoginFlow::OnNewKeyAdded(
179 scoped_ptr<base::DictionaryValue> password_data) { 179 scoped_ptr<base::DictionaryValue> password_data) {
180 VLOG(1) << "New key added"; 180 VLOG(1) << "New key added";
181 SupervisedUserAuthentication* auth = 181 SupervisedUserAuthentication* auth =
182 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); 182 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication();
183 auth->StorePasswordData(user_id(), *password_data.get()); 183 auth->StorePasswordData(user_id(), *password_data.get());
184 auth->MarkKeyIncomplete(user_id()); 184 auth->MarkKeyIncomplete(user_id(), true);
Nikita (slow) 2014/04/02 14:18:20 nit: true /* incomplete */
Denis Kuznetsov (DE-MUC) 2014/04/02 14:48:51 Done.
185 authenticator_->RemoveKey( 185 authenticator_->RemoveKey(
186 context_, 186 context_,
187 kLegacyCryptohomeManagedUserKeyLabel, 187 kLegacyCryptohomeManagedUserKeyLabel,
188 base::Bind(&SupervisedUserLoginFlow::OnOldKeyRemoved, 188 base::Bind(&SupervisedUserLoginFlow::OnOldKeyRemoved,
189 weak_factory_.GetWeakPtr())); 189 weak_factory_.GetWeakPtr()));
190 } 190 }
191 191
192 void SupervisedUserLoginFlow::OnOldKeyRemoved() { 192 void SupervisedUserLoginFlow::OnOldKeyRemoved() {
193 UMA_HISTOGRAM_ENUMERATION( 193 UMA_HISTOGRAM_ENUMERATION(
194 "ManagedUsers.ChromeOS.PasswordChange", 194 "ManagedUsers.ChromeOS.PasswordChange",
(...skipping 28 matching lines...) Expand all
223 scoped_ptr<base::DictionaryValue> password_data) { 223 scoped_ptr<base::DictionaryValue> password_data) {
224 VLOG(1) << "Updated password for supervised user"; 224 VLOG(1) << "Updated password for supervised user";
225 225
226 SupervisedUserAuthentication* auth = 226 SupervisedUserAuthentication* auth =
227 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); 227 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication();
228 228
229 // Incomplete state is not there in password_data, carry it from old state. 229 // Incomplete state is not there in password_data, carry it from old state.
230 bool was_incomplete = auth->HasIncompleteKey(user_id()); 230 bool was_incomplete = auth->HasIncompleteKey(user_id());
231 auth->StorePasswordData(user_id(), *password_data.get()); 231 auth->StorePasswordData(user_id(), *password_data.get());
232 if (was_incomplete) 232 if (was_incomplete)
233 auth->MarkKeyIncomplete(user_id()); 233 auth->MarkKeyIncomplete(user_id(), true);
Nikita (slow) 2014/04/02 14:18:20 nit: true /* incomplete */
Denis Kuznetsov (DE-MUC) 2014/04/02 14:48:51 Done.
234 234
235 UMA_HISTOGRAM_ENUMERATION( 235 UMA_HISTOGRAM_ENUMERATION(
236 "ManagedUsers.ChromeOS.PasswordChange", 236 "ManagedUsers.ChromeOS.PasswordChange",
237 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_USER_SESSION, 237 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_USER_SESSION,
238 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); 238 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE);
239 Finish(); 239 Finish();
240 } 240 }
241 241
242 void SupervisedUserLoginFlow::Finish() { 242 void SupervisedUserLoginFlow::Finish() {
243 LoginUtils::Get()->DoBrowserLaunch(profile_, host()); 243 LoginUtils::Get()->DoBrowserLaunch(profile_, host());
244 profile_ = NULL; 244 profile_ = NULL;
245 UnregisterFlowSoon(); 245 UnregisterFlowSoon();
246 } 246 }
247 247
248 void SupervisedUserLoginFlow::LaunchExtraSteps( 248 void SupervisedUserLoginFlow::LaunchExtraSteps(
249 Profile* profile) { 249 Profile* profile) {
250 profile_ = profile; 250 profile_ = profile;
251 UserManager::Get()->GetSupervisedUserManager()->LoadSupervisedUserToken( 251 UserManager::Get()->GetSupervisedUserManager()->LoadSupervisedUserToken(
252 profile, 252 profile,
253 base::Bind( 253 base::Bind(
254 &SupervisedUserLoginFlow::OnSyncSetupDataLoaded, 254 &SupervisedUserLoginFlow::OnSyncSetupDataLoaded,
255 weak_factory_.GetWeakPtr())); 255 weak_factory_.GetWeakPtr()));
256 } 256 }
257 257
258 } // namespace chromeos 258 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698