diff options
author | Frederic Peters <fpeters@entrouvert.com> | 2004-12-16 12:32:47 +0000 |
---|---|---|
committer | Frederic Peters <fpeters@entrouvert.com> | 2004-12-16 12:32:47 +0000 |
commit | f5471b3acf9069cba291593e21f77705299d3b7e (patch) | |
tree | eea14ac802edb50b39c98cfaffad7dc3baa7c00b /lasso/xml | |
parent | 1e7cd347178a0fb14fbe1b5581cc73a41f9f64bc (diff) | |
download | lasso-f5471b3acf9069cba291593e21f77705299d3b7e.tar.gz lasso-f5471b3acf9069cba291593e21f77705299d3b7e.tar.xz lasso-f5471b3acf9069cba291593e21f77705299d3b7e.zip |
added minimal support (only XML, no mapping to URL yet) for
<xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/>
added memory management to list* XmlSnippet
Diffstat (limited to 'lasso/xml')
-rw-r--r-- | lasso/xml/internals.h | 1 | ||||
-rw-r--r-- | lasso/xml/lib_authn_request.c | 1 | ||||
-rw-r--r-- | lasso/xml/lib_authn_request.h | 2 | ||||
-rw-r--r-- | lasso/xml/lib_authn_request_envelope.c | 4 | ||||
-rw-r--r-- | lasso/xml/lib_authn_request_envelope.h | 2 | ||||
-rw-r--r-- | lasso/xml/lib_authn_response.c | 1 | ||||
-rw-r--r-- | lasso/xml/lib_authn_response.h | 2 | ||||
-rw-r--r-- | lasso/xml/lib_federation_termination_notification.c | 2 | ||||
-rw-r--r-- | lasso/xml/lib_federation_termination_notification.h | 2 | ||||
-rw-r--r-- | lasso/xml/lib_logout_request.c | 2 | ||||
-rw-r--r-- | lasso/xml/lib_logout_request.h | 2 | ||||
-rw-r--r-- | lasso/xml/lib_name_identifier_mapping_request.c | 2 | ||||
-rw-r--r-- | lasso/xml/lib_name_identifier_mapping_request.h | 2 | ||||
-rw-r--r-- | lasso/xml/lib_name_identifier_mapping_response.c | 2 | ||||
-rw-r--r-- | lasso/xml/lib_name_identifier_mapping_response.h | 2 | ||||
-rw-r--r-- | lasso/xml/lib_register_name_identifier_request.c | 3 | ||||
-rw-r--r-- | lasso/xml/lib_register_name_identifier_request.h | 2 | ||||
-rw-r--r-- | lasso/xml/lib_status_response.c | 3 | ||||
-rw-r--r-- | lasso/xml/lib_status_response.h | 2 | ||||
-rw-r--r-- | lasso/xml/xml.c | 47 |
20 files changed, 71 insertions, 15 deletions
diff --git a/lasso/xml/internals.h b/lasso/xml/internals.h index 85b3806b..efc065a8 100644 --- a/lasso/xml/internals.h +++ b/lasso/xml/internals.h @@ -39,6 +39,7 @@ typedef enum { SNIPPET_NODE_IN_CHILD, SNIPPET_LIST_NODES, SNIPPET_LIST_CONTENT, + SNIPPET_EXTENSION, /* transformers for content transformation */ SNIPPET_STRING = 1 << 0, /* default, can be omitted */ diff --git a/lasso/xml/lib_authn_request.c b/lasso/xml/lib_authn_request.c index ecedef11..5b1ddceb 100644 --- a/lasso/xml/lib_authn_request.c +++ b/lasso/xml/lib_authn_request.c @@ -86,6 +86,7 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { + { "Extension", SNIPPET_EXTENSION, G_STRUCT_OFFSET(LassoLibAuthnRequest, Extension) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnRequest, ProviderID) }, { "NameIDPolicy", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnRequest, NameIDPolicy) }, { "ProtocolProfile", SNIPPET_CONTENT, diff --git a/lasso/xml/lib_authn_request.h b/lasso/xml/lib_authn_request.h index 743a0df0..31f7e218 100644 --- a/lasso/xml/lib_authn_request.h +++ b/lasso/xml/lib_authn_request.h @@ -52,6 +52,8 @@ typedef struct _LassoLibAuthnRequestClass LassoLibAuthnRequestClass; struct _LassoLibAuthnRequest { LassoSamlpRequestAbstract parent; + /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ + GList *Extension; /* <xs:element ref="ProviderID"/> */ char *ProviderID; /* <xs:element ref="AffiliationID" minOccurs="0"/> */ diff --git a/lasso/xml/lib_authn_request_envelope.c b/lasso/xml/lib_authn_request_envelope.c index 1b6145cc..928d0db2 100644 --- a/lasso/xml/lib_authn_request_envelope.c +++ b/lasso/xml/lib_authn_request_envelope.c @@ -67,6 +67,10 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { + { "Extension", SNIPPET_EXTENSION, + G_STRUCT_OFFSET(LassoLibAuthnRequestEnvelope, Extension) }, + { "AuthnRequest", SNIPPET_NODE, + G_STRUCT_OFFSET(LassoLibAuthnRequestEnvelope, AuthnRequest) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnRequestEnvelope, ProviderID) }, { "ProviderName", SNIPPET_CONTENT, diff --git a/lasso/xml/lib_authn_request_envelope.h b/lasso/xml/lib_authn_request_envelope.h index a0c37e38..5f8e3466 100644 --- a/lasso/xml/lib_authn_request_envelope.h +++ b/lasso/xml/lib_authn_request_envelope.h @@ -56,7 +56,7 @@ struct _LassoLibAuthnRequestEnvelope { LassoNode parent; /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ - LassoNode *Extension; /* XXX */ + GList *Extension; /* <xs:element ref="AuthnRequest"/> */ LassoLibAuthnRequest *AuthnRequest; /* <xs:element ref="ProviderID"/> */ diff --git a/lasso/xml/lib_authn_response.c b/lasso/xml/lib_authn_response.c index e90c3d2f..a906817e 100644 --- a/lasso/xml/lib_authn_response.c +++ b/lasso/xml/lib_authn_response.c @@ -58,6 +58,7 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { + { "Extension", SNIPPET_EXTENSION, G_STRUCT_OFFSET(LassoLibAuthnResponse, Extension) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnResponse, ProviderID) }, { "RelayState", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnResponse, RelayState) }, { "consent", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoLibAuthnResponse, consent) }, diff --git a/lasso/xml/lib_authn_response.h b/lasso/xml/lib_authn_response.h index 1d14241e..bc805413 100644 --- a/lasso/xml/lib_authn_response.h +++ b/lasso/xml/lib_authn_response.h @@ -54,7 +54,7 @@ struct _LassoLibAuthnResponse { LassoSamlpResponse parent; /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ - LassoNode *Extension; + GList *Extension; /* <xs:element ref="ProviderID"/> */ char *ProviderID; /* <xs:element ref="RelayState" minOccurs="0"/> */ diff --git a/lasso/xml/lib_federation_termination_notification.c b/lasso/xml/lib_federation_termination_notification.c index 9a57c80b..22502df9 100644 --- a/lasso/xml/lib_federation_termination_notification.c +++ b/lasso/xml/lib_federation_termination_notification.c @@ -59,6 +59,8 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { + { "Extension", SNIPPET_EXTENSION, + G_STRUCT_OFFSET(LassoLibFederationTerminationNotification, Extension) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibFederationTerminationNotification, ProviderID) }, { "NameIdentifier", SNIPPET_NODE, diff --git a/lasso/xml/lib_federation_termination_notification.h b/lasso/xml/lib_federation_termination_notification.h index abe37f89..2750abdb 100644 --- a/lasso/xml/lib_federation_termination_notification.h +++ b/lasso/xml/lib_federation_termination_notification.h @@ -58,7 +58,7 @@ struct _LassoLibFederationTerminationNotification { LassoSamlpRequestAbstract parent; /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ - LassoNode *Extension; + GList *Extension; /* <xs:element ref="ProviderID"/> */ char *ProviderID; /* <xs:element ref="saml:NameIdentifier"/> */ diff --git a/lasso/xml/lib_logout_request.c b/lasso/xml/lib_logout_request.c index 58d4b551..c7b5af05 100644 --- a/lasso/xml/lib_logout_request.c +++ b/lasso/xml/lib_logout_request.c @@ -61,7 +61,7 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { - /* TODO: <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ + { "Extension", SNIPPET_EXTENSION, G_STRUCT_OFFSET(LassoLibLogoutRequest, Extension) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibLogoutRequest, ProviderID) }, { "NameIdentifier", SNIPPET_NODE, G_STRUCT_OFFSET(LassoLibLogoutRequest, NameIdentifier) }, { "SessionIndex", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibLogoutRequest, SessionIndex) }, diff --git a/lasso/xml/lib_logout_request.h b/lasso/xml/lib_logout_request.h index 0915a7c2..a4237ef7 100644 --- a/lasso/xml/lib_logout_request.h +++ b/lasso/xml/lib_logout_request.h @@ -53,6 +53,8 @@ typedef struct _LassoLibLogoutRequestClass LassoLibLogoutRequestClass; struct _LassoLibLogoutRequest { LassoSamlpRequestAbstract parent; + /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ + GList *Extension; char *ProviderID; LassoSamlNameIdentifier *NameIdentifier; char *SessionIndex; diff --git a/lasso/xml/lib_name_identifier_mapping_request.c b/lasso/xml/lib_name_identifier_mapping_request.c index d167619d..9f7c727d 100644 --- a/lasso/xml/lib_name_identifier_mapping_request.c +++ b/lasso/xml/lib_name_identifier_mapping_request.c @@ -58,6 +58,8 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { + { "Extension", SNIPPET_EXTENSION, + G_STRUCT_OFFSET(LassoLibNameIdentifierMappingRequest, Extension) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibNameIdentifierMappingRequest, ProviderID) }, { "NameIdentifier", SNIPPET_NODE, diff --git a/lasso/xml/lib_name_identifier_mapping_request.h b/lasso/xml/lib_name_identifier_mapping_request.h index 4b659d80..401f0cc9 100644 --- a/lasso/xml/lib_name_identifier_mapping_request.h +++ b/lasso/xml/lib_name_identifier_mapping_request.h @@ -57,7 +57,7 @@ struct _LassoLibNameIdentifierMappingRequest { LassoSamlpRequestAbstract parent; /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ - LassoNode *Extension; /* XXX */ + GList *Extension; /* <xs:element ref="ProviderID"/> */ char *ProviderID; /* <xs:element ref="saml:NameIdentifier"/> */ diff --git a/lasso/xml/lib_name_identifier_mapping_response.c b/lasso/xml/lib_name_identifier_mapping_response.c index 4e086a2b..2edc26a2 100644 --- a/lasso/xml/lib_name_identifier_mapping_response.c +++ b/lasso/xml/lib_name_identifier_mapping_response.c @@ -48,6 +48,8 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { + { "Extension", SNIPPET_EXTENSION, + G_STRUCT_OFFSET(LassoLibNameIdentifierMappingResponse, Extension) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibNameIdentifierMappingResponse, ProviderID) }, { "Status", SNIPPET_NODE, diff --git a/lasso/xml/lib_name_identifier_mapping_response.h b/lasso/xml/lib_name_identifier_mapping_response.h index 6af696b2..dddf3a72 100644 --- a/lasso/xml/lib_name_identifier_mapping_response.h +++ b/lasso/xml/lib_name_identifier_mapping_response.h @@ -59,7 +59,7 @@ struct _LassoLibNameIdentifierMappingResponse { LassoSamlpResponseAbstract parent; /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ - LassoNode *Extension; + GList *Extension; /* <xs:element ref="ProviderID"/> */ char *ProviderID; /* <xs:element ref="samlp:Status"/> */ diff --git a/lasso/xml/lib_register_name_identifier_request.c b/lasso/xml/lib_register_name_identifier_request.c index 25d39e86..0846275c 100644 --- a/lasso/xml/lib_register_name_identifier_request.c +++ b/lasso/xml/lib_register_name_identifier_request.c @@ -64,7 +64,8 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { - /* TODO: <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ + { "Extension", SNIPPET_EXTENSION, + G_STRUCT_OFFSET(LassoLibRegisterNameIdentifierRequest, Extension) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibRegisterNameIdentifierRequest, ProviderID) }, { "IDPProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER, diff --git a/lasso/xml/lib_register_name_identifier_request.h b/lasso/xml/lib_register_name_identifier_request.h index 091857dd..d0dacd27 100644 --- a/lasso/xml/lib_register_name_identifier_request.h +++ b/lasso/xml/lib_register_name_identifier_request.h @@ -56,6 +56,8 @@ typedef struct _LassoLibRegisterNameIdentifierRequestClass \ struct _LassoLibRegisterNameIdentifierRequest { LassoSamlpRequestAbstract parent; + /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ + GList *Extension; /* <xs:element ref="ProviderID"/> */ char *ProviderID; /* <xs:element ref="IDPProvidedNameIdentifier"/> */ diff --git a/lasso/xml/lib_status_response.c b/lasso/xml/lib_status_response.c index dbd3f918..2861b26b 100644 --- a/lasso/xml/lib_status_response.c +++ b/lasso/xml/lib_status_response.c @@ -58,7 +58,8 @@ /*****************************************************************************/ static struct XmlSnippet schema_snippets[] = { - /* TODO <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ + { "Extension", SNIPPET_EXTENSION, + G_STRUCT_OFFSET(LassoLibStatusResponse, Extension) }, { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibStatusResponse, ProviderID) }, { "Status", SNIPPET_NODE, G_STRUCT_OFFSET(LassoLibStatusResponse, Status) }, { "RelayState", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibStatusResponse, RelayState) }, diff --git a/lasso/xml/lib_status_response.h b/lasso/xml/lib_status_response.h index a0c07e71..0e4c9e6a 100644 --- a/lasso/xml/lib_status_response.h +++ b/lasso/xml/lib_status_response.h @@ -53,6 +53,8 @@ typedef struct _LassoLibStatusResponseClass LassoLibStatusResponseClass; struct _LassoLibStatusResponse { LassoSamlpResponseAbstract parent; + /* <xs:element ref="Extension" minOccurs="0" maxOccurs="unbounded"/> */ + GList *Extension; /* <xs:element ref="ProviderID"/> */ char *ProviderID; /* <xs:element ref="samlp:Status"/> */ diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 3d4b991a..4442dc48 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -533,6 +533,9 @@ lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode) GList **location = value; xmlChar *s = xmlNodeGetContent(t); *location = g_list_append(*location, s); + } else if (type == SNIPPET_EXTENSION) { + GList **location = value; + *location = g_list_append(*location, xmlCopyNode(t, 2)); } if (tmp == NULL) @@ -638,6 +641,7 @@ lasso_node_dispose(GObject *object) LassoNodeClass *class; struct XmlSnippet *snippet; SnippetType type; + GList *elem; class = LASSO_NODE_GET_CLASS(object); while (class && LASSO_IS_NODE_CLASS(class) && class->node_data) { @@ -657,15 +661,37 @@ lasso_node_dispose(GObject *object) fprintf(stderr, "freeing %s/%s (at %p)\n", G_OBJECT_TYPE_NAME(object), snippet->name, *value); #endif - if (snippet->type == SNIPPET_NODE || - snippet->type == SNIPPET_NAME_IDENTIFIER || - snippet->type == SNIPPET_NODE_IN_CHILD) { - lasso_node_destroy(*value); - } else { - g_free(*value); + switch (type) { + case SNIPPET_NODE: + case SNIPPET_NAME_IDENTIFIER: + case SNIPPET_NODE_IN_CHILD: + lasso_node_destroy(*value); + break; + case SNIPPET_EXTENSION: + case SNIPPET_LIST_NODES: + case SNIPPET_LIST_CONTENT: + elem = (GList*)(*value); + while (elem) { + if (type == SNIPPET_EXTENSION) + xmlFreeNode(elem->data); + if (type == SNIPPET_LIST_NODES) + lasso_node_destroy(elem->data); + if (type == SNIPPET_LIST_CONTENT) + g_free(elem->data); + elem = g_list_next(elem); + } + g_list_free(*value); + break; + case SNIPPET_CONTENT: + case SNIPPET_TEXT_CHILD: + case SNIPPET_ATTRIBUTE: + g_free(*value); + break; + default: + fprintf(stderr, "%d\n", type); + g_assert_not_reached(); } - /* XXX: memory management for lists */ *value = NULL; } class = g_type_class_peek_parent(class); @@ -1048,6 +1074,13 @@ lasso_node_build_xmlNode_from_snippets(LassoNode *node, xmlNode *xmlnode, elem = g_list_next(elem); } break; + case SNIPPET_EXTENSION: + elem = (GList *)value; + while (elem) { + xmlAddChild(xmlnode, xmlCopyNode(elem->data, 2)); + elem = g_list_next(elem); + } + break; case SNIPPET_INTEGER: case SNIPPET_BOOLEAN: g_assert_not_reached(); |