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 "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_manager.h" | |
17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
18 #include "chromeos/cryptohome/signed_secret.pb.h" | 17 #include "chromeos/cryptohome/signed_secret.pb.h" |
19 #include "chromeos/login/auth/key.h" | 18 #include "chromeos/login/auth/key.h" |
20 #include "components/user_manager/user.h" | 19 #include "components/user_manager/user.h" |
| 20 #include "components/user_manager/user_manager.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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_manager::User* user = | 226 const user_manager::User* user = |
227 UserManager::Get()->FindUser(supervised_user_id); | 227 user_manager::UserManager::Get()->FindUser(supervised_user_id); |
228 base::FilePath profile_path = ProfileHelper::GetProfilePathByUserIdHash( | 228 base::FilePath profile_path = ProfileHelper::GetProfilePathByUserIdHash( |
229 user->username_hash()); | 229 user->username_hash()); |
230 JSONFileValueSerializer serializer(profile_path.Append(kPasswordUpdateFile)); | 230 JSONFileValueSerializer serializer(profile_path.Append(kPasswordUpdateFile)); |
231 if (!serializer.Serialize(*password_data)) { | 231 if (!serializer.Serialize(*password_data)) { |
232 LOG(ERROR) << "Failed to schedule password update for supervised user " | 232 LOG(ERROR) << "Failed to schedule password update for supervised user " |
233 << supervised_user_id; | 233 << supervised_user_id; |
234 UMA_HISTOGRAM_ENUMERATION( | 234 UMA_HISTOGRAM_ENUMERATION( |
235 "ManagedUsers.ChromeOS.PasswordChange", | 235 "ManagedUsers.ChromeOS.PasswordChange", |
236 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_STORE_DATA, | 236 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_STORE_DATA, |
237 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 Loading... |
274 base::DictionaryValue holder; | 274 base::DictionaryValue holder; |
275 owner_->GetPasswordInformation(user_id, &holder); | 275 owner_->GetPasswordInformation(user_id, &holder); |
276 holder.SetBoolean(kHasIncompleteKey, incomplete); | 276 holder.SetBoolean(kHasIncompleteKey, incomplete); |
277 owner_->SetPasswordInformation(user_id, &holder); | 277 owner_->SetPasswordInformation(user_id, &holder); |
278 } | 278 } |
279 | 279 |
280 void SupervisedUserAuthentication::LoadPasswordUpdateData( | 280 void SupervisedUserAuthentication::LoadPasswordUpdateData( |
281 const std::string& user_id, | 281 const std::string& user_id, |
282 const PasswordDataCallback& success_callback, | 282 const PasswordDataCallback& success_callback, |
283 const base::Closure& failure_callback) { | 283 const base::Closure& failure_callback) { |
284 const user_manager::User* user = UserManager::Get()->FindUser(user_id); | 284 const user_manager::User* user = |
| 285 user_manager::UserManager::Get()->FindUser(user_id); |
285 base::FilePath profile_path = | 286 base::FilePath profile_path = |
286 ProfileHelper::GetProfilePathByUserIdHash(user->username_hash()); | 287 ProfileHelper::GetProfilePathByUserIdHash(user->username_hash()); |
287 PostTaskAndReplyWithResult( | 288 PostTaskAndReplyWithResult( |
288 content::BrowserThread::GetBlockingPool(), | 289 content::BrowserThread::GetBlockingPool(), |
289 FROM_HERE, | 290 FROM_HERE, |
290 base::Bind(&LoadPasswordData, profile_path), | 291 base::Bind(&LoadPasswordData, profile_path), |
291 base::Bind(&OnPasswordDataLoaded, success_callback, failure_callback)); | 292 base::Bind(&OnPasswordDataLoaded, success_callback, failure_callback)); |
292 } | 293 } |
293 | 294 |
294 std::string SupervisedUserAuthentication::BuildPasswordSignature( | 295 std::string SupervisedUserAuthentication::BuildPasswordSignature( |
(...skipping 18 matching lines...) Expand all Loading... |
313 LOG(FATAL) << "HMAC::Sign failed"; | 314 LOG(FATAL) << "HMAC::Sign failed"; |
314 | 315 |
315 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes)); | 316 std::string raw_result(out_bytes, out_bytes + sizeof(out_bytes)); |
316 | 317 |
317 std::string result; | 318 std::string result; |
318 base::Base64Encode(raw_result, &result); | 319 base::Base64Encode(raw_result, &result); |
319 return result; | 320 return result; |
320 } | 321 } |
321 | 322 |
322 } // namespace chromeos | 323 } // namespace chromeos |
OLD | NEW |