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

Side by Side Diff: chromeos/login/auth/extended_authenticator_impl.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 "chromeos/login/auth/extended_authenticator_impl.h" 5 #include "chromeos/login/auth/extended_authenticator_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chromeos/cryptohome/async_method_caller.h" 10 #include "chromeos/cryptohome/async_method_caller.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const UserContext& context, 72 const UserContext& context,
73 const base::Closure& success_callback) { 73 const base::Closure& success_callback) {
74 TransformKeyIfNeeded( 74 TransformKeyIfNeeded(
75 context, 75 context,
76 base::Bind(&ExtendedAuthenticatorImpl::DoAuthenticateToCheck, 76 base::Bind(&ExtendedAuthenticatorImpl::DoAuthenticateToCheck,
77 this, 77 this,
78 success_callback)); 78 success_callback));
79 } 79 }
80 80
81 void ExtendedAuthenticatorImpl::CreateMount( 81 void ExtendedAuthenticatorImpl::CreateMount(
82 const std::string& user_id, 82 const user_manager::UserID& user_id,
83 const std::vector<cryptohome::KeyDefinition>& keys, 83 const std::vector<cryptohome::KeyDefinition>& keys,
84 const ResultCallback& success_callback) { 84 const ResultCallback& success_callback) {
85 RecordStartMarker("MountEx"); 85 RecordStartMarker("MountEx");
86 86
87 std::string canonicalized = gaia::CanonicalizeEmail(user_id); 87 cryptohome::Identification id(user_id);
88 cryptohome::Identification id(canonicalized);
89 cryptohome::Authorization auth(keys.front()); 88 cryptohome::Authorization auth(keys.front());
90 cryptohome::MountParameters mount(false); 89 cryptohome::MountParameters mount(false);
91 for (size_t i = 0; i < keys.size(); i++) { 90 for (size_t i = 0; i < keys.size(); i++) {
92 mount.create_keys.push_back(keys[i]); 91 mount.create_keys.push_back(keys[i]);
93 } 92 }
94 UserContext context(user_id); 93 UserContext context(user_id);
95 Key key(keys.front().secret); 94 Key key(keys.front().secret);
96 key.SetLabel(keys.front().label); 95 key.SetLabel(keys.front().label);
97 context.SetKey(key); 96 context.SetKey(key);
98 97
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 it->Run(); 178 it->Run();
180 } 179 }
181 system_salt_callbacks_.clear(); 180 system_salt_callbacks_.clear();
182 } 181 }
183 182
184 void ExtendedAuthenticatorImpl::DoAuthenticateToMount( 183 void ExtendedAuthenticatorImpl::DoAuthenticateToMount(
185 const ResultCallback& success_callback, 184 const ResultCallback& success_callback,
186 const UserContext& user_context) { 185 const UserContext& user_context) {
187 RecordStartMarker("MountEx"); 186 RecordStartMarker("MountEx");
188 187
189 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); 188 cryptohome::Identification id(user_context.GetUserID());
190 cryptohome::Identification id(canonicalized);
191 const Key* const key = user_context.GetKey(); 189 const Key* const key = user_context.GetKey();
192 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel()); 190 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel());
193 cryptohome::MountParameters mount(false); 191 cryptohome::MountParameters mount(false);
194 192
195 cryptohome::HomedirMethods::GetInstance()->MountEx( 193 cryptohome::HomedirMethods::GetInstance()->MountEx(
196 id, 194 id,
197 auth, 195 auth,
198 mount, 196 mount,
199 base::Bind(&ExtendedAuthenticatorImpl::OnMountComplete, 197 base::Bind(&ExtendedAuthenticatorImpl::OnMountComplete,
200 this, 198 this,
201 "MountEx", 199 "MountEx",
202 user_context, 200 user_context,
203 success_callback)); 201 success_callback));
204 } 202 }
205 203
206 void ExtendedAuthenticatorImpl::DoAuthenticateToCheck( 204 void ExtendedAuthenticatorImpl::DoAuthenticateToCheck(
207 const base::Closure& success_callback, 205 const base::Closure& success_callback,
208 const UserContext& user_context) { 206 const UserContext& user_context) {
209 RecordStartMarker("CheckKeyEx"); 207 RecordStartMarker("CheckKeyEx");
210 208
211 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); 209 cryptohome::Identification id(user_context.GetUserID());
212 cryptohome::Identification id(canonicalized);
213 const Key* const key = user_context.GetKey(); 210 const Key* const key = user_context.GetKey();
214 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel()); 211 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel());
215 212
216 cryptohome::HomedirMethods::GetInstance()->CheckKeyEx( 213 cryptohome::HomedirMethods::GetInstance()->CheckKeyEx(
217 id, 214 id,
218 auth, 215 auth,
219 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete, 216 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete,
220 this, 217 this,
221 "CheckKeyEx", 218 "CheckKeyEx",
222 user_context, 219 user_context,
223 success_callback)); 220 success_callback));
224 } 221 }
225 222
226 void ExtendedAuthenticatorImpl::DoAddKey(const cryptohome::KeyDefinition& key, 223 void ExtendedAuthenticatorImpl::DoAddKey(const cryptohome::KeyDefinition& key,
227 bool replace_existing, 224 bool replace_existing,
228 const base::Closure& success_callback, 225 const base::Closure& success_callback,
229 const UserContext& user_context) { 226 const UserContext& user_context) {
230 RecordStartMarker("AddKeyEx"); 227 RecordStartMarker("AddKeyEx");
231 228
232 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); 229 cryptohome::Identification id(user_context.GetUserID());
233 cryptohome::Identification id(canonicalized);
234 const Key* const auth_key = user_context.GetKey(); 230 const Key* const auth_key = user_context.GetKey();
235 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); 231 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel());
236 232
237 cryptohome::HomedirMethods::GetInstance()->AddKeyEx( 233 cryptohome::HomedirMethods::GetInstance()->AddKeyEx(
238 id, 234 id,
239 auth, 235 auth,
240 key, 236 key,
241 replace_existing, 237 replace_existing,
242 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete, 238 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete,
243 this, 239 this,
244 "AddKeyEx", 240 "AddKeyEx",
245 user_context, 241 user_context,
246 success_callback)); 242 success_callback));
247 } 243 }
248 244
249 void ExtendedAuthenticatorImpl::DoUpdateKeyAuthorized( 245 void ExtendedAuthenticatorImpl::DoUpdateKeyAuthorized(
250 const cryptohome::KeyDefinition& key, 246 const cryptohome::KeyDefinition& key,
251 const std::string& signature, 247 const std::string& signature,
252 const base::Closure& success_callback, 248 const base::Closure& success_callback,
253 const UserContext& user_context) { 249 const UserContext& user_context) {
254 RecordStartMarker("UpdateKeyAuthorized"); 250 RecordStartMarker("UpdateKeyAuthorized");
255 251
256 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); 252 cryptohome::Identification id(user_context.GetUserID());
257 cryptohome::Identification id(canonicalized);
258 const Key* const auth_key = user_context.GetKey(); 253 const Key* const auth_key = user_context.GetKey();
259 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); 254 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel());
260 255
261 cryptohome::HomedirMethods::GetInstance()->UpdateKeyEx( 256 cryptohome::HomedirMethods::GetInstance()->UpdateKeyEx(
262 id, 257 id,
263 auth, 258 auth,
264 key, 259 key,
265 signature, 260 signature,
266 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete, 261 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete,
267 this, 262 this,
268 "UpdateKeyAuthorized", 263 "UpdateKeyAuthorized",
269 user_context, 264 user_context,
270 success_callback)); 265 success_callback));
271 } 266 }
272 267
273 void ExtendedAuthenticatorImpl::DoRemoveKey(const std::string& key_to_remove, 268 void ExtendedAuthenticatorImpl::DoRemoveKey(const std::string& key_to_remove,
274 const base::Closure& success_callback, 269 const base::Closure& success_callback,
275 const UserContext& user_context) { 270 const UserContext& user_context) {
276 RecordStartMarker("RemoveKeyEx"); 271 RecordStartMarker("RemoveKeyEx");
277 272
278 std::string canonicalized = gaia::CanonicalizeEmail(user_context.GetUserID()); 273 cryptohome::Identification id(user_context.GetUserID());
279 cryptohome::Identification id(canonicalized);
280 const Key* const auth_key = user_context.GetKey(); 274 const Key* const auth_key = user_context.GetKey();
281 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); 275 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel());
282 276
283 cryptohome::HomedirMethods::GetInstance()->RemoveKeyEx( 277 cryptohome::HomedirMethods::GetInstance()->RemoveKeyEx(
284 id, 278 id,
285 auth, 279 auth,
286 key_to_remove, 280 key_to_remove,
287 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete, 281 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete,
288 this, 282 this,
289 "RemoveKeyEx", 283 "RemoveKeyEx",
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 if (consumer_) 350 if (consumer_)
357 consumer_->OnAuthenticationFailure(state); 351 consumer_->OnAuthenticationFailure(state);
358 352
359 if (old_consumer_) { 353 if (old_consumer_) {
360 AuthFailure failure(AuthFailure::UNLOCK_FAILED); 354 AuthFailure failure(AuthFailure::UNLOCK_FAILED);
361 old_consumer_->OnAuthFailure(failure); 355 old_consumer_->OnAuthFailure(failure);
362 } 356 }
363 } 357 }
364 358
365 } // namespace chromeos 359 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698