blob: 87605f8ec9d6d6a20fd5607d377577b101588a6b [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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 Nobleb7ebd3b2014-11-26 16:33:03 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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 Nobleb7ebd3b2014-11-26 16:33:03 -080016 *
17 */
18
Julien Boeuf5be92a32015-08-28 16:28:18 -070019#include <grpc++/security/server_credentials.h>
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080020
Craig Tillerf75fc122015-06-25 06:58:00 -070021#include <grpc/grpc.h>
Julien Boeufbc265582015-08-17 13:23:05 -070022#include <grpc/support/log.h>
Craig Tillerf75fc122015-06-25 06:58:00 -070023
Craig Tiller42bc87c2015-02-23 08:50:19 -080024namespace grpc {
25namespace {
Vijay Paic0b2acb2016-11-01 16:31:56 -070026class InsecureServerCredentialsImpl final : public ServerCredentials {
Craig Tiller42bc87c2015-02-23 08:50:19 -080027 public:
Vijay Pai713c7b82016-11-01 16:33:18 -070028 int AddPortToServer(const grpc::string& addr, grpc_server* server) override {
Craig Tillerc5ae3eb2015-08-03 10:42:22 -070029 return grpc_server_add_insecure_http2_port(server, addr.c_str());
Craig Tiller42bc87c2015-02-23 08:50:19 -080030 }
Julien Boeufc2274e72015-08-10 12:45:17 -070031 void SetAuthMetadataProcessor(
Vijay Paic0b2acb2016-11-01 16:31:56 -070032 const std::shared_ptr<AuthMetadataProcessor>& processor) override {
Julien Boeufbc265582015-08-17 13:23:05 -070033 (void)processor;
34 GPR_ASSERT(0); // Should not be called on InsecureServerCredentials.
35 }
Craig Tiller42bc87c2015-02-23 08:50:19 -080036};
37} // namespace
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080038
Craig Tiller42bc87c2015-02-23 08:50:19 -080039std::shared_ptr<ServerCredentials> InsecureServerCredentials() {
Yang Gao6baa9b62015-03-17 10:49:39 -070040 return std::shared_ptr<ServerCredentials>(
41 new InsecureServerCredentialsImpl());
Craig Tiller42bc87c2015-02-23 08:50:19 -080042}
43
44} // namespace grpc