summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lasso/xml/lib_authentication_statement.c16
-rw-r--r--lasso/xml/lib_authn_context.c26
-rw-r--r--lasso/xml/lib_authn_request.c78
-rw-r--r--lasso/xml/lib_authn_request_envelope.c52
-rw-r--r--lasso/xml/lib_authn_response.c26
-rw-r--r--lasso/xml/lib_authn_response_envelope.c30
-rw-r--r--lasso/xml/lib_federation_termination_notification.c28
-rw-r--r--lasso/xml/lib_idp_entries.c17
-rw-r--r--lasso/xml/lib_idp_entry.c22
-rw-r--r--lasso/xml/lib_idp_list.c18
-rw-r--r--lasso/xml/lib_logout_request.c35
-rw-r--r--lasso/xml/lib_name_identifier_mapping_request.c32
-rw-r--r--lasso/xml/lib_name_identifier_mapping_response.c32
-rw-r--r--lasso/xml/lib_register_name_identifier_request.c49
-rw-r--r--lasso/xml/lib_request_authn_context.c29
-rw-r--r--lasso/xml/lib_scoping.c24
-rw-r--r--lasso/xml/lib_status_response.c18
-rw-r--r--lasso/xml/lib_subject.c19
-rw-r--r--lasso/xml/saml_advice.c16
-rw-r--r--lasso/xml/saml_assertion.c30
-rw-r--r--lasso/xml/saml_audience_restriction_condition.c18
-rw-r--r--lasso/xml/saml_authentication_statement.c23
-rw-r--r--lasso/xml/saml_conditions.c23
-rw-r--r--lasso/xml/saml_subject.c24
-rw-r--r--lasso/xml/saml_subject_confirmation.c21
-rw-r--r--lasso/xml/saml_subject_statement_abstract.c24
-rw-r--r--lasso/xml/samlp_request.c18
-rw-r--r--lasso/xml/samlp_response.c22
-rw-r--r--lasso/xml/samlp_status.c22
-rw-r--r--lasso/xml/samlp_status_code.c17
-rw-r--r--lasso/xml/xml.c27
-rw-r--r--lasso/xml/xml.h10
32 files changed, 283 insertions, 563 deletions
diff --git a/lasso/xml/lib_authentication_statement.c b/lasso/xml/lib_authentication_statement.c
index afff1b36..cae6bbc7 100644
--- a/lasso/xml/lib_authentication_statement.c
+++ b/lasso/xml/lib_authentication_statement.c
@@ -72,24 +72,18 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthenticationStatement *statement = LASSO_LIB_AUTHENTICATION_STATEMENT(node);
- xmlNode *t;
int rc;
+ struct XmlSnippet snippets[] = {
+ { "AuthnContext", 'n', (void**)&(statement->AuthnContext) },
+ { NULL, 0, NULL}
+ };
rc = parent_class->init_from_xml(node, xmlnode);
if (rc) return rc;
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "AuthnContext") == 0) {
- statement->AuthnContext = LASSO_LIB_AUTHN_CONTEXT(
- lasso_node_new_from_xmlNode(t));
- break;
- }
- t = t->next;
- }
-
statement->ReauthenticateOnOrAfter = xmlGetProp(xmlnode, "ReauthenticateOnOrAfter");
statement->SessionIndex = xmlGetProp(xmlnode, "SessionIndex");
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_authn_context.c b/lasso/xml/lib_authn_context.c
index 8bb9e751..49acccf2 100644
--- a/lasso/xml/lib_authn_context.c
+++ b/lasso/xml/lib_authn_context.c
@@ -81,23 +81,15 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnContext *context = LASSO_LIB_AUTHN_CONTEXT(node);
- xmlNode *t;
- int rc;
-
- rc = parent_class->init_from_xml(node, xmlnode);
- if (rc)
- return rc;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE) {
- if (strcmp(t->name, "AuthnContextClassRef") == 0)
- context->AuthnContextClassRef = xmlNodeGetContent(t);
- if (strcmp(t->name, "AuthnContextStatementRef") == 0 )
- context->AuthnContextStatementRef = xmlNodeGetContent(t);
- }
- t = t->next;
- }
+ struct XmlSnippet snippets[] = {
+ { "AuthnContextClassRef", 'c', (void**)&(context->AuthnContextClassRef) },
+ { "AuthnContextStatementRef", 'c', (void**)&(context->AuthnContextStatementRef) },
+ { NULL, 0, NULL}
+ };
+
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_authn_request.c b/lasso/xml/lib_authn_request.c
index 7d3ad054..f99e9719 100644
--- a/lasso/xml/lib_authn_request.c
+++ b/lasso/xml/lib_authn_request.c
@@ -215,60 +215,36 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
xmlNode *t, *n;
char *s;
int rc;
+ char *force_authn = NULL, *is_passive = NULL;
+ struct XmlSnippet snippets[] = {
+ { "ProviderID", 'c', (void**)&(request->ProviderID) },
+ { "NameIDPolicy", 'c', (void**)&(request->NameIDPolicy) },
+ { "ProtocolProfile", 'c', (void**)&(request->ProtocolProfile) },
+ { "AssertionConsumerServiceID", 'c',
+ (void**)&(request->AssertionConsumerServiceID) },
+ /* XXX: RequestAuthnContext */
+ { "RelayState", 'c', (void**)&(request->RelayState) },
+ { "ForceAuthn", 'c', (void**)&force_authn },
+ { "IsPassive", 'c', (void**)&is_passive },
+ /* XXX: Scoping */
+ { NULL, 0, NULL}
+ };
+
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
- rc = parent_class->init_from_xml(node, xmlnode);
- if (rc)
- return rc;
+ request->consent = xmlGetProp(xmlnode, "consent");
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
- t = xmlnode->children;
- while (t) {
- n = t;
- t = t->next;
- if (n->type != XML_ELEMENT_NODE) {
- continue;
- }
- if (strcmp(n->name, "ProviderID") == 0) {
- request->ProviderID = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "NameIDPolicy") == 0) {
- request->NameIDPolicy = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "ForceAuthn") == 0) {
- s = xmlNodeGetContent(n);
- request->ForceAuthn = (strcmp(s, "true") == 0);
- xmlFree(s);
- continue;
- }
- if (strcmp(n->name, "IsPassive") == 0) {
- s = xmlNodeGetContent(n);
- request->IsPassive = (strcmp(s, "true") == 0);
- xmlFree(s);
- continue;
- }
- if (strcmp(n->name, "ProtocolProfile") == 0) {
- request->ProtocolProfile = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "AssertionConsumerServiceID") == 0) {
- request->AssertionConsumerServiceID = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "RequestAuthnContext") == 0) {
- /* XXX */
- continue;
- }
- if (strcmp(n->name, "RelayState") == 0) {
- request->RelayState = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "Scoping") == 0) {
- /* XXX */
- continue;
- }
+ if (is_passive) {
+ request->IsPassive = (strcmp(is_passive, "true") == 0);
+ xmlFree(is_passive);
}
- request->consent = xmlGetProp(xmlnode, "consent");
+ if (force_authn) {
+ request->ForceAuthn = (strcmp(force_authn, "true") == 0);
+ xmlFree(force_authn);
+ }
+
return 0;
}
diff --git a/lasso/xml/lib_authn_request_envelope.c b/lasso/xml/lib_authn_request_envelope.c
index a36c1eee..c0cad135 100644
--- a/lasso/xml/lib_authn_request_envelope.c
+++ b/lasso/xml/lib_authn_request_envelope.c
@@ -94,49 +94,27 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnRequestEnvelope *env = LASSO_LIB_AUTHN_REQUEST_ENVELOPE(node);
- xmlNode *t, *n;
- char *s;
+ char *is_passive = NULL;
+ struct XmlSnippet snippets[] = {
+ /* XXX: Extension */
+ { "ProviderID", 'c', (void**)&(env->ProviderID) },
+ { "ProviderName", 'c', (void**)&(env->ProviderName) },
+ { "AssertionConsumerServiceURL", 'c', (void**)&(env->AssertionConsumerServiceURL) },
+ { "IDPList", 'n', (void**)&(env->IDPList) },
+ { "IsPassive", 'c', (void**)&is_passive },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- n = t;
- t = t->next;
- if (n->type != XML_ELEMENT_NODE) {
- continue;
- }
- if (strcmp(n->name, "Extension") == 0) {
- /* XXX */
- continue;
- }
- if (strcmp(n->name, "ProviderID") == 0) {
- env->ProviderID = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "ProviderName") == 0) {
- env->ProviderName = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "AssertionConsumerServiceURL") == 0) {
- env->AssertionConsumerServiceURL = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "IDPList") == 0) {
- env->IDPList = LASSO_LIB_IDP_LIST(lasso_node_new_from_xmlNode(n));
- continue;
- }
- }
-
- s = xmlGetProp(xmlnode, "IsPassive");
- if (s) {
- env->IsPassive = (strcmp(s, "true") == 0);
- xmlFree(s);
+ lasso_node_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 */
diff --git a/lasso/xml/lib_authn_response.c b/lasso/xml/lib_authn_response.c
index eb53bf16..558e4763 100644
--- a/lasso/xml/lib_authn_response.c
+++ b/lasso/xml/lib_authn_response.c
@@ -85,23 +85,15 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnResponse *response = LASSO_LIB_AUTHN_RESPONSE(node);
- xmlNode *t;
- int rc;
-
- rc = parent_class->init_from_xml(node, xmlnode);
- if (rc)
- return rc;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProviderID") == 0) {
- response->ProviderID = xmlNodeGetContent(t);
- }
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "RelayState") == 0 ) {
- response->RelayState = xmlNodeGetContent(t);
- }
- t = t->next;
- }
+ struct XmlSnippet snippets[] = {
+ { "ProviderID", 'c', (void**)&(response->ProviderID) },
+ { "RelayState", 'c', (void**)&(response->RelayState) },
+ { NULL, 0, NULL}
+ };
+
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
response->consent = xmlGetProp(xmlnode, "consent");
return 0;
}
diff --git a/lasso/xml/lib_authn_response_envelope.c b/lasso/xml/lib_authn_response_envelope.c
index 36977a23..126fbcb8 100644
--- a/lasso/xml/lib_authn_response_envelope.c
+++ b/lasso/xml/lib_authn_response_envelope.c
@@ -57,32 +57,16 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node);
- xmlNode *t, *n;
+ struct XmlSnippet snippets[] = {
+ /* Extension */
+ { "AuthnResponse", 'n', (void**)&(env->AuthnResponse) },
+ { "AssertionConsumerServiceURL", 'c', (void**)&(env->AssertionConsumerServiceURL) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return 1;
-
- t = xmlnode->children;
- while (t) {
- n = t;
- t = t->next;
- if (n->type != XML_ELEMENT_NODE) {
- continue;
- }
- if (strcmp(n->name, "Extension") == 0) {
- /* XXX */
- continue;
- }
- if (strcmp(n->name, "AuthnResponse") == 0) {
- env->AuthnResponse = LASSO_LIB_AUTHN_RESPONSE(
- lasso_node_new_from_xmlNode(n));
- continue;
- }
- if (strcmp(n->name, "AssertionConsumerServiceURL") == 0) {
- env->AssertionConsumerServiceURL = xmlNodeGetContent(n);
- continue;
- }
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_federation_termination_notification.c b/lasso/xml/lib_federation_termination_notification.c
index ead6b065..d12277c8 100644
--- a/lasso/xml/lib_federation_termination_notification.c
+++ b/lasso/xml/lib_federation_termination_notification.c
@@ -86,30 +86,18 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibFederationTerminationNotification *ob;
- xmlNode *t, *n;
+ LassoLibFederationTerminationNotification *ob =
+ LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
+ struct XmlSnippet snippets[] = {
+ { "ProviderID", 'c', (void**)&(ob->ProviderID) },
+ { "NameIdentifier", 'n', (void**)&(ob->NameIdentifier) },
+ { NULL, 0, NULL}
+ };
- ob = LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
if (parent_class->init_from_xml(node, xmlnode))
return 1;
-
- t = xmlnode->children;
- while (t) {
- n = t;
- t = t->next;
- if (n->type != XML_ELEMENT_NODE)
- continue;
- if (strcmp(n->name, "ProviderID") == 0) {
- ob->ProviderID = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "NameIdentifier") == 0) {
- ob->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
- lasso_node_new_from_xmlNode(n));
- continue;
- }
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
ob->consent = xmlGetProp(xmlnode, "consent");
return 0;
}
diff --git a/lasso/xml/lib_idp_entries.c b/lasso/xml/lib_idp_entries.c
index 5829477e..acb46f0e 100644
--- a/lasso/xml/lib_idp_entries.c
+++ b/lasso/xml/lib_idp_entries.c
@@ -62,19 +62,14 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibIDPEntries *entries = LASSO_LIB_IDP_ENTRIES(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "IDPEntry", 'n', (void**)&(entries->IDPEntry) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
- return 1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "IDPEntry") == 0) {
- /* XXX: should actually be "add to list" */
- entries->IDPEntry = LASSO_LIB_IDP_ENTRY(lasso_node_new_from_xmlNode(t));
- }
- t = t->next;
- }
+ return -1;
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_idp_entry.c b/lasso/xml/lib_idp_entry.c
index 662cf79f..afc8d419 100644
--- a/lasso/xml/lib_idp_entry.c
+++ b/lasso/xml/lib_idp_entry.c
@@ -68,24 +68,16 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibIDPEntry *entry = LASSO_LIB_IDP_ENTRY(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "Loc", 'c', (void**)&(entry->Loc) },
+ { "ProviderID", 'c', (void**)&(entry->ProviderID) },
+ { "ProviderName", 'c', (void**)&(entry->ProviderName) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "Loc") == 0) {
- entry->Loc = xmlNodeGetContent(t);
- }
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProviderID") == 0) {
- entry->ProviderID = xmlNodeGetContent(t);
- }
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProviderName") == 0) {
- entry->ProviderName = xmlNodeGetContent(t);
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_idp_list.c b/lasso/xml/lib_idp_list.c
index ffe0fa6b..cc55395a 100644
--- a/lasso/xml/lib_idp_list.c
+++ b/lasso/xml/lib_idp_list.c
@@ -67,21 +67,15 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibIDPList *list = LASSO_LIB_IDP_LIST(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "IDPEntries", 'n', (void**)&(list->IDPEntries) },
+ { "GetComplete", 'c', (void**)&(list->GetComplete) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "IDPEntries") == 0) {
- list->IDPEntries = LASSO_LIB_IDP_ENTRIES(lasso_node_new_from_xmlNode(t));
- }
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "GetComplete") == 0) {
- list->GetComplete = xmlNodeGetContent(t);
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_logout_request.c b/lasso/xml/lib_logout_request.c
index bb1e22af..f70aa97e 100644
--- a/lasso/xml/lib_logout_request.c
+++ b/lasso/xml/lib_logout_request.c
@@ -170,36 +170,17 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node);
- xmlNode *t, *n;
+ struct XmlSnippet snippets[] = {
+ { "ProviderID", 'c', (void**)&(request->ProviderID) },
+ { "NameIdentifier", 'n', (void**)&(request->NameIdentifier) },
+ { "SessionIndex", 'c', (void**)&(request->SessionIndex) },
+ { "RelayState", 'c', (void**)&(request->RelayState) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- n = t;
- t = t->next;
- if (n->type != XML_ELEMENT_NODE) {
- continue;
- }
- if (strcmp(n->name, "ProviderID") == 0) {
- request->ProviderID = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "NameIdentifier") == 0) {
- request->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
- lasso_node_new_from_xmlNode(n));
- continue;
- }
- if (strcmp(n->name, "SessionIndex") == 0) {
- request->SessionIndex = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "RelayState") == 0) {
- request->RelayState = xmlNodeGetContent(n);
- continue;
- }
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
request->consent = xmlGetProp(xmlnode, "consent");
return 0;
}
diff --git a/lasso/xml/lib_name_identifier_mapping_request.c b/lasso/xml/lib_name_identifier_mapping_request.c
index 3e28e5e3..66a4e57f 100644
--- a/lasso/xml/lib_name_identifier_mapping_request.c
+++ b/lasso/xml/lib_name_identifier_mapping_request.c
@@ -90,32 +90,18 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibNameIdentifierMappingRequest *request;
- xmlNode *t;
-
- request = LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node);
+ LassoLibNameIdentifierMappingRequest *request =
+ LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node);
+ struct XmlSnippet snippets[] = {
+ { "ProviderID", 'c', (void**)&(request->ProviderID) },
+ { "NameIdentifier", 'n', (void**)&(request->NameIdentifier) },
+ { "TargetNamespace", 'c', (void**)&(request->TargetNamespace) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
- if (strcmp(t->name, "ProviderID") == 0) {
- request->ProviderID = xmlNodeGetContent(t);
- }
- if (strcmp(t->name, "NameIdentifier") == 0) {
- request->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
- lasso_node_new_from_xmlNode(t));
- }
- if (strcmp(t->name, "TargetNamespace") == 0) {
- request->TargetNamespace = xmlNodeGetContent(t);
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
request->consent = xmlGetProp(xmlnode, "consent");
return 0;
}
diff --git a/lasso/xml/lib_name_identifier_mapping_response.c b/lasso/xml/lib_name_identifier_mapping_response.c
index a5f9a68d..8dd1aac8 100644
--- a/lasso/xml/lib_name_identifier_mapping_response.c
+++ b/lasso/xml/lib_name_identifier_mapping_response.c
@@ -75,32 +75,18 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibNameIdentifierMappingResponse *response;
- xmlNode *t;
-
- response = LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node);
+ LassoLibNameIdentifierMappingResponse *response =
+ LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node);
+ struct XmlSnippet snippets[] = {
+ { "ProviderID", 'c', (void**)&(response->ProviderID) },
+ { "Status", 'n', (void**)&(response->Status) },
+ { "NameIdentifier", 'n', (void**)&(response->NameIdentifier) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
- if (strcmp(t->name, "ProviderID") == 0) {
- response->ProviderID = xmlNodeGetContent(t);
- }
- if (strcmp(t->name, "Status") == 0) {
- response->Status = LASSO_SAMLP_STATUS(lasso_node_new_from_xmlNode(t));
- }
- if (strcmp(t->name, "NameIdentifier") == 0) {
- response->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
- lasso_node_new_from_xmlNode(t));
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_register_name_identifier_request.c b/lasso/xml/lib_register_name_identifier_request.c
index b9442007..192af208 100644
--- a/lasso/xml/lib_register_name_identifier_request.c
+++ b/lasso/xml/lib_register_name_identifier_request.c
@@ -114,44 +114,23 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- xmlNode *t, *n;
- LassoLibRegisterNameIdentifierRequest *request;
-
- request = LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node);
+ LassoLibRegisterNameIdentifierRequest *request =
+ LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node);
+ struct XmlSnippet snippets[] = {
+ { "ProviderID", 'c', (void**)&(request->ProviderID) },
+ { "IDPProvidedNameIdentifier", 'i',
+ (void**)&(request->IDPProvidedNameIdentifier) },
+ { "SPProvidedNameIdentifier", 'i',
+ (void**)&(request->SPProvidedNameIdentifier) },
+ { "OldProvidedNameIdentifier", 'i',
+ (void**)&(request->OldProvidedNameIdentifier) },
+ { "RelayState", 'c', (void**)&(request->RelayState) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- n = t;
- t = t->next;
- if (n->type != XML_ELEMENT_NODE)
- continue;
- if (strcmp(n->name, "ProviderID") == 0) {
- request->ProviderID = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "IDPProvidedNameIdentifier") == 0) {
- request->IDPProvidedNameIdentifier =
- lasso_saml_name_identifier_new_from_xmlNode(n);
- continue;
- }
- if (strcmp(n->name, "SPProvidedNameIdentifier") == 0) {
- request->SPProvidedNameIdentifier =
- lasso_saml_name_identifier_new_from_xmlNode(n);
- continue;
- }
- if (strcmp(n->name, "OldProvidedNameIdentifier") == 0) {
- request->OldProvidedNameIdentifier =
- lasso_saml_name_identifier_new_from_xmlNode(n);
- continue;
- }
- if (strcmp(n->name, "RelayState") == 0) {
- request->RelayState = xmlNodeGetContent(n);
- continue;
- }
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_request_authn_context.c b/lasso/xml/lib_request_authn_context.c
index 1eda1ea3..5263fa7d 100644
--- a/lasso/xml/lib_request_authn_context.c
+++ b/lasso/xml/lib_request_authn_context.c
@@ -77,30 +77,17 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node);
- xmlNode *t, *n;
+ struct XmlSnippet snippets[] = {
+ { "AuthnContextClassRef", 'c', (void**)&(context->AuthnContextClassRef) },
+ { "AuthnContextStatementRef", 'c', (void**)&(context->AuthnContextStatementRef) },
+ { "AuthnContextComparisonType", 'c',
+ (void**)&(context->AuthnContextComparisonType) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- n = t;
- t = t->next;
- if (n->type != XML_ELEMENT_NODE)
- continue;
- if (strcmp(n->name, "AuthnContextClassRef") == 0) {
- context->AuthnContextClassRef = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "AuthnContextStatementRef") == 0) {
- context->AuthnContextStatementRef = xmlNodeGetContent(n);
- continue;
- }
- if (strcmp(n->name, "AuthnContextComparisonType") == 0) {
- context->AuthnContextComparisonType = xmlNodeGetContent(n);
- continue;
- }
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_scoping.c b/lasso/xml/lib_scoping.c
index 833d16b5..e750f7c8 100644
--- a/lasso/xml/lib_scoping.c
+++ b/lasso/xml/lib_scoping.c
@@ -67,23 +67,21 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibScoping *scoping = LASSO_LIB_SCOPING(node);
- xmlNode *t;
- char *s;
+ char *proxy_count = NULL;
+ struct XmlSnippet snippets[] = {
+ { "ProxyCount", 'c', (void**)&proxy_count },
+ { "IDPList", 'n', (void**)&(scoping->IDPList) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProxyCount") == 0) {
- s = xmlNodeGetContent(t);
- scoping->ProxyCount = atoi(s);
- xmlFree(s);
- }
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "IDPList") == 0)
- scoping->IDPList = LASSO_LIB_IDP_LIST(lasso_node_new_from_xmlNode(t));
- t = t->next;
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
+ if (proxy_count) {
+ scoping->ProxyCount = atoi(proxy_count);
+ xmlFree(proxy_count);
}
+
return 0;
}
diff --git a/lasso/xml/lib_status_response.c b/lasso/xml/lib_status_response.c
index 5a2a59d0..e8874dcd 100644
--- a/lasso/xml/lib_status_response.c
+++ b/lasso/xml/lib_status_response.c
@@ -86,20 +86,16 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "ProviderID", 'c', (void**)&(response->ProviderID) },
+ { "Status", 'n', (void**)&(response->Status) },
+ { "RelayState", 'c', (void**)&(response->RelayState) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "ProviderID") == 0)
- response->ProviderID = xmlNodeGetContent(t);
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "Status") == 0)
- response->Status = LASSO_SAMLP_STATUS(lasso_node_new_from_xmlNode(t));
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "RelayState") == 0)
- response->RelayState = xmlNodeGetContent(t);
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/lib_subject.c b/lasso/xml/lib_subject.c
index 339e10d7..fab82c4c 100644
--- a/lasso/xml/lib_subject.c
+++ b/lasso/xml/lib_subject.c
@@ -71,23 +71,14 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibSubject *subject = LASSO_LIB_SUBJECT(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "IDPProvidedNameIdentifier", 'i', (void**)&(subject->IDPProvidedNameIdentifier) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
- if (strcmp(t->name, "IDPProvidedNameIdentifier") != 0) {
- t = t->next;
- continue;
- }
- subject->IDPProvidedNameIdentifier = lasso_saml_name_identifier_new_from_xmlNode(t);
- break;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/saml_advice.c b/lasso/xml/saml_advice.c
index b7eb57bf..0ebd0329 100644
--- a/lasso/xml/saml_advice.c
+++ b/lasso/xml/saml_advice.c
@@ -70,19 +70,15 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlAdvice *advice = LASSO_SAML_ADVICE(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "AssertionIDReference", 'c', (void**)&(advice->AssertionIDReference) },
+ { "Assertion", 'n', (void**)&(advice->Assertion) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "AssertionIDReference") == 0)
- advice->AssertionIDReference = xmlNodeGetContent(t);
- if (t->type == XML_ELEMENT_NODE && strcmp(t->name, "Assertion") == 0)
- advice->Assertion = lasso_node_new_from_xmlNode(t);
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/saml_assertion.c b/lasso/xml/saml_assertion.c
index 8802bd04..12c976ac 100644
--- a/lasso/xml/saml_assertion.c
+++ b/lasso/xml/saml_assertion.c
@@ -134,8 +134,14 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
char *s;
- xmlNode *t;
LassoSamlAssertion *assertion = LASSO_SAML_ASSERTION(node);
+ struct XmlSnippet snippets[] = {
+ { "Conditions", 'n', (void**)&(assertion->Conditions) },
+ { "Advice", 'n', (void**)&(assertion->Advice) },
+ { "SubjectStatement", 'n', (void**)&(assertion->SubjectStatement) },
+ { "AuthenticationStatement", 'n', (void**)&(assertion->AuthenticationStatement) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
@@ -154,28 +160,8 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
xmlFree(s);
}
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
-
- if (strcmp(t->name, "Conditions") == 0)
- assertion->Conditions = LASSO_SAML_CONDITIONS(
- lasso_node_new_from_xmlNode(t));
- if (strcmp(t->name, "Advice") == 0)
- assertion->Advice = LASSO_SAML_ADVICE(
- lasso_node_new_from_xmlNode(t));
- if (strcmp(t->name, "SubjectStatement") == 0)
- assertion->SubjectStatement = LASSO_SAML_SUBJECT_STATEMENT(
- lasso_node_new_from_xmlNode(t));
- if (strcmp(t->name, "AuthenticationStatement") == 0)
- assertion->AuthenticationStatement = LASSO_SAML_AUTHENTICATION_STATEMENT(
- lasso_node_new_from_xmlNode(t));
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
- t = t->next;
- }
return 0;
}
diff --git a/lasso/xml/saml_audience_restriction_condition.c b/lasso/xml/saml_audience_restriction_condition.c
index f4548bf6..fc4e3914 100644
--- a/lasso/xml/saml_audience_restriction_condition.c
+++ b/lasso/xml/saml_audience_restriction_condition.c
@@ -67,20 +67,16 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlAudienceRestrictionCondition *condition;
- xmlNode *t;
+ LassoSamlAudienceRestrictionCondition *condition =
+ LASSO_SAML_AUDIENCE_RESTRICTION_CONDITION(node);
+ struct XmlSnippet snippets[] = {
+ { "Audience", 'c', (void**)&(condition->Audience) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE) {
- if (strcmp(t->name, "Audience") == 0)
- condition->Audience = xmlNodeGetContent(t);
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/saml_authentication_statement.c b/lasso/xml/saml_authentication_statement.c
index 27369319..f4f40736 100644
--- a/lasso/xml/saml_authentication_statement.c
+++ b/lasso/xml/saml_authentication_statement.c
@@ -76,28 +76,17 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlAuthenticationStatement *statement = LASSO_SAML_AUTHENTICATION_STATEMENT(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "SubjectLocality", 'n', (void**)&(statement->SubjectLocality) },
+ { "AuthorityBinding", 'n', (void**)&(statement->AuthorityBinding) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
statement->AuthenticationMethod = xmlGetProp(xmlnode, "AuthenticationMethod");
statement->AuthenticationInstant = xmlGetProp(xmlnode, "AuthenticationInstant");
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE) {
- if (strcmp(t->name, "SubjectLocality") == 0) {
- statement->SubjectLocality = LASSO_SAML_SUBJECT_LOCALITY(
- lasso_node_new_from_xmlNode(t));
- }
- if (strcmp(t->name, "AuthorityBinding") == 0) {
- statement->AuthorityBinding = LASSO_SAML_AUTHORITY_BINDING(
- lasso_node_new_from_xmlNode(t));
- }
- }
- t = t->next;
- }
return 0;
}
diff --git a/lasso/xml/saml_conditions.c b/lasso/xml/saml_conditions.c
index 7108db1c..7bc9a06f 100644
--- a/lasso/xml/saml_conditions.c
+++ b/lasso/xml/saml_conditions.c
@@ -68,27 +68,18 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlConditions *conditions = LASSO_SAML_CONDITIONS(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "AudienceRestrictionCondition", 'n',
+ (void**)&(conditions->AudienceRestrictionCondition) },
+ { NULL, 0, NULL}
+ };
+
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
conditions->NotBefore = xmlGetProp(xmlnode, "NotBefore");
conditions->NotOnOrAfter = xmlGetProp(xmlnode, "NotOnOrAfter");
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
-
- if (strcmp(t->name, "AudienceRestrictionCondition") == 0) {
- conditions->AudienceRestrictionCondition =
- LASSO_SAML_AUDIENCE_RESTRICTION_CONDITION(
- lasso_node_new_from_xmlNode(t));
- }
- t = t->next;
- }
return 0;
}
diff --git a/lasso/xml/saml_subject.c b/lasso/xml/saml_subject.c
index e80f0861..202d60aa 100644
--- a/lasso/xml/saml_subject.c
+++ b/lasso/xml/saml_subject.c
@@ -69,28 +69,16 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- xmlNode *t;
LassoSamlSubject *subject = LASSO_SAML_SUBJECT(node);
+ struct XmlSnippet snippets[] = {
+ { "NameIdentifier", 'n', (void**)&(subject->NameIdentifier) },
+ { "SubjectConfirmation", 'n', (void**)&(subject->SubjectConfirmation) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
- if (strcmp(t->name, "NameIdentifier") == 0) {
- subject->NameIdentifier = LASSO_SAML_NAME_IDENTIFIER(
- lasso_node_new_from_xmlNode(t));
- }
- if (strcmp(t->name, "SubjectConfirmation") == 0) {
- subject->SubjectConfirmation = LASSO_SAML_SUBJECT_CONFIRMATION(
- lasso_node_new_from_xmlNode(t));
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/saml_subject_confirmation.c b/lasso/xml/saml_subject_confirmation.c
index 86dc9759..317632c8 100644
--- a/lasso/xml/saml_subject_confirmation.c
+++ b/lasso/xml/saml_subject_confirmation.c
@@ -67,25 +67,16 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- xmlNode *t;
LassoSamlSubjectConfirmation *confirm = LASSO_SAML_SUBJECT_CONFIRMATION(node);
+ struct XmlSnippet snippets[] = {
+ { "ConfirmationMethod", 'c', (void**)&(confirm->ConfirmationMethod) },
+ { "SubjectConfirmationData", 'c', (void**)&(confirm->SubjectConfirmationData) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
-
- if (strcmp(t->name, "ConfirmationMethod") == 0)
- confirm->ConfirmationMethod = xmlNodeGetContent(t);
- if (strcmp(t->name, "SubjectConfirmationData") == 0)
- confirm->SubjectConfirmationData = xmlNodeGetContent(t);
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/saml_subject_statement_abstract.c b/lasso/xml/saml_subject_statement_abstract.c
index fb2a96e0..f8cb32e9 100644
--- a/lasso/xml/saml_subject_statement_abstract.c
+++ b/lasso/xml/saml_subject_statement_abstract.c
@@ -64,26 +64,16 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- xmlNode *t;
- LassoSamlSubjectStatementAbstract *statement;
+ LassoSamlSubjectStatementAbstract *statement =
+ LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(node);
+ struct XmlSnippet snippets[] = {
+ { "Subject", 'n', (void**)&(statement->Subject) },
+ { NULL, 0, NULL}
+ };
- statement = LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(node);
-
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
-
- if (strcmp(t->name, "Subject") == 0)
- statement->Subject = LASSO_SAML_SUBJECT(
- lasso_node_new_from_xmlNode(t));
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/samlp_request.c b/lasso/xml/samlp_request.c
index 958fd1df..079fe154 100644
--- a/lasso/xml/samlp_request.c
+++ b/lasso/xml/samlp_request.c
@@ -68,21 +68,15 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- xmlNode *t;
+ LassoSamlpRequest *request = LASSO_SAMLP_REQUEST(node);
+ struct XmlSnippet snippets[] = {
+ { "AssertionArtifact", 'c', (void**)&(request->AssertionArtifact) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE) {
- if (strcmp(t->name, "AssertionArtifact") == 0) {
- LASSO_SAMLP_REQUEST(node)->AssertionArtifact = xmlNodeGetContent(t);
- break;
- }
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/samlp_response.c b/lasso/xml/samlp_response.c
index c5545702..fc2bc8cd 100644
--- a/lasso/xml/samlp_response.c
+++ b/lasso/xml/samlp_response.c
@@ -79,26 +79,16 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- xmlNode *t;
LassoSamlpResponse *response = LASSO_SAMLP_RESPONSE(node);
+ struct XmlSnippet snippets[] = {
+ { "Assertion", 'n', (void**)&(response->Assertion) },
+ { "Status", 'n', (void**)&(response->Status) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type == XML_ELEMENT_NODE) {
- if (strcmp(t->name, "Assertion") == 0) {
- response->Assertion = LASSO_SAML_ASSERTION(
- lasso_node_new_from_xmlNode(t));
- }
- if (strcmp(t->name, "Status") == 0) {
- response->Status = LASSO_SAMLP_STATUS(
- lasso_node_new_from_xmlNode(t));
- }
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/samlp_status.c b/lasso/xml/samlp_status.c
index 542dd1a1..8c3c876a 100644
--- a/lasso/xml/samlp_status.c
+++ b/lasso/xml/samlp_status.c
@@ -66,26 +66,16 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- xmlNode *t;
LassoSamlpStatus *status = LASSO_SAMLP_STATUS(node);
+ struct XmlSnippet snippets[] = {
+ { "StatusCode", 'n', (void**)&(status->StatusCode) },
+ { "StatusMessage", 'c', (void**)&(status->StatusMessage) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE) {
- t = t->next;
- continue;
- }
- if (strcmp(t->name, "StatusCode") == 0) {
- status->StatusCode = LASSO_SAMLP_STATUS_CODE(lasso_node_new_from_xmlNode(t));
- }
- if (strcmp(t->name, "StatusMessage") == 0) {
- status->StatusMessage = xmlNodeGetContent(t);
- }
- t = t->next;
- }
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
return 0;
}
diff --git a/lasso/xml/samlp_status_code.c b/lasso/xml/samlp_status_code.c
index a1c64a32..98529e5c 100644
--- a/lasso/xml/samlp_status_code.c
+++ b/lasso/xml/samlp_status_code.c
@@ -64,22 +64,15 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlpStatusCode *status_code = LASSO_SAMLP_STATUS_CODE(node);
- xmlNode *t;
+ struct XmlSnippet snippets[] = {
+ { "StatusCode", 'n', (void**)&(status_code->StatusCode) },
+ { NULL, 0, NULL}
+ };
if (parent_class->init_from_xml(node, xmlnode))
return -1;
-
+ lasso_node_init_xml_with_snippets(xmlnode, snippets);
status_code->Value = xmlGetProp(xmlnode, "Value");
- t = xmlnode->children;
- while (t) {
- if (t->type != XML_ELEMENT_NODE || strcmp(t->name, "StatusCode") != 0) {
- t = t->next;
- continue;
- }
- status_code->StatusCode = LASSO_SAMLP_STATUS_CODE(lasso_node_new_from_xmlNode(t));
- break;
- }
-
return 0;
}
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index 2a82737e..8b251578 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -725,3 +725,30 @@ lasso_node_init_from_message(LassoNode *node, const char *message)
return LASSO_MESSAGE_FORMAT_UNKNOWN;
}
+void
+lasso_node_init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
+{
+ xmlNode *t;
+ int i;
+
+ t = node->children;
+ for (t = node->children; t; t = t->next) {
+ if (t->type != XML_ELEMENT_NODE)
+ continue;
+
+ for (i = 0; snippets[i].name; i++) {
+ if (strcmp(t->name, snippets[i].name) != 0)
+ continue;
+ if (snippets[i].type == 'n') /* node */
+ *(snippets[i].value) = lasso_node_new_from_xmlNode(t);
+ if (snippets[i].type == 'c') /* content */
+ *(snippets[i].value) = xmlNodeGetContent(t);
+ if (snippets[i].type == 'i') /* special case for name identifier */
+ *(snippets[i].value) =
+ lasso_saml_name_identifier_new_from_xmlNode(t);
+ break;
+ }
+ }
+
+}
+
diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h
index acf972d8..c88b88fd 100644
--- a/lasso/xml/xml.h
+++ b/lasso/xml/xml.h
@@ -70,6 +70,12 @@ typedef struct _xmlAttr LassoAttr;
typedef struct _LassoNode LassoNode;
typedef struct _LassoNodeClass LassoNodeClass;
+struct XmlSnippet {
+ char *name;
+ char type;
+ void **value;
+};
+
/**
* _LassoNode:
**/
@@ -115,6 +121,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);
+
+void lasso_node_init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets);
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */