summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2004-11-17 23:04:57 +0000
committerFrederic Peters <fpeters@entrouvert.com>2004-11-17 23:04:57 +0000
commit59bdda3549b13cbe97ce49fdb541f8bad006f08e (patch)
tree5f8809c208fafea2e5fda8078b032636ebece261
parentcfc07351978eef632c1b06f06f7246c2860cfc9c (diff)
downloadlasso-59bdda3549b13cbe97ce49fdb541f8bad006f08e.tar.gz
lasso-59bdda3549b13cbe97ce49fdb541f8bad006f08e.tar.xz
lasso-59bdda3549b13cbe97ce49fdb541f8bad006f08e.zip
use same "xmlsnippets" (name will probably change) to build xml nodes
-rw-r--r--lasso/xml/lib_authentication_statement.c28
-rw-r--r--lasso/xml/lib_authn_context.c24
-rw-r--r--lasso/xml/lib_authn_request.c69
-rw-r--r--lasso/xml/lib_authn_request_envelope.c44
-rw-r--r--lasso/xml/lib_authn_response.c25
-rw-r--r--lasso/xml/lib_authn_response_envelope.c29
-rw-r--r--lasso/xml/lib_federation_termination_notification.c28
-rw-r--r--lasso/xml/lib_idp_entries.c19
-rw-r--r--lasso/xml/lib_idp_entry.c27
-rw-r--r--lasso/xml/lib_idp_list.c24
-rw-r--r--lasso/xml/lib_logout_request.c33
-rw-r--r--lasso/xml/lib_name_identifier_mapping_request.c31
-rw-r--r--lasso/xml/lib_name_identifier_mapping_response.c31
-rw-r--r--lasso/xml/lib_register_name_identifier_request.c64
-rw-r--r--lasso/xml/lib_request_authn_context.c32
-rw-r--r--lasso/xml/lib_scoping.c30
-rw-r--r--lasso/xml/lib_status_response.c29
-rw-r--r--lasso/xml/lib_subject.c26
-rw-r--r--lasso/xml/saml_advice.c22
-rw-r--r--lasso/xml/saml_assertion.c33
-rw-r--r--lasso/xml/saml_audience_restriction_condition.c22
-rw-r--r--lasso/xml/saml_authentication_statement.c24
-rw-r--r--lasso/xml/saml_conditions.c23
-rw-r--r--lasso/xml/saml_subject.c29
-rw-r--r--lasso/xml/saml_subject_confirmation.c23
-rw-r--r--lasso/xml/saml_subject_statement_abstract.c22
-rw-r--r--lasso/xml/samlp_request.c18
-rw-r--r--lasso/xml/samlp_response.c39
-rw-r--r--lasso/xml/samlp_status.c23
-rw-r--r--lasso/xml/samlp_status_code.c22
-rw-r--r--lasso/xml/xml.c29
-rw-r--r--lasso/xml/xml.h1
32 files changed, 423 insertions, 500 deletions
diff --git a/lasso/xml/lib_authentication_statement.c b/lasso/xml/lib_authentication_statement.c
index cae6bbc7..4472ccb4 100644
--- a/lasso/xml/lib_authentication_statement.c
+++ b/lasso/xml/lib_authentication_statement.c
@@ -47,39 +47,35 @@ The schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibAuthenticationStatement *statement = LASSO_LIB_AUTHENTICATION_STATEMENT(node); \
+ struct XmlSnippet snippets[] = { \
+ { "AuthnContext", 'n', (void**)&(statement->AuthnContext) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibAuthenticationStatement *statement = LASSO_LIB_AUTHENTICATION_STATEMENT(node);
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
- if (statement->AuthnContext)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(statement->AuthnContext)));
- if (statement->ReauthenticateOnOrAfter)
- xmlSetProp(xmlnode, "ReauthenticateOnOrAfter", statement->ReauthenticateOnOrAfter);
- if (statement->SessionIndex)
- xmlSetProp(xmlnode, "SessionIndex", statement->SessionIndex);
-
return xmlnode;
}
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibAuthenticationStatement *statement = LASSO_LIB_AUTHENTICATION_STATEMENT(node);
- int rc;
- struct XmlSnippet snippets[] = {
- { "AuthnContext", 'n', (void**)&(statement->AuthnContext) },
- { NULL, 0, NULL}
- };
+ snippets();
- rc = parent_class->init_from_xml(node, xmlnode);
- if (rc) return rc;
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
statement->ReauthenticateOnOrAfter = xmlGetProp(xmlnode, "ReauthenticateOnOrAfter");
statement->SessionIndex = xmlGetProp(xmlnode, "SessionIndex");
diff --git a/lasso/xml/lib_authn_context.c b/lasso/xml/lib_authn_context.c
index 49acccf2..cbdbb03a 100644
--- a/lasso/xml/lib_authn_context.c
+++ b/lasso/xml/lib_authn_context.c
@@ -56,23 +56,26 @@ From schema liberty-authentication-context-v1.2.xsd:
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibAuthnContext *context = LASSO_LIB_AUTHN_CONTEXT(node); \
+ struct XmlSnippet snippets[] = { \
+ { "AuthnContextClassRef", 'c', (void**)&(context->AuthnContextClassRef) }, \
+ { "AuthnContextStatementRef", 'c', (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);
- if (LASSO_LIB_AUTHN_CONTEXT(node)->AuthnContextClassRef)
- xmlNewTextChild(xmlnode, NULL, "AuthnContextClassRef",
- LASSO_LIB_AUTHN_CONTEXT(node)->AuthnContextClassRef);
- if (LASSO_LIB_AUTHN_CONTEXT(node)->AuthnContextStatementRef)
- xmlNewTextChild(xmlnode, NULL, "AuthnContextStatementRef",
- LASSO_LIB_AUTHN_CONTEXT(node)->AuthnContextStatementRef);
-
xmlNodeSetName(xmlnode, "AuthnContext");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -80,12 +83,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibAuthnContext *context = LASSO_LIB_AUTHN_CONTEXT(node);
- struct XmlSnippet snippets[] = {
- { "AuthnContextClassRef", 'c', (void**)&(context->AuthnContextClassRef) },
- { "AuthnContextStatementRef", 'c', (void**)&(context->AuthnContextStatementRef) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_authn_request.c b/lasso/xml/lib_authn_request.c
index f99e9719..ea8d2a0f 100644
--- a/lasso/xml/lib_authn_request.c
+++ b/lasso/xml/lib_authn_request.c
@@ -81,48 +81,45 @@ From liberty-metadata-v1.0.xsd:
*/
-static LassoNodeClass *parent_class = NULL;
-
-
/*****************************************************************************/
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(node); \
+ 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} \
+ };
+
+static LassoNodeClass *parent_class = NULL;
+
static xmlNode*
get_xmlNode(LassoNode *node)
{
- LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(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));
- if (request->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", request->ProviderID);
- if (request->AffiliationID)
- xmlNewTextChild(xmlnode, NULL, "AffiliationID", request->AffiliationID);
- if (request->NameIDPolicy)
- xmlNewTextChild(xmlnode, NULL, "NameIDPolicy", request->NameIDPolicy);
- if (request->ProtocolProfile)
- xmlNewTextChild(xmlnode, NULL, "ProtocolProfile", request->ProtocolProfile);
- if (request->AssertionConsumerServiceID)
- xmlNewTextChild(xmlnode, NULL, "AssertionConsumerServiceID",
- request->AssertionConsumerServiceID);
- if (request->RelayState)
- xmlNewTextChild(xmlnode, NULL, "RelayState", request->RelayState);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
if (request->consent)
xmlSetProp(xmlnode, "consent", request->consent);
- xmlNewTextChild(xmlnode, NULL, "IsPassive", request->IsPassive ? "true" : "false");
- xmlNewTextChild(xmlnode, NULL, "ForceAuthn", request->ForceAuthn ? "true" : "false");
-
- if (request->RequestAuthnContext)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(request->RequestAuthnContext)));
- if (request->Scoping)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(request->Scoping)));
-
return xmlnode;
}
@@ -211,25 +208,11 @@ init_from_query(LassoNode *node, char **query_fields)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(node);
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}
- };
-
+ snippets();
+
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_authn_request_envelope.c b/lasso/xml/lib_authn_request_envelope.c
index c0cad135..380f274f 100644
--- a/lasso/xml/lib_authn_request_envelope.c
+++ b/lasso/xml/lib_authn_request_envelope.c
@@ -62,30 +62,32 @@
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibAuthnRequestEnvelope *env = LASSO_LIB_AUTHN_REQUEST_ENVELOPE(node); \
+ 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} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibAuthnRequestEnvelope *env = LASSO_LIB_AUTHN_REQUEST_ENVELOPE(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "AuthnRequestEnvelope");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (env->Extension)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->Extension)));
- if (env->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", env->ProviderID);
- if (env->ProviderName)
- xmlNewTextChild(xmlnode, NULL, "ProviderName", env->ProviderName);
- if (env->AssertionConsumerServiceURL)
- xmlNewTextChild(xmlnode, NULL, "AssertionConsumerServiceURL",
- env->AssertionConsumerServiceURL);
- if (env->IDPList)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->IDPList)));
-
- xmlNewTextChild(xmlnode, NULL, "IsPassive", env->IsPassive ? "true" : "false");
+ is_passive = env->IsPassive ? "true" : "false";
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -93,17 +95,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibAuthnRequestEnvelope *env = LASSO_LIB_AUTHN_REQUEST_ENVELOPE(node);
- 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}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_authn_response.c b/lasso/xml/lib_authn_response.c
index 558e4763..238c888b 100644
--- a/lasso/xml/lib_authn_response.c
+++ b/lasso/xml/lib_authn_response.c
@@ -57,24 +57,26 @@ From liberty-metadata-v1.0.xsd:
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibAuthnResponse *response = LASSO_LIB_AUTHN_RESPONSE(node); \
+ struct XmlSnippet snippets[] = { \
+ { "ProviderID", 'c', (void**)&(response->ProviderID) }, \
+ { "RelayState", 'c', (void**)&(response->RelayState) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
- LassoLibAuthnResponse *response = LASSO_LIB_AUTHN_RESPONSE(node);
xmlNode *xmlnode;
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "AuthnResponse");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (response->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", response->ProviderID);
-
- if (response->RelayState)
- xmlNewTextChild(xmlnode, NULL, "RelayState", response->RelayState);
-
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
if (response->consent)
xmlSetProp(xmlnode, "consent", response->consent);
@@ -84,12 +86,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibAuthnResponse *response = LASSO_LIB_AUTHN_RESPONSE(node);
- struct XmlSnippet snippets[] = {
- { "ProviderID", 'c', (void**)&(response->ProviderID) },
- { "RelayState", 'c', (void**)&(response->RelayState) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_authn_response_envelope.c b/lasso/xml/lib_authn_response_envelope.c
index 126fbcb8..ecef55bb 100644
--- a/lasso/xml/lib_authn_response_envelope.c
+++ b/lasso/xml/lib_authn_response_envelope.c
@@ -31,24 +31,27 @@
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node); \
+ struct XmlSnippet snippets[] = { \
+ /* Extension */ \
+ { "AuthnResponse", 'n', (void**)&(env->AuthnResponse) }, \
+ { "AssertionConsumerServiceURL", 'c', \
+ (void**)&(env->AssertionConsumerServiceURL) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "AuthnResponseEnvelope");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (env->Extension)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->Extension)));
- if (env->AuthnResponse)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(env->AuthnResponse)));
- if (env->AssertionConsumerServiceURL)
- xmlNewTextChild(xmlnode, NULL, "AssertionConsumerServiceURL",
- env->AssertionConsumerServiceURL);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -56,13 +59,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node);
- struct XmlSnippet snippets[] = {
- /* Extension */
- { "AuthnResponse", 'n', (void**)&(env->AuthnResponse) },
- { "AssertionConsumerServiceURL", 'c', (void**)&(env->AssertionConsumerServiceURL) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return 1;
diff --git a/lasso/xml/lib_federation_termination_notification.c b/lasso/xml/lib_federation_termination_notification.c
index d12277c8..25b738b4 100644
--- a/lasso/xml/lib_federation_termination_notification.c
+++ b/lasso/xml/lib_federation_termination_notification.c
@@ -58,24 +58,27 @@ From liberty-metadata-v1.0.xsd:
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibFederationTerminationNotification *ob = \
+ LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node); \
+ struct XmlSnippet snippets[] = { \
+ { "ProviderID", 'c', (void**)&(ob->ProviderID) }, \
+ { "NameIdentifier", 'n', (void**)&(ob->NameIdentifier) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibFederationTerminationNotification *ob;
-
- ob = LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "FederationTerminationNotification");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (ob->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", ob->ProviderID);
- if (ob->NameIdentifier)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(ob->NameIdentifier)));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
if (ob->consent)
xmlSetProp(xmlnode, "consent", ob->consent);
@@ -86,14 +89,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibFederationTerminationNotification *ob =
- LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
- struct XmlSnippet snippets[] = {
- { "ProviderID", 'c', (void**)&(ob->ProviderID) },
- { "NameIdentifier", 'n', (void**)&(ob->NameIdentifier) },
- { NULL, 0, NULL}
- };
-
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return 1;
diff --git a/lasso/xml/lib_idp_entries.c b/lasso/xml/lib_idp_entries.c
index acb46f0e..94088971 100644
--- a/lasso/xml/lib_idp_entries.c
+++ b/lasso/xml/lib_idp_entries.c
@@ -41,19 +41,24 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibIDPEntries *entries = LASSO_LIB_IDP_ENTRIES(node); \
+ struct XmlSnippet snippets[] = { \
+ { "IDPEntry", 'n', (void**)&(entries->IDPEntry) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibIDPEntries *entries = LASSO_LIB_IDP_ENTRIES(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "IDPEntries");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (entries->IDPEntry)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(entries->IDPEntry)));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -61,11 +66,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibIDPEntries *entries = LASSO_LIB_IDP_ENTRIES(node);
- struct XmlSnippet snippets[] = {
- { "IDPEntry", 'n', (void**)&(entries->IDPEntry) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_idp_entry.c b/lasso/xml/lib_idp_entry.c
index afc8d419..dbe9ff2c 100644
--- a/lasso/xml/lib_idp_entry.c
+++ b/lasso/xml/lib_idp_entry.c
@@ -43,23 +43,26 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibIDPEntry *entry = LASSO_LIB_IDP_ENTRY(node); \
+ struct XmlSnippet snippets[] = { \
+ { "Loc", 'c', (void**)&(entry->Loc) }, \
+ { "ProviderID", 'c', (void**)&(entry->ProviderID) }, \
+ { "ProviderName", 'c', (void**)&(entry->ProviderName) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibIDPEntry *entry = LASSO_LIB_IDP_ENTRY(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "IDPEntry");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (entry->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", entry->ProviderID);
- if (entry->ProviderName)
- xmlNewTextChild(xmlnode, NULL, "ProviderName", entry->ProviderName);
- if (entry->Loc)
- xmlNewTextChild(xmlnode, NULL, "Loc", entry->Loc);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -67,13 +70,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibIDPEntry *entry = LASSO_LIB_IDP_ENTRY(node);
- struct XmlSnippet snippets[] = {
- { "Loc", 'c', (void**)&(entry->Loc) },
- { "ProviderID", 'c', (void**)&(entry->ProviderID) },
- { "ProviderName", 'c', (void**)&(entry->ProviderName) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_idp_list.c b/lasso/xml/lib_idp_list.c
index cc55395a..f6265dbb 100644
--- a/lasso/xml/lib_idp_list.c
+++ b/lasso/xml/lib_idp_list.c
@@ -43,22 +43,25 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibIDPList *list = LASSO_LIB_IDP_LIST(node); \
+ struct XmlSnippet snippets[] = { \
+ { "IDPEntries", 'n', (void**)&(list->IDPEntries) }, \
+ { "GetComplete", 'c', (void**)&(list->GetComplete) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibIDPList *list = LASSO_LIB_IDP_LIST(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "IDPList");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (list->IDPEntries)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(list->IDPEntries)));
-
- if (list->GetComplete)
- xmlNewTextChild(xmlnode, NULL, "GetComplete", list->GetComplete);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -66,12 +69,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibIDPList *list = LASSO_LIB_IDP_LIST(node);
- struct XmlSnippet snippets[] = {
- { "IDPEntries", 'n', (void**)&(list->IDPEntries) },
- { "GetComplete", 'c', (void**)&(list->GetComplete) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_logout_request.c b/lasso/xml/lib_logout_request.c
index f70aa97e..26fa1705 100644
--- a/lasso/xml/lib_logout_request.c
+++ b/lasso/xml/lib_logout_request.c
@@ -61,27 +61,29 @@ From liberty-metadata-v1.0.xsd:
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node); \
+ 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} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
- LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node);
xmlNode *xmlnode;
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "LogoutRequest");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- if (request->Extension)
- xmlNewTextChild(xmlnode, NULL, "Extension", request->Extension);
- if (request->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", request->ProviderID);
- if (request->NameIdentifier)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(request->NameIdentifier)));
- if (request->SessionIndex)
- xmlNewTextChild(xmlnode, NULL, "SessionIndex", request->SessionIndex);
- if (request->RelayState)
- xmlNewTextChild(xmlnode, NULL, "RelayState", request->RelayState);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
+
if (request->consent)
xmlSetProp(xmlnode, "consent", request->consent);
@@ -169,14 +171,7 @@ init_from_query(LassoNode *node, char **query_fields)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node);
- 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}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_name_identifier_mapping_request.c b/lasso/xml/lib_name_identifier_mapping_request.c
index 66a4e57f..1f6c0b90 100644
--- a/lasso/xml/lib_name_identifier_mapping_request.c
+++ b/lasso/xml/lib_name_identifier_mapping_request.c
@@ -58,28 +58,30 @@ From liberty-metadata-v1.0.xsd:
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ 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} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibNameIdentifierMappingRequest *request;
+ 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));
-
- if (request->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", request->ProviderID);
-
- if (request->NameIdentifier)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(request->NameIdentifier)));
-
- if (request->TargetNamespace)
- xmlNewTextChild(xmlnode, NULL, "TargetNamespace", request->TargetNamespace);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
if (request->consent)
xmlSetProp(xmlnode, "consent", request->consent);
@@ -90,14 +92,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- 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}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_name_identifier_mapping_response.c b/lasso/xml/lib_name_identifier_mapping_response.c
index 8dd1aac8..b1caba6a 100644
--- a/lasso/xml/lib_name_identifier_mapping_response.c
+++ b/lasso/xml/lib_name_identifier_mapping_response.c
@@ -48,26 +48,28 @@ The Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ 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} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibNameIdentifierMappingResponse *response;
+ snippets();
- response = LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node);
-
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "NameIdentifierMappingResponse");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (response->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", response->ProviderID);
- if (response->Status)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(response->Status)));
- if (response->NameIdentifier)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(response->NameIdentifier)));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -75,14 +77,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- 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}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_register_name_identifier_request.c b/lasso/xml/lib_register_name_identifier_request.c
index 192af208..d93db7b3 100644
--- a/lasso/xml/lib_register_name_identifier_request.c
+++ b/lasso/xml/lib_register_name_identifier_request.c
@@ -64,49 +64,35 @@ From liberty-metadata-v1.0.xsd:
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ 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} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
- xmlNode *xmlnode, *t;
- LassoLibRegisterNameIdentifierRequest *request;
+ xmlNode *xmlnode;
xmlNs *xmlns;
-
- request = LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node);
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "RegisterNameIdentifierRequest");
xmlns = xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
xmlSetNs(xmlnode, xmlns);
-
- if (request->Extension)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(request->Extension));
- if (request->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", request->ProviderID);
-
- if (request->IDPProvidedNameIdentifier) {
- t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(request->IDPProvidedNameIdentifier)));
- xmlNodeSetName(t, "IDPProvidedNameIdentifier");
- xmlSetNs(t, xmlns);
- }
-
- if (request->SPProvidedNameIdentifier) {
- t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(request->SPProvidedNameIdentifier)));
- xmlNodeSetName(t, "SPProvidedNameIdentifier");
- xmlSetNs(t, xmlns);
- }
-
- if (request->OldProvidedNameIdentifier) {
- t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(request->OldProvidedNameIdentifier)));
- xmlNodeSetName(t, "OldProvidedNameIdentifier");
- xmlSetNs(t, xmlns);
- }
- if (request->RelayState)
- xmlNewTextChild(xmlnode, NULL, "RelayState", request->RelayState);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -114,19 +100,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- 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}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_request_authn_context.c b/lasso/xml/lib_request_authn_context.c
index 5263fa7d..4a72216f 100644
--- a/lasso/xml/lib_request_authn_context.c
+++ b/lasso/xml/lib_request_authn_context.c
@@ -48,27 +48,28 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node); \
+ struct XmlSnippet snippets[] = { \
+ { "AuthnContextClassRef", 'c', (void**)&(context->AuthnContextClassRef) }, \
+ { "AuthnContextStatementRef", 'c', (void**)&(context->AuthnContextStatementRef) }, \
+ { "AuthnContextComparisonType", 'c', \
+ (void**)&(context->AuthnContextComparisonType) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node);
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "RequestAuthnContext");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (context->AuthnContextClassRef)
- xmlNewTextChild(xmlnode, NULL,
- "AuthnContextClassRef", context->AuthnContextClassRef);
- if (context->AuthnContextStatementRef)
- xmlNewTextChild(xmlnode, NULL,
- "AuthnContextStatementRef", context->AuthnContextStatementRef);
- if (context->AuthnContextComparisonType)
- xmlNewTextChild(xmlnode, NULL,
- "AuthnContextComparisonType", context->AuthnContextComparisonType);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -76,14 +77,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node);
- struct XmlSnippet snippets[] = {
- { "AuthnContextClassRef", 'c', (void**)&(context->AuthnContextClassRef) },
- { "AuthnContextStatementRef", 'c', (void**)&(context->AuthnContextStatementRef) },
- { "AuthnContextComparisonType", 'c',
- (void**)&(context->AuthnContextComparisonType) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_scoping.c b/lasso/xml/lib_scoping.c
index e750f7c8..72be82fd 100644
--- a/lasso/xml/lib_scoping.c
+++ b/lasso/xml/lib_scoping.c
@@ -41,24 +41,32 @@ Schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibScoping *scoping = LASSO_LIB_SCOPING(node); \
+ char *proxy_count = NULL; \
+ struct XmlSnippet snippets[] = { \
+ { "ProxyCount", 'c', (void**)&proxy_count }, \
+ { "IDPList", 'n', (void**)&(scoping->IDPList) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibScoping *scoping = LASSO_LIB_SCOPING(node);
- char s[20];
+ snippets();
xmlnode = xmlNewNode(NULL, "Scoping");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
if (scoping->ProxyCount) {
- snprintf(s, 19, "%d", scoping->ProxyCount);
- xmlNewTextChild(xmlnode, NULL, "ProxyCount", s);
+ proxy_count = g_strdup_printf("%d", scoping->ProxyCount);
}
- if (scoping->IDPList)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(scoping->IDPList)));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
+
+ if (proxy_count)
+ g_free(proxy_count);
return xmlnode;
}
@@ -66,13 +74,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibScoping *scoping = LASSO_LIB_SCOPING(node);
- char *proxy_count = NULL;
- struct XmlSnippet snippets[] = {
- { "ProxyCount", 'c', (void**)&proxy_count },
- { "IDPList", 'n', (void**)&(scoping->IDPList) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_status_response.c b/lasso/xml/lib_status_response.c
index e8874dcd..a68c403b 100644
--- a/lasso/xml/lib_status_response.c
+++ b/lasso/xml/lib_status_response.c
@@ -58,26 +58,27 @@ From liberty-metadata-v1.0.xsd:
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node); \
+ struct XmlSnippet snippets[] = { \
+ { "ProviderID", 'c', (void**)&(response->ProviderID) }, \
+ { "Status", 'n', (void**)&(response->Status) }, \
+ { "RelayState", 'c', (void**)&(response->RelayState) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node);
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "StatusResponse");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (response->ProviderID)
- xmlNewTextChild(xmlnode, NULL, "ProviderID", response->ProviderID);
-
- if (response->Status)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(response->Status)));
-
- if (response->RelayState)
- xmlNewTextChild(xmlnode, NULL, "RelayState", response->RelayState);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -85,13 +86,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node);
- struct XmlSnippet snippets[] = {
- { "ProviderID", 'c', (void**)&(response->ProviderID) },
- { "Status", 'n', (void**)&(response->Status) },
- { "RelayState", 'c', (void**)&(response->RelayState) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/lib_subject.c b/lasso/xml/lib_subject.c
index fab82c4c..88a9b020 100644
--- a/lasso/xml/lib_subject.c
+++ b/lasso/xml/lib_subject.c
@@ -45,23 +45,25 @@ The schema fragment (liberty-idff-protocols-schema-v1.2.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoLibSubject *subject = LASSO_LIB_SUBJECT(node); \
+ struct XmlSnippet snippets[] = { \
+ { "IDPProvidedNameIdentifier", 'i', \
+ (void**)&(subject->IDPProvidedNameIdentifier) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
- xmlNode *xmlnode, *t;
- LassoLibSubject *subject = LASSO_LIB_SUBJECT(node);
+ xmlNode *xmlnode;
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
-
- if (subject->IDPProvidedNameIdentifier) {
- t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(subject->IDPProvidedNameIdentifier)));
- xmlNodeSetName(xmlnode, "IDPProvidedNameIdentifier");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_LIB_HREF, LASSO_LIB_PREFIX));
- }
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -70,11 +72,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoLibSubject *subject = LASSO_LIB_SUBJECT(node);
- struct XmlSnippet snippets[] = {
- { "IDPProvidedNameIdentifier", 'i', (void**)&(subject->IDPProvidedNameIdentifier) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/saml_advice.c b/lasso/xml/saml_advice.c
index 0ebd0329..3b2f355d 100644
--- a/lasso/xml/saml_advice.c
+++ b/lasso/xml/saml_advice.c
@@ -48,20 +48,25 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlAdvice *advice = LASSO_SAML_ADVICE(node); \
+ struct XmlSnippet snippets[] = { \
+ { "AssertionIDReference", 'c', (void**)&(advice->AssertionIDReference) }, \
+ { "Assertion", 'n', (void**)&(advice->Assertion) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlAdvice *advice = LASSO_SAML_ADVICE(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "Advice");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- if (advice->AssertionIDReference)
- xmlNewTextChild(xmlnode, NULL, "AssertionIDReference", advice->AssertionIDReference);
- if (advice->Assertion)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(advice->Assertion)));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -69,12 +74,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlAdvice *advice = LASSO_SAML_ADVICE(node);
- struct XmlSnippet snippets[] = {
- { "AssertionIDReference", 'c', (void**)&(advice->AssertionIDReference) },
- { "Assertion", 'n', (void**)&(advice->Assertion) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/saml_assertion.c b/lasso/xml/saml_assertion.c
index 12c976ac..34157a39 100644
--- a/lasso/xml/saml_assertion.c
+++ b/lasso/xml/saml_assertion.c
@@ -60,6 +60,16 @@ From oasis-sstc-saml-schema-assertion-1.0.xsd:
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ 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} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static void
@@ -97,9 +107,9 @@ static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlAssertion *assertion = LASSO_SAML_ASSERTION(node);
xmlNs *ns;
char s[10];
+ snippets();
xmlnode = xmlNewNode(NULL, "Assertion");
xmlSetProp(xmlnode, "AssertionID", assertion->AssertionID);
@@ -114,17 +124,7 @@ get_xmlNode(LassoNode *node)
if (assertion->IssueInstant)
xmlSetProp(xmlnode, "IssueInstant", assertion->IssueInstant);
- if (assertion->Conditions)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(assertion->Conditions)));
- if (assertion->Advice)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(assertion->Advice)));
- if (assertion->AuthenticationStatement)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(assertion->AuthenticationStatement)));
- if (assertion->SubjectStatement)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(assertion->SubjectStatement)));
-
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
insure_namespace(xmlnode, ns);
return xmlnode;
@@ -134,14 +134,7 @@ static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
char *s;
- 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}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/saml_audience_restriction_condition.c b/lasso/xml/saml_audience_restriction_condition.c
index fc4e3914..e1fcb3eb 100644
--- a/lasso/xml/saml_audience_restriction_condition.c
+++ b/lasso/xml/saml_audience_restriction_condition.c
@@ -46,20 +46,25 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlAudienceRestrictionCondition *condition = \
+ LASSO_SAML_AUDIENCE_RESTRICTION_CONDITION(node); \
+ struct XmlSnippet snippets[] = { \
+ { "Audience", 'c', (void**)&(condition->Audience) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlAudienceRestrictionCondition *condition;
-
- condition = LASSO_SAML_AUDIENCE_RESTRICTION_CONDITION(node);
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "AudienceRestrictionCondition");
- if (condition->Audience)
- xmlNewTextChild(xmlnode, NULL, "Audience", condition->Audience);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -67,12 +72,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlAudienceRestrictionCondition *condition =
- LASSO_SAML_AUDIENCE_RESTRICTION_CONDITION(node);
- struct XmlSnippet snippets[] = {
- { "Audience", 'c', (void**)&(condition->Audience) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/saml_authentication_statement.c b/lasso/xml/saml_authentication_statement.c
index f4f40736..60bd3d96 100644
--- a/lasso/xml/saml_authentication_statement.c
+++ b/lasso/xml/saml_authentication_statement.c
@@ -47,23 +47,26 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlAuthenticationStatement *statement = LASSO_SAML_AUTHENTICATION_STATEMENT(node); \
+ struct XmlSnippet snippets[] = { \
+ { "SubjectLocality", 'n', (void**)&(statement->SubjectLocality) }, \
+ { "AuthorityBinding", 'n', (void**)&(statement->AuthorityBinding) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlAuthenticationStatement *statement = LASSO_SAML_AUTHENTICATION_STATEMENT(node);
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "AuthenticationStatement");
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
- if (statement->SubjectLocality)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(statement->SubjectLocality)));
- if (statement->AuthorityBinding)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(statement->AuthorityBinding)));
if (statement->AuthenticationMethod)
xmlSetProp(xmlnode, "AuthenticationMethod", statement->AuthenticationMethod);
if (statement->AuthenticationInstant)
@@ -75,12 +78,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlAuthenticationStatement *statement = LASSO_SAML_AUTHENTICATION_STATEMENT(node);
- struct XmlSnippet snippets[] = {
- { "SubjectLocality", 'n', (void**)&(statement->SubjectLocality) },
- { "AuthorityBinding", 'n', (void**)&(statement->AuthorityBinding) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/saml_conditions.c b/lasso/xml/saml_conditions.c
index 7bc9a06f..ae97f630 100644
--- a/lasso/xml/saml_conditions.c
+++ b/lasso/xml/saml_conditions.c
@@ -43,19 +43,26 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlConditions *conditions = LASSO_SAML_CONDITIONS(node); \
+ struct XmlSnippet snippets[] = { \
+ { "AudienceRestrictionCondition", 'n', \
+ (void**)&(conditions->AudienceRestrictionCondition) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlConditions *conditions = LASSO_SAML_CONDITIONS(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "Conditions");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- if (conditions->AudienceRestrictionCondition)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(conditions->AudienceRestrictionCondition)));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
+
if (conditions->NotBefore)
xmlSetProp(xmlnode, "NotBefore", conditions->NotBefore);
if (conditions->NotOnOrAfter)
@@ -67,13 +74,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlConditions *conditions = LASSO_SAML_CONDITIONS(node);
- struct XmlSnippet snippets[] = {
- { "AudienceRestrictionCondition", 'n',
- (void**)&(conditions->AudienceRestrictionCondition) },
- { NULL, 0, NULL}
- };
-
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/saml_subject.c b/lasso/xml/saml_subject.c
index 202d60aa..3a5f9279 100644
--- a/lasso/xml/saml_subject.c
+++ b/lasso/xml/saml_subject.c
@@ -44,24 +44,26 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlSubject *subject = LASSO_SAML_SUBJECT(node); \
+ struct XmlSnippet snippets[] = { \
+ { "NameIdentifier", 'n', (void**)&(subject->NameIdentifier) }, \
+ { "SubjectConfirmation", 'n', (void**)&(subject->SubjectConfirmation) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
- LassoSamlSubject *subject = LASSO_SAML_SUBJECT(node);
xmlNode *xmlnode;
+ snippets();
xmlnode = xmlNewNode(NULL, "Subject");
- xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
-
- if (subject->NameIdentifier)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(subject->NameIdentifier)));
-
- if (subject->SubjectConfirmation)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(subject->SubjectConfirmation)));
+ xmlSetNs(xmlnode, xmlNewNs(xmlnode,
+ LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -69,12 +71,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlSubject *subject = LASSO_SAML_SUBJECT(node);
- struct XmlSnippet snippets[] = {
- { "NameIdentifier", 'n', (void**)&(subject->NameIdentifier) },
- { "SubjectConfirmation", 'n', (void**)&(subject->SubjectConfirmation) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/saml_subject_confirmation.c b/lasso/xml/saml_subject_confirmation.c
index 317632c8..d25c65c3 100644
--- a/lasso/xml/saml_subject_confirmation.c
+++ b/lasso/xml/saml_subject_confirmation.c
@@ -45,21 +45,25 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlSubjectConfirmation *confirm = LASSO_SAML_SUBJECT_CONFIRMATION(node); \
+ struct XmlSnippet snippets[] = { \
+ { "ConfirmationMethod", 'c', (void**)&(confirm->ConfirmationMethod) }, \
+ { "SubjectConfirmationData", 'c', (void**)&(confirm->SubjectConfirmationData) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlSubjectConfirmation *confirm = LASSO_SAML_SUBJECT_CONFIRMATION(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "SubjectConfirmation");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_ASSERTION_HREF, LASSO_SAML_ASSERTION_PREFIX));
- if (confirm->ConfirmationMethod)
- xmlNewTextChild(xmlnode, NULL, "ConfirmationMethod", confirm->ConfirmationMethod);
- if (confirm->SubjectConfirmationData)
- xmlNewTextChild(xmlnode, NULL, "SubjectConfirmationMethod",
- confirm->SubjectConfirmationData);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -67,12 +71,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlSubjectConfirmation *confirm = LASSO_SAML_SUBJECT_CONFIRMATION(node);
- struct XmlSnippet snippets[] = {
- { "ConfirmationMethod", 'c', (void**)&(confirm->ConfirmationMethod) },
- { "SubjectConfirmationData", 'c', (void**)&(confirm->SubjectConfirmationData) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/saml_subject_statement_abstract.c b/lasso/xml/saml_subject_statement_abstract.c
index f8cb32e9..8c95d15c 100644
--- a/lasso/xml/saml_subject_statement_abstract.c
+++ b/lasso/xml/saml_subject_statement_abstract.c
@@ -43,20 +43,25 @@ The schema fragment (oasis-sstc-saml-schema-assertion-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlSubjectStatementAbstract *statement = \
+ LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(node); \
+ struct XmlSnippet snippets[] = { \
+ { "Subject", 'n', (void**)&(statement->Subject) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlSubjectStatementAbstract *statement;
-
- statement = LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(node);
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "SubjectStatementAbstract");
- if (statement->Subject)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(statement->Subject)));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -64,12 +69,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlSubjectStatementAbstract *statement =
- LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(node);
- struct XmlSnippet snippets[] = {
- { "Subject", 'n', (void**)&(statement->Subject) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/samlp_request.c b/lasso/xml/samlp_request.c
index 079fe154..e6a17bb2 100644
--- a/lasso/xml/samlp_request.c
+++ b/lasso/xml/samlp_request.c
@@ -51,28 +51,32 @@
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlpRequest *request = LASSO_SAMLP_REQUEST(node); \
+ struct XmlSnippet snippets[] = { \
+ { "AssertionArtifact", 'c', (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);
- xmlNewTextChild(xmlnode, NULL, "AssertionArtifact",
- LASSO_SAMLP_REQUEST(node)->AssertionArtifact);
xmlNodeSetName(xmlnode, "Request");
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
+
return xmlnode;
}
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlpRequest *request = LASSO_SAMLP_REQUEST(node);
- struct XmlSnippet snippets[] = {
- { "AssertionArtifact", 'c', (void**)&(request->AssertionArtifact) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/samlp_response.c b/lasso/xml/samlp_response.c
index fc2bc8cd..8a089432 100644
--- a/lasso/xml/samlp_response.c
+++ b/lasso/xml/samlp_response.c
@@ -47,30 +47,34 @@ Schema fragment (oasis-sstc-saml-schema-protocol-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlpResponse *response = LASSO_SAMLP_RESPONSE(node); \
+ struct XmlSnippet snippets[] = { \
+ { "Assertion", 'n', (void**)&(response->Assertion) }, \
+ { "Status", 'n', (void**)&(response->Status) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode, *t;
+ snippets();
xmlnode = parent_class->get_xmlNode(node);
xmlNodeSetName(xmlnode, "Response");
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
- if (LASSO_SAMLP_RESPONSE(node)->Status) /* XXX: is mandatory */
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(LASSO_SAMLP_RESPONSE(node)->Status)));
-
- if (LASSO_SAMLP_RESPONSE(node)->Assertion) {
- t = xmlAddChild(xmlnode, lasso_node_get_xmlNode(
- LASSO_NODE(LASSO_SAMLP_RESPONSE(node)->Assertion)));
- if (strcmp(t->ns->href, LASSO_LIB_HREF) == 0) {
- /* 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");
- }
+ for (t = xmlnode->children; t && strcmp(t->name, "Assertion"); t = t->next) ;
+
+ if (t && strcmp(t->ns->href, LASSO_LIB_HREF) == 0) {
+ /* 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");
}
return xmlnode;
@@ -79,12 +83,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlpResponse *response = LASSO_SAMLP_RESPONSE(node);
- struct XmlSnippet snippets[] = {
- { "Assertion", 'n', (void**)&(response->Assertion) },
- { "Status", 'n', (void**)&(response->Status) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/samlp_status.c b/lasso/xml/samlp_status.c
index 8c3c876a..9e0c1659 100644
--- a/lasso/xml/samlp_status.c
+++ b/lasso/xml/samlp_status.c
@@ -44,21 +44,25 @@ Schema fragment (oasis-sstc-saml-schema-protocol-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlpStatus *status = LASSO_SAMLP_STATUS(node); \
+ struct XmlSnippet snippets[] = { \
+ { "StatusCode", 'n', (void**)&(status->StatusCode) }, \
+ { "StatusMessage", 'c', (void**)&(status->StatusMessage) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlpStatus *status = LASSO_SAMLP_STATUS(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "Status");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX));
- if (status->StatusCode)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(status->StatusCode)));
-
- if (status->StatusMessage)
- xmlNewTextChild(xmlnode, NULL, "StatusMessage", status->StatusMessage);
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
return xmlnode;
}
@@ -66,12 +70,7 @@ get_xmlNode(LassoNode *node)
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlpStatus *status = LASSO_SAMLP_STATUS(node);
- struct XmlSnippet snippets[] = {
- { "StatusCode", 'n', (void**)&(status->StatusCode) },
- { "StatusMessage", 'c', (void**)&(status->StatusMessage) },
- { NULL, 0, NULL}
- };
+ snippets();
if (parent_class->init_from_xml(node, xmlnode))
return -1;
diff --git a/lasso/xml/samlp_status_code.c b/lasso/xml/samlp_status_code.c
index 98529e5c..87846c1a 100644
--- a/lasso/xml/samlp_status_code.c
+++ b/lasso/xml/samlp_status_code.c
@@ -41,34 +41,36 @@ Schema fragment (oasis-sstc-saml-schema-protocol-1.0.xsd):
/* private methods */
/*****************************************************************************/
+#define snippets() \
+ LassoSamlpStatusCode *status_code = LASSO_SAMLP_STATUS_CODE(node); \
+ struct XmlSnippet snippets[] = { \
+ { "StatusCode", 'n', (void**)&(status_code->StatusCode) }, \
+ { NULL, 0, NULL} \
+ };
+
static LassoNodeClass *parent_class = NULL;
static xmlNode*
get_xmlNode(LassoNode *node)
{
xmlNode *xmlnode;
- LassoSamlpStatusCode *status_code = LASSO_SAMLP_STATUS_CODE(node);
+ snippets();
xmlnode = xmlNewNode(NULL, "StatusCode");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, LASSO_SAML_PROTOCOL_HREF, LASSO_SAML_PROTOCOL_PREFIX));
+ lasso_node_build_xml_with_snippets(xmlnode, snippets);
+
if (status_code->Value)
xmlSetProp(xmlnode, "Value", status_code->Value);
- if (status_code->StatusCode)
- xmlAddChild(xmlnode, lasso_node_get_xmlNode(LASSO_NODE(status_code->StatusCode)));
-
return xmlnode;
}
static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- LassoSamlpStatusCode *status_code = LASSO_SAMLP_STATUS_CODE(node);
- struct XmlSnippet snippets[] = {
- { "StatusCode", 'n', (void**)&(status_code->StatusCode) },
- { NULL, 0, NULL}
- };
-
+ snippets();
+
if (parent_class->init_from_xml(node, xmlnode))
return -1;
lasso_node_init_xml_with_snippets(xmlnode, snippets);
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index 8b251578..3702887b 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -744,7 +744,7 @@ lasso_node_init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
if (snippets[i].type == 'c') /* content */
*(snippets[i].value) = xmlNodeGetContent(t);
if (snippets[i].type == 'i') /* special case for name identifier */
- *(snippets[i].value) =
+ *(snippets[i].value) = (void*)
lasso_saml_name_identifier_new_from_xmlNode(t);
break;
}
@@ -752,3 +752,30 @@ lasso_node_init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
}
+void
+lasso_node_build_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets)
+{
+ int i;
+
+ for (i = 0; snippets[i].name; i++) {
+ if (*(snippets[i].value) == NULL)
+ continue;
+ if (snippets[i].type == 'n')
+ xmlAddChild(node, lasso_node_get_xmlNode(
+ LASSO_NODE(*(snippets[i].value))));
+ if (snippets[i].type == 'c')
+ xmlNewTextChild(node, NULL, snippets[i].name,
+ (char*)(*(snippets[i].value)));
+ if (snippets[i].type == 'i') {
+ xmlNode *t;
+ xmlNs *xmlns;
+ xmlns = xmlNewNs(node, LASSO_LIB_HREF, LASSO_LIB_PREFIX);
+
+ t = xmlAddChild(node, lasso_node_get_xmlNode(
+ LASSO_NODE(*(snippets[i].value))));
+ xmlNodeSetName(t, snippets[i].name);
+ xmlSetNs(t, xmlns);
+ }
+ }
+}
+
diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h
index c88b88fd..a6e7e032 100644
--- a/lasso/xml/xml.h
+++ b/lasso/xml/xml.h
@@ -123,6 +123,7 @@ LASSO_EXPORT gint lasso_node_verify_signature(LassoNode *node,
void lasso_node_init_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets);
+void lasso_node_build_xml_with_snippets(xmlNode *node, struct XmlSnippet *snippets);
#ifdef __cplusplus