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 <grpc/support/port_platform.h>
20
21 #include "src/core/lib/security/credentials/local/local_credentials.h"
22
23 #include <grpc/grpc.h>
24 #include <grpc/support/alloc.h>
25 #include <grpc/support/log.h>
26
27 #include "src/core/lib/channel/channel_args.h"
28 #include "src/core/lib/security/security_connector/local/local_security_connector.h"
29
30 #define GRPC_CREDENTIALS_TYPE_LOCAL "Local"
31
32 grpc_core::RefCountedPtr<grpc_channel_security_connector>
create_security_connector(grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,const char * target_name,const grpc_channel_args * args,grpc_channel_args **)33 grpc_local_credentials::create_security_connector(
34 grpc_core::RefCountedPtr<grpc_call_credentials> request_metadata_creds,
35 const char* target_name, const grpc_channel_args* args,
36 grpc_channel_args** /*new_args*/) {
37 return grpc_local_channel_security_connector_create(
38 this->Ref(), std::move(request_metadata_creds), args, target_name);
39 }
40
41 grpc_core::RefCountedPtr<grpc_server_security_connector>
create_security_connector(const grpc_channel_args *)42 grpc_local_server_credentials::create_security_connector(
43 const grpc_channel_args* /* args */) {
44 return grpc_local_server_security_connector_create(this->Ref());
45 }
46
grpc_local_credentials(grpc_local_connect_type connect_type)47 grpc_local_credentials::grpc_local_credentials(
48 grpc_local_connect_type connect_type)
49 : grpc_channel_credentials(GRPC_CREDENTIALS_TYPE_LOCAL),
50 connect_type_(connect_type) {}
51
grpc_local_credentials_create(grpc_local_connect_type connect_type)52 grpc_channel_credentials* grpc_local_credentials_create(
53 grpc_local_connect_type connect_type) {
54 return new grpc_local_credentials(connect_type);
55 }
56
grpc_local_server_credentials(grpc_local_connect_type connect_type)57 grpc_local_server_credentials::grpc_local_server_credentials(
58 grpc_local_connect_type connect_type)
59 : grpc_server_credentials(GRPC_CREDENTIALS_TYPE_LOCAL),
60 connect_type_(connect_type) {}
61
grpc_local_server_credentials_create(grpc_local_connect_type connect_type)62 grpc_server_credentials* grpc_local_server_credentials_create(
63 grpc_local_connect_type connect_type) {
64 return new grpc_local_server_credentials(connect_type);
65 }
66