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

Side by Side Diff: chrome/browser/chromeos/login/supervised/supervised_user_authentication.cc

Issue 398753004: [cros] Move User class to user_manager component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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 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 "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h" 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 13 #include "base/threading/sequenced_worker_pool.h"
14 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" 14 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h"
15 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 15 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
16 #include "chrome/browser/chromeos/login/users/user.h"
17 #include "chrome/browser/chromeos/login/users/user_manager.h" 16 #include "chrome/browser/chromeos/login/users/user_manager.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" 17 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chromeos/cryptohome/signed_secret.pb.h" 18 #include "chromeos/cryptohome/signed_secret.pb.h"
20 #include "chromeos/login/auth/key.h" 19 #include "chromeos/login/auth/key.h"
20 #include "components/user_manager/user.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "crypto/hmac.h" 22 #include "crypto/hmac.h"
23 #include "crypto/random.h" 23 #include "crypto/random.h"
24 #include "crypto/symmetric_key.h" 24 #include "crypto/symmetric_key.h"
25 25
26 namespace chromeos { 26 namespace chromeos {
27 27
28 namespace { 28 namespace {
29 29
30 // Byte size of hash salt. 30 // Byte size of hash salt.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 &updated_revision); 216 &updated_revision);
217 if (updated_schema > local_schema) 217 if (updated_schema > local_schema)
218 return true; 218 return true;
219 DCHECK_EQ(updated_schema, local_schema); 219 DCHECK_EQ(updated_schema, local_schema);
220 return updated_revision > local_revision; 220 return updated_revision > local_revision;
221 } 221 }
222 222
223 void SupervisedUserAuthentication::ScheduleSupervisedPasswordChange( 223 void SupervisedUserAuthentication::ScheduleSupervisedPasswordChange(
224 const std::string& supervised_user_id, 224 const std::string& supervised_user_id,
225 const base::DictionaryValue* password_data) { 225 const base::DictionaryValue* password_data) {
226 const User* user = UserManager::Get()->FindUser(supervised_user_id); 226 const user_manager::User* user =
227 UserManager::Get()->FindUser(supervised_user_id);
227 base::FilePath profile_path = ProfileHelper::GetProfilePathByUserIdHash( 228 base::FilePath profile_path = ProfileHelper::GetProfilePathByUserIdHash(
228 user->username_hash()); 229 user->username_hash());
229 JSONFileValueSerializer serializer(profile_path.Append(kPasswordUpdateFile)); 230 JSONFileValueSerializer serializer(profile_path.Append(kPasswordUpdateFile));
230 if (!serializer.Serialize(*password_data)) { 231 if (!serializer.Serialize(*password_data)) {
231 LOG(ERROR) << "Failed to schedule password update for supervised user " 232 LOG(ERROR) << "Failed to schedule password update for supervised user "
232 << supervised_user_id; 233 << supervised_user_id;
233 UMA_HISTOGRAM_ENUMERATION( 234 UMA_HISTOGRAM_ENUMERATION(
234 "ManagedUsers.ChromeOS.PasswordChange", 235 "ManagedUsers.ChromeOS.PasswordChange",
235 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_STORE_DATA, 236 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_STORE_DATA,
236 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); 237 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 base::DictionaryValue holder; 274 base::DictionaryValue holder;
274 owner_->GetPasswordInformation(user_id, &holder); 275 owner_->GetPasswordInformation(user_id, &holder);
275 holder.SetBoolean(kHasIncompleteKey, incomplete); 276 holder.SetBoolean(kHasIncompleteKey, incomplete);
276 owner_->SetPasswordInformation(user_id, &holder); 277 owner_->SetPasswordInformation(user_id, &holder);
277 } 278 }
278 279
279 void SupervisedUserAuthentication::LoadPasswordUpdateData( 280 void SupervisedUserAuthentication::LoadPasswordUpdateData(
280 const std::string& user_id, 281 const std::string& user_id,
281 const PasswordDataCallback& success_callback, 282 const PasswordDataCallback& success_callback,
282 const base::Closure& failure_callback) { 283 const base::Closure& failure_callback) {
283 const User* user = UserManager::Get()->FindUser(user_id); 284 const user_manager::User* user = UserManager::Get()->FindUser(user_id);
284 base::FilePath profile_path = 285 base::FilePath profile_path =
285 ProfileHelper::GetProfilePathByUserIdHash(user->username_hash()); 286 ProfileHelper::GetProfilePathByUserIdHash(user->username_hash());
286 PostTaskAndReplyWithResult( 287 PostTaskAndReplyWithResult(
287 content::BrowserThread::GetBlockingPool(), 288 content::BrowserThread::GetBlockingPool(),
288 FROM_HERE, 289 FROM_HERE,
289 base::Bind(&LoadPasswordData, profile_path), 290 base::Bind(&LoadPasswordData, profile_path),
290 base::Bind(&OnPasswordDataLoaded, success_callback, failure_callback)); 291 base::Bind(&OnPasswordDataLoaded, success_callback, failure_callback));
291 } 292 }
292 293
293 std::string SupervisedUserAuthentication::BuildPasswordSignature( 294 std::string SupervisedUserAuthentication::BuildPasswordSignature(
(...skipping 18 matching lines...) Expand all
312 LOG(FATAL) << "HMAC::Sign failed"; 313 LOG(FATAL) << "HMAC::Sign failed";
313 314
314 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes)); 315 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes));
315 316
316 std::string result; 317 std::string result;
317 base::Base64Encode(raw_result, &result); 318 base::Base64Encode(raw_result, &result);
318 return result; 319 return result;
319 } 320 }
320 321
321 } // namespace chromeos 322 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698