summaryrefslogtreecommitdiffstats
path: root/lasso/xml
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2004-12-02 14:54:43 +0000
committerFrederic Peters <fpeters@entrouvert.com>2004-12-02 14:54:43 +0000
commit05577f56728d3fbae3f484e37e1202d6676b38e2 (patch)
tree4979b780ebce2fd4eb3a1691661b3ea89402e89e /lasso/xml
parent169b16b94fc7a581b182307a610b91b1d944d0ae (diff)
downloadlasso-05577f56728d3fbae3f484e37e1202d6676b38e2.tar.gz
lasso-05577f56728d3fbae3f484e37e1202d6676b38e2.tar.xz
lasso-05577f56728d3fbae3f484e37e1202d6676b38e2.zip
last(?) iteration on XmlSnippet; now attached to classes, get_xmlNode and
init_from_xml are no longer necessary in many cases. Previous XmlSnippet renamed to XmlSnippetObsolete to keep compatibility (id-wsf classes have not yet been converted).
Diffstat (limited to 'lasso/xml')
-rw-r--r--lasso/xml/disco_credentials.c2
-rw-r--r--lasso/xml/disco_description.c2
-rw-r--r--lasso/xml/disco_insert_entry.c2
-rw-r--r--lasso/xml/disco_modify.c2
-rw-r--r--lasso/xml/disco_modify_response.c2
-rw-r--r--lasso/xml/disco_options.c2
-rw-r--r--lasso/xml/disco_query.c2
-rw-r--r--lasso/xml/disco_query_response.c2
-rw-r--r--lasso/xml/disco_remove_entry.c2
-rw-r--r--lasso/xml/disco_requested_service_type.c2
-rw-r--r--lasso/xml/disco_resource_offering.c2
-rw-r--r--lasso/xml/disco_service_instance.c2
-rw-r--r--lasso/xml/dst_data.c2
-rw-r--r--lasso/xml/dst_query.c2
-rw-r--r--lasso/xml/dst_query_item.c10
-rw-r--r--lasso/xml/dst_query_response.c2
-rw-r--r--lasso/xml/internals.h31
-rw-r--r--lasso/xml/lib_assertion.c36
-rw-r--r--lasso/xml/lib_authentication_statement.c54
-rw-r--r--lasso/xml/lib_authn_context.c52
-rw-r--r--lasso/xml/lib_authn_request.c85
-rw-r--r--lasso/xml/lib_authn_request_envelope.c67
-rw-r--r--lasso/xml/lib_authn_response.c51
-rw-r--r--lasso/xml/lib_authn_response_envelope.c52
-rw-r--r--lasso/xml/lib_federation_termination_notification.c55
-rw-r--r--lasso/xml/lib_idp_entries.c46
-rw-r--r--lasso/xml/lib_idp_entry.c49
-rw-r--r--lasso/xml/lib_idp_list.c48
-rw-r--r--lasso/xml/lib_logout_request.c56
-rw-r--r--lasso/xml/lib_logout_response.c23
-rw-r--r--lasso/xml/lib_name_identifier_mapping_request.c59
-rw-r--r--lasso/xml/lib_name_identifier_mapping_response.c54
-rw-r--r--lasso/xml/lib_register_name_identifier_request.c66
-rw-r--r--lasso/xml/lib_register_name_identifier_response.c19
-rw-r--r--lasso/xml/lib_request_authn_context.c57
-rw-r--r--lasso/xml/lib_scoping.c60
-rw-r--r--lasso/xml/lib_status_response.c51
-rw-r--r--lasso/xml/lib_subject.c48
-rw-r--r--lasso/xml/saml_advice.c51
-rw-r--r--lasso/xml/saml_assertion.c87
-rw-r--r--lasso/xml/saml_attribute.c34
-rw-r--r--lasso/xml/saml_attribute_designator.c54
-rw-r--r--lasso/xml/saml_attribute_statement.c35
-rw-r--r--lasso/xml/saml_audience_restriction_condition.c49
-rw-r--r--lasso/xml/saml_authentication_statement.c57
-rw-r--r--lasso/xml/saml_authority_binding.c54
-rw-r--r--lasso/xml/saml_condition_abstract.c19
-rw-r--r--lasso/xml/saml_conditions.c56
-rw-r--r--lasso/xml/saml_name_identifier.c50
-rw-r--r--lasso/xml/saml_statement_abstract.c19
-rw-r--r--lasso/xml/saml_subject.c50
-rw-r--r--lasso/xml/saml_subject_confirmation.c53
-rw-r--r--lasso/xml/saml_subject_locality.c50
-rw-r--r--lasso/xml/saml_subject_statement.c18
-rw-r--r--lasso/xml/saml_subject_statement_abstract.c48
-rw-r--r--lasso/xml/samlp_request.c47
-rw-r--r--lasso/xml/samlp_request_abstract.c61
-rw-r--r--lasso/xml/samlp_request_abstract.h2
-rw-r--r--lasso/xml/samlp_response.c40
-rw-r--r--lasso/xml/samlp_response_abstract.c72
-rw-r--r--lasso/xml/samlp_status.c47
-rw-r--r--lasso/xml/samlp_status_code.c47
-rw-r--r--lasso/xml/utility_status.c2
-rw-r--r--lasso/xml/xml.c218
-rw-r--r--lasso/xml/xml.h10
65 files changed, 858 insertions, 1631 deletions
diff --git a/lasso/xml/disco_credentials.c b/lasso/xml/disco_credentials.c
index 98e3e19a..fd12abdf 100644
--- a/lasso/xml/disco_credentials.c
+++ b/lasso/xml/disco_credentials.c
@@ -44,7 +44,7 @@
#define snippets() \
LassoDiscoCredentials *credentials = LASSO_DISCO_CREDENTIALS(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "", SNIPPET_LIST_NODES, (void**)&credentials->any }, \
{ NULL, 0, NULL} \
};
diff --git a/lasso/xml/disco_description.c b/lasso/xml/disco_description.c
index d5aacdea..e257a6d5 100644
--- a/lasso/xml/disco_description.c
+++ b/lasso/xml/disco_description.c
@@ -61,7 +61,7 @@
#define snippets() \
LassoDiscoDescription *description = LASSO_DISCO_DESCRIPTION(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "SecurityMechID", SNIPPET_CONTENT, (void**)&(description->SecurityMechID) }, \
{ "CredentialRef", SNIPPET_CONTENT, (void**)&(description->CredentialRef) }, \
{ "id", SNIPPET_ATTRIBUTE, (void**)&(description->id) }, \
diff --git a/lasso/xml/disco_insert_entry.c b/lasso/xml/disco_insert_entry.c
index 8b6de6c6..0ed30f2c 100644
--- a/lasso/xml/disco_insert_entry.c
+++ b/lasso/xml/disco_insert_entry.c
@@ -42,7 +42,7 @@
#define snippets() \
LassoDiscoInsertEntry *entry = LASSO_DISCO_INSERT_ENTRY(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "ResourceOffering", SNIPPET_NODE, (void**)&(entry->ResourceOffering) }, \
{ "any", SNIPPET_LIST_NODES, (void**)&(entry->any) }, \
{ NULL, 0, NULL} \
diff --git a/lasso/xml/disco_modify.c b/lasso/xml/disco_modify.c
index addd503b..90bf46aa 100644
--- a/lasso/xml/disco_modify.c
+++ b/lasso/xml/disco_modify.c
@@ -54,7 +54,7 @@
#define snippets() \
LassoDiscoModify *modify = LASSO_DISCO_MODIFY(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "ResourceID", SNIPPET_CONTENT, (void**)&(modify->ResourceID) }, \
{ "EncryptedResourceID", SNIPPET_CONTENT, \
(void**)&(modify->EncryptedResourceID) }, \
diff --git a/lasso/xml/disco_modify_response.c b/lasso/xml/disco_modify_response.c
index 1f426814..2f4ed608 100644
--- a/lasso/xml/disco_modify_response.c
+++ b/lasso/xml/disco_modify_response.c
@@ -49,7 +49,7 @@
#define snippets() \
LassoDiscoModifyResponse *response = LASSO_DISCO_MODIFY_RESPONSE(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "Status", SNIPPET_NODE, (void**)&(response->Status) }, \
{ "id", SNIPPET_ATTRIBUTE, (void**)&(response->id) }, \
{ "newEntryIDs", SNIPPET_ATTRIBUTE, (void**)&(response->newEntryIDs) }, \
diff --git a/lasso/xml/disco_options.c b/lasso/xml/disco_options.c
index 5db5ab1a..bf262514 100644
--- a/lasso/xml/disco_options.c
+++ b/lasso/xml/disco_options.c
@@ -42,7 +42,7 @@
#define snippets() \
LassoDiscoOptions *options = LASSO_DISCO_OPTIONS(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "Option", SNIPPET_LIST_CONTENT, (void**)&(options->Option) }, \
{ NULL, 0, NULL} \
};
diff --git a/lasso/xml/disco_query.c b/lasso/xml/disco_query.c
index 8b21da10..889bd615 100644
--- a/lasso/xml/disco_query.c
+++ b/lasso/xml/disco_query.c
@@ -60,7 +60,7 @@
#define snippets() \
LassoDiscoQuery *query = LASSO_DISCO_QUERY(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "ResourceID", SNIPPET_CONTENT, (void**)&query->ResourceID }, \
{ "EncryptedResourceID", SNIPPET_CONTENT, (void**)&query->EncryptedResourceID }, \
{ "RequestedServiceType", SNIPPET_LIST_NODES, \
diff --git a/lasso/xml/disco_query_response.c b/lasso/xml/disco_query_response.c
index 62aad629..8e68da15 100644
--- a/lasso/xml/disco_query_response.c
+++ b/lasso/xml/disco_query_response.c
@@ -51,7 +51,7 @@
#define snippets() \
LassoDiscoQueryResponse *query_response = LASSO_DISCO_QUERY_RESPONSE(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "Status", SNIPPET_NODE, (void**)&query_response->Status }, \
{ "ResourceOffering", SNIPPET_LIST_NODES, \
(void**)&query_response->ResourceOffering }, \
diff --git a/lasso/xml/disco_remove_entry.c b/lasso/xml/disco_remove_entry.c
index d8da72f0..9e32c30b 100644
--- a/lasso/xml/disco_remove_entry.c
+++ b/lasso/xml/disco_remove_entry.c
@@ -45,7 +45,7 @@
#define snippets() \
LassoDiscoRemoveEntry *entry = LASSO_DISCO_REMOVE_ENTRY(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "entryID", SNIPPET_ATTRIBUTE, (void**)&(entry->entryID) }, \
{ NULL, 0, NULL} \
};
diff --git a/lasso/xml/disco_requested_service_type.c b/lasso/xml/disco_requested_service_type.c
index 27394689..f773335e 100644
--- a/lasso/xml/disco_requested_service_type.c
+++ b/lasso/xml/disco_requested_service_type.c
@@ -45,7 +45,7 @@
#define snippets() \
LassoDiscoRequestedServiceType *RequestedServiceType = \
LASSO_DISCO_REQUESTED_SERVICE_TYPE(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "ServiceType", SNIPPET_CONTENT, (void**)&RequestedServiceType->ServiceType }, \
{ "Options", SNIPPET_NODE, (void**)&RequestedServiceType->Options }, \
{ NULL, 0, NULL} \
diff --git a/lasso/xml/disco_resource_offering.c b/lasso/xml/disco_resource_offering.c
index 4fcd2fa6..dd77fbcf 100644
--- a/lasso/xml/disco_resource_offering.c
+++ b/lasso/xml/disco_resource_offering.c
@@ -61,7 +61,7 @@
#define snippets() \
LassoDiscoResourceOffering *resource = LASSO_DISCO_RESOURCE_OFFERING(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "ResourceID", SNIPPET_CONTENT, (void**)&(resource->ResourceID) }, \
{ "EncryptedResourceID", SNIPPET_CONTENT, \
(void**)&(resource->EncryptedResourceID) }, \
diff --git a/lasso/xml/disco_service_instance.c b/lasso/xml/disco_service_instance.c
index b5d5e487..4a5cc3b3 100644
--- a/lasso/xml/disco_service_instance.c
+++ b/lasso/xml/disco_service_instance.c
@@ -45,7 +45,7 @@
#define snippets() \
LassoDiscoServiceInstance *instance = LASSO_DISCO_SERVICE_INSTANCE(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "ServiceType", SNIPPET_CONTENT, (void**)&(instance->ServiceType) }, \
{ "ProviderID", SNIPPET_CONTENT, (void**)&(instance->ProviderID) }, \
{ "Description", SNIPPET_LIST_NODES, (void**)&(instance->Description) }, \
diff --git a/lasso/xml/dst_data.c b/lasso/xml/dst_data.c
index 1ed51896..33ae97ba 100644
--- a/lasso/xml/dst_data.c
+++ b/lasso/xml/dst_data.c
@@ -32,7 +32,7 @@
#define snippets() \
LassoDstData *data = LASSO_DST_DATA(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ NULL, 0, NULL} \
};
diff --git a/lasso/xml/dst_query.c b/lasso/xml/dst_query.c
index a2287926..28b864d9 100644
--- a/lasso/xml/dst_query.c
+++ b/lasso/xml/dst_query.c
@@ -32,7 +32,7 @@
#define snippets() \
LassoDstQuery *query = LASSO_DST_QUERY(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "ResourceID", SNIPPET_CONTENT, (void**)&query->ResourceID }, \
{ "EncryptedResourceID", SNIPPET_CONTENT, (void**)&query->EncryptedResourceID }, \
{ "QueryItem", SNIPPET_LIST_NODES, (void**)&query->QueryItem }, \
diff --git a/lasso/xml/dst_query_item.c b/lasso/xml/dst_query_item.c
index c844e542..eb441ede 100644
--- a/lasso/xml/dst_query_item.c
+++ b/lasso/xml/dst_query_item.c
@@ -33,11 +33,11 @@
/* FIXME : implement includeCommonAttributes attribute in snippets */
#define snippets() \
LassoDstQueryItem *query_item = LASSO_DST_QUERY_ITEM(node); \
- struct XmlSnippet snippets[] = { \
- { "Select", SNIPPET_LIST_NODES, (void**)&(query_item->Select) }, \
- { "id", SNIPPET_ATTRIBUTE, (void**)&(query_item->id) }, \
- { "itemID", SNIPPET_ATTRIBUTE, (void**)&(query_item->itemID) }, \
- { "changedSince", SNIPPET_ATTRIBUTE, (void**)&(query_item->changedSince) }, \
+ struct XmlSnippetObsolete snippets[] = { \
+ { "Select", SNIPPET_LIST_NODES, (void**)&(query_item->Select) }, \
+ { "id", SNIPPET_ATTRIBUTE, (void**)&(query_item->id) }, \
+ { "itemID", SNIPPET_ATTRIBUTE, (void**)&(query_item->itemID) }, \
+ { "changedSince", SNIPPET_ATTRIBUTE, (void**)&(query_item->changedSince) }, \
{ NULL, 0, NULL} \
};
diff --git a/lasso/xml/dst_query_response.c b/lasso/xml/dst_query_response.c
index dd06eb1f..66b429c1 100644
--- a/lasso/xml/dst_query_response.c
+++ b/lasso/xml/dst_query_response.c
@@ -32,7 +32,7 @@
#define snippets() \
LassoDstQueryResponse *query_response = LASSO_DST_QUERY_RESPONSE(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "Status", SNIPPET_NODE, (void**)&(query_response->Status) }, \
{ NULL, 0, NULL } \
};
diff --git a/lasso/xml/internals.h b/lasso/xml/internals.h
index da0a2d58..0ed21e7b 100644
--- a/lasso/xml/internals.h
+++ b/lasso/xml/internals.h
@@ -33,20 +33,43 @@ extern "C" {
typedef enum {
SNIPPET_NODE,
SNIPPET_CONTENT,
+ SNIPPET_CONTENT_BOOL,
+ SNIPPET_CONTENT_INT,
+ SNIPPET_TEXT_CHILD,
SNIPPET_NAME_IDENTIFIER,
SNIPPET_ATTRIBUTE,
+ SNIPPET_ATTRIBUTE_INT,
SNIPPET_LIST_NODES,
SNIPPET_LIST_CONTENT,
} SnippetType;
-struct XmlSnippet {
+struct XmlSnippetObsolete {
char *name;
- char type;
+ SnippetType type;
void **value;
};
-void init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets);
-void build_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets);
+struct XmlSnippet {
+ char *name;
+ SnippetType type;
+ guint offset;
+};
+
+void init_xml_with_snippets(xmlNode *node, struct XmlSnippetObsolete *snippets);
+void build_xml_with_snippets(xmlNode *node, struct XmlSnippetObsolete *snippets);
+
+struct _LassoNodeClassData
+{
+ struct XmlSnippet *snippets;
+ char *node_name;
+ xmlNs *ns;
+};
+
+void lasso_node_class_set_nodename(LassoNodeClass *klass, char *name);
+void lasso_node_class_set_ns(LassoNodeClass *klass, char *href, char *prefix);
+void lasso_node_class_add_snippets(LassoNodeClass *klass, struct XmlSnippet *snippets);
+void lasso_node_build_xmlNode_from_snippets(LassoNode *node, xmlNode *xmlnode,
+ struct XmlSnippet *snippets);
#ifdef __cplusplus
}
diff --git a/lasso/xml/lib_assertion.c b/lasso/xml/lib_assertion.c
index 4cf2d403..d3023f0a 100644
--- a/lasso/xml/lib_assertion.c
+++ b/lasso/xml/lib_assertion.c
@@ -54,28 +54,11 @@
/* private methods */
/*****************************************************************************/
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlSetProp(xmlnode, "InResponseTo", LASSO_LIB_ASSERTION(node)->InResponseTo);
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- int rc = 0;
- rc = parent_class->init_from_xml(node, xmlnode);
- LASSO_LIB_ASSERTION(node)->InResponseTo = xmlGetProp(xmlnode, "InResponseTo");
- return rc;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "InResponseTo", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoLibAssertion, InResponseTo) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -90,9 +73,12 @@ instance_init(LassoLibAssertion *node)
static void
class_init(LassoLibAssertionClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Assertion");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_authentication_statement.c b/lasso/xml/lib_authentication_statement.c
index 9189437a..6c300a1a 100644
--- a/lasso/xml/lib_authentication_statement.c
+++ b/lasso/xml/lib_authentication_statement.c
@@ -48,42 +48,15 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibAuthenticationStatement *statement = LASSO_LIB_AUTHENTICATION_STATEMENT(node); \
- struct XmlSnippet snippets[] = { \
- { "AuthnContext", SNIPPET_NODE, (void**)&(statement->AuthnContext) }, \
- { "ReauthenticateOnOrAfter", SNIPPET_ATTRIBUTE, \
- (void**)&(statement->ReauthenticateOnOrAfter) }, \
- { "SessionIndex", SNIPPET_ATTRIBUTE, (void**)&(statement->SessionIndex) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
-
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "AuthnContext", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoLibAuthenticationStatement, AuthnContext) },
+ { "ReauthenticateOnOrAfter", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoLibAuthenticationStatement, ReauthenticateOnOrAfter) },
+ { "SessionIndex", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoLibAuthenticationStatement, SessionIndex) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -100,11 +73,12 @@ instance_init(LassoLibAuthenticationStatement *node)
static void
class_init(LassoLibAuthenticationStatementClass *klass)
{
- LassoNodeClass *nodeClass = LASSO_NODE_CLASS(klass);
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
- parent_class = g_type_class_peek_parent(klass);
- nodeClass->get_xmlNode = get_xmlNode;
- nodeClass->init_from_xml = init_from_xml;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AuthenticationStatement");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_authn_context.c b/lasso/xml/lib_authn_context.c
index 1fdcc79c..161c4c14 100644
--- a/lasso/xml/lib_authn_context.c
+++ b/lasso/xml/lib_authn_context.c
@@ -56,42 +56,13 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibAuthnContext *context = LASSO_LIB_AUTHN_CONTEXT(node); \
- struct XmlSnippet snippets[] = { \
- { "AuthnContextClassRef", SNIPPET_CONTENT, \
- (void**)&(context->AuthnContextClassRef) }, \
- { "AuthnContextStatementRef", SNIPPET_CONTENT, \
- (void**)&(context->AuthnContextStatementRef) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "AuthnContext");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "AuthnContextClassRef", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibAuthnContext, AuthnContextClassRef) },
+ { "AuthnContextStatementRef", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibAuthnContext, AuthnContextStatementRef) },
+ { NULL, 0, 0 }
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -107,9 +78,12 @@ instance_init(LassoLibAuthnContext *node)
static void
class_init(LassoLibAuthnContextClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AuthnContext");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_authn_request.c b/lasso/xml/lib_authn_request.c
index ec87c849..55ae654a 100644
--- a/lasso/xml/lib_authn_request.c
+++ b/lasso/xml/lib_authn_request.c
@@ -1,4 +1,4 @@
-/* $Id$
+/* $id: lib_authn_request.c,v 1.18 2004/11/26 14:13:02 fpeters Exp $
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
@@ -85,43 +85,24 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(node); \
- char *force_authn = NULL, *is_passive = NULL; \
- struct XmlSnippet snippets[] = { \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(request->ProviderID) }, \
- { "NameIDPolicy", SNIPPET_CONTENT, (void**)&(request->NameIDPolicy) }, \
- { "ProtocolProfile", SNIPPET_CONTENT, (void**)&(request->ProtocolProfile) }, \
- { "AssertionConsumerServiceID", SNIPPET_CONTENT, \
- (void**)&(request->AssertionConsumerServiceID) }, \
- /* XXX: RequestAuthnContext */ \
- { "RelayState", SNIPPET_CONTENT, (void**)&(request->RelayState) }, \
- { "ForceAuthn", SNIPPET_CONTENT, (void**)&force_authn }, \
- { "IsPassive", SNIPPET_CONTENT, (void**)&is_passive }, \
- /* XXX: Scoping */ \
- { "consent", SNIPPET_ATTRIBUTE, (void**)&(request->consent) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnRequest, ProviderID) },
+ { "NameIDPolicy", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnRequest, NameIDPolicy) },
+ { "ProtocolProfile", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibAuthnRequest, ProtocolProfile) },
+ { "AssertionConsumerServiceID", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibAuthnRequest, AssertionConsumerServiceID) },
+ /* XXX: RequestAuthnContext */
+ { "RelayState", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnRequest, RelayState) },
+ { "ForceAuthn", SNIPPET_CONTENT_BOOL, G_STRUCT_OFFSET(LassoLibAuthnRequest, ForceAuthn) },
+ { "IsPassive", SNIPPET_CONTENT_BOOL, G_STRUCT_OFFSET(LassoLibAuthnRequest, IsPassive) },
+ /* XXX: Scoping */
+ { "consent", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoLibAuthnRequest, consent) },
+ { NULL, 0, 0}
+};
static LassoNodeClass *parent_class = NULL;
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- is_passive = request->IsPassive ? "true" : "false";
- force_authn = request->ForceAuthn ? "true" : "false";
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "AuthnRequest");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
static gchar*
build_query(LassoNode *node)
{
@@ -208,28 +189,6 @@ init_from_query(LassoNode *node, char **query_fields)
return parent_class->init_from_query(node, query_fields);
}
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
-
- init_xml_with_snippets(xmlnode, snippets);
-
- if (is_passive) {
- request->IsPassive = (strcmp(is_passive, "true") == 0);
- xmlFree(is_passive);
- }
- if (force_authn) {
- request->ForceAuthn = (strcmp(force_authn, "true") == 0);
- xmlFree(force_authn);
- }
-
- return 0;
-}
-
/*****************************************************************************/
/* instance and class init functions */
@@ -254,13 +213,15 @@ instance_init(LassoLibAuthnRequest *node)
static void
class_init(LassoLibAuthnRequestClass *klass)
{
- LassoNodeClass *nodeClass = LASSO_NODE_CLASS(klass);
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
- nodeClass->build_query = build_query;
- nodeClass->get_xmlNode = get_xmlNode;
- nodeClass->init_from_query = init_from_query;
- nodeClass->init_from_xml = init_from_xml;
+ nclass->build_query = build_query;
+ nclass->init_from_query = init_from_query;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AuthnRequest");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_authn_request_envelope.c b/lasso/xml/lib_authn_request_envelope.c
index 77be75ad..0b13e689 100644
--- a/lasso/xml/lib_authn_request_envelope.c
+++ b/lasso/xml/lib_authn_request_envelope.c
@@ -66,52 +66,20 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibAuthnRequestEnvelope *env = LASSO_LIB_AUTHN_REQUEST_ENVELOPE(node); \
- char *is_passive = NULL; \
- struct XmlSnippet snippets[] = { \
- /* XXX: Extension */ \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(env->ProviderID) }, \
- { "ProviderName", SNIPPET_CONTENT, (void**)&(env->ProviderName) }, \
- { "AssertionConsumerServiceURL", SNIPPET_CONTENT, \
- (void**)&(env->AssertionConsumerServiceURL) }, \
- { "IDPList", SNIPPET_NODE, (void**)&(env->IDPList) }, \
- { "IsPassive", SNIPPET_CONTENT, (void**)&is_passive }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "AuthnRequestEnvelope");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- is_passive = env->IsPassive ? "true" : "false";
- build_xml_with_snippets(xmlnode, snippets);
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibAuthnRequestEnvelope, ProviderID) },
+ { "ProviderName", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibAuthnRequestEnvelope, ProviderName) },
+ { "AssertionConsumerServiceURL", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibAuthnRequestEnvelope, AssertionConsumerServiceURL) },
+ { "IDPList", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoLibAuthnRequestEnvelope, IDPList) },
+ { "IsPassive", SNIPPET_CONTENT_BOOL,
+ G_STRUCT_OFFSET(LassoLibAuthnRequestEnvelope, IsPassive) },
+ { NULL, 0, 0 }
+};
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- if (is_passive) {
- env->IsPassive = (strcmp(is_passive, "true") == 0);
- xmlFree(is_passive);
- }
- return 0;
-}
-
-
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@@ -131,9 +99,12 @@ instance_init(LassoLibAuthnRequestEnvelope *node)
static void
class_init(LassoLibAuthnRequestEnvelopeClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AuthnRequestEnvelope");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_authn_response.c b/lasso/xml/lib_authn_response.c
index 5a9a7ef9..e90c3d2f 100644
--- a/lasso/xml/lib_authn_response.c
+++ b/lasso/xml/lib_authn_response.c
@@ -57,42 +57,12 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibAuthnResponse *response = LASSO_LIB_AUTHN_RESPONSE(node); \
- struct XmlSnippet snippets[] = { \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(response->ProviderID) }, \
- { "RelayState", SNIPPET_CONTENT, (void**)&(response->RelayState) }, \
- { "consent", SNIPPET_ATTRIBUTE, (void**)&(response->consent) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "AuthnResponse");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnResponse, ProviderID) },
+ { "RelayState", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibAuthnResponse, RelayState) },
+ { "consent", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoLibAuthnResponse, consent) },
+ { NULL, 0, 0 }
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -110,9 +80,12 @@ instance_init(LassoLibAuthnResponse *node)
static void
class_init(LassoLibAuthnResponseClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AuthnResponse");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_authn_response_envelope.c b/lasso/xml/lib_authn_response_envelope.c
index 11a803be..d84998b6 100644
--- a/lasso/xml/lib_authn_response_envelope.c
+++ b/lasso/xml/lib_authn_response_envelope.c
@@ -31,42 +31,13 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node); \
- struct XmlSnippet snippets[] = { \
- /* Extension */ \
- { "AuthnResponse", SNIPPET_NODE, (void**)&(env->AuthnResponse) }, \
- { "AssertionConsumerServiceURL", SNIPPET_CONTENT, \
- (void**)&(env->AssertionConsumerServiceURL) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "AuthnResponseEnvelope");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return 1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "AuthnResponse", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoLibAuthnResponseEnvelope, AuthnResponse) },
+ { "AssertionConsumerServiceURL", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibAuthnResponseEnvelope, AssertionConsumerServiceURL) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -83,9 +54,12 @@ instance_init(LassoLibAuthnResponseEnvelope *node)
static void
class_init(LassoLibAuthnResponseEnvelopeClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AuthnResponseEnvelope");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_federation_termination_notification.c b/lasso/xml/lib_federation_termination_notification.c
index 01623ea2..9a57c80b 100644
--- a/lasso/xml/lib_federation_termination_notification.c
+++ b/lasso/xml/lib_federation_termination_notification.c
@@ -58,43 +58,18 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibFederationTerminationNotification *ob = \
- LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node); \
- struct XmlSnippet snippets[] = { \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(ob->ProviderID) }, \
- { "NameIdentifier", SNIPPET_NODE, (void**)&(ob->NameIdentifier) }, \
- { "consent", SNIPPET_ATTRIBUTE, (void**)&(ob->consent) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibFederationTerminationNotification, ProviderID) },
+ { "NameIdentifier", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoLibFederationTerminationNotification, NameIdentifier) },
+ { "consent", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoLibFederationTerminationNotification, consent) },
+ { NULL, 0, 0}
+};
static LassoNodeClass *parent_class = NULL;
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "FederationTerminationNotification");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
- if (parent_class->init_from_xml(node, xmlnode))
- return 1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
-
static gchar*
build_query(LassoNode *node)
{
@@ -198,11 +173,15 @@ instance_init(LassoLibFederationTerminationNotification *node)
static void
class_init(LassoLibFederationTerminationNotificationClass *klass)
{
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
- LASSO_NODE_CLASS(klass)->build_query = build_query;
- LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
+ nclass->build_query = build_query;
+ nclass->init_from_query = init_from_query;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "FederationTerminationNotification");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_idp_entries.c b/lasso/xml/lib_idp_entries.c
index 2a66b5e0..214f61ea 100644
--- a/lasso/xml/lib_idp_entries.c
+++ b/lasso/xml/lib_idp_entries.c
@@ -41,38 +41,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibIDPEntries *entries = LASSO_LIB_IDP_ENTRIES(node); \
- struct XmlSnippet snippets[] = { \
- { "IDPEntry", SNIPPET_NODE, (void**)&(entries->IDPEntry) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "IDPEntries");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "IDPEntry", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoLibIDPEntries, IDPEntry) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -87,9 +60,12 @@ instance_init(LassoLibIDPEntries *node)
static void
class_init(LassoLibIDPEntriesClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "IDPEntries");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_idp_entry.c b/lasso/xml/lib_idp_entry.c
index 39021580..80dbc629 100644
--- a/lasso/xml/lib_idp_entry.c
+++ b/lasso/xml/lib_idp_entry.c
@@ -43,41 +43,13 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibIDPEntry *entry = LASSO_LIB_IDP_ENTRY(node); \
- struct XmlSnippet snippets[] = { \
- { "Loc", SNIPPET_CONTENT, (void**)&(entry->Loc) }, \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(entry->ProviderID) }, \
- { "ProviderName", SNIPPET_CONTENT, (void**)&(entry->ProviderName) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "Loc", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibIDPEntry, Loc) },
+ { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibIDPEntry, ProviderID) },
+ { "ProviderName", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibIDPEntry, ProviderName) },
+ { NULL, 0, 0}
+};
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "IDPEntry");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@@ -93,9 +65,12 @@ instance_init(LassoLibIDPEntry *node)
static void
class_init(LassoLibIDPEntryClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "IDPEntry");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_idp_list.c b/lasso/xml/lib_idp_list.c
index 747906f7..3ab00174 100644
--- a/lasso/xml/lib_idp_list.c
+++ b/lasso/xml/lib_idp_list.c
@@ -43,40 +43,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibIDPList *list = LASSO_LIB_IDP_LIST(node); \
- struct XmlSnippet snippets[] = { \
- { "IDPEntries", SNIPPET_NODE, (void**)&(list->IDPEntries) }, \
- { "GetComplete", SNIPPET_CONTENT, (void**)&(list->GetComplete) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "IDPList");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "IDPEntries", SNIPPET_NODE, G_STRUCT_OFFSET(LassoLibIDPList, IDPEntries) },
+ { "GetComplete", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibIDPList, GetComplete) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -92,9 +63,12 @@ instance_init(LassoLibIDPList *node)
static void
class_init(LassoLibIDPListClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "IDPList");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_logout_request.c b/lasso/xml/lib_logout_request.c
index 39c9e4cd..0b2f660d 100644
--- a/lasso/xml/lib_logout_request.c
+++ b/lasso/xml/lib_logout_request.c
@@ -60,33 +60,17 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node); \
- struct XmlSnippet snippets[] = { \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(request->ProviderID) }, \
- { "NameIdentifier", SNIPPET_NODE, (void**)&(request->NameIdentifier) }, \
- { "SessionIndex", SNIPPET_CONTENT, (void**)&(request->SessionIndex) }, \
- { "RelayState", SNIPPET_CONTENT, (void**)&(request->RelayState) }, \
- { "consent", SNIPPET_ATTRIBUTE, (void**)&(request->consent) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibLogoutRequest, ProviderID) },
+ { "NameIdentifier", SNIPPET_NODE, G_STRUCT_OFFSET(LassoLibLogoutRequest, NameIdentifier) },
+ { "SessionIndex", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibLogoutRequest, SessionIndex) },
+ { "RelayState", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibLogoutRequest, RelayState) },
+ { "consent", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoLibLogoutRequest, consent) },
+ { NULL, 0, 0}
+};
static LassoNodeClass *parent_class = NULL;
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "LogoutRequest");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
static gchar*
build_query(LassoNode *node)
{
@@ -174,18 +158,6 @@ init_from_query(LassoNode *node, char **query_fields)
return parent_class->init_from_query(node, query_fields);
}
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
-
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@@ -204,11 +176,15 @@ instance_init(LassoLibLogoutRequest *node)
static void
class_init(LassoLibLogoutRequestClass *klass)
{
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
- LASSO_NODE_CLASS(klass)->build_query = build_query;
- LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
+ nclass->build_query = build_query;
+ nclass->init_from_query = init_from_query;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "LogoutRequest");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_logout_response.c b/lasso/xml/lib_logout_response.c
index 57b10554..8c5bfab9 100644
--- a/lasso/xml/lib_logout_response.c
+++ b/lasso/xml/lib_logout_response.c
@@ -36,20 +36,6 @@
/* private methods */
/*****************************************************************************/
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "LogoutResponse");
-
- return xmlnode;
-}
-
-
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@@ -62,11 +48,10 @@ instance_init(LassoLibLogoutResponse *node)
static void
class_init(LassoLibLogoutResponseClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
-#if 0 /* could be used to check QName */
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
-#endif
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "LogoutResponse");
}
GType
diff --git a/lasso/xml/lib_name_identifier_mapping_request.c b/lasso/xml/lib_name_identifier_mapping_request.c
index 14259e6f..d167619d 100644
--- a/lasso/xml/lib_name_identifier_mapping_request.c
+++ b/lasso/xml/lib_name_identifier_mapping_request.c
@@ -57,45 +57,17 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibNameIdentifierMappingRequest *request = \
- LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node); \
- struct XmlSnippet snippets[] = { \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(request->ProviderID) }, \
- { "NameIdentifier", SNIPPET_NODE, (void**)&(request->NameIdentifier) }, \
- { "TargetNamespace", SNIPPET_CONTENT, (void**)&(request->TargetNamespace) }, \
- { "consent", SNIPPET_ATTRIBUTE, (void**)&(request->consent) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- request = LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node);
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "NameIdentifierMappingRequest");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibNameIdentifierMappingRequest, ProviderID) },
+ { "NameIdentifier", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoLibNameIdentifierMappingRequest, NameIdentifier) },
+ { "TargetNamespace", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibNameIdentifierMappingRequest, TargetNamespace) },
+ { "consent", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoLibNameIdentifierMappingRequest, consent) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -114,9 +86,12 @@ instance_init(LassoLibNameIdentifierMappingRequest *node)
static void
class_init(LassoLibNameIdentifierMappingRequestClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "NameIdentifierMappingRequest");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_name_identifier_mapping_response.c b/lasso/xml/lib_name_identifier_mapping_response.c
index f93486ed..4e086a2b 100644
--- a/lasso/xml/lib_name_identifier_mapping_response.c
+++ b/lasso/xml/lib_name_identifier_mapping_response.c
@@ -47,42 +47,15 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibNameIdentifierMappingResponse *response = \
- LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node); \
- struct XmlSnippet snippets[] = { \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(response->ProviderID) }, \
- { "Status", SNIPPET_NODE, (void**)&(response->Status) }, \
- { "NameIdentifier", SNIPPET_NODE, (void**)&(response->NameIdentifier) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "NameIdentifierMappingResponse");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibNameIdentifierMappingResponse, ProviderID) },
+ { "Status", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoLibNameIdentifierMappingResponse, Status) },
+ { "NameIdentifier", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoLibNameIdentifierMappingResponse, NameIdentifier) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -100,9 +73,12 @@ instance_init(LassoLibNameIdentifierMappingResponse *node)
static void
class_init(LassoLibNameIdentifierMappingResponseClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "NameIdentifierMappingResponse");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_register_name_identifier_request.c b/lasso/xml/lib_register_name_identifier_request.c
index a7a1916f..9d66d0fc 100644
--- a/lasso/xml/lib_register_name_identifier_request.c
+++ b/lasso/xml/lib_register_name_identifier_request.c
@@ -63,50 +63,22 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibRegisterNameIdentifierRequest *request = \
- LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node); \
- struct XmlSnippet snippets[] = { \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(request->ProviderID) }, \
- { "IDPProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER, \
- (void**)&(request->IDPProvidedNameIdentifier) }, \
- { "SPProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER, \
- (void**)&(request->SPProvidedNameIdentifier) }, \
- { "OldProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER, \
- (void**)&(request->OldProvidedNameIdentifier) }, \
- { "RelayState", SNIPPET_CONTENT, (void**)&(request->RelayState) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibRegisterNameIdentifierRequest, ProviderID) },
+ { "IDPProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER,
+ G_STRUCT_OFFSET(LassoLibRegisterNameIdentifierRequest, IDPProvidedNameIdentifier)},
+ { "SPProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER,
+ G_STRUCT_OFFSET(LassoLibRegisterNameIdentifierRequest, SPProvidedNameIdentifier) },
+ { "OldProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER,
+ G_STRUCT_OFFSET(LassoLibRegisterNameIdentifierRequest, OldProvidedNameIdentifier)},
+ { "RelayState", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibRegisterNameIdentifierRequest, RelayState) },
+ { NULL, 0, 0}
+};
static LassoNodeClass *parent_class = NULL;
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- xmlNs *xmlns;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "RegisterNameIdentifierRequest");
- xmlns = xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
- xmlSetNs(xmlnode, xmlns);
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
static gchar*
build_query(LassoNode *node)
{
@@ -256,11 +228,15 @@ instance_init(LassoLibRegisterNameIdentifierRequest *node)
static void
class_init(LassoLibRegisterNameIdentifierRequestClass *klass)
{
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
- LASSO_NODE_CLASS(klass)->build_query = build_query;
- LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
+ nclass->build_query = build_query;
+ nclass->init_from_query = init_from_query;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "RegisterNameIdentifierRequest");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_register_name_identifier_response.c b/lasso/xml/lib_register_name_identifier_response.c
index bee94e96..0af644b9 100644
--- a/lasso/xml/lib_register_name_identifier_response.c
+++ b/lasso/xml/lib_register_name_identifier_response.c
@@ -36,19 +36,6 @@
/* private methods */
/*****************************************************************************/
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "RegisterNameIdentifierResponse");
-
- return xmlnode;
-}
-
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@@ -61,8 +48,10 @@ instance_init(LassoLibRegisterNameIdentifierResponse *node)
static void
class_init(LassoLibRegisterNameIdentifierResponseClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "RegisterNameIdentifierResponse");
}
GType
diff --git a/lasso/xml/lib_request_authn_context.c b/lasso/xml/lib_request_authn_context.c
index cf9eb27b..788aad5e 100644
--- a/lasso/xml/lib_request_authn_context.c
+++ b/lasso/xml/lib_request_authn_context.c
@@ -49,45 +49,15 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node); \
- struct XmlSnippet snippets[] = { \
- { "AuthnContextClassRef", SNIPPET_CONTENT, \
- (void**)&(context->AuthnContextClassRef) }, \
- { "AuthnContextStatementRef", SNIPPET_CONTENT, \
- (void**)&(context->AuthnContextStatementRef) }, \
- { "AuthnContextComparisonType", SNIPPET_CONTENT, \
- (void**)&(context->AuthnContextComparisonType) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "RequestAuthnContext");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "AuthnContextClassRef", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibRequestAuthnContext, AuthnContextClassRef) },
+ { "AuthnContextStatementRef", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibRequestAuthnContext, AuthnContextStatementRef) },
+ { "AuthnContextComparisonType", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoLibRequestAuthnContext, AuthnContextComparisonType) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -104,9 +74,12 @@ instance_init(LassoLibRequestAuthnContext *node)
static void
class_init(LassoLibRequestAuthnContextClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "RequestAuthnContext");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_scoping.c b/lasso/xml/lib_scoping.c
index fb849deb..b5050ac8 100644
--- a/lasso/xml/lib_scoping.c
+++ b/lasso/xml/lib_scoping.c
@@ -41,52 +41,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibScoping *scoping = LASSO_LIB_SCOPING(node); \
- char *proxy_count = NULL; \
- struct XmlSnippet snippets[] = { \
- { "ProxyCount", SNIPPET_CONTENT, (void**)&proxy_count }, \
- { "IDPList", SNIPPET_NODE, (void**)&(scoping->IDPList) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "Scoping");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- if (scoping->ProxyCount) {
- proxy_count = g_strdup_printf("%d", scoping->ProxyCount);
- }
- build_xml_with_snippets(xmlnode, snippets);
-
- if (proxy_count)
- g_free(proxy_count);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- if (proxy_count) {
- scoping->ProxyCount = atoi(proxy_count);
- xmlFree(proxy_count);
- }
-
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "ProxyCount", SNIPPET_CONTENT_INT, G_STRUCT_OFFSET(LassoLibScoping, ProxyCount) },
+ { "IDPList", SNIPPET_NODE, G_STRUCT_OFFSET(LassoLibScoping, IDPList) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -102,9 +61,12 @@ instance_init(LassoLibScoping *node)
static void
class_init(LassoLibScopingClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Scoping");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_status_response.c b/lasso/xml/lib_status_response.c
index 272c895b..04c4be22 100644
--- a/lasso/xml/lib_status_response.c
+++ b/lasso/xml/lib_status_response.c
@@ -57,42 +57,15 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node); \
- struct XmlSnippet snippets[] = { \
- { "ProviderID", SNIPPET_CONTENT, (void**)&(response->ProviderID) }, \
- { "Status", SNIPPET_NODE, (void**)&(response->Status) }, \
- { "RelayState", SNIPPET_CONTENT, (void**)&(response->RelayState) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "ProviderID", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibStatusResponse, ProviderID) },
+ { "Status", SNIPPET_NODE, G_STRUCT_OFFSET(LassoLibStatusResponse, Status) },
+ { "RelayState", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoLibStatusResponse, RelayState) },
+ { NULL, 0, 0}
+};
static LassoNodeClass *parent_class = NULL;
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "StatusResponse");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
static gchar*
build_query(LassoNode *node)
{
@@ -174,11 +147,15 @@ instance_init(LassoLibStatusResponse *node)
static void
class_init(LassoLibStatusResponseClass *klass)
{
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
- LASSO_NODE_CLASS(klass)->build_query = build_query;
- LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
+ nclass->build_query = build_query;
+ nclass->init_from_query = init_from_query;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "StatusResponse");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/lib_subject.c b/lasso/xml/lib_subject.c
index fb4849d8..f4cd26d4 100644
--- a/lasso/xml/lib_subject.c
+++ b/lasso/xml/lib_subject.c
@@ -44,40 +44,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoLibSubject *subject = LASSO_LIB_SUBJECT(node); \
- struct XmlSnippet snippets[] = { \
- { "IDPProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER, \
- (void**)&(subject->IDPProvidedNameIdentifier) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "IDPProvidedNameIdentifier", SNIPPET_NAME_IDENTIFIER,
+ G_STRUCT_OFFSET(LassoLibSubject, IDPProvidedNameIdentifier) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -92,9 +63,12 @@ instance_init(LassoLibSubject *node)
static void
class_init(LassoLibSubjectClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Subject");
+ lasso_node_class_set_ns(nclass, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_advice.c b/lasso/xml/saml_advice.c
index 0758cfae..5fb75670 100644
--- a/lasso/xml/saml_advice.c
+++ b/lasso/xml/saml_advice.c
@@ -48,42 +48,12 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlAdvice *advice = LASSO_SAML_ADVICE(node); \
- struct XmlSnippet snippets[] = { \
- { "AssertionIDReference", SNIPPET_CONTENT, \
- (void**)&(advice->AssertionIDReference) }, \
- { "Assertion", SNIPPET_NODE, (void**)&(advice->Assertion) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "Advice");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "AssertionIDReference", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoSamlAdvice, AssertionIDReference) },
+ { "Assertion", SNIPPET_NODE, G_STRUCT_OFFSET(LassoSamlAdvice, Assertion) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -99,9 +69,12 @@ instance_init(LassoSamlAdvice *node)
static void
class_init(LassoSamlAdviceClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Advice");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_assertion.c b/lasso/xml/saml_assertion.c
index 08976154..ec9f5609 100644
--- a/lasso/xml/saml_assertion.c
+++ b/lasso/xml/saml_assertion.c
@@ -60,19 +60,24 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlAssertion *assertion = LASSO_SAML_ASSERTION(node); \
- struct XmlSnippet snippets[] = { \
- { "Conditions", SNIPPET_NODE, (void**)&(assertion->Conditions) }, \
- { "Advice", SNIPPET_NODE, (void**)&(assertion->Advice) }, \
- { "SubjectStatement", SNIPPET_NODE, (void**)&(assertion->SubjectStatement) }, \
- { "AuthenticationStatement", SNIPPET_NODE, \
- (void**)&(assertion->AuthenticationStatement) }, \
- { "AssertionID", SNIPPET_ATTRIBUTE, (void**)&(assertion->AssertionID) }, \
- { "Issuer", SNIPPET_ATTRIBUTE, (void**)&(assertion->Issuer) }, \
- { "IssueInstant", SNIPPET_ATTRIBUTE, (void**)&(assertion->IssueInstant) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "Conditions", SNIPPET_NODE, G_STRUCT_OFFSET(LassoSamlAssertion, Conditions) },
+ { "Advice", SNIPPET_NODE, G_STRUCT_OFFSET(LassoSamlAssertion, Advice) },
+ { "SubjectStatement", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoSamlAssertion, SubjectStatement) },
+ { "AuthenticationStatement", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoSamlAssertion, AuthenticationStatement) },
+ { "MajorVersion", SNIPPET_ATTRIBUTE_INT,
+ G_STRUCT_OFFSET(LassoSamlAssertion, MajorVersion) },
+ { "MinorVersion", SNIPPET_ATTRIBUTE_INT,
+ G_STRUCT_OFFSET(LassoSamlAssertion, MinorVersion) },
+ { "AssertionID", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAssertion, AssertionID) },
+ { "Issuer", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoSamlAssertion, Issuer) },
+ { "IssueInstant", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAssertion, IssueInstant) },
+ { NULL, 0, 0}
+};
static LassoNodeClass *parent_class = NULL;
@@ -96,7 +101,9 @@ insure_namespace(xmlNode *xmlnode, xmlNs *ns)
if (xmlnode->ns && strcmp(xmlnode->ns->href, LASSO_LIB_HREF) == 0) {
typename = g_strdup_printf("lib:%sType", xmlnode->name);
xmlSetNs(xmlnode, ns);
- xmlNewNsProp(xmlnode, xsi_ns, "type", typename);
+ if (xmlHasNsProp(t, "type", LASSO_XSI_HREF) == NULL) {
+ xmlNewNsProp(xmlnode, xsi_ns, "type", typename);
+ }
g_free(typename);
}
@@ -112,49 +119,14 @@ get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
xmlNs *ns;
- char s[10];
- snippets();
-
- xmlnode = xmlNewNode(NULL, "Assertion");
- ns = xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
- xmlSetNs(xmlnode, ns);
- snprintf(s, 9, "%d", assertion->MajorVersion);
- xmlSetProp(xmlnode, "MajorVersion", s);
- snprintf(s, 9, "%d", assertion->MinorVersion);
- xmlSetProp(xmlnode, "MinorVersion", s);
-
- build_xml_with_snippets(xmlnode, snippets);
+
+ xmlnode = parent_class->get_xmlNode(node);
+ ns = xmlSearchNs(NULL, xmlnode, "saml");
insure_namespace(xmlnode, ns);
return xmlnode;
}
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- char *s;
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
-
- s = xmlGetProp(xmlnode, "MajorVersion");
- if (s) {
- assertion->MajorVersion = atoi(s);
- xmlFree(s);
- }
- s = xmlGetProp(xmlnode, "MinorVersion");
- if (s) {
- assertion->MinorVersion = atoi(s);
- xmlFree(s);
- }
-
- init_xml_with_snippets(xmlnode, snippets);
-
- return 0;
-}
-
-
gint
lasso_saml_assertion_set_signature(LassoSamlAssertion *node,
gint sign_method,
@@ -183,16 +155,21 @@ lasso_saml_assertion_set_signature(LassoSamlAssertion *node,
/*****************************************************************************/
static void
-instance_init(LassoSamlAssertion *node)
+instance_init(LassoSamlAssertion *assertion)
{
}
static void
class_init(LassoSamlAssertionClass *klass)
{
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ nclass->get_xmlNode = get_xmlNode;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Assertion");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_attribute.c b/lasso/xml/saml_attribute.c
index 449d3928..33b19d7c 100644
--- a/lasso/xml/saml_attribute.c
+++ b/lasso/xml/saml_attribute.c
@@ -58,27 +58,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlAttribute *attribute = LASSO_SAML_ATTRIBUTE(node); \
- struct XmlSnippet snippets[] = { \
- { "AttributeValue", SNIPPET_LIST_NODES, (void**)&(attribute->AttributeValue) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "Attribute");
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "AttributeValue", SNIPPET_LIST_NODES,
+ G_STRUCT_OFFSET(LassoSamlAttribute, AttributeValue) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -93,8 +77,12 @@ instance_init(LassoSamlAttribute *node)
static void
class_init(LassoSamlAttributeClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Attribute");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_attribute_designator.c b/lasso/xml/saml_attribute_designator.c
index 14d27891..3cbab912 100644
--- a/lasso/xml/saml_attribute_designator.c
+++ b/lasso/xml/saml_attribute_designator.c
@@ -39,45 +39,13 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlAttributeDesignator *designator = \
- LASSO_SAML_ATTRIBUTE_DESIGNATOR(node); \
- struct XmlSnippet snippets[] = { \
- { "AttributeName", SNIPPET_ATTRIBUTE, (void**)&(designator->AttributeName) }, \
- { "AttributeNamespace", SNIPPET_ATTRIBUTE, \
- (void**)&(designator->AttributeNamespace) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "AttributeDesignator");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode)) {
- return -1;
- }
-
- init_xml_with_snippets(xmlnode, snippets);
-
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "AttributeName", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAttributeDesignator, AttributeName) },
+ { "AttributeNamespace", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAttributeDesignator, AttributeNamespace) },
+ { NULL, 0, 0 }
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -93,8 +61,12 @@ instance_init(LassoSamlAttributeDesignator *node)
static void
class_init(LassoSamlAttributeDesignatorClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AttributeDesignator");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_attribute_statement.c b/lasso/xml/saml_attribute_statement.c
index bf933674..060e6db6 100644
--- a/lasso/xml/saml_attribute_statement.c
+++ b/lasso/xml/saml_attribute_statement.c
@@ -44,28 +44,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlAttributeStatement *statement = \
- LASSO_SAML_ATTRIBUTE_STATEMENT(node); \
- struct XmlSnippet snippets[] = { \
- { "Attribute", SNIPPET_LIST_NODES, (void**)&(statement->Attribute) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "AttributeStatement");
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "Attribute", SNIPPET_LIST_NODES,
+ G_STRUCT_OFFSET(LassoSamlAttributeStatement, Attribute) },
+ { NULL, 0, 0 }
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -80,8 +63,12 @@ instance_init(LassoSamlAttributeStatement *node)
static void
class_init(LassoSamlAttributeStatementClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AttributeStatement");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_audience_restriction_condition.c b/lasso/xml/saml_audience_restriction_condition.c
index d1351a3f..832e25b0 100644
--- a/lasso/xml/saml_audience_restriction_condition.c
+++ b/lasso/xml/saml_audience_restriction_condition.c
@@ -46,41 +46,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlAudienceRestrictionCondition *condition = \
- LASSO_SAML_AUDIENCE_RESTRICTION_CONDITION(node); \
- struct XmlSnippet snippets[] = { \
- { "Audience", SNIPPET_CONTENT, (void**)&(condition->Audience) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "AudienceRestrictionCondition");
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
-
+static struct XmlSnippet schema_snippets[] = {
+ { "Audience", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoSamlAudienceRestrictionCondition, Audience) },
+ { NULL, 0, 0 }
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -95,9 +65,12 @@ instance_init(LassoSamlAudienceRestrictionCondition *node)
static void
class_init(LassoSamlAudienceRestrictionConditionClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AudienceRestrictionCondition");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_authentication_statement.c b/lasso/xml/saml_authentication_statement.c
index b191ac99..94003093 100644
--- a/lasso/xml/saml_authentication_statement.c
+++ b/lasso/xml/saml_authentication_statement.c
@@ -47,44 +47,18 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlAuthenticationStatement *statement = LASSO_SAML_AUTHENTICATION_STATEMENT(node); \
- struct XmlSnippet snippets[] = { \
- { "SubjectLocality", SNIPPET_NODE, (void**)&(statement->SubjectLocality) }, \
- { "AuthorityBinding", SNIPPET_NODE, (void**)&(statement->AuthorityBinding) }, \
- { "AuthenticationMethod", SNIPPET_ATTRIBUTE, \
- (void**)&(statement->AuthenticationMethod) }, \
- { "AuthenticationInstant", SNIPPET_ATTRIBUTE, \
- (void**)&(statement->AuthenticationInstant) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "SubjectLocality", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoSamlAuthenticationStatement, SubjectLocality) },
+ { "AuthorityBinding", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoSamlAuthenticationStatement, AuthorityBinding) },
+ { "AuthenticationMethod", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAuthenticationStatement, AuthenticationMethod) },
+ { "AuthenticationInstant", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAuthenticationStatement, AuthenticationInstant) },
+ { NULL, 0, 0}
+};
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "AuthenticationStatement");
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@@ -101,9 +75,12 @@ instance_init(LassoSamlAuthenticationStatement *node)
static void
class_init(LassoSamlAuthenticationStatementClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AuthenticationStatement");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_authority_binding.c b/lasso/xml/saml_authority_binding.c
index 628cc9fc..5bb2f41e 100644
--- a/lasso/xml/saml_authority_binding.c
+++ b/lasso/xml/saml_authority_binding.c
@@ -40,42 +40,15 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlAuthorityBinding *binding = LASSO_SAML_AUTHORITY_BINDING(node); \
- struct XmlSnippet snippets[] = { \
- { "AuthorityKind", SNIPPET_ATTRIBUTE, (void**)&(binding->AuthorityKind) }, \
- { "Location", SNIPPET_ATTRIBUTE, (void**)&(binding->Location) }, \
- { "Binding", SNIPPET_ATTRIBUTE, (void**)&(binding->Binding) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "AuthorityBinding");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
-
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "AuthorityKind", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAuthorityBinding, AuthorityKind) },
+ { "Location", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAuthorityBinding, Location) },
+ { "Binding", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlAuthorityBinding, Binding) },
+ { NULL, 0, 0 }
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -92,9 +65,12 @@ instance_init(LassoSamlAuthorityBinding *node)
static void
class_init(LassoSamlAuthorityBindingClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "AuthorityBinding");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_condition_abstract.c b/lasso/xml/saml_condition_abstract.c
index f0698e5c..eddddc0d 100644
--- a/lasso/xml/saml_condition_abstract.c
+++ b/lasso/xml/saml_condition_abstract.c
@@ -36,18 +36,6 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
-
- xmlnode = xmlNewNode(NULL, "ConditionAbstract");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- return xmlnode;
-}
/*****************************************************************************/
/* instance and class init functions */
@@ -61,8 +49,11 @@ instance_init(LassoSamlConditionAbstract *node)
static void
class_init(LassoSamlConditionAbstractClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "ConditionAbstract");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
}
GType
diff --git a/lasso/xml/saml_conditions.c b/lasso/xml/saml_conditions.c
index b9953cf2..1805b64f 100644
--- a/lasso/xml/saml_conditions.c
+++ b/lasso/xml/saml_conditions.c
@@ -43,44 +43,15 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlConditions *conditions = LASSO_SAML_CONDITIONS(node); \
- struct XmlSnippet snippets[] = { \
- { "AudienceRestrictionCondition", SNIPPET_NODE, \
- (void**)&(conditions->AudienceRestrictionCondition) }, \
- { "NotBefore", SNIPPET_ATTRIBUTE, (void**)&(conditions->NotBefore) }, \
- { "NotOnOrAfter", SNIPPET_ATTRIBUTE, (void**)&(conditions->NotOnOrAfter) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "Conditions");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
-
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "AudienceRestrictionCondition", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoSamlConditions, AudienceRestrictionCondition) },
+ { "NotBefore", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlConditions, NotBefore) },
+ { "NotOnOrAfter", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlConditions, NotOnOrAfter) },
+ { NULL, 0, 0 }
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -97,9 +68,12 @@ instance_init(LassoSamlConditions *node)
static void
class_init(LassoSamlConditionsClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Conditions");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_name_identifier.c b/lasso/xml/saml_name_identifier.c
index 7ee34f83..55c7c373 100644
--- a/lasso/xml/saml_name_identifier.c
+++ b/lasso/xml/saml_name_identifier.c
@@ -79,40 +79,13 @@ lasso_saml_name_identifier_build_query(LassoSamlNameIdentifier *identifier,
/* private methods */
/*****************************************************************************/
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- LassoSamlNameIdentifier *identifier = LASSO_SAML_NAME_IDENTIFIER(node);
-
- xmlnode = xmlNewNode(NULL, "NameIdentifier");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- xmlAddChild(xmlnode, xmlNewText(identifier->content));
- if (identifier->Format)
- xmlSetProp(xmlnode, "Format", identifier->Format);
- if (identifier->NameQualifier)
- xmlSetProp(xmlnode, "NameQualifier", identifier->NameQualifier);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- LassoSamlNameIdentifier *identifier = LASSO_SAML_NAME_IDENTIFIER(node);
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
-
- identifier->content = xmlNodeGetContent(xmlnode);
- identifier->Format = xmlGetProp(xmlnode, "Format");
- identifier->NameQualifier = xmlGetProp(xmlnode, "NameQualifier");
-
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "NameQualifier", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlNameIdentifier, NameQualifier) },
+ { "Format", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoSamlNameIdentifier, Format) },
+ { "", SNIPPET_TEXT_CHILD, G_STRUCT_OFFSET(LassoSamlNameIdentifier, content) },
+ { NULL, 0, 0 }
+};
static gchar*
build_query(LassoNode *node)
@@ -135,10 +108,13 @@ instance_init(LassoSamlNameIdentifier *node)
static void
class_init(LassoSamlNameIdentifierClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
LASSO_NODE_CLASS(klass)->build_query = build_query;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "NameIdentifier");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_statement_abstract.c b/lasso/xml/saml_statement_abstract.c
index 95be722d..49d3db51 100644
--- a/lasso/xml/saml_statement_abstract.c
+++ b/lasso/xml/saml_statement_abstract.c
@@ -37,18 +37,6 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- xmlnode = xmlNewNode(NULL, "StatementAbstract");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- return xmlnode;
-}
-
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@@ -61,8 +49,11 @@ instance_init(LassoSamlStatementAbstract *node)
static void
class_init(LassoSamlStatementAbstractClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "StatementAbstract");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
}
GType
diff --git a/lasso/xml/saml_subject.c b/lasso/xml/saml_subject.c
index 4d4521d7..ce735d68 100644
--- a/lasso/xml/saml_subject.c
+++ b/lasso/xml/saml_subject.c
@@ -44,40 +44,13 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlSubject *subject = LASSO_SAML_SUBJECT(node); \
- struct XmlSnippet snippets[] = { \
- { "NameIdentifier", SNIPPET_NODE, (void**)&(subject->NameIdentifier) }, \
- { "SubjectConfirmation", SNIPPET_NODE, (void**)&(subject->SubjectConfirmation) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "Subject");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "NameIdentifier", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoSamlSubject, NameIdentifier) },
+ { "SubjectConfirmation", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoSamlSubject, SubjectConfirmation) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -93,9 +66,12 @@ instance_init(LassoSamlSubject *node)
static void
class_init(LassoSamlSubjectClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Subject");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_subject_confirmation.c b/lasso/xml/saml_subject_confirmation.c
index c20a66fd..1c530c69 100644
--- a/lasso/xml/saml_subject_confirmation.c
+++ b/lasso/xml/saml_subject_confirmation.c
@@ -45,43 +45,13 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlSubjectConfirmation *confirm = LASSO_SAML_SUBJECT_CONFIRMATION(node); \
- struct XmlSnippet snippets[] = { \
- { "ConfirmationMethod", SNIPPET_CONTENT, \
- (void**)&(confirm->ConfirmationMethod) }, \
- { "SubjectConfirmationData", SNIPPET_CONTENT, \
- (void**)&(confirm->SubjectConfirmationData) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "SubjectConfirmation");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "ConfirmationMethod", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoSamlSubjectConfirmation, ConfirmationMethod) },
+ { "SubjectConfirmationData", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoSamlSubjectConfirmation, SubjectConfirmationData) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -95,9 +65,12 @@ instance_init(LassoSamlSubjectConfirmation *node)
static void
class_init(LassoSamlSubjectConfirmationClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "SubjectStatement");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_subject_locality.c b/lasso/xml/saml_subject_locality.c
index da50d998..314a909a 100644
--- a/lasso/xml/saml_subject_locality.c
+++ b/lasso/xml/saml_subject_locality.c
@@ -39,42 +39,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlSubjectLocality *locality = LASSO_SAML_SUBJECT_LOCALITY(node); \
- struct XmlSnippet snippets[] = { \
- { "IPAddress", SNIPPET_ATTRIBUTE, (void**)&(locality->IPAddress) }, \
- { "DNSAddress", SNIPPET_ATTRIBUTE, (void**)&(locality->DNSAddress) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "SubjectLocality");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode,
- LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
-
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "IPAddress", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoSamlSubjectLocality, IPAddress) },
+ { "DNSAddress", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoSamlSubjectLocality, DNSAddress) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -90,9 +59,12 @@ instance_init(LassoSamlSubjectLocality *node)
static void
class_init(LassoSamlSubjectLocalityClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "SubjectLocality");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/saml_subject_statement.c b/lasso/xml/saml_subject_statement.c
index 2fc851cf..ecc5d892 100644
--- a/lasso/xml/saml_subject_statement.c
+++ b/lasso/xml/saml_subject_statement.c
@@ -35,17 +35,6 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "SubjectStatement");
- return xmlnode;
-}
-
/*****************************************************************************/
/* instance and class init functions */
/*****************************************************************************/
@@ -58,8 +47,11 @@ instance_init(LassoSamlSubjectStatement *node)
static void
class_init(LassoSamlSubjectStatementClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "SubjectStatement");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
}
GType
diff --git a/lasso/xml/saml_subject_statement_abstract.c b/lasso/xml/saml_subject_statement_abstract.c
index 0eb04b0e..317b7f7f 100644
--- a/lasso/xml/saml_subject_statement_abstract.c
+++ b/lasso/xml/saml_subject_statement_abstract.c
@@ -43,40 +43,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlSubjectStatementAbstract *statement = \
- LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(node); \
- struct XmlSnippet snippets[] = { \
- { "Subject", SNIPPET_NODE, (void**)&(statement->Subject) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "SubjectStatementAbstract");
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "Subject", SNIPPET_NODE,
+ G_STRUCT_OFFSET(LassoSamlSubjectStatementAbstract, Subject) },
+ { NULL, 0, 0 }
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -91,9 +62,12 @@ instance_init(LassoSamlSubjectStatementAbstract *node)
static void
class_init(LassoSamlSubjectStatementAbstractClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "SubjectStatementAbstract");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/samlp_request.c b/lasso/xml/samlp_request.c
index 7886ebc7..f84cc838 100644
--- a/lasso/xml/samlp_request.c
+++ b/lasso/xml/samlp_request.c
@@ -50,39 +50,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlpRequest *request = LASSO_SAMLP_REQUEST(node); \
- struct XmlSnippet snippets[] = { \
- { "AssertionArtifact", SNIPPET_CONTENT, (void**)&(request->AssertionArtifact) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "Request");
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
+static struct XmlSnippet schema_snippets[] = {
+ { "AssertionArtifact", SNIPPET_CONTENT,
+ G_STRUCT_OFFSET(LassoSamlpRequest, AssertionArtifact) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -97,9 +69,12 @@ instance_init(LassoSamlpRequest *node)
static void
class_init(LassoSamlpRequestClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Request");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/samlp_request_abstract.c b/lasso/xml/samlp_request_abstract.c
index bb680c2f..4630125e 100644
--- a/lasso/xml/samlp_request_abstract.c
+++ b/lasso/xml/samlp_request_abstract.c
@@ -54,6 +54,17 @@
/* private methods */
/*****************************************************************************/
+static struct XmlSnippet schema_snippets[] = {
+ { "RequestID", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoSamlpRequestAbstract, RequestID) },
+ { "MajorVersion", SNIPPET_ATTRIBUTE_INT,
+ G_STRUCT_OFFSET(LassoSamlpRequestAbstract, MajorVersion) },
+ { "MinorVersion", SNIPPET_ATTRIBUTE_INT,
+ G_STRUCT_OFFSET(LassoSamlpRequestAbstract, MinorVersion) },
+ { "IssueInstant", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlpRequestAbstract, IssueInstant) },
+ { NULL, 0, 0}
+};
+
static LassoNodeClass *parent_class = NULL;
static gchar*
@@ -75,16 +86,8 @@ get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlpRequestAbstract *request = LASSO_SAMLP_REQUEST_ABSTRACT(node);
- char t[10];
- xmlnode = xmlNewNode(NULL, "RequestAbstract");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX));
- xmlSetProp(xmlnode, "RequestID", request->RequestID);
- snprintf(t, 9, "%d", request->MajorVersion);
- xmlSetProp(xmlnode, "MajorVersion", t);
- snprintf(t, 9, "%d", request->MinorVersion);
- xmlSetProp(xmlnode, "MinorVersion", t);
- xmlSetProp(xmlnode, "IssueInstant", request->IssueInstant);
+ xmlnode = parent_class->get_xmlNode(node);
/* signature stuff */
if (request->sign_type != LASSO_SIGNATURE_TYPE_NONE) {
@@ -156,31 +159,6 @@ init_from_query(LassoNode *node, char **query_fields)
return TRUE;
}
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- char *t;
- LassoSamlpRequestAbstract *request = LASSO_SAMLP_REQUEST_ABSTRACT(node);
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
-
- request->RequestID = xmlGetProp(xmlnode, "RequestID");
- request->IssueInstant = xmlGetProp(xmlnode, "IssueInstant");
- t = xmlGetProp(xmlnode, "MajorVersion");
- if (t) {
- request->MajorVersion = atoi(t);
- xmlFree(t);
- }
- t = xmlGetProp(xmlnode, "MinorVersion");
- if (t) {
- request->MinorVersion = atoi(t);
- xmlFree(t);
- }
- return 0;
-}
-
-
static char*
get_sign_attr_name()
{
@@ -206,12 +184,17 @@ instance_init(LassoSamlpRequestAbstract *node)
static void
class_init(LassoSamlpRequestAbstractClass *klass)
{
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->build_query = build_query;
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
- LASSO_NODE_CLASS(klass)->get_sign_attr_name = get_sign_attr_name;
+ nclass->build_query = build_query;
+ nclass->get_xmlNode = get_xmlNode;
+ nclass->init_from_query = init_from_query;
+ nclass->get_sign_attr_name = get_sign_attr_name;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "RequestAbstract");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/samlp_request_abstract.h b/lasso/xml/samlp_request_abstract.h
index 4b27e9d0..213b490b 100644
--- a/lasso/xml/samlp_request_abstract.h
+++ b/lasso/xml/samlp_request_abstract.h
@@ -54,7 +54,7 @@ struct _LassoSamlpRequestAbstract {
LassoNode parent;
/* <element ref="samlp:RespondWith" minOccurs="0" maxOccurs="unbounded"/> */
- char *RespondWith; /* XXX */
+ char *RespondWith; /* XXX: turn into a GList */
/* <attribute name="RequestID" type="saml:IDType" use="required"/> */
char *RequestID;
/* <attribute name="MajorVersion" type="integer" use="required"/> */
diff --git a/lasso/xml/samlp_response.c b/lasso/xml/samlp_response.c
index 85731c08..27371848 100644
--- a/lasso/xml/samlp_response.c
+++ b/lasso/xml/samlp_response.c
@@ -46,13 +46,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlpResponse *response = LASSO_SAMLP_RESPONSE(node); \
- struct XmlSnippet snippets[] = { \
- { "Assertion", SNIPPET_NODE, (void**)&(response->Assertion) }, \
- { "Status", SNIPPET_NODE, (void**)&(response->Status) }, \
- { NULL, 0, NULL} \
- };
+static struct XmlSnippet schema_snippets[] = {
+ { "Assertion", SNIPPET_NODE, G_STRUCT_OFFSET(LassoSamlpResponse, Assertion) },
+ { "Status", SNIPPET_NODE, G_STRUCT_OFFSET(LassoSamlpResponse, Status) },
+ { NULL, 0, 0}
+};
static LassoNodeClass *parent_class = NULL;
@@ -60,11 +58,8 @@ static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode, *t;
- snippets();
xmlnode = parent_class->get_xmlNode(node);
- xmlNodeSetName(xmlnode, "Response");
- build_xml_with_snippets(xmlnode, snippets);
for (t = xmlnode->children; t && strcmp(t->name, "Assertion"); t = t->next) ;
@@ -72,24 +67,14 @@ get_xmlNode(LassoNode *node)
/* liberty nodes are not allowed in samlp nodes */
xmlSetNs(t, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF,
LASSO_SAML_ASSERTION_PREFIX));
- xmlNewNsProp(t, xmlNewNs(xmlnode, LASSO_XSI_HREF, LASSO_XSI_PREFIX),
- "type", "lib:AssertionType");
+ if (xmlHasNsProp(t, "type", LASSO_XSI_HREF) == NULL)
+ xmlNewNsProp(t, xmlNewNs(xmlnode, LASSO_XSI_HREF, LASSO_XSI_PREFIX),
+ "type", "lib:AssertionType");
}
return xmlnode;
}
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
-
/*****************************************************************************/
/* instance and class init functions */
@@ -105,9 +90,14 @@ instance_init(LassoSamlpResponse *node)
static void
class_init(LassoSamlpResponseClass *klass)
{
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ nclass->get_xmlNode = get_xmlNode;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Response");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/samlp_response_abstract.c b/lasso/xml/samlp_response_abstract.c
index c3bb7201..2a60ad4b 100644
--- a/lasso/xml/samlp_response_abstract.c
+++ b/lasso/xml/samlp_response_abstract.c
@@ -56,6 +56,21 @@
/* private methods */
/*****************************************************************************/
+static struct XmlSnippet schema_snippets[] = {
+ { "ResponseID", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlpResponseAbstract, ResponseID) },
+ { "MajorVersion", SNIPPET_ATTRIBUTE_INT,
+ G_STRUCT_OFFSET(LassoSamlpResponseAbstract, MajorVersion) },
+ { "MinorVersion", SNIPPET_ATTRIBUTE_INT,
+ G_STRUCT_OFFSET(LassoSamlpResponseAbstract, MinorVersion) },
+ { "IssueInstant", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlpResponseAbstract, IssueInstant) },
+ { "InResponseTo", SNIPPET_ATTRIBUTE,
+ G_STRUCT_OFFSET(LassoSamlpResponseAbstract, InResponseTo) },
+ { "Recipient", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoSamlpResponseAbstract, Recipient) },
+ { NULL, 0, 0}
+};
+
static LassoNodeClass *parent_class = NULL;
static gchar*
@@ -78,20 +93,8 @@ get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
LassoSamlpResponseAbstract *response = LASSO_SAMLP_RESPONSE_ABSTRACT(node);
- char t[10];
-
- xmlnode = xmlNewNode(NULL, "ResponseAbstract");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX));
- xmlSetProp(xmlnode, "ResponseID", response->ResponseID);
- snprintf(t, 9, "%d", response->MajorVersion);
- xmlSetProp(xmlnode, "MajorVersion", t);
- snprintf(t, 9, "%d", response->MinorVersion);
- xmlSetProp(xmlnode, "MinorVersion", t);
- xmlSetProp(xmlnode, "IssueInstant", response->IssueInstant);
- if (response->InResponseTo)
- xmlSetProp(xmlnode, "InResponseTo", t);
- if (response->Recipient)
- xmlSetProp(xmlnode, "Recipient", t);
+
+ xmlnode = parent_class->get_xmlNode(node);
/* signature stuff */
if (response->sign_type != LASSO_SIGNATURE_TYPE_NONE) {
@@ -172,32 +175,6 @@ init_from_query(LassoNode *node, char **query_fields)
return TRUE;
}
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- char *t;
- LassoSamlpResponseAbstract *response = LASSO_SAMLP_RESPONSE_ABSTRACT(node);
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
-
- response->ResponseID = xmlGetProp(xmlnode, "ResponseID");
- response->IssueInstant = xmlGetProp(xmlnode, "IssueInstant");
- response->InResponseTo = xmlGetProp(xmlnode, "InResponseTo");
- response->Recipient = xmlGetProp(xmlnode, "Recipient");
- t = xmlGetProp(xmlnode, "MajorVersion");
- if (t) {
- response->MajorVersion = atoi(t);
- xmlFree(t);
- }
- t = xmlGetProp(xmlnode, "MinorVersion");
- if (t) {
- response->MinorVersion = atoi(t);
- xmlFree(t);
- }
- return 0;
-}
-
static char*
get_sign_attr_name()
{
@@ -225,12 +202,17 @@ instance_init(LassoSamlpResponseAbstract *node)
static void
class_init(LassoSamlpResponseAbstractClass *klass)
{
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
- LASSO_NODE_CLASS(klass)->build_query = build_query;
- LASSO_NODE_CLASS(klass)->init_from_query = init_from_query;
- LASSO_NODE_CLASS(klass)->get_sign_attr_name = get_sign_attr_name;
+ nclass->get_xmlNode = get_xmlNode;
+ nclass->build_query = build_query;
+ nclass->init_from_query = init_from_query;
+ nclass->get_sign_attr_name = get_sign_attr_name;
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "ResponseAbstract");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/samlp_status.c b/lasso/xml/samlp_status.c
index 0979302d..4f3b5fae 100644
--- a/lasso/xml/samlp_status.c
+++ b/lasso/xml/samlp_status.c
@@ -44,39 +44,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlpStatus *status = LASSO_SAMLP_STATUS(node); \
- struct XmlSnippet snippets[] = { \
- { "StatusCode", SNIPPET_NODE, (void**)&(status->StatusCode) }, \
- { "StatusMessage", SNIPPET_CONTENT, (void**)&(status->StatusMessage) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "Status");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "StatusCode", SNIPPET_NODE, G_STRUCT_OFFSET(LassoSamlpStatus, StatusCode) },
+ { "StatusMessage", SNIPPET_CONTENT, G_STRUCT_OFFSET(LassoSamlpStatus, StatusMessage) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -93,9 +65,12 @@ instance_init(LassoSamlpStatus *node)
static void
class_init(LassoSamlpStatusClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "Status");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/samlp_status_code.c b/lasso/xml/samlp_status_code.c
index 501ee716..d4d779ec 100644
--- a/lasso/xml/samlp_status_code.c
+++ b/lasso/xml/samlp_status_code.c
@@ -41,39 +41,11 @@
/* private methods */
/*****************************************************************************/
-#define snippets() \
- LassoSamlpStatusCode *status_code = LASSO_SAMLP_STATUS_CODE(node); \
- struct XmlSnippet snippets[] = { \
- { "StatusCode", SNIPPET_NODE, (void**)&(status_code->StatusCode) }, \
- { "Value", SNIPPET_ATTRIBUTE, (void**)&(status_code->Value) }, \
- { NULL, 0, NULL} \
- };
-
-static LassoNodeClass *parent_class = NULL;
-
-static xmlNode*
-get_xmlNode(LassoNode *node)
-{
- xmlNode *xmlnode;
- snippets();
-
- xmlnode = xmlNewNode(NULL, "StatusCode");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX));
- build_xml_with_snippets(xmlnode, snippets);
-
- return xmlnode;
-}
-
-static int
-init_from_xml(LassoNode *node, xmlNode *xmlnode)
-{
- snippets();
-
- if (parent_class->init_from_xml(node, xmlnode))
- return -1;
- init_xml_with_snippets(xmlnode, snippets);
- return 0;
-}
+static struct XmlSnippet schema_snippets[] = {
+ { "StatusCode", SNIPPET_NODE, G_STRUCT_OFFSET(LassoSamlpStatusCode, StatusCode) },
+ { "Value", SNIPPET_ATTRIBUTE, G_STRUCT_OFFSET(LassoSamlpStatusCode, Value) },
+ { NULL, 0, 0}
+};
/*****************************************************************************/
/* instance and class init functions */
@@ -88,9 +60,12 @@ instance_init(LassoSamlpStatusCode *node)
static void
class_init(LassoSamlpStatusCodeClass *klass)
{
- parent_class = g_type_class_peek_parent(klass);
- LASSO_NODE_CLASS(klass)->get_xmlNode = get_xmlNode;
- LASSO_NODE_CLASS(klass)->init_from_xml = init_from_xml;
+ LassoNodeClass *nclass = LASSO_NODE_CLASS(klass);
+
+ nclass->node_data = g_new0(LassoNodeClassData, 1);
+ lasso_node_class_set_nodename(nclass, "StatusCode");
+ lasso_node_class_set_ns(nclass, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX);
+ lasso_node_class_add_snippets(nclass, schema_snippets);
}
GType
diff --git a/lasso/xml/utility_status.c b/lasso/xml/utility_status.c
index de2e46d1..f0673160 100644
--- a/lasso/xml/utility_status.c
+++ b/lasso/xml/utility_status.c
@@ -52,7 +52,7 @@
#define snippets() \
LassoUtilityStatus *status = LASSO_UTILITY_STATUS(node); \
- struct XmlSnippet snippets[] = { \
+ struct XmlSnippetObsolete snippets[] = { \
{ "Status", SNIPPET_NODE, (void**)&(status->Status) }, \
{ "code", SNIPPET_ATTRIBUTE, (void**)&(status->code) }, \
{ "ref", SNIPPET_ATTRIBUTE, (void**)&(status->ref) }, \
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index a0ca284e..107f4937 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -450,6 +450,82 @@ lasso_node_impl_destroy(LassoNode *node)
static int
lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
+ struct XmlSnippet *snippet;
+ xmlNode *t;
+ LassoNodeClass *class;
+ void *value;
+
+ class = LASSO_NODE_GET_CLASS(node);
+
+ if (class->node_data == NULL)
+ return 0;
+
+ while (class && LASSO_IS_NODE_CLASS(class) && class->node_data) {
+ for (snippet = class->node_data->snippets; snippet && snippet->name; snippet++) {
+ value = G_STRUCT_MEMBER_P(node, snippet->offset);
+ if (snippet->type == SNIPPET_ATTRIBUTE)
+ (*(char**)value) = xmlGetProp(xmlnode, snippet->name);
+ if (snippet->type == SNIPPET_ATTRIBUTE_INT) {
+ xmlChar *s = xmlGetProp(xmlnode, snippet->name);
+ (*(int*)value) = atoi(s);
+ xmlFree(s);
+ }
+ if (snippet->type == SNIPPET_TEXT_CHILD)
+ (*(char**)value) = xmlNodeGetContent(xmlnode);
+ }
+
+ for (t = xmlnode->children; t; t = t->next) {
+ if (t->type != XML_ELEMENT_NODE)
+ continue;
+
+ for (snippet = class->node_data->snippets;
+ snippet && snippet->name; snippet++) {
+ value = G_STRUCT_MEMBER_P(node, snippet->offset);
+
+ if (strcmp(t->name, snippet->name) != 0)
+ continue;
+
+ if (snippet->type == SNIPPET_NODE) {
+ LassoNode **location = value;
+ LassoNode *n = lasso_node_new_from_xmlNode(t);
+ *location = n;
+ }
+ else if (snippet->type == SNIPPET_CONTENT)
+ (*(char**)value) = xmlNodeGetContent(t);
+ else if (snippet->type == SNIPPET_CONTENT_BOOL) {
+ xmlChar *s = xmlNodeGetContent(t);
+ (*(gboolean*)value) = (strcmp(s, "true") == 0);
+ } else if (snippet->type == SNIPPET_CONTENT_INT) {
+ xmlChar *s = xmlNodeGetContent(t);
+ (*(gboolean*)value) = atoi(s);
+ } else if (snippet->type == SNIPPET_NAME_IDENTIFIER)
+ (*(LassoSamlNameIdentifier**)value) =
+ lasso_saml_name_identifier_new_from_xmlNode(t);
+ else if (snippet->type == SNIPPET_LIST_NODES) {
+ xmlNode *ts;
+ GList *s = NULL;
+ for (ts = t->children; ts; ts = ts->next) {
+ if (ts->type != XML_ELEMENT_NODE)
+ continue;
+ g_list_append(s, lasso_node_new_from_xmlNode(ts));
+ }
+ (*(GList**)value) = s;
+ } else if (snippet->type == SNIPPET_LIST_CONTENT) {
+ xmlNode *ts;
+ GList *s = NULL;
+ for (ts = t->children; ts; ts = ts->next) {
+ if (ts->type != XML_ELEMENT_NODE)
+ continue;
+ g_list_append(s, xmlNodeGetContent(ts));
+ }
+ (*(GList**)value) = s;
+ }
+ break;
+ }
+ }
+ class = g_type_class_peek_parent(class);
+ }
+
return 0;
}
@@ -462,18 +538,46 @@ lasso_node_impl_build_query(LassoNode *node)
return NULL;
}
+static xmlNode*
+lasso_node_impl_get_xmlNode(LassoNode *node)
+{
+ LassoNodeClass *class = LASSO_NODE_GET_CLASS(node);
+ xmlNode *xmlnode;
+ xmlNs *firstns = NULL;
+
+ if (class->node_data == NULL)
+ return NULL;
+
+ xmlnode = xmlNewNode(NULL, class->node_data->node_name);
+ while (class && LASSO_IS_NODE_CLASS(class) && class->node_data) {
+ if (firstns == NULL) firstns = class->node_data->ns;
+ xmlSetNs(xmlnode, class->node_data->ns);
+ lasso_node_build_xmlNode_from_snippets(node, xmlnode, class->node_data->snippets);
+ class = g_type_class_peek_parent(class);
+ }
+
+ class = LASSO_NODE_GET_CLASS(node);
+ xmlSetNs(xmlnode, firstns);
+
+ xmlReconciliateNs(NULL, xmlnode);
+
+ return xmlnode;
+}
+
/*****************************************************************************/
/* overrided parent class methods */
/*****************************************************************************/
static void
-lasso_node_dispose(LassoNode *node)
+lasso_node_dispose(GObject *object)
{
+ parent_class->dispose(object);
}
static void
-lasso_node_finalize(LassoNode *node)
+lasso_node_finalize(GObject *object)
{
+ parent_class->finalize(object);
}
/*****************************************************************************/
@@ -481,7 +585,7 @@ lasso_node_finalize(LassoNode *node)
/*****************************************************************************/
static void
-instance_init(LassoNode *instance)
+instance_init(LassoNode *node)
{
}
@@ -499,10 +603,13 @@ class_init(LassoNodeClass *class)
/* virtual private methods */
class->build_query = lasso_node_impl_build_query;
- class->get_xmlNode = NULL; /* nothing here */
- /* override parent class methods */
- gobject_class->dispose = (void *)lasso_node_dispose;
- gobject_class->finalize = (void *)lasso_node_finalize;
+ class->get_xmlNode = lasso_node_impl_get_xmlNode;
+
+ /* override */
+ gobject_class->dispose = lasso_node_dispose;
+ gobject_class->finalize = lasso_node_finalize;
+
+ class->node_data = NULL;
}
GType
@@ -722,7 +829,7 @@ lasso_node_init_from_message(LassoNode *node, const char *message)
}
void
-init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
+init_xml_with_snippets(xmlNode *node, struct XmlSnippetObsolete *snippets)
{
xmlNode *t;
int i;
@@ -771,7 +878,7 @@ init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
}
void
-build_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
+build_xml_with_snippets(xmlNode *node, struct XmlSnippetObsolete *snippets)
{
int i;
@@ -812,3 +919,96 @@ build_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
}
}
+
+/**
+ * lasso_node_class_add_snippets
+ * @klass: self
+ * @snippets: array of XmlSnippet (NULL terminated)
+ **/
+void
+lasso_node_class_add_snippets(LassoNodeClass *klass, struct XmlSnippet *snippets)
+{
+ klass->node_data->snippets = snippets;
+}
+
+
+void
+lasso_node_class_set_nodename(LassoNodeClass *klass, char *name)
+{
+ if (klass->node_data->node_name)
+ g_free(klass->node_data->node_name);
+ klass->node_data->node_name = g_strdup(name);
+}
+
+void
+lasso_node_class_set_ns(LassoNodeClass *klass, char *href, char *prefix)
+{
+ if (klass->node_data->ns)
+ xmlFreeNs(klass->node_data->ns);
+ klass->node_data->ns = xmlNewNs(NULL, href, prefix);
+}
+
+
+void
+lasso_node_build_xmlNode_from_snippets(LassoNode *node, xmlNode *xmlnode,
+ struct XmlSnippet *snippets)
+{
+ struct XmlSnippet *snippet;
+
+ if (snippets == NULL)
+ return;
+
+ for (snippet = snippets; snippet->name; snippet++) {
+ void *value = G_STRUCT_MEMBER(void*, node, snippet->offset);
+
+ if (value == NULL && (snippet->type != SNIPPET_ATTRIBUTE_INT &&
+ snippet->type != SNIPPET_CONTENT_BOOL &&
+ snippet->type != SNIPPET_CONTENT_INT))
+ continue;
+
+ if (snippet->type == SNIPPET_ATTRIBUTE)
+ xmlSetProp(xmlnode, snippet->name, (char*)value);
+ else if (snippet->type == SNIPPET_ATTRIBUTE_INT) {
+ char t[40];
+ g_snprintf(t, 40, "%d", GPOINTER_TO_INT(value));
+ xmlSetProp(xmlnode, snippet->name, t);
+ } else if (snippet->type == SNIPPET_TEXT_CHILD)
+ xmlAddChild(xmlnode, xmlNewText((char*)value));
+ else if (snippet->type == SNIPPET_NODE)
+ xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(value)));
+ else if (snippet->type == SNIPPET_CONTENT)
+ xmlNewTextChild(xmlnode, NULL, snippet->name, (char*)(value));
+ else if (snippet->type == SNIPPET_CONTENT_BOOL) {
+ char *s;
+ s = GPOINTER_TO_INT(value) ? "true" : "false";
+ xmlNewTextChild(xmlnode, NULL, snippet->name, s);
+ } else if (snippet->type == SNIPPET_CONTENT_INT) {
+ char t[40];
+ g_snprintf(t, 40, "%d", GPOINTER_TO_INT(value));
+ xmlNewTextChild(xmlnode, NULL, snippet->name, t);
+ } else if (snippet->type == SNIPPET_NAME_IDENTIFIER) {
+ xmlNode *t;
+ xmlNs *xmlns;
+ xmlns = xmlNewNs(NULL, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+
+ t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(value)));
+ xmlNodeSetName(t, snippet->name);
+ xmlSetNs(t, xmlns);
+ } else if (snippet->type == SNIPPET_LIST_NODES) {
+ GList *elem = (GList *)value;
+ while (elem) {
+ xmlAddChild(xmlnode,
+ lasso_node_get_xmlNode(LASSO_NODE(elem->data)));
+ elem = g_list_next(elem);
+ }
+ } else if (snippet->type == SNIPPET_LIST_CONTENT) {
+ /* sequence of simple elements (no children, no attrs, just content) */
+ GList *elem = (GList *)value;
+ while (elem) {
+ xmlNewTextChild(xmlnode, NULL, snippet->name, (char*)(elem->data));
+ elem = g_list_next(elem);
+ }
+ }
+ }
+}
+
diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h
index 8fd0440c..1c2f36f7 100644
--- a/lasso/xml/xml.h
+++ b/lasso/xml/xml.h
@@ -43,10 +43,6 @@ extern "C" {
#include <lasso/xml/strings.h>
#include <lasso/xml/tools.h>
-#ifdef LASSO_INTERNALS
-#include <lasso/xml/internals.h>
-#endif
-
#define LASSO_TYPE_NODE (lasso_node_get_type())
#define LASSO_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), LASSO_TYPE_NODE, LassoNode))
#define LASSO_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), LASSO_TYPE_NODE, LassoNodeClass))
@@ -71,6 +67,7 @@ typedef enum {
typedef struct _LassoNode LassoNode;
typedef struct _LassoNodeClass LassoNodeClass;
+typedef struct _LassoNodeClassData LassoNodeClassData;
/**
* _LassoNode:
@@ -81,6 +78,7 @@ struct _LassoNode {
struct _LassoNodeClass {
GObjectClass parent_class;
+ LassoNodeClassData *node_data;
void (* destroy) (LassoNode *node);
char* (* build_query) (LassoNode *node);
@@ -118,6 +116,10 @@ LASSO_EXPORT int lasso_node_init_from_xml(LassoNode *node, xmlNode *xmlnode);
LASSO_EXPORT gint lasso_node_verify_signature(LassoNode *node,
const char *public_key_file, const char *ca_cert_chain_file);
+#ifdef LASSO_INTERNALS
+#include <lasso/xml/internals.h>
+#endif
+
#ifdef __cplusplus
}
#endif /* __cplusplus */