• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 //
3 // Copyright 2020 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 #include "src/core/lib/security/credentials/insecure/insecure_credentials.h"
20 
21 #include <grpc/support/port_platform.h>
22 
23 #include <utility>
24 
25 #include "src/core/lib/channel/channel_args.h"
26 #include "src/core/lib/security/security_connector/insecure/insecure_security_connector.h"
27 
28 namespace grpc_core {
29 
30 RefCountedPtr<grpc_channel_security_connector>
create_security_connector(RefCountedPtr<grpc_call_credentials> request_metadata_creds,const char *,ChannelArgs *)31 InsecureCredentials::create_security_connector(
32     RefCountedPtr<grpc_call_credentials> request_metadata_creds,
33     const char* /* target_name */, ChannelArgs* /* args */) {
34   return MakeRefCounted<InsecureChannelSecurityConnector>(
35       Ref(), std::move(request_metadata_creds));
36 }
37 
Type()38 UniqueTypeName InsecureCredentials::Type() {
39   static UniqueTypeName::Factory kFactory("Insecure");
40   return kFactory.Create();
41 }
42 
cmp_impl(const grpc_channel_credentials *) const43 int InsecureCredentials::cmp_impl(
44     const grpc_channel_credentials* /* other */) const {
45   // All insecure credentials objects should compare equal.
46   return 0;
47 }
48 
49 RefCountedPtr<grpc_server_security_connector>
create_security_connector(const ChannelArgs &)50 InsecureServerCredentials::create_security_connector(
51     const ChannelArgs& /* args */) {
52   return MakeRefCounted<InsecureServerSecurityConnector>(Ref());
53 }
54 
Type()55 UniqueTypeName InsecureServerCredentials::Type() {
56   static auto* kFactory = new UniqueTypeName::Factory("Insecure");
57   return kFactory->Create();
58 }
59 
60 }  // namespace grpc_core
61 
grpc_insecure_credentials_create()62 grpc_channel_credentials* grpc_insecure_credentials_create() {
63   // Create a singleton object for InsecureCredentials so that channels to the
64   // same target with InsecureCredentials can reuse the subchannels.
65   static auto* creds = new grpc_core::InsecureCredentials();
66   return creds->Ref().release();
67 }
68 
grpc_insecure_server_credentials_create()69 grpc_server_credentials* grpc_insecure_server_credentials_create() {
70   return new grpc_core::InsecureServerCredentials();
71 }
72