GRPC C++  1.26.0
secure_server_credentials.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_INTERNAL_CPP_SERVER_SECURE_SERVER_CREDENTIALS_H
20 #define GRPC_INTERNAL_CPP_SERVER_SECURE_SERVER_CREDENTIALS_H
21 
22 #include <memory>
23 
26 
27 #include <grpc/grpc_security.h>
28 
30 
31 namespace grpc_impl {
32 
34 } // namespace grpc_impl
35 
36 namespace grpc {
37 
39 
41  public:
42  static void Destroy(void* wrapper);
43 
44  static void Process(void* wrapper, grpc_auth_context* context,
45  const grpc_metadata* md, size_t num_md,
46  grpc_process_auth_metadata_done_cb cb, void* user_data);
47 
49  const std::shared_ptr<AuthMetadataProcessor>& processor)
50  : processor_(processor) {
51  if (processor && processor->IsBlocking()) {
52  thread_pool_.reset(CreateDefaultThreadPool());
53  }
54  }
55 
56  private:
57  void InvokeProcessor(grpc_auth_context* context, const grpc_metadata* md,
58  size_t num_md, grpc_process_auth_metadata_done_cb cb,
59  void* user_data);
60  std::unique_ptr<ThreadPoolInterface> thread_pool_;
61  std::shared_ptr<AuthMetadataProcessor> processor_;
62 };
63 
64 } // namespace grpc
65 
66 namespace grpc_impl {
67 
69  public:
70  explicit SecureServerCredentials(grpc_server_credentials* creds)
71  : creds_(creds) {}
73  grpc_server_credentials_release(creds_);
74  }
75 
76  int AddPortToServer(const grpc::string& addr, grpc_server* server) override;
77 
79  const std::shared_ptr<grpc::AuthMetadataProcessor>& processor) override;
80 
81  private:
82  grpc_server_credentials* creds_;
83  std::unique_ptr<grpc::AuthMetadataProcessorAyncWrapper> processor_;
84 };
85 
86 } // namespace grpc_impl
87 
88 #endif // GRPC_INTERNAL_CPP_SERVER_SECURE_SERVER_CREDENTIALS_H
Definition: secure_server_credentials.h:40
static void Destroy(void *wrapper)
Definition: secure_server_credentials.cc:31
static void Process(void *wrapper, grpc_auth_context *context, const grpc_metadata *md, size_t num_md, grpc_process_auth_metadata_done_cb cb, void *user_data)
Definition: secure_server_credentials.cc:36
AuthMetadataProcessorAyncWrapper(const std::shared_ptr< AuthMetadataProcessor > &processor)
Definition: secure_server_credentials.h:48
Definition: secure_server_credentials.h:68
void SetAuthMetadataProcessor(const std::shared_ptr< grpc::AuthMetadataProcessor > &processor) override
This method is not thread-safe and has to be called before the server is started.
Definition: secure_server_credentials.cc:103
int AddPortToServer(const grpc::string &addr, grpc_server *server) override
Tries to bind server to the given addr (eg, localhost:1234, 192.168.1.1:31416, [::1]:27182,...
Definition: secure_server_credentials.cc:98
SecureServerCredentials(grpc_server_credentials *creds)
Definition: secure_server_credentials.h:70
~SecureServerCredentials() override
Definition: secure_server_credentials.h:72
Wrapper around grpc_server_credentials, a way to authenticate a server.
Definition: server_credentials_impl.h:40
struct grpc_server grpc_server
A server listens to some port and responds to request calls.
Definition: grpc_types.h:65
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
ThreadPoolInterface * CreateDefaultThreadPool()
Definition: create_default_thread_pool.cc:38
std::string string
Definition: config.h:35
::grpc_impl::SecureServerCredentials SecureServerCredentials
Definition: secure_server_credentials.h:38
A single metadata element.
Definition: grpc_types.h:485