diff --git a/internal/platform/implementation/credential_storage.h b/internal/platform/implementation/credential_storage.h index 47593ec7..6c86170a 100644 --- a/internal/platform/implementation/credential_storage.h +++ b/internal/platform/implementation/credential_storage.h @@ -22,14 +22,15 @@ #include "internal/platform/exception.h" #include "third_party/nearby/presence/credential.h" +#include "third_party/nearby/presence/presence_identity.h" namespace location { namespace nearby { namespace api { +using ::nearby::presence::PresenceIdentity; using ::nearby::presence::PrivateCredential; using ::nearby::presence::PublicCredential; -using ::nearby::presence::TrustType; enum class CredentialOperationStatus { kFailed = 0, @@ -38,7 +39,7 @@ enum class CredentialOperationStatus { struct CredentialSelector { std::string account_name; - TrustType trust_type; + PresenceIdentity::IdentityType identity_type; }; struct SaveCredentialCallback { diff --git a/presence/BUILD b/presence/BUILD index f6ad9feb..a9e1e92f 100644 --- a/presence/BUILD +++ b/presence/BUILD @@ -38,7 +38,6 @@ cc_library( "presence_action.cc", "presence_client.cc", "presence_device.cc", - "presence_identity.cc", "presence_zone.cc", ], hdrs = [ @@ -52,7 +51,6 @@ cc_library( "presence_action.h", "presence_client.h", "presence_device.h", - "presence_identity.h", "presence_zone.h", "scan_request.h", "status.h", @@ -70,6 +68,7 @@ cc_library( srcs = ["broadcast_request.cc"], hdrs = ["broadcast_request.h"], deps = [ + ":credential", ":encryption", ":types", "//internal/platform:logging", @@ -97,6 +96,7 @@ cc_library( name = "certificate_manager", hdrs = ["certificate_manager.h"], deps = [ + ":credential", ":types", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", @@ -110,6 +110,7 @@ cc_library( deps = [ ":broadcast_request", ":certificate_manager", + ":credential", ":types", "//internal/platform:logging", "//internal/platform:uuid", @@ -133,7 +134,11 @@ cc_library( cc_library( name = "credential", - hdrs = ["credential.h"], + srcs = ["presence_identity.cc"], + hdrs = [ + "credential.h", + "presence_identity.h", + ], visibility = [ "//third_party/nearby:__subpackages__", ], @@ -150,6 +155,7 @@ cc_test( ":action_factory", ":advertisement_factory", ":certificate_manager", + ":credential", ":types", "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", @@ -216,12 +222,27 @@ cc_test( ], shard_count = 6, deps = [ + ":credential", ":types", "@com_github_protobuf_matchers//protobuf-matchers", "@com_google_googletest//:gtest_main", ], ) +cc_test( + name = "credential_test", + size = "small", + srcs = [ + "presence_identity_test.cc", + ], + shard_count = 6, + deps = [ + ":credential", + "@com_github_protobuf_matchers//protobuf-matchers", + "@com_google_googletest//:gtest_main", + ], +) + cc_test( name = "presence_test", size = "small", diff --git a/presence/credential.h b/presence/credential.h index bae5f544..00a5f4a5 100644 --- a/presence/credential.h +++ b/presence/credential.h @@ -19,29 +19,14 @@ #include #include +#include "third_party/nearby/presence/presence_identity.h" #include "third_party/nearby/presence/proto/device_metadata.pb.h" namespace nearby { namespace presence { -enum class TrustType { - kUnspecified = 0, - - // The same user itself. - kPrivate = 1, - - // The user selects the contact from its contact list. - kTrusted = 2, - - // For offline credentials and without dependence on Gaia account - kProvisioned = 3, - - // For offline public identities and without dependence on Gaia account - kPublic = 4, -}; - struct PrivateCredential { - TrustType trust_type; + PresenceIdentity::IdentityType identity_type; // The unique id of (and hashed based on) a pair of secret // key (PrivateCredential.verification_key) and X509Certificate's public @@ -73,7 +58,7 @@ struct PrivateCredential { }; struct PublicCredential { - TrustType trust_type; + PresenceIdentity::IdentityType identity_type; // The unique id of (and hashed based on) a pair of secret // key (PrivateCredential.verification_key) and X509Certificate's public diff --git a/presence/implementation/credential_manager.h b/presence/implementation/credential_manager.h index 02872195..90a5d064 100644 --- a/presence/implementation/credential_manager.h +++ b/presence/implementation/credential_manager.h @@ -23,9 +23,11 @@ #include "absl/strings/string_view.h" #include "internal/platform/implementation/credential_storage.h" #include "third_party/nearby/presence/credential.h" +#include "third_party/nearby/presence/presence_identity.h" namespace nearby { namespace presence { +using ::nearby::presence::PresenceIdentity; struct GenerateCredentialsCallback { std::function)> credentials_generated_cb; @@ -53,7 +55,8 @@ class CredentialManager { // The user’s own public credentials won’t be saved on local credential // storage. virtual void GenerateCredentials( - proto::DeviceMetadata device_metadata, std::vector trust_types, + proto::DeviceMetadata device_metadata, + std::vector identity_types, GenerateCredentialsCallback credentials_generated_cb) = 0; // Update remote public credentials. diff --git a/presence/implementation/credential_manager_impl.h b/presence/implementation/credential_manager_impl.h index 2cbb7f60..4025149b 100644 --- a/presence/implementation/credential_manager_impl.h +++ b/presence/implementation/credential_manager_impl.h @@ -24,6 +24,7 @@ #include "internal/platform/credential_storage.h" #include "third_party/nearby/presence/credential.h" #include "third_party/nearby/presence/implementation/credential_manager.h" +#include "third_party/nearby/presence/presence_identity.h" namespace nearby { namespace presence { @@ -33,7 +34,8 @@ class CredentialManagerImpl : public CredentialManager { CredentialManagerImpl() = default; void GenerateCredentials( - proto::DeviceMetadata device_metadata, std::vector trust_types, + proto::DeviceMetadata device_metadata, + std::vector identity_types, GenerateCredentialsCallback credentials_generated_cb) override {} void UpdateRemotePublicCredentials(