1# Copyright 2015 gRPC authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15
16cdef class CallCredentials:
17
18  cdef grpc_call_credentials *c(self)
19
20  # TODO(https://github.com/grpc/grpc/issues/12531): remove.
21  cdef grpc_call_credentials *c_credentials
22
23
24cdef int _get_metadata(
25    void *state, grpc_auth_metadata_context context,
26    grpc_credentials_plugin_metadata_cb cb, void *user_data,
27    grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
28    size_t *num_creds_md, grpc_status_code *status,
29    const char **error_details) with gil
30
31cdef void _destroy(void *state) with gil
32
33
34cdef class MetadataPluginCallCredentials(CallCredentials):
35
36  cdef readonly object _metadata_plugin
37  cdef readonly bytes _name
38
39  cdef grpc_call_credentials *c(self)
40
41
42cdef grpc_call_credentials *_composition(call_credentialses)
43
44
45cdef class CompositeCallCredentials(CallCredentials):
46
47  cdef readonly tuple _call_credentialses
48
49  cdef grpc_call_credentials *c(self)
50
51
52cdef class ChannelCredentials:
53
54  cdef grpc_channel_credentials *c(self)
55
56  # TODO(https://github.com/grpc/grpc/issues/12531): remove.
57  cdef grpc_channel_credentials *c_credentials
58
59
60cdef class SSLSessionCacheLRU:
61
62  cdef grpc_ssl_session_cache *_cache
63
64
65cdef class SSLChannelCredentials(ChannelCredentials):
66
67  cdef readonly object _pem_root_certificates
68  cdef readonly object _private_key
69  cdef readonly object _certificate_chain
70
71  cdef grpc_channel_credentials *c(self)
72
73
74cdef class CompositeChannelCredentials(ChannelCredentials):
75
76  cdef readonly tuple _call_credentialses
77  cdef readonly ChannelCredentials _channel_credentials
78
79  cdef grpc_channel_credentials *c(self)
80
81
82cdef class ServerCertificateConfig:
83
84  cdef grpc_ssl_server_certificate_config *c_cert_config
85  cdef const char *c_pem_root_certs
86  cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs
87  cdef size_t c_ssl_pem_key_cert_pairs_count
88  cdef list references
89
90
91cdef class ServerCredentials:
92
93  cdef grpc_server_credentials *c_credentials
94  cdef grpc_ssl_pem_key_cert_pair *c_ssl_pem_key_cert_pairs
95  cdef size_t c_ssl_pem_key_cert_pairs_count
96  cdef list references
97  # the cert config related state is used only if this credentials is
98  # created with cert config/fetcher
99  cdef object initial_cert_config
100  cdef object cert_config_fetcher
101  # whether C-core has asked for the initial_cert_config
102  cdef bint initial_cert_config_fetched
103