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

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

Issue 1693383003: ChromeOS cryptohome should be able to use gaia id as user identifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed unit tests. Created 4 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const UserContext& context, 75 const UserContext& context,
76 const base::Closure& success_callback) { 76 const base::Closure& success_callback) {
77 TransformKeyIfNeeded( 77 TransformKeyIfNeeded(
78 context, 78 context,
79 base::Bind(&ExtendedAuthenticatorImpl::DoAuthenticateToCheck, 79 base::Bind(&ExtendedAuthenticatorImpl::DoAuthenticateToCheck,
80 this, 80 this,
81 success_callback)); 81 success_callback));
82 } 82 }
83 83
84 void ExtendedAuthenticatorImpl::CreateMount( 84 void ExtendedAuthenticatorImpl::CreateMount(
85 const std::string& user_id, 85 const AccountId& account_id,
86 const std::vector<cryptohome::KeyDefinition>& keys, 86 const std::vector<cryptohome::KeyDefinition>& keys,
87 const ResultCallback& success_callback) { 87 const ResultCallback& success_callback) {
88 RecordStartMarker("MountEx"); 88 RecordStartMarker("MountEx");
89 89
90 std::string canonicalized = gaia::CanonicalizeEmail(user_id); 90 cryptohome::Identification id(account_id);
91 cryptohome::Identification id(canonicalized);
92 cryptohome::Authorization auth(keys.front()); 91 cryptohome::Authorization auth(keys.front());
93 cryptohome::MountParameters mount(false); 92 cryptohome::MountParameters mount(false);
94 for (size_t i = 0; i < keys.size(); i++) { 93 for (size_t i = 0; i < keys.size(); i++) {
95 mount.create_keys.push_back(keys[i]); 94 mount.create_keys.push_back(keys[i]);
96 } 95 }
97 UserContext context(AccountId::FromUserEmail(user_id)); 96 UserContext context(account_id);
98 Key key(keys.front().secret); 97 Key key(keys.front().secret);
99 key.SetLabel(keys.front().label); 98 key.SetLabel(keys.front().label);
100 context.SetKey(key); 99 context.SetKey(key);
101 100
102 cryptohome::HomedirMethods::GetInstance()->MountEx( 101 cryptohome::HomedirMethods::GetInstance()->MountEx(
103 id, 102 id,
104 auth, 103 auth,
105 mount, 104 mount,
106 base::Bind(&ExtendedAuthenticatorImpl::OnMountComplete, 105 base::Bind(&ExtendedAuthenticatorImpl::OnMountComplete,
107 this, 106 this,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 it->Run(); 181 it->Run();
183 } 182 }
184 system_salt_callbacks_.clear(); 183 system_salt_callbacks_.clear();
185 } 184 }
186 185
187 void ExtendedAuthenticatorImpl::DoAuthenticateToMount( 186 void ExtendedAuthenticatorImpl::DoAuthenticateToMount(
188 const ResultCallback& success_callback, 187 const ResultCallback& success_callback,
189 const UserContext& user_context) { 188 const UserContext& user_context) {
190 RecordStartMarker("MountEx"); 189 RecordStartMarker("MountEx");
191 190
192 const std::string canonicalized = 191 cryptohome::Identification id(user_context.GetAccountId());
193 gaia::CanonicalizeEmail(user_context.GetAccountId().GetUserEmail());
194 cryptohome::Identification id(canonicalized);
195 const Key* const key = user_context.GetKey(); 192 const Key* const key = user_context.GetKey();
196 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel()); 193 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel());
197 cryptohome::MountParameters mount(false); 194 cryptohome::MountParameters mount(false);
198 195
199 cryptohome::HomedirMethods::GetInstance()->MountEx( 196 cryptohome::HomedirMethods::GetInstance()->MountEx(
200 id, 197 id,
201 auth, 198 auth,
202 mount, 199 mount,
203 base::Bind(&ExtendedAuthenticatorImpl::OnMountComplete, 200 base::Bind(&ExtendedAuthenticatorImpl::OnMountComplete,
204 this, 201 this,
205 "MountEx", 202 "MountEx",
206 user_context, 203 user_context,
207 success_callback)); 204 success_callback));
208 } 205 }
209 206
210 void ExtendedAuthenticatorImpl::DoAuthenticateToCheck( 207 void ExtendedAuthenticatorImpl::DoAuthenticateToCheck(
211 const base::Closure& success_callback, 208 const base::Closure& success_callback,
212 const UserContext& user_context) { 209 const UserContext& user_context) {
213 RecordStartMarker("CheckKeyEx"); 210 RecordStartMarker("CheckKeyEx");
214 211
215 const std::string canonicalized = 212 cryptohome::Identification id(user_context.GetAccountId());
216 gaia::CanonicalizeEmail(user_context.GetAccountId().GetUserEmail());
217 cryptohome::Identification id(canonicalized);
218 const Key* const key = user_context.GetKey(); 213 const Key* const key = user_context.GetKey();
219 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel()); 214 cryptohome::Authorization auth(key->GetSecret(), key->GetLabel());
220 215
221 cryptohome::HomedirMethods::GetInstance()->CheckKeyEx( 216 cryptohome::HomedirMethods::GetInstance()->CheckKeyEx(
222 id, 217 id,
223 auth, 218 auth,
224 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete, 219 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete,
225 this, 220 this,
226 "CheckKeyEx", 221 "CheckKeyEx",
227 user_context, 222 user_context,
228 success_callback)); 223 success_callback));
229 } 224 }
230 225
231 void ExtendedAuthenticatorImpl::DoAddKey(const cryptohome::KeyDefinition& key, 226 void ExtendedAuthenticatorImpl::DoAddKey(const cryptohome::KeyDefinition& key,
232 bool replace_existing, 227 bool replace_existing,
233 const base::Closure& success_callback, 228 const base::Closure& success_callback,
234 const UserContext& user_context) { 229 const UserContext& user_context) {
235 RecordStartMarker("AddKeyEx"); 230 RecordStartMarker("AddKeyEx");
236 231
237 const std::string canonicalized = 232 cryptohome::Identification id(user_context.GetAccountId());
238 gaia::CanonicalizeEmail(user_context.GetAccountId().GetUserEmail());
239 cryptohome::Identification id(canonicalized);
240 const Key* const auth_key = user_context.GetKey(); 233 const Key* const auth_key = user_context.GetKey();
241 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); 234 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel());
242 235
243 cryptohome::HomedirMethods::GetInstance()->AddKeyEx( 236 cryptohome::HomedirMethods::GetInstance()->AddKeyEx(
244 id, 237 id,
245 auth, 238 auth,
246 key, 239 key,
247 replace_existing, 240 replace_existing,
248 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete, 241 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete,
249 this, 242 this,
250 "AddKeyEx", 243 "AddKeyEx",
251 user_context, 244 user_context,
252 success_callback)); 245 success_callback));
253 } 246 }
254 247
255 void ExtendedAuthenticatorImpl::DoUpdateKeyAuthorized( 248 void ExtendedAuthenticatorImpl::DoUpdateKeyAuthorized(
256 const cryptohome::KeyDefinition& key, 249 const cryptohome::KeyDefinition& key,
257 const std::string& signature, 250 const std::string& signature,
258 const base::Closure& success_callback, 251 const base::Closure& success_callback,
259 const UserContext& user_context) { 252 const UserContext& user_context) {
260 RecordStartMarker("UpdateKeyAuthorized"); 253 RecordStartMarker("UpdateKeyAuthorized");
261 254
262 const std::string canonicalized = 255 cryptohome::Identification id(user_context.GetAccountId());
263 gaia::CanonicalizeEmail(user_context.GetAccountId().GetUserEmail());
264 cryptohome::Identification id(canonicalized);
265 const Key* const auth_key = user_context.GetKey(); 256 const Key* const auth_key = user_context.GetKey();
266 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); 257 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel());
267 258
268 cryptohome::HomedirMethods::GetInstance()->UpdateKeyEx( 259 cryptohome::HomedirMethods::GetInstance()->UpdateKeyEx(
269 id, 260 id,
270 auth, 261 auth,
271 key, 262 key,
272 signature, 263 signature,
273 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete, 264 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete,
274 this, 265 this,
275 "UpdateKeyAuthorized", 266 "UpdateKeyAuthorized",
276 user_context, 267 user_context,
277 success_callback)); 268 success_callback));
278 } 269 }
279 270
280 void ExtendedAuthenticatorImpl::DoRemoveKey(const std::string& key_to_remove, 271 void ExtendedAuthenticatorImpl::DoRemoveKey(const std::string& key_to_remove,
281 const base::Closure& success_callback, 272 const base::Closure& success_callback,
282 const UserContext& user_context) { 273 const UserContext& user_context) {
283 RecordStartMarker("RemoveKeyEx"); 274 RecordStartMarker("RemoveKeyEx");
284 275
285 const std::string canonicalized = 276 cryptohome::Identification id(user_context.GetAccountId());
286 gaia::CanonicalizeEmail(user_context.GetAccountId().GetUserEmail());
287 cryptohome::Identification id(canonicalized);
288 const Key* const auth_key = user_context.GetKey(); 277 const Key* const auth_key = user_context.GetKey();
289 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); 278 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel());
290 279
291 cryptohome::HomedirMethods::GetInstance()->RemoveKeyEx( 280 cryptohome::HomedirMethods::GetInstance()->RemoveKeyEx(
292 id, 281 id,
293 auth, 282 auth,
294 key_to_remove, 283 key_to_remove,
295 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete, 284 base::Bind(&ExtendedAuthenticatorImpl::OnOperationComplete,
296 this, 285 this,
297 "RemoveKeyEx", 286 "RemoveKeyEx",
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (consumer_) 353 if (consumer_)
365 consumer_->OnAuthenticationFailure(state); 354 consumer_->OnAuthenticationFailure(state);
366 355
367 if (old_consumer_) { 356 if (old_consumer_) {
368 AuthFailure failure(AuthFailure::UNLOCK_FAILED); 357 AuthFailure failure(AuthFailure::UNLOCK_FAILED);
369 old_consumer_->OnAuthFailure(failure); 358 old_consumer_->OnAuthFailure(failure);
370 } 359 }
371 } 360 }
372 361
373 } // namespace chromeos 362 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/login/auth/extended_authenticator_impl.h ('k') | chromeos/login/auth/fake_extended_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698