mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
introduce authentication transport function into DeviceProvider
PiperOrigin-RevId: 538909999
This commit is contained in:
committed by
Copybara-Service
parent
472fba64ae
commit
1c455e3488
@@ -1,3 +1,16 @@
|
||||
cc_library(
|
||||
name = "authentication_transport_interface",
|
||||
hdrs = [
|
||||
"authentication_transport.h",
|
||||
],
|
||||
visibility = [
|
||||
"//:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
"@com_google_absl//absl/strings",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "device",
|
||||
hdrs = [
|
||||
@@ -9,6 +22,7 @@ cc_library(
|
||||
"//presence:__subpackages__",
|
||||
],
|
||||
deps = [
|
||||
":authentication_transport_interface",
|
||||
"//internal/platform:connection_info",
|
||||
"//internal/platform:types",
|
||||
"@com_google_absl//absl/strings",
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2023 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_NEARBY_INTERNAL_INTEROP_AUTHENTICATION_TRANSPORT_H_
|
||||
#define THIRD_PARTY_NEARBY_INTERNAL_INTEROP_AUTHENTICATION_TRANSPORT_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
class AuthenticationTransport {
|
||||
public:
|
||||
virtual ~AuthenticationTransport() = default;
|
||||
virtual void WriteMessage(absl::string_view message) const = 0;
|
||||
virtual std::string ReadMessage() const = 0;
|
||||
};
|
||||
|
||||
} // namespace nearby
|
||||
|
||||
#endif // THIRD_PARTY_NEARBY_INTERNAL_INTEROP_AUTHENTICATION_TRANSPORT_H_
|
||||
@@ -15,10 +15,23 @@
|
||||
#ifndef THIRD_PARTY_NEARBY_CONNECTIONS_DEVICE_PROVIDER_H_
|
||||
#define THIRD_PARTY_NEARBY_CONNECTIONS_DEVICE_PROVIDER_H_
|
||||
|
||||
#include "internal/interop/authentication_transport.h"
|
||||
#include "internal/interop/device.h"
|
||||
|
||||
namespace nearby {
|
||||
|
||||
enum class AuthenticationRole {
|
||||
kUnknown = 0,
|
||||
kInitiator = 1,
|
||||
kReceiver = 2,
|
||||
};
|
||||
|
||||
enum class AuthenticationStatus {
|
||||
kUnknown = 0,
|
||||
kSuccess = 1,
|
||||
kFailure = 2,
|
||||
};
|
||||
|
||||
// The base device provider class for use with the Nearby Connections V3 APIs.
|
||||
// This class currently provides a function to get the local device for whatever
|
||||
// client implements it.
|
||||
@@ -27,6 +40,13 @@ 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,
|
||||
const AuthenticationTransport& authentication_transport) const {
|
||||
// We want to check out-of-band by default (Show UKEY2 digits to user).
|
||||
return AuthenticationStatus::kUnknown;
|
||||
}
|
||||
};
|
||||
} // namespace nearby
|
||||
|
||||
|
||||
Reference in New Issue
Block a user