blob: 21128447db08b4333caad4fe6ef988a4276521a3 [file] [log] [blame]
Craig Tiller47c83fd2015-02-21 22:45:35 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Craig Tiller47c83fd2015-02-21 22:45:35 -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
Craig Tiller47c83fd2015-02-21 22:45:35 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Craig Tiller47c83fd2015-02-21 22:45:35 -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.
Craig Tiller47c83fd2015-02-21 22:45:35 -080016 *
17 */
18
Julien Boeuf5be92a32015-08-28 16:28:18 -070019#include <grpc++/security/credentials.h>
yang-g9e2f90c2015-08-21 15:35:03 -070020
yang-g8c2be9f2015-08-19 16:28:09 -070021#include <grpc++/channel.h>
yang-g9e2f90c2015-08-21 15:35:03 -070022#include <grpc++/support/channel_arguments.h>
23#include <grpc++/support/config.h>
Craig Tillerf40df232016-03-25 13:38:14 -070024#include <grpc/grpc.h>
25#include <grpc/support/log.h>
yang-gc317f072015-08-20 12:18:08 -070026#include "src/cpp/client/create_channel_internal.h"
Craig Tiller47c83fd2015-02-21 22:45:35 -080027
28namespace grpc {
29
30namespace {
Vijay Paic0b2acb2016-11-01 16:31:56 -070031class InsecureChannelCredentialsImpl final : public ChannelCredentials {
Craig Tiller47c83fd2015-02-21 22:45:35 -080032 public:
yang-g8c2be9f2015-08-19 16:28:09 -070033 std::shared_ptr<grpc::Channel> CreateChannel(
Vijay Paic0b2acb2016-11-01 16:31:56 -070034 const string& target, const grpc::ChannelArguments& args) override {
Craig Tiller47c83fd2015-02-21 22:45:35 -080035 grpc_channel_args channel_args;
36 args.SetChannelArgs(&channel_args);
yang-gc317f072015-08-20 12:18:08 -070037 return CreateChannelInternal(
38 "",
39 grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr));
Craig Tiller47c83fd2015-02-21 22:45:35 -080040 }
Craig Tillerad9d0c42015-02-23 10:53:01 -080041
Vijay Pai713c7b82016-11-01 16:33:18 -070042 SecureChannelCredentials* AsSecureCredentials() override { return nullptr; }
Craig Tiller47c83fd2015-02-21 22:45:35 -080043};
44} // namespace
45
Julien Boeuf54a902e2015-10-12 13:26:21 -070046std::shared_ptr<ChannelCredentials> InsecureChannelCredentials() {
47 return std::shared_ptr<ChannelCredentials>(
48 new InsecureChannelCredentialsImpl());
Craig Tiller47c83fd2015-02-21 22:45:35 -080049}
50
51} // namespace grpc