source: appstream-generator/build/girepo/gio/TlsDatabase.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 17.3 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.TlsDatabase;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import gio.AsyncResultIF;
26private import gio.Cancellable;
27private import gio.SocketConnectableIF;
28private import gio.TlsCertificate;
29private import gio.TlsInteraction;
30private import glib.ByteArray;
31private import glib.ErrorG;
32private import glib.GException;
33private import glib.ListG;
34private import glib.Str;
35private import gobject.ObjectG;
36
37
38/**
39 * #GTlsDatabase is used to lookup certificates and other information
40 * from a certificate or key store. It is an abstract base class which
41 * TLS library specific subtypes override.
42 *
43 * Most common client applications will not directly interact with
44 * #GTlsDatabase. It is used internally by #GTlsConnection.
45 *
46 * Since: 2.30
47 */
48public class TlsDatabase : ObjectG
49{
50        /** the main Gtk struct */
51        protected GTlsDatabase* gTlsDatabase;
52
53        /** Get the main Gtk struct */
54        public GTlsDatabase* getTlsDatabaseStruct()
55        {
56                return gTlsDatabase;
57        }
58
59        /** the main Gtk struct as a void* */
60        protected override void* getStruct()
61        {
62                return cast(void*)gTlsDatabase;
63        }
64
65        protected override void setStruct(GObject* obj)
66        {
67                gTlsDatabase = cast(GTlsDatabase*)obj;
68                super.setStruct(obj);
69        }
70
71        /**
72         * Sets our main struct and passes it to the parent class.
73         */
74        public this (GTlsDatabase* gTlsDatabase, bool ownedRef = false)
75        {
76                this.gTlsDatabase = gTlsDatabase;
77                super(cast(GObject*)gTlsDatabase, ownedRef);
78        }
79
80
81        /** */
82        public static GType getType()
83        {
84                return g_tls_database_get_type();
85        }
86
87        /**
88         * Create a handle string for the certificate. The database will only be able
89         * to create a handle for certificates that originate from the database. In
90         * cases where the database cannot create a handle for a certificate, %NULL
91         * will be returned.
92         *
93         * This handle should be stable across various instances of the application,
94         * and between applications. If a certificate is modified in the database,
95         * then it is not guaranteed that this handle will continue to point to it.
96         *
97         * Params:
98         *     certificate = certificate for which to create a handle.
99         *
100         * Returns: a newly allocated string containing the
101         *     handle.
102         *
103         * Since: 2.30
104         */
105        public string createCertificateHandle(TlsCertificate certificate)
106        {
107                auto retStr = g_tls_database_create_certificate_handle(gTlsDatabase, (certificate is null) ? null : certificate.getTlsCertificateStruct());
108               
109                scope(exit) Str.freeString(retStr);
110                return Str.toString(retStr);
111        }
112
113        /**
114         * Lookup a certificate by its handle.
115         *
116         * The handle should have been created by calling
117         * g_tls_database_create_certificate_handle() on a #GTlsDatabase object of
118         * the same TLS backend. The handle is designed to remain valid across
119         * instantiations of the database.
120         *
121         * If the handle is no longer valid, or does not point to a certificate in
122         * this database, then %NULL will be returned.
123         *
124         * This function can block, use g_tls_database_lookup_certificate_for_handle_async() to perform
125         * the lookup operation asynchronously.
126         *
127         * Params:
128         *     handle = a certificate handle
129         *     interaction = used to interact with the user if necessary
130         *     flags = Flags which affect the lookup.
131         *     cancellable = a #GCancellable, or %NULL
132         *
133         * Returns: a newly allocated
134         *     #GTlsCertificate, or %NULL. Use g_object_unref() to release the certificate.
135         *
136         * Since: 2.30
137         *
138         * Throws: GException on failure.
139         */
140        public TlsCertificate lookupCertificateForHandle(string handle, TlsInteraction interaction, GTlsDatabaseLookupFlags flags, Cancellable cancellable)
141        {
142                GError* err = null;
143               
144                auto p = g_tls_database_lookup_certificate_for_handle(gTlsDatabase, Str.toStringz(handle), (interaction is null) ? null : interaction.getTlsInteractionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
145               
146                if (err !is null)
147                {
148                        throw new GException( new ErrorG(err) );
149                }
150               
151                if(p is null)
152                {
153                        return null;
154                }
155               
156                return ObjectG.getDObject!(TlsCertificate)(cast(GTlsCertificate*) p, true);
157        }
158
159        /**
160         * Asynchronously lookup a certificate by its handle in the database. See
161         * g_tls_database_lookup_certificate_for_handle() for more information.
162         *
163         * Params:
164         *     handle = a certificate handle
165         *     interaction = used to interact with the user if necessary
166         *     flags = Flags which affect the lookup.
167         *     cancellable = a #GCancellable, or %NULL
168         *     callback = callback to call when the operation completes
169         *     userData = the data to pass to the callback function
170         *
171         * Since: 2.30
172         */
173        public void lookupCertificateForHandleAsync(string handle, TlsInteraction interaction, GTlsDatabaseLookupFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
174        {
175                g_tls_database_lookup_certificate_for_handle_async(gTlsDatabase, Str.toStringz(handle), (interaction is null) ? null : interaction.getTlsInteractionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
176        }
177
178        /**
179         * Finish an asynchronous lookup of a certificate by its handle. See
180         * g_tls_database_lookup_certificate_handle() for more information.
181         *
182         * If the handle is no longer valid, or does not point to a certificate in
183         * this database, then %NULL will be returned.
184         *
185         * Params:
186         *     result = a #GAsyncResult.
187         *
188         * Returns: a newly allocated #GTlsCertificate object.
189         *     Use g_object_unref() to release the certificate.
190         *
191         * Since: 2.30
192         *
193         * Throws: GException on failure.
194         */
195        public TlsCertificate lookupCertificateForHandleFinish(AsyncResultIF result)
196        {
197                GError* err = null;
198               
199                auto p = g_tls_database_lookup_certificate_for_handle_finish(gTlsDatabase, (result is null) ? null : result.getAsyncResultStruct(), &err);
200               
201                if (err !is null)
202                {
203                        throw new GException( new ErrorG(err) );
204                }
205               
206                if(p is null)
207                {
208                        return null;
209                }
210               
211                return ObjectG.getDObject!(TlsCertificate)(cast(GTlsCertificate*) p, true);
212        }
213
214        /**
215         * Lookup the issuer of @certificate in the database.
216         *
217         * The %issuer property
218         * of @certificate is not modified, and the two certificates are not hooked
219         * into a chain.
220         *
221         * This function can block, use g_tls_database_lookup_certificate_issuer_async() to perform
222         * the lookup operation asynchronously.
223         *
224         * Params:
225         *     certificate = a #GTlsCertificate
226         *     interaction = used to interact with the user if necessary
227         *     flags = flags which affect the lookup operation
228         *     cancellable = a #GCancellable, or %NULL
229         *
230         * Returns: a newly allocated issuer #GTlsCertificate,
231         *     or %NULL. Use g_object_unref() to release the certificate.
232         *
233         * Since: 2.30
234         *
235         * Throws: GException on failure.
236         */
237        public TlsCertificate lookupCertificateIssuer(TlsCertificate certificate, TlsInteraction interaction, GTlsDatabaseLookupFlags flags, Cancellable cancellable)
238        {
239                GError* err = null;
240               
241                auto p = g_tls_database_lookup_certificate_issuer(gTlsDatabase, (certificate is null) ? null : certificate.getTlsCertificateStruct(), (interaction is null) ? null : interaction.getTlsInteractionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
242               
243                if (err !is null)
244                {
245                        throw new GException( new ErrorG(err) );
246                }
247               
248                if(p is null)
249                {
250                        return null;
251                }
252               
253                return ObjectG.getDObject!(TlsCertificate)(cast(GTlsCertificate*) p, true);
254        }
255
256        /**
257         * Asynchronously lookup the issuer of @certificate in the database. See
258         * g_tls_database_lookup_certificate_issuer() for more information.
259         *
260         * Params:
261         *     certificate = a #GTlsCertificate
262         *     interaction = used to interact with the user if necessary
263         *     flags = flags which affect the lookup operation
264         *     cancellable = a #GCancellable, or %NULL
265         *     callback = callback to call when the operation completes
266         *     userData = the data to pass to the callback function
267         *
268         * Since: 2.30
269         */
270        public void lookupCertificateIssuerAsync(TlsCertificate certificate, TlsInteraction interaction, GTlsDatabaseLookupFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
271        {
272                g_tls_database_lookup_certificate_issuer_async(gTlsDatabase, (certificate is null) ? null : certificate.getTlsCertificateStruct(), (interaction is null) ? null : interaction.getTlsInteractionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
273        }
274
275        /**
276         * Finish an asynchronous lookup issuer operation. See
277         * g_tls_database_lookup_certificate_issuer() for more information.
278         *
279         * Params:
280         *     result = a #GAsyncResult.
281         *
282         * Returns: a newly allocated issuer #GTlsCertificate,
283         *     or %NULL. Use g_object_unref() to release the certificate.
284         *
285         * Since: 2.30
286         *
287         * Throws: GException on failure.
288         */
289        public TlsCertificate lookupCertificateIssuerFinish(AsyncResultIF result)
290        {
291                GError* err = null;
292               
293                auto p = g_tls_database_lookup_certificate_issuer_finish(gTlsDatabase, (result is null) ? null : result.getAsyncResultStruct(), &err);
294               
295                if (err !is null)
296                {
297                        throw new GException( new ErrorG(err) );
298                }
299               
300                if(p is null)
301                {
302                        return null;
303                }
304               
305                return ObjectG.getDObject!(TlsCertificate)(cast(GTlsCertificate*) p, true);
306        }
307
308        /**
309         * Lookup certificates issued by this issuer in the database.
310         *
311         * This function can block, use g_tls_database_lookup_certificates_issued_by_async() to perform
312         * the lookup operation asynchronously.
313         *
314         * Params:
315         *     issuerRawDn = a #GByteArray which holds the DER encoded issuer DN.
316         *     interaction = used to interact with the user if necessary
317         *     flags = Flags which affect the lookup operation.
318         *     cancellable = a #GCancellable, or %NULL
319         *
320         * Returns: a newly allocated list of #GTlsCertificate
321         *     objects. Use g_object_unref() on each certificate, and g_list_free() on the release the list.
322         *
323         * Since: 2.30
324         *
325         * Throws: GException on failure.
326         */
327        public ListG lookupCertificatesIssuedBy(ByteArray issuerRawDn, TlsInteraction interaction, GTlsDatabaseLookupFlags flags, Cancellable cancellable)
328        {
329                GError* err = null;
330               
331                auto p = g_tls_database_lookup_certificates_issued_by(gTlsDatabase, (issuerRawDn is null) ? null : issuerRawDn.getByteArrayStruct(), (interaction is null) ? null : interaction.getTlsInteractionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
332               
333                if (err !is null)
334                {
335                        throw new GException( new ErrorG(err) );
336                }
337               
338                if(p is null)
339                {
340                        return null;
341                }
342               
343                return new ListG(cast(GList*) p, true);
344        }
345
346        /**
347         * Asynchronously lookup certificates issued by this issuer in the database. See
348         * g_tls_database_lookup_certificates_issued_by() for more information.
349         *
350         * The database may choose to hold a reference to the issuer byte array for the duration
351         * of of this asynchronous operation. The byte array should not be modified during
352         * this time.
353         *
354         * Params:
355         *     issuerRawDn = a #GByteArray which holds the DER encoded issuer DN.
356         *     interaction = used to interact with the user if necessary
357         *     flags = Flags which affect the lookup operation.
358         *     cancellable = a #GCancellable, or %NULL
359         *     callback = callback to call when the operation completes
360         *     userData = the data to pass to the callback function
361         *
362         * Since: 2.30
363         */
364        public void lookupCertificatesIssuedByAsync(ByteArray issuerRawDn, TlsInteraction interaction, GTlsDatabaseLookupFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
365        {
366                g_tls_database_lookup_certificates_issued_by_async(gTlsDatabase, (issuerRawDn is null) ? null : issuerRawDn.getByteArrayStruct(), (interaction is null) ? null : interaction.getTlsInteractionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
367        }
368
369        /**
370         * Finish an asynchronous lookup of certificates. See
371         * g_tls_database_lookup_certificates_issued_by() for more information.
372         *
373         * Params:
374         *     result = a #GAsyncResult.
375         *
376         * Returns: a newly allocated list of #GTlsCertificate
377         *     objects. Use g_object_unref() on each certificate, and g_list_free() on the release the list.
378         *
379         * Since: 2.30
380         *
381         * Throws: GException on failure.
382         */
383        public ListG lookupCertificatesIssuedByFinish(AsyncResultIF result)
384        {
385                GError* err = null;
386               
387                auto p = g_tls_database_lookup_certificates_issued_by_finish(gTlsDatabase, (result is null) ? null : result.getAsyncResultStruct(), &err);
388               
389                if (err !is null)
390                {
391                        throw new GException( new ErrorG(err) );
392                }
393               
394                if(p is null)
395                {
396                        return null;
397                }
398               
399                return new ListG(cast(GList*) p, true);
400        }
401
402        /**
403         * Verify's a certificate chain after looking up and adding any missing
404         * certificates to the chain.
405         *
406         * @chain is a chain of #GTlsCertificate objects each pointing to the next
407         * certificate in the chain by its %issuer property. The chain may initially
408         * consist of one or more certificates. After the verification process is
409         * complete, @chain may be modified by adding missing certificates, or removing
410         * extra certificates. If a certificate anchor was found, then it is added to
411         * the @chain.
412         *
413         * @purpose describes the purpose (or usage) for which the certificate
414         * is being used. Typically @purpose will be set to #G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER
415         * which means that the certificate is being used to authenticate a server
416         * (and we are acting as the client).
417         *
418         * The @identity is used to check for pinned certificates (trust exceptions)
419         * in the database. These will override the normal verification process on a
420         * host by host basis.
421         *
422         * Currently there are no @flags, and %G_TLS_DATABASE_VERIFY_NONE should be
423         * used.
424         *
425         * This function can block, use g_tls_database_verify_chain_async() to perform
426         * the verification operation asynchronously.
427         *
428         * Params:
429         *     chain = a #GTlsCertificate chain
430         *     purpose = the purpose that this certificate chain will be used for.
431         *     identity = the expected peer identity
432         *     interaction = used to interact with the user if necessary
433         *     flags = additional verify flags
434         *     cancellable = a #GCancellable, or %NULL
435         *
436         * Returns: the appropriate #GTlsCertificateFlags which represents the
437         *     result of verification.
438         *
439         * Since: 2.30
440         *
441         * Throws: GException on failure.
442         */
443        public GTlsCertificateFlags verifyChain(TlsCertificate chain, string purpose, SocketConnectableIF identity, TlsInteraction interaction, GTlsDatabaseVerifyFlags flags, Cancellable cancellable)
444        {
445                GError* err = null;
446               
447                auto p = g_tls_database_verify_chain(gTlsDatabase, (chain is null) ? null : chain.getTlsCertificateStruct(), Str.toStringz(purpose), (identity is null) ? null : identity.getSocketConnectableStruct(), (interaction is null) ? null : interaction.getTlsInteractionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), &err);
448               
449                if (err !is null)
450                {
451                        throw new GException( new ErrorG(err) );
452                }
453               
454                return p;
455        }
456
457        /**
458         * Asynchronously verify's a certificate chain after looking up and adding
459         * any missing certificates to the chain. See g_tls_database_verify_chain()
460         * for more information.
461         *
462         * Params:
463         *     chain = a #GTlsCertificate chain
464         *     purpose = the purpose that this certificate chain will be used for.
465         *     identity = the expected peer identity
466         *     interaction = used to interact with the user if necessary
467         *     flags = additional verify flags
468         *     cancellable = a #GCancellable, or %NULL
469         *     callback = callback to call when the operation completes
470         *     userData = the data to pass to the callback function
471         *
472         * Since: 2.30
473         */
474        public void verifyChainAsync(TlsCertificate chain, string purpose, SocketConnectableIF identity, TlsInteraction interaction, GTlsDatabaseVerifyFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
475        {
476                g_tls_database_verify_chain_async(gTlsDatabase, (chain is null) ? null : chain.getTlsCertificateStruct(), Str.toStringz(purpose), (identity is null) ? null : identity.getSocketConnectableStruct(), (interaction is null) ? null : interaction.getTlsInteractionStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
477        }
478
479        /**
480         * Finish an asynchronous verify chain operation. See
481         * g_tls_database_verify_chain() for more information. *
482         *
483         * Params:
484         *     result = a #GAsyncResult.
485         *
486         * Returns: the appropriate #GTlsCertificateFlags which represents the
487         *     result of verification.
488         *
489         * Since: 2.30
490         *
491         * Throws: GException on failure.
492         */
493        public GTlsCertificateFlags verifyChainFinish(AsyncResultIF result)
494        {
495                GError* err = null;
496               
497                auto p = g_tls_database_verify_chain_finish(gTlsDatabase, (result is null) ? null : result.getAsyncResultStruct(), &err);
498               
499                if (err !is null)
500                {
501                        throw new GException( new ErrorG(err) );
502                }
503               
504                return p;
505        }
506}
Note: See TracBrowser for help on using the repository browser.