Replace to use IdentityType where TrustType were used.

PiperOrigin-RevId: 463713311
This commit is contained in:
hais
2022-07-27 17:07:19 -07:00
committed by Copybara-Service
parent c7c698412c
commit d5f86a04d6
5 changed files with 37 additions and 25 deletions
@@ -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 {
+24 -3
View File
@@ -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",
+3 -18
View File
@@ -19,29 +19,14 @@
#include <string>
#include <vector>
#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
+4 -1
View File
@@ -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<void(std::vector<PublicCredential>)> credentials_generated_cb;
@@ -53,7 +55,8 @@ class CredentialManager {
// The users own public credentials wont be saved on local credential
// storage.
virtual void GenerateCredentials(
proto::DeviceMetadata device_metadata, std::vector<TrustType> trust_types,
proto::DeviceMetadata device_metadata,
std::vector<PresenceIdentity::IdentityType> identity_types,
GenerateCredentialsCallback credentials_generated_cb) = 0;
// Update remote public credentials.
@@ -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<TrustType> trust_types,
proto::DeviceMetadata device_metadata,
std::vector<PresenceIdentity::IdentityType> identity_types,
GenerateCredentialsCallback credentials_generated_cb) override {}
void UpdateRemotePublicCredentials(