| 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/signin/easy_unlock_service_signin_chromeos.h" | 5 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/base64url.h" | 9 #include "base/base64url.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 } | 421 } |
| 422 | 422 |
| 423 // If the fetched data belongs to the currently focused user, notify the app | 423 // If the fetched data belongs to the currently focused user, notify the app |
| 424 // that it has to refresh it's user data. | 424 // that it has to refresh it's user data. |
| 425 if (account_id == account_id_) | 425 if (account_id == account_id_) |
| 426 NotifyUserUpdated(); | 426 NotifyUserUpdated(); |
| 427 | 427 |
| 428 if (devices.empty()) | 428 if (devices.empty()) |
| 429 return; | 429 return; |
| 430 | 430 |
| 431 PA_LOG(WARNING) << "Loaded devices: " << devices.size(); |
| 432 |
| 431 cryptauth::RemoteDeviceList remote_devices; | 433 cryptauth::RemoteDeviceList remote_devices; |
| 432 for (const auto& device : devices) { | 434 for (const auto& device : devices) { |
| 433 std::string decoded_public_key, decoded_psk, decoded_challenge; | 435 std::string decoded_public_key, decoded_psk; |
| 434 if (!base::Base64UrlDecode(device.public_key, | 436 if (!base::Base64UrlDecode(device.public_key, |
| 435 base::Base64UrlDecodePolicy::REQUIRE_PADDING, | 437 base::Base64UrlDecodePolicy::REQUIRE_PADDING, |
| 436 &decoded_public_key) || | 438 &decoded_public_key) || |
| 437 !base::Base64UrlDecode(device.psk, | 439 !base::Base64UrlDecode(device.psk, |
| 438 base::Base64UrlDecodePolicy::REQUIRE_PADDING, | 440 base::Base64UrlDecodePolicy::REQUIRE_PADDING, |
| 439 &decoded_psk) || | 441 &decoded_psk)) { |
| 440 !base::Base64UrlDecode(device.challenge, | 442 PA_LOG(ERROR) << "Unable base64url decode stored remote device:\n " |
| 441 base::Base64UrlDecodePolicy::REQUIRE_PADDING, | 443 << "public key: " << device.public_key << "\n" |
| 442 &decoded_challenge)) { | 444 << "psk: " << device.psk; |
| 443 PA_LOG(ERROR) << "Unable base64url decode stored remote device: " | |
| 444 << device.public_key; | |
| 445 continue; | 445 continue; |
| 446 } | 446 } |
| 447 cryptauth::RemoteDevice remote_device( | 447 cryptauth::RemoteDevice remote_device( |
| 448 account_id.GetUserEmail(), std::string(), decoded_public_key, | 448 account_id.GetUserEmail(), std::string(), decoded_public_key, |
| 449 device.bluetooth_address, decoded_psk, decoded_challenge); | 449 device.bluetooth_address, decoded_psk, device.challenge); |
| 450 remote_devices.push_back(remote_device); | 450 remote_devices.push_back(remote_device); |
| 451 PA_LOG(INFO) << "Loaded Remote Device:\n" | 451 PA_LOG(INFO) << "Loaded Remote Device:\n" |
| 452 << " user id: " << remote_device.user_id << "\n" | 452 << " user id: " << remote_device.user_id << "\n" |
| 453 << " name: " << remote_device.name << "\n" | 453 << " name: " << remote_device.name << "\n" |
| 454 << " public key" << device.public_key << "\n" | 454 << " public key" << device.public_key << "\n" |
| 455 << " bt_addr:" << remote_device.bluetooth_address; | 455 << " bt_addr:" << remote_device.bluetooth_address; |
| 456 } | 456 } |
| 457 | 457 |
| 458 SetProximityAuthDevices(account_id, remote_devices); | 458 SetProximityAuthDevices(account_id, remote_devices); |
| 459 } | 459 } |
| 460 | 460 |
| 461 const EasyUnlockServiceSignin::UserData* | 461 const EasyUnlockServiceSignin::UserData* |
| 462 EasyUnlockServiceSignin::FindLoadedDataForCurrentUser() const { | 462 EasyUnlockServiceSignin::FindLoadedDataForCurrentUser() const { |
| 463 if (!account_id_.is_valid()) | 463 if (!account_id_.is_valid()) |
| 464 return nullptr; | 464 return nullptr; |
| 465 | 465 |
| 466 const auto it = user_data_.find(account_id_); | 466 const auto it = user_data_.find(account_id_); |
| 467 if (it == user_data_.end()) | 467 if (it == user_data_.end()) |
| 468 return nullptr; | 468 return nullptr; |
| 469 if (it->second->state != USER_DATA_STATE_LOADED) | 469 if (it->second->state != USER_DATA_STATE_LOADED) |
| 470 return nullptr; | 470 return nullptr; |
| 471 return it->second.get(); | 471 return it->second.get(); |
| 472 } | 472 } |
| OLD | NEW |