binder_server_credentials.cc
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
16 
17 #ifndef GRPC_NO_BINDER
18 
21 
24 
25 namespace grpc {
26 namespace experimental {
27 
28 namespace {
29 
30 class BinderServerCredentialsImpl final : public ServerCredentials {
31  public:
32  explicit BinderServerCredentialsImpl(
33  std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
34  security_policy)
35  : security_policy_(security_policy) {}
36 #ifdef GPR_SUPPORT_BINDER_TRANSPORT
37  int AddPortToServer(const std::string& addr, grpc_server* server) override {
41  return absl::make_unique<grpc_binder::TransactionReceiverAndroid>(
42  nullptr, std::move(transact_cb));
43  },
45  }
46 #else
47  int AddPortToServer(const std::string& /*addr*/,
48  grpc_server* /*server*/) override {
49  return 0;
50  }
51 #endif // GPR_SUPPORT_BINDER_TRANSPORT
52 
53  void SetAuthMetadataProcessor(
54  const std::shared_ptr<AuthMetadataProcessor>& /*processor*/) override {
55  GPR_ASSERT(false);
56  }
57 
58  private:
59  bool IsInsecure() const override { return true; }
60 
61  std::shared_ptr<grpc::experimental::binder::SecurityPolicy> security_policy_;
62 };
63 
64 } // namespace
65 
66 std::shared_ptr<ServerCredentials> BinderServerCredentials(
67  std::shared_ptr<grpc::experimental::binder::SecurityPolicy>
68  security_policy) {
69  GPR_ASSERT(security_policy != nullptr);
70  return std::shared_ptr<ServerCredentials>(
71  new BinderServerCredentialsImpl(security_policy));
72 }
73 
74 } // namespace experimental
75 } // namespace grpc
76 #endif
grpc
Definition: grpcpp/alarm.h:33
binder_server.h
grpc_core::AddBinderPort
bool AddBinderPort(const std::string &addr, grpc_server *server, BinderTxReceiverFactory factory, std::shared_ptr< grpc::experimental::binder::SecurityPolicy > security_policy)
Definition: binder_server.cc:232
grpc::experimental::BinderServerCredentials
std::shared_ptr< grpc::ServerCredentials > BinderServerCredentials(std::shared_ptr< grpc::experimental::binder::SecurityPolicy > security_policy)
Definition: binder_server_credentials.cc:66
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
binder_security_policy.h
binder_android.h
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_server
struct grpc_server grpc_server
Definition: grpc_types.h:65
security_policy_
std::shared_ptr< grpc::experimental::binder::SecurityPolicy > security_policy_
Definition: binder_server_credentials.cc:61
server_credentials.h
grpc_binder::TransactionReceiver::OnTransactCb
std::function< absl::Status(transaction_code_t, ReadableParcel *, int uid)> OnTransactCb
Definition: binder.h:80
server
Definition: examples/python/async_streaming/server.py:1
grpc.beta.implementations.ServerCredentials
ServerCredentials
Definition: implementations.py:231
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:48