Debian Codegraph @

src/core/lib/security/credentials/insecure/insecure_credentials.cc

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