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/supervised_user/chromeos/manager_password_service.h" | 5 #include "chrome/browser/supervised_user/chromeos/manager_password_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.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/values.h" | 10 #include "base/values.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 &encryption_key)) { | 124 &encryption_key)) { |
125 LOG(WARNING) << "Can not apply password change to " << user_id | 125 LOG(WARNING) << "Can not apply password change to " << user_id |
126 << ": no signature / encryption keys."; | 126 << ": no signature / encryption keys."; |
127 UMA_HISTOGRAM_ENUMERATION( | 127 UMA_HISTOGRAM_ENUMERATION( |
128 "ManagedUsers.ChromeOS.PasswordChange", | 128 "ManagedUsers.ChromeOS.PasswordChange", |
129 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_NO_SIGNATURE_KEY, | 129 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_NO_SIGNATURE_KEY, |
130 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); | 130 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); |
131 return; | 131 return; |
132 } | 132 } |
133 | 133 |
134 UserContext manager_key(user_id); | 134 UserContext manager_key(AccountId::FromUserEmail(user_id)); |
135 manager_key.SetKey(Key(master_key)); | 135 manager_key.SetKey(Key(master_key)); |
136 manager_key.SetIsUsingOAuth(false); | 136 manager_key.SetIsUsingOAuth(false); |
137 | 137 |
138 // As master key can have old label, leave label field empty - it will work | 138 // As master key can have old label, leave label field empty - it will work |
139 // as wildcard. | 139 // as wildcard. |
140 | 140 |
141 std::string new_key; | 141 std::string new_key; |
142 int revision; | 142 int revision; |
143 | 143 |
144 bool has_data = password_data->GetStringWithoutPathExpansion( | 144 bool has_data = password_data->GetStringWithoutPathExpansion( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 master_key_context, | 233 master_key_context, |
234 new_master_key, | 234 new_master_key, |
235 true /* replace existing */, | 235 true /* replace existing */, |
236 base::Bind(&ManagerPasswordService::OnNewManagerKeySuccess, | 236 base::Bind(&ManagerPasswordService::OnNewManagerKeySuccess, |
237 weak_ptr_factory_.GetWeakPtr(), | 237 weak_ptr_factory_.GetWeakPtr(), |
238 new_master_key_context)); | 238 new_master_key_context)); |
239 } | 239 } |
240 | 240 |
241 void ManagerPasswordService::OnNewManagerKeySuccess( | 241 void ManagerPasswordService::OnNewManagerKeySuccess( |
242 const UserContext& master_key_context) { | 242 const UserContext& master_key_context) { |
243 VLOG(1) << "Added new master key for " << master_key_context.GetUserID(); | 243 VLOG(1) << "Added new master key for " |
| 244 << master_key_context.GetAccountId().GetUserEmail(); |
244 authenticator_->RemoveKey( | 245 authenticator_->RemoveKey( |
245 master_key_context, | 246 master_key_context, |
246 kLegacyCryptohomeSupervisedUserKeyLabel, | 247 kLegacyCryptohomeSupervisedUserKeyLabel, |
247 base::Bind(&ManagerPasswordService::OnOldSupervisedUserKeyDeleted, | 248 base::Bind(&ManagerPasswordService::OnOldSupervisedUserKeyDeleted, |
248 weak_ptr_factory_.GetWeakPtr(), | 249 weak_ptr_factory_.GetWeakPtr(), |
249 master_key_context)); | 250 master_key_context)); |
250 } | 251 } |
251 | 252 |
252 void ManagerPasswordService::OnOldSupervisedUserKeyDeleted( | 253 void ManagerPasswordService::OnOldSupervisedUserKeyDeleted( |
253 const UserContext& master_key_context) { | 254 const UserContext& master_key_context) { |
254 VLOG(1) << "Removed old supervised user key for " | 255 VLOG(1) << "Removed old supervised user key for " |
255 << master_key_context.GetUserID(); | 256 << master_key_context.GetAccountId().GetUserEmail(); |
256 authenticator_->RemoveKey( | 257 authenticator_->RemoveKey( |
257 master_key_context, | 258 master_key_context, |
258 kLegacyCryptohomeMasterKeyLabel, | 259 kLegacyCryptohomeMasterKeyLabel, |
259 base::Bind(&ManagerPasswordService::OnOldManagerKeyDeleted, | 260 base::Bind(&ManagerPasswordService::OnOldManagerKeyDeleted, |
260 weak_ptr_factory_.GetWeakPtr(), | 261 weak_ptr_factory_.GetWeakPtr(), |
261 master_key_context)); | 262 master_key_context)); |
262 } | 263 } |
263 | 264 |
264 void ManagerPasswordService::OnOldManagerKeyDeleted( | 265 void ManagerPasswordService::OnOldManagerKeyDeleted( |
265 const UserContext& master_key_context) { | 266 const UserContext& master_key_context) { |
266 VLOG(1) << "Removed old master key for " << master_key_context.GetUserID(); | 267 VLOG(1) << "Removed old master key for " |
| 268 << master_key_context.GetAccountId().GetUserEmail(); |
267 } | 269 } |
268 | 270 |
269 void ManagerPasswordService::Shutdown() { | 271 void ManagerPasswordService::Shutdown() { |
270 settings_service_subscription_.reset(); | 272 settings_service_subscription_.reset(); |
271 } | 273 } |
272 | 274 |
273 } // namespace chromeos | 275 } // namespace chromeos |
OLD | NEW |