| 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 = GCredentials.html |
|---|
| 27 |
* outPack = gio |
|---|
| 28 |
* outFile = Credentials |
|---|
| 29 |
* strct = GCredentials |
|---|
| 30 |
* realStrct= |
|---|
| 31 |
* ctorStrct= |
|---|
| 32 |
* clss = Credentials |
|---|
| 33 |
* interf = |
|---|
| 34 |
* class Code: No |
|---|
| 35 |
* interface Code: No |
|---|
| 36 |
* template for: |
|---|
| 37 |
* extend = |
|---|
| 38 |
* implements: |
|---|
| 39 |
* prefixes: |
|---|
| 40 |
* - g_credentials_ |
|---|
| 41 |
* omit structs: |
|---|
| 42 |
* omit prefixes: |
|---|
| 43 |
* omit code: |
|---|
| 44 |
* omit signals: |
|---|
| 45 |
* imports: |
|---|
| 46 |
* - glib.Str |
|---|
| 47 |
* - glib.ErrorG |
|---|
| 48 |
* - glib.GException |
|---|
| 49 |
* structWrap: |
|---|
| 50 |
* - GCredentials* -> Credentials |
|---|
| 51 |
* module aliases: |
|---|
| 52 |
* local aliases: |
|---|
| 53 |
* overrides: |
|---|
| 54 |
* - toString |
|---|
| 55 |
*/ |
|---|
| 56 |
|
|---|
| 57 |
module gio.Credentials; |
|---|
| 58 |
|
|---|
| 59 |
public import gtkc.giotypes; |
|---|
| 60 |
|
|---|
| 61 |
private import gtkc.gio; |
|---|
| 62 |
private import glib.ConstructionException; |
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
private import glib.Str; |
|---|
| 66 |
private import glib.ErrorG; |
|---|
| 67 |
private import glib.GException; |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
private import gobject.ObjectG; |
|---|
| 72 |
|
|---|
| 73 |
/** |
|---|
| 74 |
* Description |
|---|
| 75 |
* The GCredentials type is a reference-counted wrapper for native |
|---|
| 76 |
* credentials. This information is typically used for identifying, |
|---|
| 77 |
* authenticating and authorizing other processes. |
|---|
| 78 |
* Some operating systems supports looking up the credentials of the |
|---|
| 79 |
* remote peer of a communication endpoint - see e.g. |
|---|
| 80 |
* g_socket_get_credentials(). |
|---|
| 81 |
* Some operating systems supports securely sending and receiving |
|---|
| 82 |
* credentials over a Unix Domain Socket, see |
|---|
| 83 |
* GUnixCredentialsMessage, g_unix_connection_send_credentials() and |
|---|
| 84 |
* g_unix_connection_receive_credentials() for details. |
|---|
| 85 |
* On Linux, the native credential type is a struct ucred |
|---|
| 86 |
* - see the |
|---|
| 87 |
* unix(7) |
|---|
| 88 |
* man page for details. This corresponds to |
|---|
| 89 |
* G_CREDENTIALS_TYPE_LINUX_UCRED. |
|---|
| 90 |
* On FreeBSD, the native credential type is a struct cmsgcred. |
|---|
| 91 |
* This corresponds to G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED. |
|---|
| 92 |
*/ |
|---|
| 93 |
public class Credentials : ObjectG |
|---|
| 94 |
{ |
|---|
| 95 |
|
|---|
| 96 |
/** the main Gtk struct */ |
|---|
| 97 |
protected GCredentials* gCredentials; |
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
public GCredentials* getCredentialsStruct() |
|---|
| 101 |
{ |
|---|
| 102 |
return gCredentials; |
|---|
| 103 |
} |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
/** the main Gtk struct as a void* */ |
|---|
| 107 |
protected override void* getStruct() |
|---|
| 108 |
{ |
|---|
| 109 |
return cast(void*)gCredentials; |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
/** |
|---|
| 113 |
* Sets our main struct and passes it to the parent class |
|---|
| 114 |
*/ |
|---|
| 115 |
public this (GCredentials* gCredentials) |
|---|
| 116 |
{ |
|---|
| 117 |
if(gCredentials is null) |
|---|
| 118 |
{ |
|---|
| 119 |
this = null; |
|---|
| 120 |
return; |
|---|
| 121 |
} |
|---|
| 122 |
//Check if there already is a D object for this gtk struct |
|---|
| 123 |
void* ptr = getDObject(cast(GObject*)gCredentials); |
|---|
| 124 |
if( ptr !is null ) |
|---|
| 125 |
{ |
|---|
| 126 |
this = cast(Credentials)ptr; |
|---|
| 127 |
return; |
|---|
| 128 |
} |
|---|
| 129 |
super(cast(GObject*)gCredentials); |
|---|
| 130 |
this.gCredentials = gCredentials; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
protected override void setStruct(GObject* obj) |
|---|
| 134 |
{ |
|---|
| 135 |
super.setStruct(obj); |
|---|
| 136 |
gCredentials = cast(GCredentials*)obj; |
|---|
| 137 |
} |
|---|
| 138 |
|
|---|
| 139 |
/** |
|---|
| 140 |
*/ |
|---|
| 141 |
|
|---|
| 142 |
/** |
|---|
| 143 |
* Creates a new GCredentials object with credentials matching the |
|---|
| 144 |
* the current process. |
|---|
| 145 |
* Since 2.26 |
|---|
| 146 |
* Throws: ConstructionException GTK+ fails to create the object. |
|---|
| 147 |
*/ |
|---|
| 148 |
public this () |
|---|
| 149 |
{ |
|---|
| 150 |
// GCredentials * g_credentials_new (void); |
|---|
| 151 |
auto p = g_credentials_new(); |
|---|
| 152 |
if(p is null) |
|---|
| 153 |
{ |
|---|
| 154 |
throw new ConstructionException("null returned by g_credentials_new()"); |
|---|
| 155 |
} |
|---|
| 156 |
this(cast(GCredentials*) p); |
|---|
| 157 |
} |
|---|
| 158 |
|
|---|
| 159 |
/** |
|---|
| 160 |
* Creates a human-readable textual representation of credentials |
|---|
| 161 |
* that can be used in logging and debug messages. The format of the |
|---|
| 162 |
* returned string may change in future GLib release. |
|---|
| 163 |
* Since 2.26 |
|---|
| 164 |
* Returns: A string that should be freed with g_free(). |
|---|
| 165 |
*/ |
|---|
| 166 |
public override string toString() |
|---|
| 167 |
{ |
|---|
| 168 |
// gchar * g_credentials_to_string (GCredentials *credentials); |
|---|
| 169 |
return Str.toString(g_credentials_to_string(gCredentials)); |
|---|
| 170 |
} |
|---|
| 171 |
|
|---|
| 172 |
/** |
|---|
| 173 |
* Gets a pointer to native credentials of type native_type from |
|---|
| 174 |
* credentials. |
|---|
| 175 |
* It is a programming error (which will cause an warning to be |
|---|
| 176 |
* logged) to use this method if there is no GCredentials support for |
|---|
| 177 |
* the OS or if native_type isn't supported by the OS. |
|---|
| 178 |
* Since 2.26 |
|---|
| 179 |
* Params: |
|---|
| 180 |
* nativeType = The type of native credentials to get. |
|---|
| 181 |
* Returns: The pointer to native credentials or NULL if the operation there is no GCredentials support for the OS or if native_type isn't supported by the OS. Do not free the returned data, it is owned by credentials. |
|---|
| 182 |
*/ |
|---|
| 183 |
public void* getNative(GCredentialsType nativeType) |
|---|
| 184 |
{ |
|---|
| 185 |
// gpointer g_credentials_get_native (GCredentials *credentials, GCredentialsType native_type); |
|---|
| 186 |
return g_credentials_get_native(gCredentials, nativeType); |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
/** |
|---|
| 190 |
* Copies the native credentials of type native_type from native |
|---|
| 191 |
* into credentials. |
|---|
| 192 |
* It is a programming error (which will cause an warning to be |
|---|
| 193 |
* logged) to use this method if there is no GCredentials support for |
|---|
| 194 |
* the OS or if native_type isn't supported by the OS. |
|---|
| 195 |
* Since 2.26 |
|---|
| 196 |
* Params: |
|---|
| 197 |
* nativeType = The type of native credentials to set. |
|---|
| 198 |
* native = A pointer to native credentials. |
|---|
| 199 |
*/ |
|---|
| 200 |
public void setNative(GCredentialsType nativeType, void* native) |
|---|
| 201 |
{ |
|---|
| 202 |
// void g_credentials_set_native (GCredentials *credentials, GCredentialsType native_type, gpointer native); |
|---|
| 203 |
g_credentials_set_native(gCredentials, nativeType, native); |
|---|
| 204 |
} |
|---|
| 205 |
|
|---|
| 206 |
/** |
|---|
| 207 |
* Checks if credentials and other_credentials is the same user. |
|---|
| 208 |
* This operation can fail if GCredentials is not supported on the |
|---|
| 209 |
* the OS. |
|---|
| 210 |
* Since 2.26 |
|---|
| 211 |
* Params: |
|---|
| 212 |
* otherCredentials = A GCredentials. |
|---|
| 213 |
* Returns: TRUE if credentials and other_credentials has the same user, FALSE otherwise or if error is set. |
|---|
| 214 |
* Throws: GException on failure. |
|---|
| 215 |
*/ |
|---|
| 216 |
public int isSameUser(Credentials otherCredentials) |
|---|
| 217 |
{ |
|---|
| 218 |
// gboolean g_credentials_is_same_user (GCredentials *credentials, GCredentials *other_credentials, GError **error); |
|---|
| 219 |
GError* err = null; |
|---|
| 220 |
|
|---|
| 221 |
auto p = g_credentials_is_same_user(gCredentials, (otherCredentials is null) ? null : otherCredentials.getCredentialsStruct(), &err); |
|---|
| 222 |
|
|---|
| 223 |
if (err !is null) |
|---|
| 224 |
{ |
|---|
| 225 |
throw new GException( new ErrorG(err) ); |
|---|
| 226 |
} |
|---|
| 227 |
|
|---|
| 228 |
return p; |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
/** |
|---|
| 232 |
* Tries to get the UNIX user identifier from credentials. This |
|---|
| 233 |
* method is only available on UNIX platforms. |
|---|
| 234 |
* This operation can fail if GCredentials is not supported on the |
|---|
| 235 |
* OS or if the native credentials type does not contain information |
|---|
| 236 |
* about the UNIX user. |
|---|
| 237 |
* Since 2.26 |
|---|
| 238 |
* Returns: The UNIX user identifier or -1 if error is set. |
|---|
| 239 |
* Throws: GException on failure. |
|---|
| 240 |
*/ |
|---|
| 241 |
public uid_t getUnixUser() |
|---|
| 242 |
{ |
|---|
| 243 |
// uid_t g_credentials_get_unix_user (GCredentials *credentials, GError **error); |
|---|
| 244 |
GError* err = null; |
|---|
| 245 |
|
|---|
| 246 |
auto p = g_credentials_get_unix_user(gCredentials, &err); |
|---|
| 247 |
|
|---|
| 248 |
if (err !is null) |
|---|
| 249 |
{ |
|---|
| 250 |
throw new GException( new ErrorG(err) ); |
|---|
| 251 |
} |
|---|
| 252 |
|
|---|
| 253 |
return p; |
|---|
| 254 |
} |
|---|
| 255 |
|
|---|
| 256 |
/** |
|---|
| 257 |
* Tries to set the UNIX user identifier on credentials. This method |
|---|
| 258 |
* is only available on UNIX platforms. |
|---|
| 259 |
* This operation can fail if GCredentials is not supported on the |
|---|
| 260 |
* OS or if the native credentials type does not contain information |
|---|
| 261 |
* about the UNIX user. |
|---|
| 262 |
* Since 2.26 |
|---|
| 263 |
* Params: |
|---|
| 264 |
* uid = The UNIX user identifier to set. |
|---|
| 265 |
* Returns: TRUE if uid was set, FALSE if error is set. |
|---|
| 266 |
* Throws: GException on failure. |
|---|
| 267 |
*/ |
|---|
| 268 |
public int setUnixUser(uid_t uid) |
|---|
| 269 |
{ |
|---|
| 270 |
// gboolean g_credentials_set_unix_user (GCredentials *credentials, uid_t uid, GError **error); |
|---|
| 271 |
GError* err = null; |
|---|
| 272 |
|
|---|
| 273 |
auto p = g_credentials_set_unix_user(gCredentials, uid, &err); |
|---|
| 274 |
|
|---|
| 275 |
if (err !is null) |
|---|
| 276 |
{ |
|---|
| 277 |
throw new GException( new ErrorG(err) ); |
|---|
| 278 |
} |
|---|
| 279 |
|
|---|
| 280 |
return p; |
|---|
| 281 |
} |
|---|
| 282 |
} |
|---|