mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
update device provider api for multi-identity auth
PiperOrigin-RevId: 548767413
This commit is contained in:
committed by
Copybara-Service
parent
8ec86f5ff9
commit
2dcfe66f2e
@@ -54,10 +54,10 @@ TEST(ConnectionsDeviceProviderTest, TestProviderWorksThreeArgs) {
|
||||
TEST(ConnectionsDeviceProviderTest, TestUnknownAuthStatus) {
|
||||
ConnectionsDeviceProvider provider(kEndpointId, kEndpointInfo, {});
|
||||
MockAuthenticationTransport transport;
|
||||
EXPECT_EQ(provider.AuthenticateConnection(/*local_device=*/nullptr,
|
||||
/*remote_device=*/nullptr,
|
||||
AuthenticationRole::kInitiator,
|
||||
/*shared_secret=*/"", transport),
|
||||
EXPECT_EQ(provider.AuthenticateAsInitiator(ConnectionsDevice("", {}),
|
||||
/*shared_secret=*/"", transport),
|
||||
AuthenticationStatus::kUnknown);
|
||||
EXPECT_EQ(provider.AuthenticateAsResponder(/*shared_secret=*/"", transport),
|
||||
AuthenticationStatus::kUnknown);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,6 @@
|
||||
|
||||
namespace nearby {
|
||||
|
||||
enum class AuthenticationRole {
|
||||
kUnknown = 0,
|
||||
kInitiator = 1,
|
||||
kReceiver = 2,
|
||||
};
|
||||
|
||||
enum class AuthenticationStatus {
|
||||
kUnknown = 0,
|
||||
kSuccess = 1,
|
||||
@@ -40,9 +34,15 @@ class NearbyDeviceProvider {
|
||||
virtual ~NearbyDeviceProvider() = default;
|
||||
|
||||
const virtual NearbyDevice* GetLocalDevice() = 0;
|
||||
virtual AuthenticationStatus AuthenticateConnection(
|
||||
NearbyDevice* local_device, NearbyDevice* remote_device,
|
||||
AuthenticationRole role, absl::string_view shared_secret,
|
||||
virtual AuthenticationStatus AuthenticateAsInitiator(
|
||||
const NearbyDevice& remote_device, absl::string_view shared_secret,
|
||||
const AuthenticationTransport& authentication_transport) const {
|
||||
// We want to check out-of-band by default (Show UKEY2 digits to user).
|
||||
return AuthenticationStatus::kUnknown;
|
||||
}
|
||||
|
||||
virtual AuthenticationStatus AuthenticateAsResponder(
|
||||
absl::string_view shared_secret,
|
||||
const AuthenticationTransport& authentication_transport) const {
|
||||
// We want to check out-of-band by default (Show UKEY2 digits to user).
|
||||
return AuthenticationStatus::kUnknown;
|
||||
|
||||
@@ -28,9 +28,15 @@ class PresenceDeviceProvider : public NearbyDeviceProvider {
|
||||
: device_{metadata} {}
|
||||
|
||||
const NearbyDevice* GetLocalDevice() override { return &device_; }
|
||||
AuthenticationStatus AuthenticateConnection(
|
||||
NearbyDevice* local_device, NearbyDevice* remote_device,
|
||||
AuthenticationRole role, absl::string_view shared_secret,
|
||||
AuthenticationStatus AuthenticateAsInitiator(
|
||||
const NearbyDevice& remote_device, absl::string_view shared_secret,
|
||||
const AuthenticationTransport& authentication_transport) const override {
|
||||
// TODO(b/282027237): Implement.
|
||||
return AuthenticationStatus::kUnknown;
|
||||
}
|
||||
|
||||
AuthenticationStatus AuthenticateAsResponder(
|
||||
absl::string_view shared_secret,
|
||||
const AuthenticationTransport& authentication_transport) const override {
|
||||
// TODO(b/282027237): Implement.
|
||||
return AuthenticationStatus::kUnknown;
|
||||
|
||||
Reference in New Issue
Block a user