diff options
| author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2009-03-27 15:04:41 +0000 |
|---|---|---|
| committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2009-03-27 15:04:41 +0000 |
| commit | 7f09fe60de4f66a35ef751d8dd902066e196860b (patch) | |
| tree | a178545feb8606bb4a9bdeb0bb1526fd5d8740ac | |
| parent | a017ddc81ec438462924dd5ad552c83b7b8d7849 (diff) | |
| download | lasso-7f09fe60de4f66a35ef751d8dd902066e196860b.tar.gz lasso-7f09fe60de4f66a35ef751d8dd902066e196860b.tar.xz lasso-7f09fe60de4f66a35ef751d8dd902066e196860b.zip | |
Fix bug #94: permit any content for AttributeValue
* lasso/xml/private.h:
* lasso/xml/xml.h
* lassoi/xml/xml.c:
add an implementation helper for the AttributeValue objects
implementation of get_xmlNode.
make lasso_node_set_original_xmlnode public API.
* lasso/xml/saml-2.0/samlp2_extensions.c:
* lasso/xml/saml-2.0/saml2_attribute_value.c:
* lasso/xml/saml_attribute_value.c:
implement get_xmlNode for the AttributeValue and Extensions objects.
If the any field is empty, use the original_xmlnode value. In order
to support free-style content, you must use the method
lasso_node_set_original_xmlnode, properties and children are
extracted from the given node and added to the node created by the
generic get_xmlNode virtual method.
| -rw-r--r-- | lasso/xml/private.h | 2 | ||||
| -rw-r--r-- | lasso/xml/saml-2.0/saml2_attribute_value.c | 21 | ||||
| -rw-r--r-- | lasso/xml/saml-2.0/samlp2_extensions.c | 15 | ||||
| -rw-r--r-- | lasso/xml/saml_attribute_value.c | 21 | ||||
| -rw-r--r-- | lasso/xml/xml.c | 44 | ||||
| -rw-r--r-- | lasso/xml/xml.h | 4 |
6 files changed, 92 insertions, 15 deletions
diff --git a/lasso/xml/private.h b/lasso/xml/private.h index 5d1c85fb..9bd87ac5 100644 --- a/lasso/xml/private.h +++ b/lasso/xml/private.h @@ -144,6 +144,8 @@ gchar* lasso_node_build_deflated_query(LassoNode *node); gboolean lasso_node_init_from_deflated_query_part(LassoNode *node, char *deflate_string); +xmlNode* lasso_node_get_xmlnode_for_any_type(LassoNode *node, xmlNode *cur); + char* lasso_concat_url_query(char *url, char *query); xmlDocPtr lasso_xml_parse_memory(const char *buffer, int size); diff --git a/lasso/xml/saml-2.0/saml2_attribute_value.c b/lasso/xml/saml-2.0/saml2_attribute_value.c index 8a1ead39..8d46f3f8 100644 --- a/lasso/xml/saml-2.0/saml2_attribute_value.c +++ b/lasso/xml/saml-2.0/saml2_attribute_value.c @@ -43,10 +43,21 @@ static struct XmlSnippet schema_snippets[] = { /* instance and class init functions */ /*****************************************************************************/ -static void -instance_init(LassoSaml2AttributeValue *node) +static xmlNode* +get_xmlNode(LassoNode *node, gboolean lasso_dump) { - node->any = NULL; + LassoSaml2AttributeValue *value = LASSO_SAML2_ATTRIBUTE_VALUE(node); + LassoNodeClass *parent_class = NULL; + xmlNode *cur; + + parent_class = g_type_class_peek_parent(LASSO_NODE_GET_CLASS(node)); + cur = parent_class->get_xmlNode(node, lasso_dump); + + if (value->any) { + return cur; + } else { + return lasso_node_get_xmlnode_for_any_type(node, cur); + } } static void @@ -55,6 +66,8 @@ class_init(LassoSaml2AttributeValueClass *klass) LassoNodeClass *nclass = LASSO_NODE_CLASS(klass); nclass->node_data = g_new0(LassoNodeClassData, 1); + nclass->get_xmlNode = get_xmlNode; + nclass->node_data->keep_xmlnode = TRUE; lasso_node_class_set_nodename(nclass, "AttributeValue"); lasso_node_class_set_ns(nclass, LASSO_SAML2_ASSERTION_HREF, LASSO_SAML2_ASSERTION_PREFIX); lasso_node_class_add_snippets(nclass, schema_snippets); @@ -75,7 +88,7 @@ lasso_saml2_attribute_value_get_type() NULL, sizeof(LassoSaml2AttributeValue), 0, - (GInstanceInitFunc) instance_init, + NULL, NULL }; diff --git a/lasso/xml/saml-2.0/samlp2_extensions.c b/lasso/xml/saml-2.0/samlp2_extensions.c index c9f8db49..22e44bd5 100644 --- a/lasso/xml/saml-2.0/samlp2_extensions.c +++ b/lasso/xml/saml-2.0/samlp2_extensions.c @@ -52,11 +52,22 @@ static struct XmlSnippet schema_snippets[] = { static LassoNodeClass *parent_class = NULL; - /*****************************************************************************/ /* instance and class init functions */ /*****************************************************************************/ +static xmlNode* +get_xmlNode(LassoNode *node, gboolean lasso_dump) +{ + LassoNodeClass *parent_class = NULL; + xmlNode *cur; + + parent_class = g_type_class_peek_parent(LASSO_NODE_GET_CLASS(node)); + cur = parent_class->get_xmlNode(node, lasso_dump); + + return lasso_node_get_xmlnode_for_any_type(node, cur); +} + static void class_init(LassoSamlp2ExtensionsClass *klass) { @@ -64,6 +75,8 @@ class_init(LassoSamlp2ExtensionsClass *klass) parent_class = g_type_class_peek_parent(klass); nclass->node_data = g_new0(LassoNodeClassData, 1); + nclass->node_data->keep_xmlnode = TRUE; + nclass->get_xmlNode = get_xmlNode; lasso_node_class_set_nodename(nclass, "Extensions"); lasso_node_class_set_ns(nclass, LASSO_SAML2_PROTOCOL_HREF, LASSO_SAML2_PROTOCOL_PREFIX); lasso_node_class_add_snippets(nclass, schema_snippets); diff --git a/lasso/xml/saml_attribute_value.c b/lasso/xml/saml_attribute_value.c index baaca977..ef9ecfaf 100644 --- a/lasso/xml/saml_attribute_value.c +++ b/lasso/xml/saml_attribute_value.c @@ -45,10 +45,21 @@ static struct XmlSnippet schema_snippets[] = { /* instance and class init functions */ /*****************************************************************************/ -static void -instance_init(LassoSamlAttributeValue *node) +static xmlNode* +get_xmlNode(LassoNode *node, gboolean lasso_dump) { - node->any = NULL; + LassoSamlAttributeValue *value = LASSO_SAML_ATTRIBUTE_VALUE(node); + LassoNodeClass *parent_class = NULL; + xmlNode *cur; + + parent_class = g_type_class_peek_parent(LASSO_NODE_GET_CLASS(node)); + cur = parent_class->get_xmlNode(node, lasso_dump); + + if (value->any) { + return cur; + } else { + return lasso_node_get_xmlnode_for_any_type(node, cur); + } } static void @@ -57,6 +68,8 @@ class_init(LassoSamlAttributeValueClass *klass) LassoNodeClass *nclass = LASSO_NODE_CLASS(klass); nclass->node_data = g_new0(LassoNodeClassData, 1); + nclass->get_xmlNode = get_xmlNode; + nclass->node_data->keep_xmlnode = TRUE; lasso_node_class_set_nodename(nclass, "AttributeValue"); lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX); lasso_node_class_add_snippets(nclass, schema_snippets); @@ -77,7 +90,7 @@ lasso_saml_attribute_value_get_type() NULL, sizeof(LassoSamlAttributeValue), 0, - (GInstanceInitFunc) instance_init, + NULL, NULL }; diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index ab7ef951..bd576ab8 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -983,16 +983,24 @@ lasso_node_get_original_xmlnode(LassoNode *node) return g_object_get_qdata(G_OBJECT(node), original_xmlnode_quark); } -/*****************************************************************************/ -/* implementation methods */ -/*****************************************************************************/ - -static void -lasso_node_set_original_xmlnode(LassoNode *node, xmlNodePtr xmlNode) +/** + * lasso_node_set_original_xmlnode: + * @node: the #LassoNode object + * @xmlNode: an #xmlNode + * + * Set the underlying XML representation of the object. + * + */ +void +lasso_node_set_original_xmlnode(LassoNode *node, xmlNode* xmlNode) { g_object_set_qdata_full(G_OBJECT(node), original_xmlnode_quark, xmlCopyNode(xmlNode, 1), (GDestroyNotify)xmlFreeNode); } +/*****************************************************************************/ +/* implementation methods */ +/*****************************************************************************/ + static void lasso_node_remove_original_xmlnode(LassoNode *node, SnippetType type) { LassoNodeClass *class; @@ -2644,3 +2652,27 @@ xml_insure_namespace(xmlNode *xmlnode, xmlNs *ns, gboolean force, gchar *ns_href } } +/** + * lasso_node_get_xmlnode_for_any_type: + * @node: a #LassoNode. + * @xmlnode: the #xmlNode returned. + * + * Return value: a xmlNode completed with the content of the produced by the get_xmlNode virtual + * method of the parent class. + */ +xmlNode* +lasso_node_get_xmlnode_for_any_type(LassoNode *node, xmlNode *cur) +{ + + xmlNode *original_xmlnode; + + original_xmlnode = lasso_node_get_original_xmlnode(node); + if (original_xmlnode) { + return xmlCopyNode(original_xmlnode, 1); + } else { + xmlNode *children = xmlCopyNodeList(original_xmlnode->children); + xmlCopyPropList(cur, original_xmlnode->properties); + xmlAddChildList(cur, children); + return cur; + } +} diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h index 89410fdc..255fdec0 100644 --- a/lasso/xml/xml.h +++ b/lasso/xml/xml.h @@ -148,9 +148,13 @@ LASSO_EXPORT char* lasso_node_export_to_ecp_soap_response(LassoNode *node, const char *assertionConsumerURL); LASSO_EXPORT xmlNode* lasso_node_get_xmlNode(LassoNode *node, gboolean lasso_dump); + LASSO_EXPORT xmlNode* lasso_node_get_original_xmlnode(LassoNode *node); +LASSO_EXPORT void lasso_node_set_original_xmlnode(LassoNode *node, xmlNode* xmlNode); + LASSO_EXPORT LassoMessageFormat lasso_node_init_from_message(LassoNode *node, const char *message); + LASSO_EXPORT gboolean lasso_node_init_from_query(LassoNode *node, const char *query); LASSO_EXPORT int lasso_node_init_from_xml(LassoNode *node, xmlNode *xmlnode); |
