| 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 #ifndef COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ | 5 #ifndef COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ |
| 6 #define COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ | 6 #define COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "components/cryptauth/proto/cryptauth_api.pb.h" |
| 12 |
| 11 namespace cryptauth { | 13 namespace cryptauth { |
| 12 | 14 |
| 13 struct RemoteDevice { | 15 struct RemoteDevice { |
| 14 public: | 16 public: |
| 15 std::string user_id; | 17 std::string user_id; |
| 16 std::string name; | 18 std::string name; |
| 17 std::string public_key; | 19 std::string public_key; |
| 18 std::string bluetooth_address; | 20 std::string bluetooth_address; |
| 19 std::string persistent_symmetric_key; | 21 std::string persistent_symmetric_key; |
| 20 std::string sign_in_challenge; | 22 std::string sign_in_challenge; |
| 21 | 23 |
| 24 // Note: To save space, the BeaconSeeds may not necessarily be included in |
| 25 // this object. |
| 26 bool are_beacon_seeds_loaded; |
| 27 std::vector<BeaconSeed> beacon_seeds; |
| 28 |
| 22 RemoteDevice(); | 29 RemoteDevice(); |
| 23 RemoteDevice(const std::string& user_id, | 30 RemoteDevice(const std::string& user_id, |
| 24 const std::string& name, | 31 const std::string& name, |
| 25 const std::string& public_key, | 32 const std::string& public_key, |
| 26 const std::string& bluetooth_address, | 33 const std::string& bluetooth_address, |
| 27 const std::string& persistent_symmetric_key, | 34 const std::string& persistent_symmetric_key, |
| 28 std::string sign_in_challenge); | 35 std::string sign_in_challenge); |
| 29 RemoteDevice(const RemoteDevice& other); | 36 RemoteDevice(const RemoteDevice& other); |
| 30 ~RemoteDevice(); | 37 ~RemoteDevice(); |
| 31 | 38 |
| 39 // Loads a vector of BeaconSeeds for the RemoteDevice. |
| 40 void LoadBeaconSeeds(const std::vector<BeaconSeed>& beacon_seeds); |
| 41 |
| 32 // Returns a unique ID for the device. | 42 // Returns a unique ID for the device. |
| 33 std::string GetDeviceId() const; | 43 std::string GetDeviceId() const; |
| 34 | 44 |
| 35 // Returns a shortened device ID for the purpose of concise logging (device | 45 // Returns a shortened device ID for the purpose of concise logging (device |
| 36 // IDs are often so long that logs are difficult to read). Note that this | 46 // IDs are often so long that logs are difficult to read). Note that this |
| 37 // ID is not guaranteed to be unique, so it should only be used for log. | 47 // ID is not guaranteed to be unique, so it should only be used for log. |
| 38 std::string GetTruncatedDeviceIdForLogs() const; | 48 std::string GetTruncatedDeviceIdForLogs() const; |
| 39 | 49 |
| 40 bool operator==(const RemoteDevice& other) const; | 50 bool operator==(const RemoteDevice& other) const; |
| 41 | 51 |
| 42 // Compares devices via their public keys. Note that this function is | 52 // Compares devices via their public keys. Note that this function is |
| 43 // necessary in order to use |RemoteDevice| as a key of a std::map. | 53 // necessary in order to use |RemoteDevice| as a key of a std::map. |
| 44 bool operator<(const RemoteDevice& other) const; | 54 bool operator<(const RemoteDevice& other) const; |
| 45 | 55 |
| 46 // Static method for truncated device ID for logs. | 56 // Static method for truncated device ID for logs. |
| 47 static std::string TruncateDeviceIdForLogs(const std::string& full_id); | 57 static std::string TruncateDeviceIdForLogs(const std::string& full_id); |
| 48 }; | 58 }; |
| 49 | 59 |
| 50 typedef std::vector<RemoteDevice> RemoteDeviceList; | 60 typedef std::vector<RemoteDevice> RemoteDeviceList; |
| 51 | 61 |
| 52 } // namespace cryptauth | 62 } // namespace cryptauth |
| 53 | 63 |
| 54 #endif // COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ | 64 #endif // COMPONENTS_CRYPTAUTH_REMOTE_DEVICE_H_ |
| OLD | NEW |