1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GTlsClientConnection.html
27  * outPack = gio
28  * outFile = TlsClientConnection
29  * strct   = GTlsClientConnection
30  * realStrct=
31  * ctorStrct=GIOStream
32  * clss    = TlsClientConnection
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = GTlsConnection
38  * implements:
39  * prefixes:
40  * 	- g_tls_client_connection_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ErrorG
48  * 	- glib.GException
49  * 	- glib.ListG
50  * 	- gio.IOStream
51  * 	- gio.SocketConnectable
52  * 	- gio.SocketConnectableIF
53  * structWrap:
54  * 	- GIOStream* -> IOStream
55  * 	- GList* -> ListG
56  * 	- GSocketConnectable* -> SocketConnectableIF
57  * module aliases:
58  * local aliases:
59  * overrides:
60  */
61 
62 module gio.TlsClientConnection;
63 
64 public  import gtkc.giotypes;
65 
66 private import gtkc.gio;
67 private import glib.ConstructionException;
68 private import gobject.ObjectG;
69 
70 private import glib.Str;
71 private import glib.ErrorG;
72 private import glib.GException;
73 private import glib.ListG;
74 private import gio.IOStream;
75 private import gio.SocketConnectable;
76 private import gio.SocketConnectableIF;
77 
78 
79 private import gio.TlsConnection;
80 
81 /**
82  * GTlsClientConnection is the client-side subclass of
83  * GTlsConnection, representing a client-side TLS connection.
84  */
85 public class TlsClientConnection : TlsConnection
86 {
87 	
88 	/** the main Gtk struct */
89 	protected GTlsClientConnection* gTlsClientConnection;
90 	
91 	
92 	/** Get the main Gtk struct */
93 	public GTlsClientConnection* getTlsClientConnectionStruct()
94 	{
95 		return gTlsClientConnection;
96 	}
97 	
98 	
99 	/** the main Gtk struct as a void* */
100 	protected override void* getStruct()
101 	{
102 		return cast(void*)gTlsClientConnection;
103 	}
104 	
105 	/**
106 	 * Sets our main struct and passes it to the parent class
107 	 */
108 	public this (GTlsClientConnection* gTlsClientConnection)
109 	{
110 		super(cast(GTlsConnection*)gTlsClientConnection);
111 		this.gTlsClientConnection = gTlsClientConnection;
112 	}
113 	
114 	protected override void setStruct(GObject* obj)
115 	{
116 		super.setStruct(obj);
117 		gTlsClientConnection = cast(GTlsClientConnection*)obj;
118 	}
119 	
120 	/**
121 	 */
122 	
123 	/**
124 	 * Creates a new GTlsClientConnection wrapping base_io_stream (which
125 	 * must have pollable input and output streams) which is assumed to
126 	 * communicate with the server identified by server_identity.
127 	 * Since 2.28
128 	 * Params:
129 	 * baseIoStream = the GIOStream to wrap
130 	 * serverIdentity = the expected identity of the server. [allow-none]
131 	 * Throws: GException on failure.
132 	 * Throws: ConstructionException GTK+ fails to create the object.
133 	 */
134 	public this (IOStream baseIoStream, SocketConnectableIF serverIdentity)
135 	{
136 		// GIOStream * g_tls_client_connection_new (GIOStream *base_io_stream,  GSocketConnectable *server_identity,  GError **error);
137 		GError* err = null;
138 		
139 		auto p = g_tls_client_connection_new((baseIoStream is null) ? null : baseIoStream.getIOStreamStruct(), (serverIdentity is null) ? null : serverIdentity.getSocketConnectableTStruct(), &err);
140 		
141 		if (err !is null)
142 		{
143 			throw new GException( new ErrorG(err) );
144 		}
145 		
146 		if(p is null)
147 		{
148 			throw new ConstructionException("null returned by g_tls_client_connection_new((baseIoStream is null) ? null : baseIoStream.getIOStreamStruct(), (serverIdentity is null) ? null : serverIdentity.getSocketConnectableTStruct(), &err)");
149 		}
150 		this(cast(GTlsClientConnection*) p);
151 	}
152 	
153 	/**
154 	 * Sets conn's expected server identity, which is used both to tell
155 	 * servers on virtual hosts which certificate to present, and also
156 	 * to let conn know what name to look for in the certificate when
157 	 * performing G_TLS_CERTIFICATE_BAD_IDENTITY validation, if enabled.
158 	 * Since 2.28
159 	 * Params:
160 	 * identity = a GSocketConnectable describing the expected server identity
161 	 */
162 	public void setServerIdentity(SocketConnectableIF identity)
163 	{
164 		// void g_tls_client_connection_set_server_identity  (GTlsClientConnection *conn,  GSocketConnectable *identity);
165 		g_tls_client_connection_set_server_identity(gTlsClientConnection, (identity is null) ? null : identity.getSocketConnectableTStruct());
166 	}
167 	
168 	/**
169 	 * Gets conn's expected server identity
170 	 * Since 2.28
171 	 * Returns: a GSocketConnectable describing the expected server identity, or NULL if the expected identity is not known. [transfer none]
172 	 */
173 	public SocketConnectableIF getServerIdentity()
174 	{
175 		// GSocketConnectable * g_tls_client_connection_get_server_identity  (GTlsClientConnection *conn);
176 		auto p = g_tls_client_connection_get_server_identity(gTlsClientConnection);
177 		
178 		if(p is null)
179 		{
180 			return null;
181 		}
182 		
183 		return ObjectG.getDObject!(SocketConnectable, SocketConnectableIF)(cast(GSocketConnectable*) p);
184 	}
185 	
186 	/**
187 	 * Sets conn's validation flags, to override the default set of
188 	 * checks performed when validating a server certificate. By default,
189 	 * G_TLS_CERTIFICATE_VALIDATE_ALL is used.
190 	 * Since 2.28
191 	 * Params:
192 	 * flags = the GTlsCertificateFlags to use
193 	 */
194 	public void setValidationFlags(GTlsCertificateFlags flags)
195 	{
196 		// void g_tls_client_connection_set_validation_flags  (GTlsClientConnection *conn,  GTlsCertificateFlags flags);
197 		g_tls_client_connection_set_validation_flags(gTlsClientConnection, flags);
198 	}
199 	
200 	/**
201 	 * Gets conn's validation flags
202 	 * Since 2.28
203 	 * Returns: the validation flags
204 	 */
205 	public GTlsCertificateFlags getValidationFlags()
206 	{
207 		// GTlsCertificateFlags g_tls_client_connection_get_validation_flags  (GTlsClientConnection *conn);
208 		return g_tls_client_connection_get_validation_flags(gTlsClientConnection);
209 	}
210 	
211 	/**
212 	 * If use_ssl3 is TRUE, this forces conn to use SSL 3.0 rather than
213 	 * trying to properly negotiate the right version of TLS or SSL to use.
214 	 * This can be used when talking to servers that do not implement the
215 	 * fallbacks correctly and which will therefore fail to handshake with
216 	 * a "modern" TLS handshake attempt.
217 	 * Since 2.28
218 	 * Params:
219 	 * useSsl3 = whether to use SSL 3.0
220 	 */
221 	public void setUseSsl3(int useSsl3)
222 	{
223 		// void g_tls_client_connection_set_use_ssl3  (GTlsClientConnection *conn,  gboolean use_ssl3);
224 		g_tls_client_connection_set_use_ssl3(gTlsClientConnection, useSsl3);
225 	}
226 	
227 	/**
228 	 * Gets whether conn will use SSL 3.0 rather than the
229 	 * highest-supported version of TLS; see
230 	 * g_tls_client_connection_set_use_ssl3().
231 	 * Since 2.28
232 	 * Returns: whether conn will use SSL 3.0
233 	 */
234 	public int getUseSsl3()
235 	{
236 		// gboolean g_tls_client_connection_get_use_ssl3  (GTlsClientConnection *conn);
237 		return g_tls_client_connection_get_use_ssl3(gTlsClientConnection);
238 	}
239 	
240 	/**
241 	 * Gets the list of distinguished names of the Certificate Authorities
242 	 * that the server will accept certificates from. This will be set
243 	 * during the TLS handshake if the server requests a certificate.
244 	 * Otherwise, it will be NULL.
245 	 * Each item in the list is a GByteArray which contains the complete
246 	 * subject DN of the certificate authority.
247 	 * Since 2.28
248 	 * Returns: the list of CA DNs. You should unref each element with g_byte_array_unref() and then the free the list with g_list_free(). [element-type GByteArray][transfer full]
249 	 */
250 	public ListG getAcceptedCas()
251 	{
252 		// GList * g_tls_client_connection_get_accepted_cas  (GTlsClientConnection *conn);
253 		auto p = g_tls_client_connection_get_accepted_cas(gTlsClientConnection);
254 		
255 		if(p is null)
256 		{
257 			return null;
258 		}
259 		
260 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
261 	}
262 }