1 //
2 //
3 // Copyright 2018 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/local/local_credentials.h"
20
21 #include <grpc/grpc.h>
22 #include <grpc/support/port_platform.h>
23
24 #include <utility>
25
26 #include "src/core/lib/security/security_connector/local/local_security_connector.h"
27
28 grpc_core::RefCountedPtr<grpc_channel_security_connector>
create_security_connector(grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,const char * target_name,grpc_core::ChannelArgs * args)29 grpc_local_credentials::create_security_connector(
30 grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
31 const char* target_name, grpc_core::ChannelArgs* args) {
32 return grpc_local_channel_security_connector_create(
33 this->Ref(), std::move(request_metadata_creds), *args, target_name);
34 }
35
type() const36 grpc_core::UniqueTypeName grpc_local_credentials::type() const {
37 static grpc_core::UniqueTypeName::Factory kFactory("Local");
38 return kFactory.Create();
39 }
40
41 grpc_core::RefCountedPtr<grpc_server_security_connector>
create_security_connector(const grpc_core::ChannelArgs &)42 grpc_local_server_credentials::create_security_connector(
43 const grpc_core::ChannelArgs& /* args */) {
44 return grpc_local_server_security_connector_create(this->Ref());
45 }
46
type() const47 grpc_core::UniqueTypeName grpc_local_server_credentials::type() const {
48 static grpc_core::UniqueTypeName::Factory kFactory("Local");
49 return kFactory.Create();
50 }
51
grpc_local_credentials(grpc_local_connect_type connect_type)52 grpc_local_credentials::grpc_local_credentials(
53 grpc_local_connect_type connect_type)
54 : connect_type_(connect_type) {}
55
grpc_local_credentials_create(grpc_local_connect_type connect_type)56 grpc_channel_credentials* grpc_local_credentials_create(
57 grpc_local_connect_type connect_type) {
58 return new grpc_local_credentials(connect_type);
59 }
60
grpc_local_server_credentials(grpc_local_connect_type connect_type)61 grpc_local_server_credentials::grpc_local_server_credentials(
62 grpc_local_connect_type connect_type)
63 : connect_type_(connect_type) {}
64
grpc_local_server_credentials_create(grpc_local_connect_type connect_type)65 grpc_server_credentials* grpc_local_server_credentials_create(
66 grpc_local_connect_type connect_type) {
67 return new grpc_local_server_credentials(connect_type);
68 }
69