• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 //
5 // ---------------------------------------------------------------------------
6 //
7 // This file was generated by the CEF translator tool. If making changes by
8 // hand only do so within the body of existing method and function
9 // implementations. See the translator.README.txt file in the tools directory
10 // for more information.
11 //
12 // $hash=cac3e88ea15965e3a7786500606845b0b6157212$
13 //
14 
15 #include "libcef_dll/cpptoc/x509certificate_cpptoc.h"
16 #include <algorithm>
17 #include "libcef_dll/cpptoc/binary_value_cpptoc.h"
18 #include "libcef_dll/cpptoc/x509cert_principal_cpptoc.h"
19 #include "libcef_dll/shutdown_checker.h"
20 
21 namespace {
22 
23 // MEMBER FUNCTIONS - Body may be edited by hand.
24 
25 cef_x509cert_principal_t* CEF_CALLBACK
x509certificate_get_subject(struct _cef_x509certificate_t * self)26 x509certificate_get_subject(struct _cef_x509certificate_t* self) {
27   shutdown_checker::AssertNotShutdown();
28 
29   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
30 
31   DCHECK(self);
32   if (!self)
33     return NULL;
34 
35   // Execute
36   CefRefPtr<CefX509CertPrincipal> _retval =
37       CefX509CertificateCppToC::Get(self)->GetSubject();
38 
39   // Return type: refptr_same
40   return CefX509CertPrincipalCppToC::Wrap(_retval);
41 }
42 
43 cef_x509cert_principal_t* CEF_CALLBACK
x509certificate_get_issuer(struct _cef_x509certificate_t * self)44 x509certificate_get_issuer(struct _cef_x509certificate_t* self) {
45   shutdown_checker::AssertNotShutdown();
46 
47   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
48 
49   DCHECK(self);
50   if (!self)
51     return NULL;
52 
53   // Execute
54   CefRefPtr<CefX509CertPrincipal> _retval =
55       CefX509CertificateCppToC::Get(self)->GetIssuer();
56 
57   // Return type: refptr_same
58   return CefX509CertPrincipalCppToC::Wrap(_retval);
59 }
60 
61 cef_binary_value_t* CEF_CALLBACK
x509certificate_get_serial_number(struct _cef_x509certificate_t * self)62 x509certificate_get_serial_number(struct _cef_x509certificate_t* self) {
63   shutdown_checker::AssertNotShutdown();
64 
65   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
66 
67   DCHECK(self);
68   if (!self)
69     return NULL;
70 
71   // Execute
72   CefRefPtr<CefBinaryValue> _retval =
73       CefX509CertificateCppToC::Get(self)->GetSerialNumber();
74 
75   // Return type: refptr_same
76   return CefBinaryValueCppToC::Wrap(_retval);
77 }
78 
79 cef_time_t CEF_CALLBACK
x509certificate_get_valid_start(struct _cef_x509certificate_t * self)80 x509certificate_get_valid_start(struct _cef_x509certificate_t* self) {
81   shutdown_checker::AssertNotShutdown();
82 
83   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
84 
85   DCHECK(self);
86   if (!self)
87     return CefTime();
88 
89   // Execute
90   cef_time_t _retval = CefX509CertificateCppToC::Get(self)->GetValidStart();
91 
92   // Return type: simple
93   return _retval;
94 }
95 
96 cef_time_t CEF_CALLBACK
x509certificate_get_valid_expiry(struct _cef_x509certificate_t * self)97 x509certificate_get_valid_expiry(struct _cef_x509certificate_t* self) {
98   shutdown_checker::AssertNotShutdown();
99 
100   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
101 
102   DCHECK(self);
103   if (!self)
104     return CefTime();
105 
106   // Execute
107   cef_time_t _retval = CefX509CertificateCppToC::Get(self)->GetValidExpiry();
108 
109   // Return type: simple
110   return _retval;
111 }
112 
113 cef_binary_value_t* CEF_CALLBACK
x509certificate_get_derencoded(struct _cef_x509certificate_t * self)114 x509certificate_get_derencoded(struct _cef_x509certificate_t* self) {
115   shutdown_checker::AssertNotShutdown();
116 
117   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
118 
119   DCHECK(self);
120   if (!self)
121     return NULL;
122 
123   // Execute
124   CefRefPtr<CefBinaryValue> _retval =
125       CefX509CertificateCppToC::Get(self)->GetDEREncoded();
126 
127   // Return type: refptr_same
128   return CefBinaryValueCppToC::Wrap(_retval);
129 }
130 
131 cef_binary_value_t* CEF_CALLBACK
x509certificate_get_pemencoded(struct _cef_x509certificate_t * self)132 x509certificate_get_pemencoded(struct _cef_x509certificate_t* self) {
133   shutdown_checker::AssertNotShutdown();
134 
135   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
136 
137   DCHECK(self);
138   if (!self)
139     return NULL;
140 
141   // Execute
142   CefRefPtr<CefBinaryValue> _retval =
143       CefX509CertificateCppToC::Get(self)->GetPEMEncoded();
144 
145   // Return type: refptr_same
146   return CefBinaryValueCppToC::Wrap(_retval);
147 }
148 
149 size_t CEF_CALLBACK
x509certificate_get_issuer_chain_size(struct _cef_x509certificate_t * self)150 x509certificate_get_issuer_chain_size(struct _cef_x509certificate_t* self) {
151   shutdown_checker::AssertNotShutdown();
152 
153   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
154 
155   DCHECK(self);
156   if (!self)
157     return 0;
158 
159   // Execute
160   size_t _retval = CefX509CertificateCppToC::Get(self)->GetIssuerChainSize();
161 
162   // Return type: simple
163   return _retval;
164 }
165 
166 void CEF_CALLBACK
x509certificate_get_derencoded_issuer_chain(struct _cef_x509certificate_t * self,size_t * chainCount,cef_binary_value_t ** chain)167 x509certificate_get_derencoded_issuer_chain(struct _cef_x509certificate_t* self,
168                                             size_t* chainCount,
169                                             cef_binary_value_t** chain) {
170   shutdown_checker::AssertNotShutdown();
171 
172   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
173 
174   DCHECK(self);
175   if (!self)
176     return;
177   // Verify param: chain; type: refptr_vec_same_byref
178   DCHECK(chainCount && (*chainCount == 0 || chain));
179   if (!chainCount || (*chainCount > 0 && !chain))
180     return;
181 
182   // Translate param: chain; type: refptr_vec_same_byref
183   std::vector<CefRefPtr<CefBinaryValue>> chainList;
184   if (chainCount && *chainCount > 0 && chain) {
185     for (size_t i = 0; i < *chainCount; ++i) {
186       chainList.push_back(CefBinaryValueCppToC::Unwrap(chain[i]));
187     }
188   }
189 
190   // Execute
191   CefX509CertificateCppToC::Get(self)->GetDEREncodedIssuerChain(chainList);
192 
193   // Restore param: chain; type: refptr_vec_same_byref
194   if (chainCount && chain) {
195     *chainCount = std::min(chainList.size(), *chainCount);
196     if (*chainCount > 0) {
197       for (size_t i = 0; i < *chainCount; ++i) {
198         chain[i] = CefBinaryValueCppToC::Wrap(chainList[i]);
199       }
200     }
201   }
202 }
203 
204 void CEF_CALLBACK
x509certificate_get_pemencoded_issuer_chain(struct _cef_x509certificate_t * self,size_t * chainCount,cef_binary_value_t ** chain)205 x509certificate_get_pemencoded_issuer_chain(struct _cef_x509certificate_t* self,
206                                             size_t* chainCount,
207                                             cef_binary_value_t** chain) {
208   shutdown_checker::AssertNotShutdown();
209 
210   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
211 
212   DCHECK(self);
213   if (!self)
214     return;
215   // Verify param: chain; type: refptr_vec_same_byref
216   DCHECK(chainCount && (*chainCount == 0 || chain));
217   if (!chainCount || (*chainCount > 0 && !chain))
218     return;
219 
220   // Translate param: chain; type: refptr_vec_same_byref
221   std::vector<CefRefPtr<CefBinaryValue>> chainList;
222   if (chainCount && *chainCount > 0 && chain) {
223     for (size_t i = 0; i < *chainCount; ++i) {
224       chainList.push_back(CefBinaryValueCppToC::Unwrap(chain[i]));
225     }
226   }
227 
228   // Execute
229   CefX509CertificateCppToC::Get(self)->GetPEMEncodedIssuerChain(chainList);
230 
231   // Restore param: chain; type: refptr_vec_same_byref
232   if (chainCount && chain) {
233     *chainCount = std::min(chainList.size(), *chainCount);
234     if (*chainCount > 0) {
235       for (size_t i = 0; i < *chainCount; ++i) {
236         chain[i] = CefBinaryValueCppToC::Wrap(chainList[i]);
237       }
238     }
239   }
240 }
241 
242 }  // namespace
243 
244 // CONSTRUCTOR - Do not edit by hand.
245 
CefX509CertificateCppToC()246 CefX509CertificateCppToC::CefX509CertificateCppToC() {
247   GetStruct()->get_subject = x509certificate_get_subject;
248   GetStruct()->get_issuer = x509certificate_get_issuer;
249   GetStruct()->get_serial_number = x509certificate_get_serial_number;
250   GetStruct()->get_valid_start = x509certificate_get_valid_start;
251   GetStruct()->get_valid_expiry = x509certificate_get_valid_expiry;
252   GetStruct()->get_derencoded = x509certificate_get_derencoded;
253   GetStruct()->get_pemencoded = x509certificate_get_pemencoded;
254   GetStruct()->get_issuer_chain_size = x509certificate_get_issuer_chain_size;
255   GetStruct()->get_derencoded_issuer_chain =
256       x509certificate_get_derencoded_issuer_chain;
257   GetStruct()->get_pemencoded_issuer_chain =
258       x509certificate_get_pemencoded_issuer_chain;
259 }
260 
261 // DESTRUCTOR - Do not edit by hand.
262 
~CefX509CertificateCppToC()263 CefX509CertificateCppToC::~CefX509CertificateCppToC() {
264   shutdown_checker::AssertNotShutdown();
265 }
266 
267 template <>
268 CefRefPtr<CefX509Certificate> CefCppToCRefCounted<
269     CefX509CertificateCppToC,
270     CefX509Certificate,
UnwrapDerived(CefWrapperType type,cef_x509certificate_t * s)271     cef_x509certificate_t>::UnwrapDerived(CefWrapperType type,
272                                           cef_x509certificate_t* s) {
273   NOTREACHED() << "Unexpected class type: " << type;
274   return nullptr;
275 }
276 
277 template <>
278 CefWrapperType CefCppToCRefCounted<CefX509CertificateCppToC,
279                                    CefX509Certificate,
280                                    cef_x509certificate_t>::kWrapperType =
281     WT_X509CERTIFICATE;
282