purple: work around broken dbus-server.h
[siplcs.git] / src / core / sip-sec-mech.h
blobe5581bb64442493cf29f31004ba8d9705e73d2c2
1 /**
2 * @file sip-sec-mech.h
4 * pidgin-sipe
6 * Copyright (C) 2011-2015 SIPE Project <http://sipe.sourceforge.net/>
7 * Copyright (C) 2009 pier11 <pier11@operamail.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 /* Mechanism wrappers API (Inspired by GSS-API)
26 * All mechanisms should implement this API
28 * Current mechanisms are: Kerberos/GSS-API, sipe's NTLM and SSPI.
31 typedef struct {
32 gsize length;
33 guint8 *value;
34 } SipSecBuffer;
36 typedef SipSecContext
37 (*sip_sec_create_context_func)(guint type);
39 typedef gboolean
40 (*sip_sec_acquire_cred_func)(SipSecContext context,
41 const gchar *username,
42 const gchar *password);
44 typedef gboolean
45 (*sip_sec_init_context_func)(SipSecContext context,
46 SipSecBuffer in_buff,
47 SipSecBuffer *out_buff,
48 const gchar *service_name);
50 typedef void
51 (*sip_sec_destroy_context_func)(SipSecContext context);
53 typedef gboolean
54 (*sip_sec_make_signature_func)(SipSecContext context,
55 const gchar *message,
56 SipSecBuffer *signature);
58 typedef gboolean
59 (*sip_sec_verify_signature_func)(SipSecContext context,
60 const gchar *message,
61 SipSecBuffer signature);
63 typedef const gchar *(*sip_sec_context_name_func)(SipSecContext context);
65 typedef gboolean (*sip_sec_password_func)(void);
68 struct sip_sec_context {
69 sip_sec_acquire_cred_func acquire_cred_func;
70 sip_sec_init_context_func init_context_func;
71 sip_sec_destroy_context_func destroy_context_func;
72 sip_sec_make_signature_func make_signature_func;
73 sip_sec_verify_signature_func verify_signature_func;
74 sip_sec_context_name_func context_name_func;
75 guint type;
76 /** Security Context expiration interval in seconds */
77 guint expires;
78 guint flags;
81 /**
82 * sip_sec_context.flags
84 * 0x00000001 - 0x00008000: common flags
85 * 0x00010000 - 0x80000000: mechanism private flags
87 * NOTE: private flags must be set in acquire_cred_func()!
89 #define SIP_SEC_FLAG_COMMON_SSO 0x00000001
90 #define SIP_SEC_FLAG_COMMON_HTTP 0x00000002
91 #define SIP_SEC_FLAG_COMMON_READY 0x00000004
93 /**
94 * Helper macro for parsing username into domain & account parts
96 #define SIP_SEC_USERNAME_ENTERPRISE_STRING "\\@"
97 #define SIP_SEC_USERNAME_IS_ENTERPRISE (strstr(username, SIP_SEC_USERNAME_ENTERPRISE_STRING) != NULL)
98 #define SIP_SEC_USERNAME_SPLIT_START gchar **_domain_user = g_strsplit_set(username, "/\\", 2)
99 #define SIP_SEC_USERNAME_SPLIT_END g_strfreev(_domain_user)
100 #define SIP_SEC_USERNAME_DOMAIN _domain_user[0]
101 #define SIP_SEC_USERNAME_ACCOUNT _domain_user[1]
102 #define SIP_SEC_USERNAME_HAS_DOMAIN (SIP_SEC_USERNAME_ACCOUNT != NULL)