Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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 |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 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. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Julien Boeuf | 5be92a3 | 2015-08-28 16:28:18 -0700 | [diff] [blame] | 19 | #include <grpc++/security/server_credentials.h> |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 20 | |
Craig Tiller | f75fc12 | 2015-06-25 06:58:00 -0700 | [diff] [blame] | 21 | #include <grpc/grpc.h> |
Julien Boeuf | bc26558 | 2015-08-17 13:23:05 -0700 | [diff] [blame] | 22 | #include <grpc/support/log.h> |
Craig Tiller | f75fc12 | 2015-06-25 06:58:00 -0700 | [diff] [blame] | 23 | |
Craig Tiller | 42bc87c | 2015-02-23 08:50:19 -0800 | [diff] [blame] | 24 | namespace grpc { |
| 25 | namespace { |
Vijay Pai | c0b2acb | 2016-11-01 16:31:56 -0700 | [diff] [blame] | 26 | class InsecureServerCredentialsImpl final : public ServerCredentials { |
Craig Tiller | 42bc87c | 2015-02-23 08:50:19 -0800 | [diff] [blame] | 27 | public: |
Vijay Pai | 713c7b8 | 2016-11-01 16:33:18 -0700 | [diff] [blame] | 28 | int AddPortToServer(const grpc::string& addr, grpc_server* server) override { |
Craig Tiller | c5ae3eb | 2015-08-03 10:42:22 -0700 | [diff] [blame] | 29 | return grpc_server_add_insecure_http2_port(server, addr.c_str()); |
Craig Tiller | 42bc87c | 2015-02-23 08:50:19 -0800 | [diff] [blame] | 30 | } |
Julien Boeuf | c2274e7 | 2015-08-10 12:45:17 -0700 | [diff] [blame] | 31 | void SetAuthMetadataProcessor( |
Vijay Pai | c0b2acb | 2016-11-01 16:31:56 -0700 | [diff] [blame] | 32 | const std::shared_ptr<AuthMetadataProcessor>& processor) override { |
Julien Boeuf | bc26558 | 2015-08-17 13:23:05 -0700 | [diff] [blame] | 33 | (void)processor; |
| 34 | GPR_ASSERT(0); // Should not be called on InsecureServerCredentials. |
| 35 | } |
Craig Tiller | 42bc87c | 2015-02-23 08:50:19 -0800 | [diff] [blame] | 36 | }; |
| 37 | } // namespace |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 38 | |
Craig Tiller | 42bc87c | 2015-02-23 08:50:19 -0800 | [diff] [blame] | 39 | std::shared_ptr<ServerCredentials> InsecureServerCredentials() { |
Yang Gao | 6baa9b6 | 2015-03-17 10:49:39 -0700 | [diff] [blame] | 40 | return std::shared_ptr<ServerCredentials>( |
| 41 | new InsecureServerCredentialsImpl()); |
Craig Tiller | 42bc87c | 2015-02-23 08:50:19 -0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | } // namespace grpc |