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(AccountId::FromUserEmail(user_id)); | 134 UserContext manager_key(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 " | 243 VLOG(1) << "Added new master key for " << master_key_context.GetUserID(); |
244 << master_key_context.GetAccountId().GetUserEmail(); | |
245 authenticator_->RemoveKey( | 244 authenticator_->RemoveKey( |
246 master_key_context, | 245 master_key_context, |
247 kLegacyCryptohomeSupervisedUserKeyLabel, | 246 kLegacyCryptohomeSupervisedUserKeyLabel, |
248 base::Bind(&ManagerPasswordService::OnOldSupervisedUserKeyDeleted, | 247 base::Bind(&ManagerPasswordService::OnOldSupervisedUserKeyDeleted, |
249 weak_ptr_factory_.GetWeakPtr(), | 248 weak_ptr_factory_.GetWeakPtr(), |
250 master_key_context)); | 249 master_key_context)); |
251 } | 250 } |
252 | 251 |
253 void ManagerPasswordService::OnOldSupervisedUserKeyDeleted( | 252 void ManagerPasswordService::OnOldSupervisedUserKeyDeleted( |
254 const UserContext& master_key_context) { | 253 const UserContext& master_key_context) { |
255 VLOG(1) << "Removed old supervised user key for " | 254 VLOG(1) << "Removed old supervised user key for " |
256 << master_key_context.GetAccountId().GetUserEmail(); | 255 << master_key_context.GetUserID(); |
257 authenticator_->RemoveKey( | 256 authenticator_->RemoveKey( |
258 master_key_context, | 257 master_key_context, |
259 kLegacyCryptohomeMasterKeyLabel, | 258 kLegacyCryptohomeMasterKeyLabel, |
260 base::Bind(&ManagerPasswordService::OnOldManagerKeyDeleted, | 259 base::Bind(&ManagerPasswordService::OnOldManagerKeyDeleted, |
261 weak_ptr_factory_.GetWeakPtr(), | 260 weak_ptr_factory_.GetWeakPtr(), |
262 master_key_context)); | 261 master_key_context)); |
263 } | 262 } |
264 | 263 |
265 void ManagerPasswordService::OnOldManagerKeyDeleted( | 264 void ManagerPasswordService::OnOldManagerKeyDeleted( |
266 const UserContext& master_key_context) { | 265 const UserContext& master_key_context) { |
267 VLOG(1) << "Removed old master key for " | 266 VLOG(1) << "Removed old master key for " << master_key_context.GetUserID(); |
268 << master_key_context.GetAccountId().GetUserEmail(); | |
269 } | 267 } |
270 | 268 |
271 void ManagerPasswordService::Shutdown() { | 269 void ManagerPasswordService::Shutdown() { |
272 settings_service_subscription_.reset(); | 270 settings_service_subscription_.reset(); |
273 } | 271 } |
274 | 272 |
275 } // namespace chromeos | 273 } // namespace chromeos |
OLD | NEW |