0001-saml-2.0-improve-support-for-free-content-inside-sam.patch
bindings/bindings.py | ||
---|---|---|
374 | 374 |
raise Exception('should not happen: could not found type for default: ' + annotation) |
375 | 375 |
arg[2]['default'] = prefix + m.group(1) |
376 | 376 |
arg[2]['optional'] = True |
377 |
m = re.search(r'\(\s*element-type\s+(\w+)(?:\s+(\w+))?', annotation)
|
|
377 |
m = re.search(r'\(\s*element-type\s+([\w*]+)(?:\s+([\w*]+))?', annotation)
|
|
378 | 378 |
if m: |
379 | 379 |
if len(m.groups()) > 2: |
380 | 380 |
arg[2]['key-type'] = \ |
bindings/overrides.xml | ||
---|---|---|
198 | 198 |
<func name="lasso_log_set_handler" skip="true"/> |
199 | 199 |
<func name="lasso_log_remove_handler" skip="true"/> |
200 | 200 |
<func name="lasso_key_new_for_signature_from_memory" skip="true"/> |
201 |
<func name="lasso_samlp2_extensions_get_any" skip="php5,perl,java"/> |
|
202 |
<func name="lasso_samlp2_extensions_set_any" skip="php5,perl,java"/> |
|
203 |
<func name="lasso_samlp2_extensions_get_attributes" skip="php5,perl,java"/> |
|
204 |
<func name="lasso_samlp2_extensions_set_attributes" skip="php5,perl,java"/> |
|
201 | 205 |
<!-- Xml --> |
202 | 206 |
<func name="lasso_node_export_to_soap_with_headers"> |
203 | 207 |
<param name="node"/> |
bindings/python/lang.py | ||
---|---|---|
87 | 87 |
else: |
88 | 88 |
raise Exception('Unsupported caller owned return type %s' % ((repr(type), name),)) |
89 | 89 |
elif is_hashtable(type): |
90 |
raise Exception('Unsupported caller owned return type %s' % ((repr(type), name),)) |
|
90 |
el_type = element_type(type) |
|
91 |
k_type = key_type(type) |
|
92 |
v_type = value_type(type) |
|
93 |
if is_cstring(el_type) or (is_cstring(k_type) and is_cstring(v_type)): |
|
94 |
print_(' g_hash_table_destroy(%s);' % name, file=fd) |
|
95 |
else: |
|
96 |
raise Exception('Unsupported free value of type GHashTable: %s' % type) |
|
91 | 97 |
elif is_object(type): |
92 | 98 |
print_(' if (return_value) g_object_unref(%s);' % name, file=fd) |
93 | 99 |
else: |
... | ... | |
528 | 534 |
print_(' rc = _lasso.%s(self._cptr%s)' % ( |
529 | 535 |
function_name, c_args), file=fd) |
530 | 536 |
print_(' Error.raise_on_rc(rc)', file=fd) |
531 |
elif is_int(m.return_arg, self.binding_data) or is_xml_node(m.return_arg) or is_cstring(m.return_arg) or is_boolean(m.return_arg): |
|
537 |
elif (is_int(m.return_arg, self.binding_data) or is_xml_node(m.return_arg) or |
|
538 |
is_cstring(m.return_arg) or is_boolean(m.return_arg) or |
|
539 |
is_hashtable(m.return_arg)): |
|
532 | 540 |
print_(' return _lasso.%s(self._cptr%s)' % ( |
533 | 541 |
function_name, c_args), file=fd) |
534 | 542 |
elif is_glist(m.return_arg): |
... | ... | |
539 | 547 |
print_(' if value is not None:', file=fd) |
540 | 548 |
print_(' value = tuple([cptrToPy(x) for x in value])', file=fd) |
541 | 549 |
print_(' return value', file=fd) |
542 |
elif is_cstring(el_type): |
|
550 |
elif is_cstring(el_type) or is_xml_node(el_type):
|
|
543 | 551 |
print_(' return _lasso.%s(self._cptr%s)' % ( |
544 | 552 |
function_name, c_args), file=fd) |
545 | 553 |
else: |
546 | 554 |
raise Exception('Return Type GList<%s> is not supported' % el_type) |
547 |
elif is_hashtable(m.return_arg): |
|
548 |
raise Exception('Return type GHashTable unsupported') |
|
549 | 555 |
elif is_object(m.return_arg): |
550 | 556 |
print_(' return cptrToPy(_lasso.%s(self._cptr%s))' % ( |
551 | 557 |
function_name, c_args), file=fd) |
... | ... | |
929 | 935 |
arg_def = ' %s %s = %s;' % (arg[0], arg[1], defval) |
930 | 936 |
else: |
931 | 937 |
arg_def = ' %s %s;' % (arg[0], arg[1]) |
932 |
elif is_xml_node(arg) or is_list(arg) or is_time_t_pointer(arg): |
|
938 |
elif is_hashtable(arg) or is_xml_node(arg) or is_list(arg) or is_time_t_pointer(arg):
|
|
933 | 939 |
parse_tuple_format.append('O') |
934 | 940 |
parse_tuple_args.append('&cvt_%s' % aname) |
935 | 941 |
arg_def = ' %s %s = NULL;' % (arg[0], arg[1]) |
... | ... | |
970 | 976 |
qualifier = element_type(arg) |
971 | 977 |
if is_cstring(qualifier): |
972 | 978 |
print_(' set_list_of_strings(&%s, cvt_%s);' % (arg[1], arg[1]), file=fd) |
973 |
elif qualifier == 'xmlNode*':
|
|
979 |
elif is_xml_node(qualifier):
|
|
974 | 980 |
print_(' set_list_of_xml_nodes(&%s, cvt_%s);' % (arg[1], arg[1]), file=fd) |
975 | 981 |
elif isinstance(qualifier, str) and qualifier.startswith('Lasso'): |
976 | 982 |
print_(' set_list_of_pygobject(&%s, cvt_%s);' % (arg[1], arg[1]), file=fd) |
... | ... | |
980 | 986 |
print_(' %s = get_xml_node_from_pystring(cvt_%s);' % (arg[1], arg[1]), file=fd) |
981 | 987 |
elif is_time_t_pointer(arg): |
982 | 988 |
print_(' %s = get_time_t(cvt_%s);' % (arg[1], arg[1]), file=fd) |
989 |
elif is_hashtable(arg): |
|
990 |
el_type = element_type(arg) |
|
991 |
k_type = key_type(arg) |
|
992 |
v_type = value_type(arg) |
|
993 |
if is_cstring(el_type) or (is_cstring(k_type) and is_cstring(v_type)): |
|
994 | ||
995 |
print_(' %s = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);' % arg[1], file=fd) |
|
996 |
print_(' set_hashtable_of_strings(%s, cvt_%s);' % (arg[1], arg[1]), file=fd) |
|
983 | 997 |
elif f == 'O': |
984 | 998 |
if is_optional(arg): |
985 | 999 |
print_(' if (PyObject_TypeCheck((PyObject*)cvt_%s, &PyGObjectPtrType)) {' % arg[1], file=fd) |
... | ... | |
1021 | 1035 |
print_(' PyList_SetItem(cvt_%s_out, 0, out_pyvalue);' % arg[1], file=fd) |
1022 | 1036 |
elif arg[0] == 'GList*': |
1023 | 1037 |
qualifier = arg[2].get('element-type') |
1024 |
if qualifier == 'char*':
|
|
1038 |
if is_cstring(qualifier):
|
|
1025 | 1039 |
print_(' free_list(&%s, (GFunc)g_free);' % arg[1], file=fd) |
1026 |
elif qualifier == 'xmlNode*':
|
|
1040 |
elif is_xml_node(qualifier):
|
|
1027 | 1041 |
print_(' free_list(&%s, (GFunc)xmlFreeNode);' % arg[1], file=fd) |
1028 |
elif qualifier == 'LassoNode':
|
|
1042 |
elif is_object(qualifier):
|
|
1029 | 1043 |
print_(' free_list(&%s, (GFunc)g_object_unref);' % arg[1], file=fd) |
1030 | 1044 |
elif is_time_t_pointer(arg): |
1031 | 1045 |
print_(' if (%s) free(%s);' % (arg[1], arg[1]), file=fd) |
1046 |
elif not is_transfer_full(arg) and is_hashtable(arg): |
|
1047 |
self.free_value(fd, arg) |
|
1032 | 1048 |
elif not is_transfer_full(arg) and is_xml_node(arg): |
1033 | 1049 |
self.free_value(fd, arg) |
1034 | 1050 |
bindings/python/tests/binding_tests.py | ||
---|---|---|
301 | 301 |
server = lasso.Server.newFromDump(server_dump) |
302 | 302 |
assert isinstance(server, lasso.Server) |
303 | 303 | |
304 |
def test12(self): |
|
305 |
node = lasso.Samlp2Extensions() |
|
306 |
assert not node.any |
|
307 |
content = '''<samlp:Extensions |
|
308 |
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" |
|
309 |
xmlns:eo="https://www.entrouvert.com/" eo:huhu="xxx"> |
|
310 |
<eo:next_url>%s</eo:next_url> |
|
311 |
</samlp:Extensions>''' |
|
312 |
node = lasso.Node.newFromXmlNode(content) |
|
313 |
print node.dump() |
|
314 |
print content |
|
315 |
print node.any |
|
316 |
print node.attributes |
|
317 |
node.any = ('<zob>coin</zob>',) |
|
318 |
node.attributes = {'michou': 'zozo'} |
|
319 |
print node.dump() |
|
320 | ||
321 | ||
304 | 322 |
bindingSuite = unittest.makeSuite(BindingTestCase, 'test') |
305 | 323 | |
306 | 324 |
allTests = unittest.TestSuite((bindingSuite, )) |
bindings/python/wrapper_top.c | ||
---|---|---|
303 | 303 |
while (PyDict_Next(dict, &i, &key, &value)) { |
304 | 304 |
char *ckey = PyString_AsString(key); |
305 | 305 |
char *cvalue = PyString_AsString(value); |
306 |
g_hash_table_insert (a_hash, ckey, cvalue);
|
|
306 |
g_hash_table_insert (a_hash, g_strdup(ckey), g_strdup(cvalue));
|
|
307 | 307 |
} |
308 | 308 |
failure: |
309 | 309 |
return; |
lasso/utils.h | ||
---|---|---|
325 | 325 |
} \ |
326 | 326 |
} |
327 | 327 | |
328 |
#define lasso_assign_list_of_xml_node(dest, src) \ |
|
329 |
{ \ |
|
330 |
GList *__tmp = src; \ |
|
331 |
GList *__iter_dest; \ |
|
332 |
lasso_release_list_of_xml_node(dest); \ |
|
333 |
dest = g_list_copy(__tmp); \ |
|
334 |
for (__iter_dest = dest ; __iter_dest != NULL ; __iter_dest = g_list_next(__iter_dest)) { \ |
|
335 |
__iter_dest->data = xmlCopyNode(__iter_dest->data, 1); \ |
|
336 |
} \ |
|
337 |
} |
|
338 | ||
328 | 339 |
#define lasso_assign_new_sec_key(dest, src) \ |
329 | 340 |
{ \ |
330 | 341 |
xmlSecKey *__tmp = (src); \ |
... | ... | |
344 | 355 |
dest = __tmp; \ |
345 | 356 |
} |
346 | 357 | |
358 |
G_GNUC_UNUSED static void |
|
359 |
_lasso_copy_helper_assign_table_of_attributes(gpointer key, gpointer val, gpointer dest){ |
|
360 |
g_hash_table_insert((GHashTable*) dest, g_strdup(key), g_strdup(val)); |
|
361 |
} |
|
362 | ||
363 |
#define lasso_assign_table_of_attributes(dest, src) \ |
|
364 |
{\ |
|
365 |
if (!dest) {\ |
|
366 |
(dest) = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);\ |
|
367 |
}\ |
|
368 |
g_hash_table_remove_all(dest);\ |
|
369 |
g_hash_table_foreach(src, _lasso_copy_helper_assign_table_of_attributes, dest);\ |
|
370 |
} |
|
371 | ||
372 | ||
347 | 373 |
/* List appending */ |
348 | 374 | |
349 | 375 |
/* lasso_list_add_xxx macros, simplify code around list manipulation (g_list_append needs to be |
lasso/xml/saml-2.0/samlp2_extensions.c | ||
---|---|---|
45 | 45 |
* |
46 | 46 |
*/ |
47 | 47 | |
48 |
typedef struct _LassoSamlp2ExtensionsPrivate LassoSamlp2ExtensionsPrivate; |
|
49 | ||
50 |
struct _LassoSamlp2ExtensionsPrivate { |
|
51 |
GList *any; |
|
52 |
GHashTable *attributes; |
|
53 |
}; |
|
54 | ||
48 | 55 |
/*****************************************************************************/ |
49 | 56 |
/* private methods */ |
50 | 57 |
/*****************************************************************************/ |
51 | 58 | |
52 | 59 | |
53 | 60 |
static struct XmlSnippet schema_snippets[] = { |
61 |
{"", SNIPPET_LIST_XMLNODES | SNIPPET_ANY | SNIPPET_PRIVATE, |
|
62 |
G_STRUCT_OFFSET(LassoSamlp2ExtensionsPrivate, any), NULL, NULL, NULL}, |
|
63 |
{"", SNIPPET_ATTRIBUTE | SNIPPET_ANY | SNIPPET_PRIVATE, |
|
64 |
G_STRUCT_OFFSET(LassoSamlp2ExtensionsPrivate, attributes), NULL, NULL, NULL}, |
|
54 | 65 |
{NULL, 0, 0, NULL, NULL, NULL} |
55 | 66 |
}; |
56 | 67 | |
57 | 68 |
static LassoNodeClass *parent_class = NULL; |
58 | 69 | |
70 |
#define GET_PRIVATE(x) G_TYPE_INSTANCE_GET_PRIVATE(x, \ |
|
71 |
LASSO_TYPE_SAMLP2_EXTENSIONS, LassoSamlp2ExtensionsPrivate) |
|
72 | ||
59 | 73 |
/*****************************************************************************/ |
60 | 74 |
/* instance and class init functions */ |
61 | 75 |
/*****************************************************************************/ |
62 | 76 | |
63 |
static xmlNode* |
|
64 |
get_xmlNode(LassoNode *node, gboolean lasso_dump) |
|
65 |
{ |
|
66 |
LassoNodeClass *parent_class = NULL; |
|
67 |
xmlNode *cur; |
|
68 | ||
69 |
parent_class = g_type_class_peek_parent(LASSO_NODE_GET_CLASS(node)); |
|
70 |
cur = parent_class->get_xmlNode(node, lasso_dump); |
|
71 | ||
72 |
return lasso_node_get_xmlnode_for_any_type(node, cur); |
|
73 |
} |
|
74 | ||
75 | 77 |
static void |
76 | 78 |
class_init(LassoSamlp2ExtensionsClass *klass) |
77 | 79 |
{ |
... | ... | |
80 | 82 |
parent_class = g_type_class_peek_parent(klass); |
81 | 83 |
nclass->node_data = g_new0(LassoNodeClassData, 1); |
82 | 84 |
nclass->node_data->keep_xmlnode = TRUE; |
83 |
nclass->get_xmlNode = get_xmlNode; |
|
84 | 85 |
lasso_node_class_set_nodename(nclass, "Extensions"); |
85 | 86 |
lasso_node_class_set_ns(nclass, LASSO_SAML2_PROTOCOL_HREF, LASSO_SAML2_PROTOCOL_PREFIX); |
86 | 87 |
lasso_node_class_add_snippets(nclass, schema_snippets); |
88 |
g_type_class_add_private(G_OBJECT_CLASS(klass), sizeof(LassoSamlp2ExtensionsPrivate)); |
|
87 | 89 |
} |
88 | 90 | |
89 | 91 |
GType |
... | ... | |
123 | 125 |
{ |
124 | 126 |
return g_object_new(LASSO_TYPE_SAMLP2_EXTENSIONS, NULL); |
125 | 127 |
} |
128 | ||
129 |
/** |
|
130 |
* lasso_samlp2_extensions_get_any: |
|
131 |
* |
|
132 |
* Return the list of contained XML nodes. |
|
133 |
* |
|
134 |
* Return value:(element-type xmlNode)(transfer none): a #GList of xmlNode. |
|
135 |
*/ |
|
136 |
GList* |
|
137 |
lasso_samlp2_extensions_get_any(LassoSamlp2Extensions *extensions) |
|
138 |
{ |
|
139 |
LassoSamlp2ExtensionsPrivate *pv = NULL; |
|
140 | ||
141 |
pv = GET_PRIVATE(extensions); |
|
142 | ||
143 |
return pv->any; |
|
144 |
} |
|
145 | ||
146 |
/** |
|
147 |
* lasso_samlp2_extensions_set_any: |
|
148 |
* @any:(allow-none)(element-type xmlNode)(transfer none): a list of xmlNode. |
|
149 |
* |
|
150 |
* Set the list of contained XML nodes. |
|
151 |
* |
|
152 |
*/ |
|
153 |
void |
|
154 |
lasso_samlp2_extensions_set_any(LassoSamlp2Extensions *extensions, GList *any) |
|
155 |
{ |
|
156 |
LassoSamlp2ExtensionsPrivate *pv = NULL; |
|
157 | ||
158 |
pv = GET_PRIVATE(extensions); |
|
159 | ||
160 |
lasso_assign_list_of_xml_node(pv->any, any); |
|
161 |
} |
|
162 | ||
163 |
/** |
|
164 |
* lasso_samlp2_extensions_get_attributes: |
|
165 |
* |
|
166 |
* Return the list of contained XML nodes. |
|
167 |
* |
|
168 |
* Return value:(element-type xmlNode)(transfer none): a #GList of xmlNode. |
|
169 |
*/ |
|
170 |
GHashTable* |
|
171 |
lasso_samlp2_extensions_get_attributes(LassoSamlp2Extensions *extensions) |
|
172 |
{ |
|
173 |
LassoSamlp2ExtensionsPrivate *pv = NULL; |
|
174 | ||
175 |
pv = GET_PRIVATE(extensions); |
|
176 | ||
177 |
return pv->attributes; |
|
178 |
} |
|
179 | ||
180 |
/** |
|
181 |
* lasso_samlp2_extensions_set_attributes: |
|
182 |
* @attributes:(element-type char* char*): table of attributes. |
|
183 |
* |
|
184 |
* Set the table of XML attributes. |
|
185 |
*/ |
|
186 |
void |
|
187 |
lasso_samlp2_extensions_set_attributes(LassoSamlp2Extensions *extensions, GHashTable *attributes) |
|
188 |
{ |
|
189 |
LassoSamlp2ExtensionsPrivate *pv = NULL; |
|
190 | ||
191 |
pv = GET_PRIVATE(extensions); |
|
192 | ||
193 |
lasso_assign_table_of_attributes(pv->attributes, attributes); |
|
194 |
} |
lasso/xml/saml-2.0/samlp2_extensions.h | ||
---|---|---|
62 | 62 | |
63 | 63 |
LASSO_EXPORT GType lasso_samlp2_extensions_get_type(void); |
64 | 64 |
LASSO_EXPORT LassoNode* lasso_samlp2_extensions_new(void); |
65 | ||
65 |
LASSO_EXPORT GList* lasso_samlp2_extensions_get_any(LassoSamlp2Extensions *extensions); |
|
66 |
LASSO_EXPORT void lasso_samlp2_extensions_set_any(LassoSamlp2Extensions *extensions, GList *any); |
|
67 |
LASSO_EXPORT GHashTable* lasso_samlp2_extensions_get_attributes(LassoSamlp2Extensions *extensions); |
|
68 |
LASSO_EXPORT void lasso_samlp2_extensions_set_attributes(LassoSamlp2Extensions *extensions, GHashTable *attributes); |
|
66 | 69 | |
67 | 70 | |
68 | 71 |
#ifdef __cplusplus |
69 |
- |