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