Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -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 |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -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 |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -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. |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Julien Boeuf | 5be92a3 | 2015-08-28 16:28:18 -0700 | [diff] [blame] | 19 | #include <grpc++/security/credentials.h> |
yang-g | 9e2f90c | 2015-08-21 15:35:03 -0700 | [diff] [blame] | 20 | |
yang-g | 8c2be9f | 2015-08-19 16:28:09 -0700 | [diff] [blame] | 21 | #include <grpc++/channel.h> |
yang-g | 9e2f90c | 2015-08-21 15:35:03 -0700 | [diff] [blame] | 22 | #include <grpc++/support/channel_arguments.h> |
| 23 | #include <grpc++/support/config.h> |
Craig Tiller | f40df23 | 2016-03-25 13:38:14 -0700 | [diff] [blame] | 24 | #include <grpc/grpc.h> |
| 25 | #include <grpc/support/log.h> |
yang-g | c317f07 | 2015-08-20 12:18:08 -0700 | [diff] [blame] | 26 | #include "src/cpp/client/create_channel_internal.h" |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 27 | |
| 28 | namespace grpc { |
| 29 | |
| 30 | namespace { |
Vijay Pai | c0b2acb | 2016-11-01 16:31:56 -0700 | [diff] [blame] | 31 | class InsecureChannelCredentialsImpl final : public ChannelCredentials { |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 32 | public: |
yang-g | 8c2be9f | 2015-08-19 16:28:09 -0700 | [diff] [blame] | 33 | std::shared_ptr<grpc::Channel> CreateChannel( |
Vijay Pai | c0b2acb | 2016-11-01 16:31:56 -0700 | [diff] [blame] | 34 | const string& target, const grpc::ChannelArguments& args) override { |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 35 | grpc_channel_args channel_args; |
| 36 | args.SetChannelArgs(&channel_args); |
yang-g | c317f07 | 2015-08-20 12:18:08 -0700 | [diff] [blame] | 37 | return CreateChannelInternal( |
| 38 | "", |
| 39 | grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr)); |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 40 | } |
Craig Tiller | ad9d0c4 | 2015-02-23 10:53:01 -0800 | [diff] [blame] | 41 | |
Vijay Pai | 713c7b8 | 2016-11-01 16:33:18 -0700 | [diff] [blame] | 42 | SecureChannelCredentials* AsSecureCredentials() override { return nullptr; } |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 43 | }; |
| 44 | } // namespace |
| 45 | |
Julien Boeuf | 54a902e | 2015-10-12 13:26:21 -0700 | [diff] [blame] | 46 | std::shared_ptr<ChannelCredentials> InsecureChannelCredentials() { |
| 47 | return std::shared_ptr<ChannelCredentials>( |
| 48 | new InsecureChannelCredentialsImpl()); |
Craig Tiller | 47c83fd | 2015-02-21 22:45:35 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | } // namespace grpc |