| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/cryptauth/remote_device.h" | 5 #include "components/cryptauth/remote_device.h" |
| 6 | 6 |
| 7 #include "base/base64.h" |
| 8 |
| 7 namespace cryptauth { | 9 namespace cryptauth { |
| 8 | 10 |
| 9 RemoteDevice::RemoteDevice() : bluetooth_type(BLUETOOTH_CLASSIC) {} | 11 RemoteDevice::RemoteDevice() : bluetooth_type(BLUETOOTH_CLASSIC) {} |
| 10 | 12 |
| 11 RemoteDevice::RemoteDevice(const std::string& user_id, | 13 RemoteDevice::RemoteDevice(const std::string& user_id, |
| 12 const std::string& name, | 14 const std::string& name, |
| 13 const std::string& public_key, | 15 const std::string& public_key, |
| 14 BluetoothType bluetooth_type, | 16 BluetoothType bluetooth_type, |
| 15 const std::string& bluetooth_address, | 17 const std::string& bluetooth_address, |
| 16 const std::string& persistent_symmetric_key, | 18 const std::string& persistent_symmetric_key, |
| 17 std::string sign_in_challenge) | 19 std::string sign_in_challenge) |
| 18 : user_id(user_id), | 20 : user_id(user_id), |
| 19 name(name), | 21 name(name), |
| 20 public_key(public_key), | 22 public_key(public_key), |
| 21 bluetooth_type(bluetooth_type), | 23 bluetooth_type(bluetooth_type), |
| 22 bluetooth_address(bluetooth_address), | 24 bluetooth_address(bluetooth_address), |
| 23 persistent_symmetric_key(persistent_symmetric_key), | 25 persistent_symmetric_key(persistent_symmetric_key), |
| 24 sign_in_challenge(sign_in_challenge) {} | 26 sign_in_challenge(sign_in_challenge) {} |
| 25 | 27 |
| 26 RemoteDevice::RemoteDevice(const RemoteDevice& other) = default; | 28 RemoteDevice::RemoteDevice(const RemoteDevice& other) = default; |
| 27 | 29 |
| 28 RemoteDevice::~RemoteDevice() {} | 30 RemoteDevice::~RemoteDevice() {} |
| 29 | 31 |
| 32 std::string RemoteDevice::GetDeviceId() { |
| 33 std::string to_return; |
| 34 base::Base64Encode(public_key, &to_return); |
| 35 return to_return; |
| 36 } |
| 37 |
| 38 std::string RemoteDevice::GetTruncatedDeviceIdForLogs() { |
| 39 std::string id = GetDeviceId(); |
| 40 if (id.length() <= 10) { |
| 41 return id; |
| 42 } |
| 43 |
| 44 return id.substr(0, 5) + "..." + id.substr(id.length() - 5, id.length()); |
| 45 } |
| 46 |
| 30 } // namespace cryptauth | 47 } // namespace cryptauth |
| OLD | NEW |