summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2004-11-09 09:08:47 +0000
committerFrederic Peters <fpeters@entrouvert.com>2004-11-09 09:08:47 +0000
commit07e1b7c04f5d623fd624640dffe9ce2a02030422 (patch)
tree9075164bfd0aa136f8a12a8134728420cf60174c
parent9f1fa16723b0a8f34433b010f4669618e128d0cc (diff)
downloadlasso-07e1b7c04f5d623fd624640dffe9ce2a02030422.tar.gz
lasso-07e1b7c04f5d623fd624640dffe9ce2a02030422.tar.xz
lasso-07e1b7c04f5d623fd624640dffe9ce2a02030422.zip
return value on init_from_xml; and minor tweaks to code style
-rw-r--r--lasso/id-ff/federation.c4
-rw-r--r--lasso/id-ff/identity.c4
-rw-r--r--lasso/id-ff/login.c7
-rw-r--r--lasso/id-ff/logout.c158
-rw-r--r--lasso/id-ff/name_registration.c22
-rw-r--r--lasso/id-ff/profile.c6
-rw-r--r--lasso/id-ff/provider.c7
-rw-r--r--lasso/id-ff/server.c27
-rw-r--r--lasso/id-ff/session.c3
-rw-r--r--lasso/xml/lib_assertion.c6
-rw-r--r--lasso/xml/lib_authentication_statement.c8
-rw-r--r--lasso/xml/lib_authn_context.c9
-rw-r--r--lasso/xml/lib_authn_request.c9
-rw-r--r--lasso/xml/lib_authn_request_envelope.c6
-rw-r--r--lasso/xml/lib_authn_response.c8
-rw-r--r--lasso/xml/lib_authn_response_envelope.c7
-rw-r--r--lasso/xml/lib_federation_termination_notification.c6
-rw-r--r--lasso/xml/lib_idp_entries.c7
-rw-r--r--lasso/xml/lib_idp_entry.c8
-rw-r--r--lasso/xml/lib_idp_list.c7
-rw-r--r--lasso/xml/lib_logout_request.c6
-rw-r--r--lasso/xml/lib_name_identifier_mapping_request.c7
-rw-r--r--lasso/xml/lib_name_identifier_mapping_response.c7
-rw-r--r--lasso/xml/lib_register_name_identifier_request.c7
-rw-r--r--lasso/xml/lib_request_authn_context.c6
-rw-r--r--lasso/xml/lib_scoping.c7
-rw-r--r--lasso/xml/lib_status_response.c6
-rw-r--r--lasso/xml/lib_subject.c6
-rw-r--r--lasso/xml/saml_advice.c7
-rw-r--r--lasso/xml/saml_assertion.c8
-rw-r--r--lasso/xml/saml_audience_restriction_condition.c6
-rw-r--r--lasso/xml/saml_authentication_statement.c7
-rw-r--r--lasso/xml/saml_authority_binding.c8
-rw-r--r--lasso/xml/saml_conditions.c7
-rw-r--r--lasso/xml/saml_name_identifier.c8
-rw-r--r--lasso/xml/saml_subject.c6
-rw-r--r--lasso/xml/saml_subject_confirmation.c7
-rw-r--r--lasso/xml/saml_subject_locality.c6
-rw-r--r--lasso/xml/saml_subject_statement_abstract.c7
-rw-r--r--lasso/xml/samlp_request.c6
-rw-r--r--lasso/xml/samlp_request_abstract.c6
-rw-r--r--lasso/xml/samlp_response.c6
-rw-r--r--lasso/xml/samlp_response_abstract.c6
-rw-r--r--lasso/xml/samlp_status.c7
-rw-r--r--lasso/xml/samlp_status_code.c3
-rw-r--r--lasso/xml/tools.c225
-rw-r--r--lasso/xml/tools.h9
-rw-r--r--lasso/xml/xml.c29
-rw-r--r--lasso/xml/xml.h4
49 files changed, 418 insertions, 331 deletions
diff --git a/lasso/id-ff/federation.c b/lasso/id-ff/federation.c
index dd62036b..026efc65 100644
--- a/lasso/id-ff/federation.c
+++ b/lasso/id-ff/federation.c
@@ -156,7 +156,7 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoFederation *federation = LASSO_FEDERATION(node);
@@ -187,9 +187,9 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
lasso_node_new_from_xmlNode(n));
}
}
-
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/id-ff/identity.c b/lasso/id-ff/identity.c
index e4ae6f64..1d416c29 100644
--- a/lasso/id-ff/identity.c
+++ b/lasso/id-ff/identity.c
@@ -96,7 +96,7 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoIdentity *identity = LASSO_IDENTITY(node);
@@ -119,6 +119,8 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
t = t->next;
}
+
+ return 0;
}
diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c
index 723b587e..af87116c 100644
--- a/lasso/id-ff/login.c
+++ b/lasso/id-ff/login.c
@@ -1260,13 +1260,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLogin *login = LASSO_LOGIN(node);
xmlNode *t;
+ int rc;
- parent_class->init_from_xml(node, xmlnode);
+ rc = parent_class->init_from_xml(node, xmlnode);
+ if (rc) return rc;
t = xmlnode->children;
while (t) {
@@ -1289,6 +1291,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/id-ff/logout.c b/lasso/id-ff/logout.c
index 4eba20e5..57670fd4 100644
--- a/lasso/id-ff/logout.c
+++ b/lasso/id-ff/logout.c
@@ -90,7 +90,9 @@ lasso_logout_build_request_msg(LassoLogout *logout)
profile->msg_url = lasso_provider_get_metadata_one(remote_provider, "SoapEndpoint");
profile->msg_body = lasso_node_export_to_soap(profile->request,
profile->server->private_key, profile->server->certificate);
+ return 0;
}
+
if (logout->initial_http_request_method == LASSO_HTTP_METHOD_REDIRECT) {
/* build and optionaly sign the logout request QUERY message */
url = lasso_provider_get_metadata_one(remote_provider,
@@ -112,14 +114,11 @@ lasso_logout_build_request_msg(LassoLogout *logout)
g_free(url);
g_free(query);
profile->msg_body = NULL;
+ return 0;
}
- if (profile->msg_url == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Invalid http method");
- return LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD;
- }
-
- return 0;
+ message(G_LOG_LEVEL_CRITICAL, "Invalid http method");
+ return LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD;
}
@@ -147,61 +146,48 @@ lasso_logout_build_request_msg(LassoLogout *logout)
gint
lasso_logout_build_response_msg(LassoLogout *logout)
{
- /* XXX function to update (working but ugly) */
- LassoProfile *profile;
- LassoProvider *provider;
- gchar *url = NULL, *query = NULL;
- GError *err = NULL;
- gint ret = 0;
+ LassoProfile *profile;
+ LassoProvider *provider;
+ gchar *url, *query;
- g_return_val_if_fail(LASSO_IS_LOGOUT(logout), -1);
-
- profile = LASSO_PROFILE(logout);
-
- /* get the provider */
- provider = g_hash_table_lookup(profile->server->providers, profile->remote_providerID);
- if (provider == NULL) {
- message(G_LOG_LEVEL_CRITICAL, err->message);
- ret = err->code;
- g_error_free(err);
- goto done;
- }
-
- /* build logout response message */
- switch (profile->http_request_method) {
- case LASSO_HTTP_METHOD_SOAP:
- profile->msg_url = NULL;
- profile->msg_body = lasso_node_export_to_soap(profile->response,
- profile->server->private_key, profile->server->certificate);
- break;
- case LASSO_HTTP_METHOD_REDIRECT:
- url = lasso_provider_get_metadata_one(provider, "SingleLogoutServiceReturnURL");
- query = lasso_node_export_to_query(profile->response,
- profile->server->signature_method,
- profile->server->private_key);
- if ( (url == NULL) || (query == NULL) ) {
- message(G_LOG_LEVEL_CRITICAL, "Url %s or query %s not found", url, query);
- ret = -1;
- goto done;
- }
-
- profile->msg_url = g_strdup_printf("%s?%s", url, query);
- profile->msg_body = NULL;
- break;
- default:
- ret = LASSO_PROFILE_ERROR_MISSING_REQUEST;
- goto done;
- }
-
- done:
- if (url != NULL) {
- xmlFree(url);
- }
- if (query != NULL) {
- xmlFree(query);
- }
-
- return ret;
+ g_return_val_if_fail(LASSO_IS_LOGOUT(logout), -1);
+
+ profile = LASSO_PROFILE(logout);
+
+ /* get the provider */
+ provider = g_hash_table_lookup(profile->server->providers, profile->remote_providerID);
+ if (provider == NULL) {
+ return -1;
+ }
+
+ /* build logout response message */
+ if (profile->http_request_method == LASSO_HTTP_METHOD_SOAP) {
+ profile->msg_url = NULL;
+ profile->msg_body = lasso_node_export_to_soap(profile->response,
+ profile->server->private_key, profile->server->certificate);
+ return 0;
+ }
+
+ if (profile->http_request_method == LASSO_HTTP_METHOD_REDIRECT) {
+ url = lasso_provider_get_metadata_one(provider, "SingleLogoutServiceReturnURL");
+ if (url == NULL) {
+ return -1;
+ }
+ query = lasso_node_export_to_query(profile->response,
+ profile->server->signature_method,
+ profile->server->private_key);
+ if (query == NULL) {
+ g_free(url);
+ return -1;
+ }
+ profile->msg_url = g_strdup_printf("%s?%s", url, query);
+ profile->msg_body = NULL;
+ g_free(url);
+ g_free(query);
+ return 0;
+ }
+
+ return LASSO_PROFILE_ERROR_MISSING_REQUEST;
}
/**
@@ -221,33 +207,39 @@ lasso_logout_destroy(LassoLogout *logout)
* lasso_logout_get_next_providerID:
* @logout: the logout object
*
- * This method returns the provider id from providerID_index in list of providerIDs in session object.
+ * This method returns the provider id from providerID_index in list of
+ * providerIDs in session object.
+ *
* excepted the initial service provider id :
- * It gets the remote provider id in session from the logout providerID_index.
- * If it is the initial remote provider id, then it asks the next provider id
- * from providerID_index + 1;
+ * It gets the remote provider id in session from the logout provider index
+ *
+ * If it is the initial remote provider id, then it asks the next provider
+ * id from providerID_index + 1;
*
* Return value: a newly allocated string or NULL
**/
gchar*
lasso_logout_get_next_providerID(LassoLogout *logout)
{
- LassoProfile *profile;
- gchar *providerID;
-
- g_return_val_if_fail(LASSO_IS_LOGOUT(logout), NULL);
- profile = LASSO_PROFILE(logout);
-
- g_return_val_if_fail(LASSO_IS_SESSION(profile->session), NULL);
- providerID = lasso_session_get_provider_index(profile->session, logout->providerID_index);
- logout->providerID_index++;
- /* if it is the provider id of the SP requester, then get the next */
- if (logout->initial_remote_providerID && xmlStrEqual(providerID, logout->initial_remote_providerID)) {
- providerID = lasso_session_get_provider_index(profile->session, logout->providerID_index);
- logout->providerID_index++;
- }
-
- return providerID;
+ LassoProfile *profile;
+ gchar *providerID;
+
+ g_return_val_if_fail(LASSO_IS_LOGOUT(logout), NULL);
+ profile = LASSO_PROFILE(logout);
+
+ g_return_val_if_fail(LASSO_IS_SESSION(profile->session), NULL);
+ providerID = lasso_session_get_provider_index(
+ profile->session, logout->providerID_index);
+ logout->providerID_index++;
+ /* if it is the provider id of the SP requester, then get the next */
+ if (logout->initial_remote_providerID && providerID &&
+ strcmp(providerID, logout->initial_remote_providerID) == 0) {
+ providerID = lasso_session_get_provider_index(
+ profile->session, logout->providerID_index);
+ logout->providerID_index++;
+ }
+
+ return providerID;
}
/**
@@ -843,13 +835,14 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLogout *logout = LASSO_LOGOUT(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -870,6 +863,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/id-ff/name_registration.c b/lasso/id-ff/name_registration.c
index a397cb68..c2a9e4df 100644
--- a/lasso/id-ff/name_registration.c
+++ b/lasso/id-ff/name_registration.c
@@ -76,7 +76,9 @@ lasso_name_registration_build_request_msg(LassoNameRegistration *name_registrati
profile->msg_url = lasso_provider_get_metadata_one(remote_provider, "SoapEndpoint");
profile->msg_body = lasso_node_export_to_soap(profile->request,
profile->server->private_key, profile->server->certificate);
+ return 0;
}
+
if (profile->http_request_method == LASSO_HTTP_METHOD_REDIRECT) {
/* build and optionaly sign the query message and build the
* register name identifier request url */
@@ -96,17 +98,14 @@ lasso_name_registration_build_request_msg(LassoNameRegistration *name_registrati
}
/* build the msg_url */
profile->msg_url = g_strdup_printf("%s?%s", url, query);
+ profile->msg_body = NULL;
g_free(url);
g_free(query);
- profile->msg_body = NULL;
- }
-
- if (profile->msg_url == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Invalid http method");
- return LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD;
+ return 0;
}
- return 0;
+ message(G_LOG_LEVEL_CRITICAL, "Invalid http method");
+ return LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD;
}
gint
@@ -132,6 +131,7 @@ lasso_name_registration_build_response_msg(LassoNameRegistration *name_registrat
profile->msg_body = lasso_node_export_to_soap(profile->response, NULL, NULL);
return 0;
}
+
if (profile->http_request_method == LASSO_HTTP_METHOD_REDIRECT) {
url = lasso_provider_get_metadata_one(remote_provider,
"RegisterNameIdentifierServiceReturnURL");
@@ -157,7 +157,7 @@ lasso_name_registration_build_response_msg(LassoNameRegistration *name_registrat
}
message(G_LOG_LEVEL_CRITICAL, "Invalid HTTP request method");
- return -1;
+ return LASSO_PROFILE_ERROR_INVALID_HTTP_METHOD;
}
void
@@ -554,13 +554,14 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNameRegistration *name_registration = LASSO_NAME_REGISTRATION(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -573,6 +574,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/id-ff/profile.c b/lasso/id-ff/profile.c
index e06d4c6b..907afc20 100644
--- a/lasso/id-ff/profile.c
+++ b/lasso/id-ff/profile.c
@@ -298,12 +298,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoProfile *profile = LASSO_PROFILE(node);
xmlNode *t;
+ if (xmlnode == NULL)
+ return -1;
+
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
@@ -343,6 +346,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
diff --git a/lasso/id-ff/provider.c b/lasso/id-ff/provider.c
index 765d4243..3ce4a623 100644
--- a/lasso/id-ff/provider.c
+++ b/lasso/id-ff/provider.c
@@ -262,13 +262,16 @@ get_xmlNode(LassoNode *node)
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoProvider *provider = LASSO_PROVIDER(node);
xmlNode *t;
xmlChar *s;
+ if (xmlnode == NULL)
+ return -1;
+
s = xmlGetProp(xmlnode, "ProviderRole");
if (s && strcmp(s, "SP") == 0)
provider->role = LASSO_PROVIDER_ROLE_SP;
@@ -295,7 +298,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
load_descriptor(t, provider->private->IDPDescriptor);
t = t->next;
}
-
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/id-ff/server.c b/lasso/id-ff/server.c
index 56b8df36..7977a3c1 100644
--- a/lasso/id-ff/server.c
+++ b/lasso/id-ff/server.c
@@ -127,14 +127,17 @@ get_xmlNode(LassoNode *node)
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoServer *server = LASSO_SERVER(node);
xmlNode *t;
xmlChar *s;
+ int rc;
- parent_class->init_from_xml(node, xmlnode);
+ rc = parent_class->init_from_xml(node, xmlnode);
+ if (rc)
+ return rc;
s = xmlGetProp(xmlnode, "SignatureMethod");
if (s && strcmp(s, "RSA_SHA1") == 0)
@@ -173,6 +176,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
@@ -361,15 +365,16 @@ lasso_server_new(const gchar *metadata,
LassoServer*
lasso_server_new_from_dump(const gchar *dump)
{
- LassoServer *server;
- xmlDoc *doc;
-
- server = g_object_new(LASSO_TYPE_SERVER, NULL);
- doc = xmlParseMemory(dump, strlen(dump));
- init_from_xml(LASSO_NODE(server), xmlDocGetRootElement(doc));
- xmlFreeDoc(doc);
-
- return server;
+ LassoNode *server;
+ server = lasso_node_new_from_dump(dump);
+ if (server == NULL)
+ return NULL;
+
+ if (LASSO_IS_SERVER(server) == FALSE) {
+ g_object_unref(server);
+ return NULL;
+ }
+ return LASSO_SERVER(server);
}
gchar*
diff --git a/lasso/id-ff/session.c b/lasso/id-ff/session.c
index dbf180b3..5871e570 100644
--- a/lasso/id-ff/session.c
+++ b/lasso/id-ff/session.c
@@ -148,7 +148,7 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSession *session = LASSO_SESSION(node);
@@ -176,6 +176,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/lib_assertion.c b/lasso/xml/lib_assertion.c
index d1e6df53..7906ed51 100644
--- a/lasso/xml/lib_assertion.c
+++ b/lasso/xml/lib_assertion.c
@@ -69,11 +69,13 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- parent_class->init_from_xml(node, xmlnode);
+ int rc = 0;
+ rc = parent_class->init_from_xml(node, xmlnode);
LASSO_LIB_ASSERTION(node)->InResponseTo = xmlGetProp(xmlnode, "InResponseTo");
+ return rc;
}
/*****************************************************************************/
diff --git a/lasso/xml/lib_authentication_statement.c b/lasso/xml/lib_authentication_statement.c
index 25abb0a6..a55e4105 100644
--- a/lasso/xml/lib_authentication_statement.c
+++ b/lasso/xml/lib_authentication_statement.c
@@ -67,13 +67,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthenticationStatement *statement = LASSO_LIB_AUTHENTICATION_STATEMENT(node);
xmlNode *t;
+ int rc;
- parent_class->init_from_xml(node, xmlnode);
+ rc = parent_class->init_from_xml(node, xmlnode);
+ if (rc) return rc;
t = xmlnode->children;
while (t) {
@@ -87,6 +89,8 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
statement->ReauthenticateOnOrAfter = xmlGetProp(xmlnode, "ReauthenticateOnOrAfter");
statement->SessionIndex = xmlGetProp(xmlnode, "SessionIndex");
+
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/lib_authn_context.c b/lasso/xml/lib_authn_context.c
index a47bb2fb..8bb9e751 100644
--- a/lasso/xml/lib_authn_context.c
+++ b/lasso/xml/lib_authn_context.c
@@ -77,13 +77,16 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnContext *context = LASSO_LIB_AUTHN_CONTEXT(node);
xmlNode *t;
+ int rc;
- parent_class->init_from_xml(node, xmlnode);
+ rc = parent_class->init_from_xml(node, xmlnode);
+ if (rc)
+ return rc;
t = xmlnode->children;
while (t) {
@@ -95,7 +98,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
-
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/lib_authn_request.c b/lasso/xml/lib_authn_request.c
index 4aa4bbbf..7d3ad054 100644
--- a/lasso/xml/lib_authn_request.c
+++ b/lasso/xml/lib_authn_request.c
@@ -208,14 +208,17 @@ init_from_query(LassoNode *node, char **query_fields)
parent_class->init_from_query(node, query_fields);
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnRequest *request = LASSO_LIB_AUTHN_REQUEST(node);
xmlNode *t, *n;
char *s;
+ int rc;
- parent_class->init_from_xml(node, xmlnode);
+ rc = parent_class->init_from_xml(node, xmlnode);
+ if (rc)
+ return rc;
t = xmlnode->children;
while (t) {
@@ -266,7 +269,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
}
request->consent = xmlGetProp(xmlnode, "consent");
-
+ return 0;
}
diff --git a/lasso/xml/lib_authn_request_envelope.c b/lasso/xml/lib_authn_request_envelope.c
index 6ebf2266..a36c1eee 100644
--- a/lasso/xml/lib_authn_request_envelope.c
+++ b/lasso/xml/lib_authn_request_envelope.c
@@ -90,14 +90,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnRequestEnvelope *env = LASSO_LIB_AUTHN_REQUEST_ENVELOPE(node);
xmlNode *t, *n;
char *s;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -133,6 +134,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
env->IsPassive = (strcmp(s, "true") == 0);
xmlFree(s);
}
+ return 0;
}
diff --git a/lasso/xml/lib_authn_response.c b/lasso/xml/lib_authn_response.c
index b703f1c3..eb53bf16 100644
--- a/lasso/xml/lib_authn_response.c
+++ b/lasso/xml/lib_authn_response.c
@@ -81,13 +81,16 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnResponse *response = LASSO_LIB_AUTHN_RESPONSE(node);
xmlNode *t;
+ int rc;
- parent_class->init_from_xml(node, xmlnode);
+ rc = parent_class->init_from_xml(node, xmlnode);
+ if (rc)
+ return rc;
t = xmlnode->children;
while (t) {
@@ -100,6 +103,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
t = t->next;
}
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 085ba701..36977a23 100644
--- a/lasso/xml/lib_authn_response_envelope.c
+++ b/lasso/xml/lib_authn_response_envelope.c
@@ -53,13 +53,14 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibAuthnResponseEnvelope *env = LASSO_LIB_AUTHN_RESPONSE_ENVELOPE(node);
xmlNode *t, *n;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return 1;
t = xmlnode->children;
while (t) {
@@ -82,7 +83,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
continue;
}
}
-
+ return 0;
}
diff --git a/lasso/xml/lib_federation_termination_notification.c b/lasso/xml/lib_federation_termination_notification.c
index d5c63e1f..ead6b065 100644
--- a/lasso/xml/lib_federation_termination_notification.c
+++ b/lasso/xml/lib_federation_termination_notification.c
@@ -83,7 +83,7 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibFederationTerminationNotification *ob;
@@ -91,7 +91,8 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
ob = LASSO_LIB_FEDERATION_TERMINATION_NOTIFICATION(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return 1;
t = xmlnode->children;
while (t) {
@@ -110,6 +111,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
}
ob->consent = xmlGetProp(xmlnode, "consent");
+ return 0;
}
diff --git a/lasso/xml/lib_idp_entries.c b/lasso/xml/lib_idp_entries.c
index a720cc20..5829477e 100644
--- a/lasso/xml/lib_idp_entries.c
+++ b/lasso/xml/lib_idp_entries.c
@@ -58,13 +58,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibIDPEntries *entries = LASSO_LIB_IDP_ENTRIES(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ 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) {
@@ -73,6 +75,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/lib_idp_entry.c b/lasso/xml/lib_idp_entry.c
index 601ac147..662cf79f 100644
--- a/lasso/xml/lib_idp_entry.c
+++ b/lasso/xml/lib_idp_entry.c
@@ -64,13 +64,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibIDPEntry *entry = LASSO_LIB_IDP_ENTRY(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ 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) {
@@ -84,7 +86,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
-
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/lib_idp_list.c b/lasso/xml/lib_idp_list.c
index b56065ab..ffe0fa6b 100644
--- a/lasso/xml/lib_idp_list.c
+++ b/lasso/xml/lib_idp_list.c
@@ -63,13 +63,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibIDPList *list = LASSO_LIB_IDP_LIST(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ 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) {
@@ -80,6 +82,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/lib_logout_request.c b/lasso/xml/lib_logout_request.c
index e724ba0d..bb1e22af 100644
--- a/lasso/xml/lib_logout_request.c
+++ b/lasso/xml/lib_logout_request.c
@@ -166,13 +166,14 @@ init_from_query(LassoNode *node, char **query_fields)
parent_class->init_from_query(node, query_fields);
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibLogoutRequest *request = LASSO_LIB_LOGOUT_REQUEST(node);
xmlNode *t, *n;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -200,6 +201,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
}
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 e684f52a..3e28e5e3 100644
--- a/lasso/xml/lib_name_identifier_mapping_request.c
+++ b/lasso/xml/lib_name_identifier_mapping_request.c
@@ -87,7 +87,7 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibNameIdentifierMappingRequest *request;
@@ -95,7 +95,9 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
request = LASSO_LIB_NAME_IDENTIFIER_MAPPING_REQUEST(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
@@ -115,6 +117,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
t = t->next;
}
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 cb3dbdc6..a5f9a68d 100644
--- a/lasso/xml/lib_name_identifier_mapping_response.c
+++ b/lasso/xml/lib_name_identifier_mapping_response.c
@@ -72,7 +72,7 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibNameIdentifierMappingResponse *response;
@@ -80,7 +80,9 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
response = LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
@@ -99,6 +101,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/lib_register_name_identifier_request.c b/lasso/xml/lib_register_name_identifier_request.c
index ffd18ab9..b9442007 100644
--- a/lasso/xml/lib_register_name_identifier_request.c
+++ b/lasso/xml/lib_register_name_identifier_request.c
@@ -111,7 +111,7 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
xmlNode *t, *n;
@@ -119,7 +119,8 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
request = LASSO_LIB_REGISTER_NAME_IDENTIFIER_REQUEST(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -151,7 +152,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
continue;
}
}
-
+ return 0;
}
static gchar*
diff --git a/lasso/xml/lib_request_authn_context.c b/lasso/xml/lib_request_authn_context.c
index bbe48dfe..1eda1ea3 100644
--- a/lasso/xml/lib_request_authn_context.c
+++ b/lasso/xml/lib_request_authn_context.c
@@ -73,13 +73,14 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibRequestAuthnContext *context = LASSO_LIB_REQUEST_AUTHN_CONTEXT(node);
xmlNode *t, *n;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -100,6 +101,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
continue;
}
}
+ return 0;
}
diff --git a/lasso/xml/lib_scoping.c b/lasso/xml/lib_scoping.c
index e80ff896..b6a7da61 100644
--- a/lasso/xml/lib_scoping.c
+++ b/lasso/xml/lib_scoping.c
@@ -66,14 +66,16 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibScoping *scoping = LASSO_LIB_SCOPING(node);
xmlNode *t;
char *s;
- parent_class->init_from_xml(node, xmlnode);
+ 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) {
@@ -85,6 +87,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
scoping->IDPList = LASSO_LIB_IDP_LIST(lasso_node_new_from_xmlNode(t));
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/lib_status_response.c b/lasso/xml/lib_status_response.c
index 5784d861..5a2a59d0 100644
--- a/lasso/xml/lib_status_response.c
+++ b/lasso/xml/lib_status_response.c
@@ -82,13 +82,14 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibStatusResponse *response = LASSO_LIB_STATUS_RESPONSE(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ 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)
@@ -99,6 +100,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
response->RelayState = xmlNodeGetContent(t);
t = t->next;
}
+ return 0;
}
static gchar*
diff --git a/lasso/xml/lib_subject.c b/lasso/xml/lib_subject.c
index f62daa3b..339e10d7 100644
--- a/lasso/xml/lib_subject.c
+++ b/lasso/xml/lib_subject.c
@@ -67,13 +67,14 @@ get_xmlNode(LassoNode *node)
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoLibSubject *subject = LASSO_LIB_SUBJECT(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
@@ -87,6 +88,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
subject->IDPProvidedNameIdentifier = lasso_saml_name_identifier_new_from_xmlNode(t);
break;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/saml_advice.c b/lasso/xml/saml_advice.c
index 7ccf6791..b7eb57bf 100644
--- a/lasso/xml/saml_advice.c
+++ b/lasso/xml/saml_advice.c
@@ -66,13 +66,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlAdvice *advice = LASSO_SAML_ADVICE(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ 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)
@@ -81,6 +83,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
advice->Assertion = lasso_node_new_from_xmlNode(t);
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/saml_assertion.c b/lasso/xml/saml_assertion.c
index 94a3ca41..0fe83f38 100644
--- a/lasso/xml/saml_assertion.c
+++ b/lasso/xml/saml_assertion.c
@@ -132,14 +132,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
char *s;
xmlNode *t;
LassoSamlAssertion *assertion = LASSO_SAML_ASSERTION(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
assertion->AssertionID = xmlGetProp(xmlnode, "AssertionID");
assertion->Issuer = xmlGetProp(xmlnode, "Issuer");
@@ -177,11 +178,10 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
t = t->next;
}
-
+ return 0;
}
-
gint
lasso_saml_assertion_set_signature(LassoSamlAssertion *node,
gint sign_method,
diff --git a/lasso/xml/saml_audience_restriction_condition.c b/lasso/xml/saml_audience_restriction_condition.c
index 77936e21..f4548bf6 100644
--- a/lasso/xml/saml_audience_restriction_condition.c
+++ b/lasso/xml/saml_audience_restriction_condition.c
@@ -64,13 +64,14 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlAudienceRestrictionCondition *condition;
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -80,6 +81,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/saml_authentication_statement.c b/lasso/xml/saml_authentication_statement.c
index 344bd9c8..27369319 100644
--- a/lasso/xml/saml_authentication_statement.c
+++ b/lasso/xml/saml_authentication_statement.c
@@ -72,13 +72,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlAuthenticationStatement *statement = LASSO_SAML_AUTHENTICATION_STATEMENT(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
statement->AuthenticationMethod = xmlGetProp(xmlnode, "AuthenticationMethod");
statement->AuthenticationInstant = xmlGetProp(xmlnode, "AuthenticationInstant");
@@ -96,6 +98,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/saml_authority_binding.c b/lasso/xml/saml_authority_binding.c
index 81ea1f5c..9b5dab33 100644
--- a/lasso/xml/saml_authority_binding.c
+++ b/lasso/xml/saml_authority_binding.c
@@ -61,15 +61,19 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlAuthorityBinding *binding = LASSO_SAML_AUTHORITY_BINDING(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
binding->AuthorityKind = xmlGetProp(xmlnode, "AuthorityKind");
binding->Location = xmlGetProp(xmlnode, "Location");
binding->Binding = xmlGetProp(xmlnode, "Binding");
+
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/saml_conditions.c b/lasso/xml/saml_conditions.c
index a5082d2c..7108db1c 100644
--- a/lasso/xml/saml_conditions.c
+++ b/lasso/xml/saml_conditions.c
@@ -64,13 +64,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlConditions *conditions = LASSO_SAML_CONDITIONS(node);
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
conditions->NotBefore = xmlGetProp(xmlnode, "NotBefore");
conditions->NotOnOrAfter = xmlGetProp(xmlnode, "NotOnOrAfter");
t = xmlnode->children;
@@ -87,6 +89,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/saml_name_identifier.c b/lasso/xml/saml_name_identifier.c
index 020b254c..1711acf1 100644
--- a/lasso/xml/saml_name_identifier.c
+++ b/lasso/xml/saml_name_identifier.c
@@ -98,15 +98,19 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlNameIdentifier *identifier = LASSO_SAML_NAME_IDENTIFIER(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
identifier->content = xmlNodeGetContent(xmlnode);
identifier->Format = xmlGetProp(xmlnode, "Format");
identifier->NameQualifier = xmlGetProp(xmlnode, "NameQualifier");
+
+ return 0;
}
static gchar*
diff --git a/lasso/xml/saml_subject.c b/lasso/xml/saml_subject.c
index 87fec1ba..e80f0861 100644
--- a/lasso/xml/saml_subject.c
+++ b/lasso/xml/saml_subject.c
@@ -66,13 +66,14 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
xmlNode *t;
LassoSamlSubject *subject = LASSO_SAML_SUBJECT(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -90,6 +91,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/saml_subject_confirmation.c b/lasso/xml/saml_subject_confirmation.c
index a30c5d81..86dc9759 100644
--- a/lasso/xml/saml_subject_confirmation.c
+++ b/lasso/xml/saml_subject_confirmation.c
@@ -64,13 +64,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
xmlNode *t;
LassoSamlSubjectConfirmation *confirm = LASSO_SAML_SUBJECT_CONFIRMATION(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
@@ -84,6 +86,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
confirm->SubjectConfirmationData = xmlNodeGetContent(t);
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/saml_subject_locality.c b/lasso/xml/saml_subject_locality.c
index 722dbfa3..d00cfad5 100644
--- a/lasso/xml/saml_subject_locality.c
+++ b/lasso/xml/saml_subject_locality.c
@@ -57,14 +57,16 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoSamlSubjectLocality *locality = LASSO_SAML_SUBJECT_LOCALITY(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
locality->IPAddress = xmlGetProp(xmlnode, "IPAddress");
locality->DNSAddress = xmlGetProp(xmlnode, "DNSAddress");
+ return 0;
}
diff --git a/lasso/xml/saml_subject_statement_abstract.c b/lasso/xml/saml_subject_statement_abstract.c
index 1c2a30ff..fb2a96e0 100644
--- a/lasso/xml/saml_subject_statement_abstract.c
+++ b/lasso/xml/saml_subject_statement_abstract.c
@@ -61,7 +61,7 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
xmlNode *t;
@@ -69,7 +69,9 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
statement = LASSO_SAML_SUBJECT_STATEMENT_ABSTRACT(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
@@ -82,6 +84,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
lasso_node_new_from_xmlNode(t));
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/samlp_request.c b/lasso/xml/samlp_request.c
index 48a52a35..958fd1df 100644
--- a/lasso/xml/samlp_request.c
+++ b/lasso/xml/samlp_request.c
@@ -65,12 +65,13 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
xmlNode *t;
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -82,6 +83,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/samlp_request_abstract.c b/lasso/xml/samlp_request_abstract.c
index 692bfd96..b36be286 100644
--- a/lasso/xml/samlp_request_abstract.c
+++ b/lasso/xml/samlp_request_abstract.c
@@ -152,13 +152,14 @@ init_from_query(LassoNode *node, char **query_fields)
parent_class->init_from_query(node, query_fields);
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
char *t;
LassoSamlpRequestAbstract *request = LASSO_SAMLP_REQUEST_ABSTRACT(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
request->RequestID = xmlGetProp(xmlnode, "RequestID");
request->IssueInstant = xmlGetProp(xmlnode, "IssueInstant");
@@ -172,6 +173,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
request->MinorVersion = atoi(t);
xmlFree(t);
}
+ return 0;
}
diff --git a/lasso/xml/samlp_response.c b/lasso/xml/samlp_response.c
index d8bb73d0..c5545702 100644
--- a/lasso/xml/samlp_response.c
+++ b/lasso/xml/samlp_response.c
@@ -76,13 +76,14 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
xmlNode *t;
LassoSamlpResponse *response = LASSO_SAMLP_RESPONSE(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
t = xmlnode->children;
while (t) {
@@ -98,6 +99,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
diff --git a/lasso/xml/samlp_response_abstract.c b/lasso/xml/samlp_response_abstract.c
index c921e167..d003a45b 100644
--- a/lasso/xml/samlp_response_abstract.c
+++ b/lasso/xml/samlp_response_abstract.c
@@ -167,13 +167,14 @@ init_from_query(LassoNode *node, char **query_fields)
parent_class->init_from_query(node, query_fields);
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
char *t;
LassoSamlpResponseAbstract *response = LASSO_SAMLP_RESPONSE_ABSTRACT(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
response->ResponseID = xmlGetProp(xmlnode, "ResponseID");
response->IssueInstant = xmlGetProp(xmlnode, "IssueInstant");
@@ -189,6 +190,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
response->MinorVersion = atoi(t);
xmlFree(t);
}
+ return 0;
}
static char*
diff --git a/lasso/xml/samlp_status.c b/lasso/xml/samlp_status.c
index d677b920..7e8f4333 100644
--- a/lasso/xml/samlp_status.c
+++ b/lasso/xml/samlp_status.c
@@ -65,13 +65,15 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
xmlNode *t;
LassoSamlpStatus *status = LASSO_SAMLP_STATUS(node);
- parent_class->init_from_xml(node, xmlnode);
+ if (parent_class->init_from_xml(node, xmlnode))
+ return -1;
+
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
@@ -86,6 +88,7 @@ init_from_xml(LassoNode *node, xmlNode *xmlnode)
}
t = t->next;
}
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/samlp_status_code.c b/lasso/xml/samlp_status_code.c
index 8a469165..d1b2a430 100644
--- a/lasso/xml/samlp_status_code.c
+++ b/lasso/xml/samlp_status_code.c
@@ -55,10 +55,11 @@ get_xmlNode(LassoNode *node)
return xmlnode;
}
-static void
+static int
init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LASSO_SAMLP_STATUS_CODE(node)->Value = xmlGetProp(xmlnode, "Value");
+ return 0;
}
/*****************************************************************************/
diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c
index 0b6c48bb..15fffc44 100644
--- a/lasso/xml/tools.c
+++ b/lasso/xml/tools.c
@@ -40,12 +40,6 @@
#include <lasso/xml/strings.h>
-static int debug_type;
-static int debug_line;
-static char debug_filename[512];
-static char debug_function[512];
-
-
/**
* lasso_build_random_sequence:
* @buffer: buffer to fill with random sequence
@@ -185,42 +179,41 @@ lasso_get_pem_file_type(const char *pem_file)
xmlSecKeyPtr
lasso_get_public_key_from_pem_cert_file(const char *pem_cert_file)
{
- FILE *fd;
- X509 *pem_cert;
- xmlSecKeyDataPtr data;
- xmlSecKeyPtr key = NULL;
-
- g_return_val_if_fail(pem_cert_file != NULL, NULL);
-
- /* load pem certificate from file */
- fd = fopen(pem_cert_file, "r");
- if (fd == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Failed to open %s pem certificate file",
- pem_cert_file);
- return NULL;
- }
- /* read the pem X509 certificate */
- pem_cert = PEM_read_X509(fd, NULL, NULL, NULL);
- fclose(fd);
- if (pem_cert == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Failed to read X509 certificate");
- return NULL;
- }
+ FILE *fd;
+ X509 *pem_cert;
+ xmlSecKeyDataPtr data;
+ xmlSecKeyPtr key = NULL;
+
+ g_return_val_if_fail(pem_cert_file != NULL, NULL);
+
+ /* load pem certificate from file */
+ fd = fopen(pem_cert_file, "r");
+ if (fd == NULL) {
+ message(G_LOG_LEVEL_CRITICAL, "Failed to open %s pem certificate file",
+ pem_cert_file);
+ return NULL;
+ }
+ /* read the pem X509 certificate */
+ pem_cert = PEM_read_X509(fd, NULL, NULL, NULL);
+ fclose(fd);
+ if (pem_cert == NULL) {
+ message(G_LOG_LEVEL_CRITICAL, "Failed to read X509 certificate");
+ return NULL;
+ }
- /* get public key value in certificate */
- data = xmlSecOpenSSLX509CertGetKey(pem_cert);
- if (data != NULL) {
- /* create key and set key value */
- key = xmlSecKeyCreate();
- xmlSecKeySetValue(key, data);
- }
- else {
- message(G_LOG_LEVEL_CRITICAL,
- "Failed to get the public key in the X509 certificate");
- }
- X509_free(pem_cert);
+ /* get public key value in certificate */
+ data = xmlSecOpenSSLX509CertGetKey(pem_cert);
+ if (data != NULL) {
+ /* create key and set key value */
+ key = xmlSecKeyCreate();
+ xmlSecKeySetValue(key, data);
+ } else {
+ message(G_LOG_LEVEL_CRITICAL,
+ "Failed to get the public key in the X509 certificate");
+ }
+ X509_free(pem_cert);
- return key;
+ return key;
}
/**
@@ -236,75 +229,67 @@ lasso_get_public_key_from_pem_cert_file(const char *pem_cert_file)
xmlSecKeysMngrPtr
lasso_load_certs_from_pem_certs_chain_file(const char* pem_certs_chain_file)
{
- xmlSecKeysMngrPtr keys_mngr;
- GIOChannel *gioc;
- gchar *line;
- gsize len, pos;
- GString *cert = NULL;
- gint ret;
-
- g_return_val_if_fail(pem_certs_chain_file != NULL, NULL);
-
- /* create keys manager */
- keys_mngr = xmlSecKeysMngrCreate();
- if (keys_mngr == NULL) {
- message(G_LOG_LEVEL_CRITICAL,
- lasso_strerror(LASSO_DS_ERROR_KEYS_MNGR_CREATION_FAILED));
- return NULL;
- }
- /* initialize keys manager */
- if (xmlSecCryptoAppDefaultKeysMngrInit(keys_mngr) < 0) {
- message(G_LOG_LEVEL_CRITICAL,
- lasso_strerror(LASSO_DS_ERROR_KEYS_MNGR_INIT_FAILED));
- xmlSecKeysMngrDestroy(keys_mngr);
- return NULL;
- }
-
- gioc = g_io_channel_new_file(pem_certs_chain_file, "r", NULL);
- while (g_io_channel_read_line(gioc, &line, &len, &pos, NULL) == G_IO_STATUS_NORMAL) {
- if (g_strstr_len(line, 64, "BEGIN CERTIFICATE") != NULL) {
- cert = g_string_new(line);
- }
- else if (g_strstr_len(line, 64, "END CERTIFICATE") != NULL) {
- g_string_append(cert, line);
- /* load the new certificate found in the keys manager */
- ret = xmlSecCryptoAppKeysMngrCertLoadMemory(keys_mngr,
- (const xmlSecByte*) cert->str,
- (xmlSecSize) cert->len,
- xmlSecKeyDataFormatPem,
- xmlSecKeyDataTypeTrusted);
- g_string_free(cert, TRUE);
- cert = NULL;
- if (ret < 0) {
- goto error;
- }
- }
- else if (cert != NULL && line != NULL && line[0] != '\0') {
- g_string_append(cert, line);
- }
- else {
- debug("Empty line found in the CA certificate chain file")
- }
- /* free last line read */
- if (line != NULL) {
- g_free(line);
- line = NULL;
- }
- }
- goto done;
-
- error:
- if (line != NULL) {
- g_free(line);
- line = NULL;
- }
- xmlSecKeysMngrDestroy(keys_mngr);
- keys_mngr = NULL;
+ xmlSecKeysMngrPtr keys_mngr;
+ GIOChannel *gioc;
+ gchar *line;
+ gsize len, pos;
+ GString *cert = NULL;
+ gint ret;
+
+ g_return_val_if_fail(pem_certs_chain_file != NULL, NULL);
+
+ /* create keys manager */
+ keys_mngr = xmlSecKeysMngrCreate();
+ if (keys_mngr == NULL) {
+ message(G_LOG_LEVEL_CRITICAL,
+ lasso_strerror(LASSO_DS_ERROR_KEYS_MNGR_CREATION_FAILED));
+ return NULL;
+ }
+ /* initialize keys manager */
+ if (xmlSecCryptoAppDefaultKeysMngrInit(keys_mngr) < 0) {
+ message(G_LOG_LEVEL_CRITICAL,
+ lasso_strerror(LASSO_DS_ERROR_KEYS_MNGR_INIT_FAILED));
+ xmlSecKeysMngrDestroy(keys_mngr);
+ return NULL;
+ }
+
+ gioc = g_io_channel_new_file(pem_certs_chain_file, "r", NULL);
+ while (g_io_channel_read_line(gioc, &line, &len, &pos, NULL) == G_IO_STATUS_NORMAL) {
+ if (g_strstr_len(line, 64, "BEGIN CERTIFICATE") != NULL) {
+ cert = g_string_new(line);
+ } else if (g_strstr_len(line, 64, "END CERTIFICATE") != NULL) {
+ g_string_append(cert, line);
+ /* load the new certificate found in the keys manager */
+ ret = xmlSecCryptoAppKeysMngrCertLoadMemory(keys_mngr,
+ (const xmlSecByte*) cert->str,
+ (xmlSecSize) cert->len,
+ xmlSecKeyDataFormatPem,
+ xmlSecKeyDataTypeTrusted);
+ g_string_free(cert, TRUE);
+ cert = NULL;
+ if (ret < 0) {
+ if (line) {
+ g_free(line);
+ xmlSecKeysMngrDestroy(keys_mngr);
+ }
+ g_io_channel_shutdown(gioc, TRUE, NULL);
+ return NULL;
+ }
+ } else if (cert != NULL && line != NULL && line[0] != '\0') {
+ g_string_append(cert, line);
+ } else {
+ debug("Empty line found in the CA certificate chain file")
+ }
+ /* free last line read */
+ if (line != NULL) {
+ g_free(line);
+ line = NULL;
+ }
+ }
- done:
- g_io_channel_shutdown(gioc, TRUE, NULL);
+ g_io_channel_shutdown(gioc, TRUE, NULL);
- return keys_mngr;
+ return keys_mngr;
}
/**
@@ -574,41 +559,25 @@ char** urlencoded_to_strings(const char *str)
return result;
}
-
-void
-set_debug_info(int line, char *filename, char *function, int type)
-{
- debug_type = type;
- debug_line = line;
- debug_filename[511] = 0;
- debug_function[511] = 0;
- strncpy(debug_filename, filename, 511);
- strncpy(debug_function, function, 511);
-}
-
void
-_debug(GLogLevelFlags level, const char *format, ...)
+_debug(GLogLevelFlags level, const char *filename, int line,
+ const char *function, const char *format, ...)
{
char debug_string[1024];
time_t ts;
char date[20];
va_list args;
- if (level == G_LOG_LEVEL_DEBUG && debug_type == 0) {
- g_warning("message() function should not be used with G_LOG_LEVEL_DEBUG level. Use debug() function rather.");
- }
- debug_type = 0;
-
va_start(args, format);
- vsnprintf(debug_string, sizeof(debug_string), format, args);
+ vsnprintf(debug_string, 1024, format, args);
va_end(args);
time(&ts);
- strftime(date, 20, "%d-%m-%Y %H:%M:%S", localtime(&ts));
+ strftime(date, 20, "%Y-%m-%d %H:%M:%S", localtime(&ts));
if (level == G_LOG_LEVEL_DEBUG || level == G_LOG_LEVEL_CRITICAL) {
g_log("Lasso", level, "%s (%s/%s:%d)\n======> %s",
- date, debug_filename, debug_function, debug_line, debug_string);
+ date, filename, function, line, debug_string);
} else {
g_log("Lasso", level, "%s\t%s", date, debug_string);
}
diff --git a/lasso/xml/tools.h b/lasso/xml/tools.h
index 9e178ee0..23e92aea 100644
--- a/lasso/xml/tools.h
+++ b/lasso/xml/tools.h
@@ -69,19 +69,18 @@ LASSO_EXPORT char* lasso_sha1(const char *str);
char** urlencoded_to_strings(const char *str);
-void set_debug_info(int line, char *filename, char *function, int type);
-void _debug(GLogLevelFlags level, const char *format, ...);
+void _debug(GLogLevelFlags level, const char *filename, int line,
+ const char *function, const char *format, ...);
#if defined LASSO_DEBUG
# define debug(format, args...) \
- set_debug_info(__LINE__, __FILE__, __FUNCTION__, 1); \
- _debug(G_LOG_LEVEL_DEBUG, format, ##args);
+ _debug(G_LOG_LEVEL_DEBUG, __FILE__, __LINE__,__FUNCTION__, format, ##args);
#else
# define debug(format, ...);
#endif
#define message(level, format, args...) \
- set_debug_info(__LINE__, __FILE__, __FUNCTION__, 0); _debug(level, format, ##args);
+ _debug(level, __FILE__, __LINE__, __FUNCTION__, format, ##args);
#ifdef __cplusplus
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index 72cb2054..d1c21627 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -270,15 +270,15 @@ lasso_node_init_from_query(LassoNode *node, const char *query)
free(query_fields);
}
-void
+int
lasso_node_init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
LassoNodeClass *class;
- g_return_if_fail(LASSO_IS_NODE(node));
+ g_return_val_if_fail(LASSO_IS_NODE(node), -1);
class = LASSO_NODE_GET_CLASS(node);
- class->init_from_xml(node, xmlnode);
+ return class->init_from_xml(node, xmlnode);
}
@@ -456,10 +456,10 @@ lasso_node_impl_init_from_query(LassoNode *node, char **query_fields)
;
}
-static void
+static int
lasso_node_impl_init_from_xml(LassoNode *node, xmlNode *xmlnode)
{
- ;
+ return 0;
}
/*** private methods **********************************************************/
@@ -551,6 +551,18 @@ lasso_node_new()
}
LassoNode*
+lasso_node_new_from_dump(const char *dump)
+{
+ LassoNode *node;
+ xmlDoc *doc;
+
+ doc = xmlParseMemory(dump, strlen(dump));
+ node = lasso_node_new_from_xmlNode(xmlDocGetRootElement(doc));
+ xmlFreeDoc(doc);
+ return node;
+}
+
+LassoNode*
lasso_node_new_from_soap(const char *soap)
{
xmlDoc *doc;
@@ -590,6 +602,7 @@ lasso_node_new_from_xmlNode(xmlNode *xmlnode)
GType gtype;
LassoNode *node;
char *xsitype;
+ int rc;
/* XXX I'm not sure I can access ->ns like this */
@@ -628,7 +641,11 @@ lasso_node_new_from_xmlNode(xmlNode *xmlnode)
return NULL;
node = g_object_new(gtype, NULL);
- lasso_node_init_from_xml(node, xmlnode);
+ rc = lasso_node_init_from_xml(node, xmlnode);
+ if (rc) {
+ g_object_unref(node);
+ return NULL;
+ }
return node;
}
diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h
index 8f89d67b..1df4c120 100644
--- a/lasso/xml/xml.h
+++ b/lasso/xml/xml.h
@@ -72,7 +72,7 @@ struct _LassoNodeClass {
void (* destroy) (LassoNode *node);
char* (* build_query) (LassoNode *node);
void (* init_from_query) (LassoNode *node, char **query_fields);
- void (* init_from_xml) (LassoNode *node, xmlNode *xmlnode);
+ int (* init_from_xml) (LassoNode *node, xmlNode *xmlnode);
xmlNode* (* get_xmlNode) (LassoNode *node);
char* (* get_sign_attr_name) ();
@@ -99,7 +99,7 @@ LASSO_EXPORT xmlNode* lasso_node_get_xmlNode(LassoNode *node);
LASSO_EXPORT LassoMessageFormat lasso_node_init_from_message(LassoNode *node, const char *message);
LASSO_EXPORT void lasso_node_init_from_query(LassoNode *node, const char *query);
-LASSO_EXPORT void lasso_node_init_from_xml(LassoNode *node, xmlNode *xmlnode);
+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);