diff options
| author | Valery Febvre <vfebvre at easter-eggs.com> | 2004-07-31 20:34:46 +0000 |
|---|---|---|
| committer | Valery Febvre <vfebvre at easter-eggs.com> | 2004-07-31 20:34:46 +0000 |
| commit | 0ecf1691ba1f1590b480ee53a6af0c0dbb66424a (patch) | |
| tree | b8bee0ef463e7bdb376789c19f5d0d77f2fcb3e9 | |
| parent | ed561ce190fb10c4dc35e8c23c39c7292f14e5bc (diff) | |
| download | lasso-0ecf1691ba1f1590b480ee53a6af0c0dbb66424a.tar.gz lasso-0ecf1691ba1f1590b480ee53a6af0c0dbb66424a.tar.xz lasso-0ecf1691ba1f1590b480ee53a6af0c0dbb66424a.zip | |
Added a new argument 'err' in 4 methods of the LassoNode class:
lasso_node_get_attr
lasso_node_get_child
lasso_node_get_child_content
lasso_node_get_content
for reporting errors.
32 files changed, 346 insertions, 240 deletions
diff --git a/lasso/Attic/protocols/artifact.c b/lasso/Attic/protocols/artifact.c index f954913d..26b6baac 100644 --- a/lasso/Attic/protocols/artifact.c +++ b/lasso/Attic/protocols/artifact.c @@ -71,7 +71,7 @@ xmlChar* lasso_artifact_get_assertionHandle(LassoArtifact *artifact) { return (lasso_node_get_child_content(LASSO_NODE(artifact), - "AssertionHandle", NULL)); + "AssertionHandle", NULL, NULL)); } gint @@ -80,7 +80,7 @@ lasso_artifact_get_byteCode(LassoArtifact *artifact) xmlChar *byteCode; byteCode = lasso_node_get_child_content(LASSO_NODE(artifact), - "ByteCode", NULL); + "ByteCode", NULL, NULL); return ((gint)g_strtod(byteCode, NULL)); } @@ -88,20 +88,21 @@ xmlChar* lasso_artifact_get_identityProviderSuccinctID(LassoArtifact *artifact) { return (lasso_node_get_child_content(LASSO_NODE(artifact), - "IdentityProviderSuccinctID", NULL)); + "IdentityProviderSuccinctID", NULL, NULL)); } xmlChar* lasso_artifact_get_relayState(LassoArtifact *artifact) { return (lasso_node_get_child_content(LASSO_NODE(artifact), - "RelayState", NULL)); + "RelayState", NULL, NULL)); } xmlChar* lasso_artifact_get_samlArt(LassoArtifact *artifact) { - return (lasso_node_get_child_content(LASSO_NODE(artifact), "SAMLArt", NULL)); + return (lasso_node_get_child_content(LASSO_NODE(artifact), + "SAMLArt", NULL, NULL)); } /*****************************************************************************/ diff --git a/lasso/Attic/protocols/authn_request_envelope.c b/lasso/Attic/protocols/authn_request_envelope.c index 0058637f..261b5488 100644 --- a/lasso/Attic/protocols/authn_request_envelope.c +++ b/lasso/Attic/protocols/authn_request_envelope.c @@ -24,6 +24,9 @@ */ #include <string.h> + +#include <xmlsec/base64.h> + #include <lasso/protocols/authn_request_envelope.h> /*****************************************************************************/ @@ -38,7 +41,7 @@ LassoNode *lasso_authn_request_envelope_get_authnRequest(LassoAuthnRequestEnvelo { g_return_val_if_fail(LASSO_IS_AUTHN_REQUEST_ENVELOPE(request), NULL); - return(lasso_node_get_child(LASSO_NODE(request), "AuthnRequest", NULL)); + return(lasso_node_get_child(LASSO_NODE(request), "AuthnRequest", NULL, NULL)); } /*****************************************************************************/ @@ -86,13 +89,15 @@ lasso_authn_request_envelope_new(LassoAuthnRequest *authnRequest, LassoNode *request; g_return_val_if_fail(LASSO_IS_AUTHN_REQUEST(authnRequest), NULL); - g_return_val_if_fail(providerID!=NULL, NULL); - g_return_val_if_fail(assertionConsumerServiceURL!=NULL, NULL); + g_return_val_if_fail(providerID != NULL, NULL); + g_return_val_if_fail(assertionConsumerServiceURL != NULL, NULL); request = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_REQUEST_ENVELOPE, NULL)); - lasso_lib_authn_request_envelope_set_authnRequest(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), LASSO_LIB_AUTHN_REQUEST(authnRequest)); - lasso_lib_authn_request_envelope_set_providerID(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), providerID); + lasso_lib_authn_request_envelope_set_authnRequest(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), + LASSO_LIB_AUTHN_REQUEST(authnRequest)); + lasso_lib_authn_request_envelope_set_providerID(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), + providerID); lasso_lib_authn_request_envelope_set_assertionConsumerServiceURL(LASSO_LIB_AUTHN_REQUEST_ENVELOPE(request), assertionConsumerServiceURL); @@ -110,7 +115,7 @@ lasso_authn_request_envelope_new_from_export(gchar *buffer, request = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_REQUEST_ENVELOPE, NULL)); - switch(export_type){ + switch(export_type) { case lassoNodeExportTypeBase64: buffer_decoded = xmlMalloc(strlen(buffer)); xmlSecBase64Decode(buffer, buffer_decoded, strlen(buffer)); diff --git a/lasso/Attic/protocols/authn_response.c b/lasso/Attic/protocols/authn_response.c index c56091c8..78fe628d 100644 --- a/lasso/Attic/protocols/authn_response.c +++ b/lasso/Attic/protocols/authn_response.c @@ -58,7 +58,8 @@ lasso_authn_response_get_status(LassoAuthnResponse *response) { xmlChar *value; GError *err = NULL; - status_code = lasso_node_get_child(LASSO_NODE(response), "StatusCode", NULL); + status_code = lasso_node_get_child(LASSO_NODE(response), "StatusCode", + NULL, NULL); if (status_code != NULL) { value = lasso_node_get_attr_value(status_code, "Value", &err); lasso_node_destroy(status_code); @@ -150,7 +151,7 @@ lasso_authn_response_new(char *providerID, providerID); /* RelayState */ - content = lasso_node_get_child_content(request, "RelayState", lassoLibHRef); + content = lasso_node_get_child_content(request, "RelayState", lassoLibHRef, NULL); if (content != NULL) { lasso_lib_authn_response_set_relayState(LASSO_LIB_AUTHN_RESPONSE(response), content); diff --git a/lasso/Attic/protocols/authn_response_envelope.c b/lasso/Attic/protocols/authn_response_envelope.c index db4d3154..965ce29c 100644 --- a/lasso/Attic/protocols/authn_response_envelope.c +++ b/lasso/Attic/protocols/authn_response_envelope.c @@ -38,14 +38,14 @@ xmlChar *lasso_authn_response_envelope_get_assertionConsumerServiceURL(LassoAuth { g_return_val_if_fail(LASSO_IS_AUTHN_RESPONSE_ENVELOPE(response), NULL); - return(lasso_node_get_child_content(LASSO_NODE(response), "AssertionConsumerServiceURL", NULL)); + return(lasso_node_get_child_content(LASSO_NODE(response), "AssertionConsumerServiceURL", NULL, NULL)); } LassoNode* lasso_authn_response_envelope_get_authnResponse(LassoAuthnResponseEnvelope *response) { g_return_val_if_fail(LASSO_IS_AUTHN_RESPONSE_ENVELOPE(response), NULL); - return(lasso_node_get_child(LASSO_NODE(response), "AuthnResponse", NULL)); + return(lasso_node_get_child(LASSO_NODE(response), "AuthnResponse", NULL, NULL)); } /*****************************************************************************/ @@ -115,7 +115,7 @@ lasso_authn_response_envelope_new_from_soap(gchar *buffer) response = LASSO_NODE(g_object_new(LASSO_TYPE_AUTHN_RESPONSE_ENVELOPE, NULL)); envelope = lasso_node_new_from_dump(buffer); - lassoNode_response = lasso_node_get_child(envelope, "AuthnResponseEnvelope", NULL); + lassoNode_response = lasso_node_get_child(envelope, "AuthnResponseEnvelope", NULL, NULL); class = LASSO_NODE_GET_CLASS(lassoNode_response); xmlNode_response = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_response)), 1); diff --git a/lasso/Attic/protocols/elements/authentication_statement.c b/lasso/Attic/protocols/elements/authentication_statement.c index 70d150c9..110e8f6f 100644 --- a/lasso/Attic/protocols/elements/authentication_statement.c +++ b/lasso/Attic/protocols/elements/authentication_statement.c @@ -98,7 +98,7 @@ lasso_authentication_statement_new(const xmlChar *authenticationMethod subject = lasso_lib_subject_new(); if (identifier == NULL) { /* create a new NameIdentifier and use idp_identifier data to fill it */ - str = lasso_node_get_content(LASSO_NODE(idp_identifier)); + str = lasso_node_get_content(LASSO_NODE(idp_identifier), NULL); new_identifier = lasso_saml_name_identifier_new(str); xmlFree(str); str = lasso_node_get_attr_value(LASSO_NODE(idp_identifier), "NameQualifier", NULL); @@ -120,7 +120,7 @@ lasso_authentication_statement_new(const xmlChar *authenticationMethod lasso_node_destroy(new_identifier); /* create a new IdpProvidedNameIdentifier and use idp_identifier data to fill it */ - str = lasso_node_get_content(LASSO_NODE(idp_identifier)); + str = lasso_node_get_content(LASSO_NODE(idp_identifier), NULL); new_idp_identifier = lasso_lib_idp_provided_name_identifier_new(str); xmlFree(str); str = lasso_node_get_attr_value(LASSO_NODE(idp_identifier), "NameQualifier", NULL); diff --git a/lasso/Attic/protocols/federation.c b/lasso/Attic/protocols/federation.c index ee19abc3..41834e79 100644 --- a/lasso/Attic/protocols/federation.c +++ b/lasso/Attic/protocols/federation.c @@ -155,9 +155,10 @@ lasso_federation_verify_nameIdentifier(LassoFederation *federation, { gchar *federation_content, *nameIdentifier_content; - nameIdentifier_content = lasso_node_get_content(nameIdentifier); + nameIdentifier_content = lasso_node_get_content(nameIdentifier, NULL); if(federation->local_nameIdentifier != NULL) { - federation_content = lasso_node_get_content(federation->local_nameIdentifier); + federation_content = lasso_node_get_content(federation->local_nameIdentifier, + NULL); if(xmlStrEqual(federation_content, nameIdentifier_content)) { xmlFree(federation_content); return(TRUE); @@ -165,7 +166,8 @@ lasso_federation_verify_nameIdentifier(LassoFederation *federation, xmlFree(federation_content); } if(federation->remote_nameIdentifier != NULL) { - federation_content = lasso_node_get_content(federation->remote_nameIdentifier); + federation_content = lasso_node_get_content(federation->remote_nameIdentifier, + NULL); if(xmlStrEqual(federation_content, nameIdentifier_content)) { xmlFree(federation_content); return(TRUE); diff --git a/lasso/Attic/protocols/federation_termination_notification.c b/lasso/Attic/protocols/federation_termination_notification.c index eeb4a82c..4a4c546c 100644 --- a/lasso/Attic/protocols/federation_termination_notification.c +++ b/lasso/Attic/protocols/federation_termination_notification.c @@ -168,7 +168,7 @@ lasso_federation_termination_notification_new_from_soap(const xmlChar *buffer) envelope = lasso_node_new_from_dump(buffer); lassoNode_notification = lasso_node_get_child(envelope, "FederationTerminationNotification", - lassoLibHRef); + lassoLibHRef, NULL); class = LASSO_NODE_GET_CLASS(lassoNode_notification); xmlNode_notification = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_notification)), 1); diff --git a/lasso/Attic/protocols/logout_request.c b/lasso/Attic/protocols/logout_request.c index 59c1159d..e7722232 100644 --- a/lasso/Attic/protocols/logout_request.c +++ b/lasso/Attic/protocols/logout_request.c @@ -184,7 +184,8 @@ lasso_logout_request_new_from_soap(gchar *buffer) request = LASSO_NODE(g_object_new(LASSO_TYPE_LOGOUT_REQUEST, NULL)); envelope = lasso_node_new_from_dump(buffer); - lassoNode_request = lasso_node_get_child(envelope, "LogoutRequest", lassoLibHRef); + lassoNode_request = lasso_node_get_child(envelope, "LogoutRequest", + lassoLibHRef, NULL); class = LASSO_NODE_GET_CLASS(lassoNode_request); xmlNode_request = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_request)), 1); @@ -202,7 +203,7 @@ LassoNode* lasso_logout_request_new_from_export(gchar *buffer, lassoNodeExportTypes export_type) { - LassoNode *request; + LassoNode *request = NULL; g_return_val_if_fail(buffer != NULL, NULL); diff --git a/lasso/Attic/protocols/logout_response.c b/lasso/Attic/protocols/logout_response.c index 5eeacc69..26be9553 100644 --- a/lasso/Attic/protocols/logout_response.c +++ b/lasso/Attic/protocols/logout_response.c @@ -36,7 +36,8 @@ lasso_logout_response_get_status_code_value(LassoLogoutResponse *response) xmlChar *value; GError *err = NULL; - status_code = lasso_node_get_child(LASSO_NODE(response), "StatusCode", NULL); + status_code = lasso_node_get_child(LASSO_NODE(response), "StatusCode", + NULL, NULL); if (status_code != NULL) { value = lasso_node_get_attr_value(status_code, "Value", &err); lasso_node_destroy(status_code); @@ -97,8 +98,8 @@ lasso_logout_response_new(gchar *providerID, const gchar *statusCodeValue, LassoNode *request) { - LassoNode *response, *ss, *ssc, *request_providerID, *request_relayState; - xmlChar *inResponseTo, *recipient, *relayState; + LassoNode *response, *ss, *ssc; + xmlChar *inResponseTo, *request_providerID, *request_relayState; xmlChar *id, *time; response = LASSO_NODE(g_object_new(LASSO_TYPE_LOGOUT_RESPONSE, NULL)); @@ -124,24 +125,21 @@ lasso_logout_response_new(gchar *providerID, lasso_lib_status_response_set_providerID(LASSO_LIB_STATUS_RESPONSE(response), providerID); - inResponseTo = xmlNodeGetContent((xmlNodePtr)lasso_node_get_attr(request, "RequestID")); + inResponseTo = lasso_node_get_attr_value(request, "RequestID", NULL); lasso_samlp_response_abstract_set_inResponseTo(LASSO_SAMLP_RESPONSE_ABSTRACT(response), inResponseTo); + xmlFree(inResponseTo); - request_providerID = lasso_node_get_child(request, "ProviderID", NULL); - recipient = lasso_node_get_content(request_providerID); + request_providerID = lasso_node_get_child_content(request, "ProviderID", NULL, NULL); lasso_samlp_response_abstract_set_recipient(LASSO_SAMLP_RESPONSE_ABSTRACT(response), - recipient); - lasso_node_destroy(request_providerID); - xmlFree(recipient); + request_providerID); + xmlFree(request_providerID); - request_relayState = lasso_node_get_child(request, "RelayState", NULL); + request_relayState = lasso_node_get_child_content(request, "RelayState", NULL, NULL); if (request_relayState != NULL) { - relayState = lasso_node_get_content(request_relayState); lasso_lib_status_response_set_relayState(LASSO_LIB_STATUS_RESPONSE(response), - relayState); - lasso_node_destroy(request_relayState); - xmlFree(relayState); + request_relayState); + xmlFree(request_relayState); } ss = lasso_samlp_status_new(); @@ -258,13 +256,14 @@ lasso_logout_response_new_from_soap(gchar *buffer) response = LASSO_NODE(g_object_new(LASSO_TYPE_LOGOUT_RESPONSE, NULL)); envelope = lasso_node_new_from_dump(buffer); - if(envelope==NULL){ + if(envelope == NULL) { message(G_LOG_LEVEL_ERROR, "Error while parsing the soap msg\n"); return(NULL); } - lassoNode_response = lasso_node_get_child(envelope, "LogoutResponse", NULL); - if(lassoNode_response==NULL){ + lassoNode_response = lasso_node_get_child(envelope, "LogoutResponse", + NULL, NULL); + if(lassoNode_response == NULL) { message(G_LOG_LEVEL_ERROR, "LogoutResponse node not found\n"); return(NULL); } diff --git a/lasso/Attic/protocols/name_identifier_mapping_request.c b/lasso/Attic/protocols/name_identifier_mapping_request.c index 4dc40272..67f5dc37 100644 --- a/lasso/Attic/protocols/name_identifier_mapping_request.c +++ b/lasso/Attic/protocols/name_identifier_mapping_request.c @@ -182,7 +182,7 @@ lasso_name_identifier_mapping_request_new_from_soap(const xmlChar *buffer) envelope = lasso_node_new_from_dump(buffer); lassoNode_request = lasso_node_get_child(envelope, "NameIdentifierMappingRequest", - lassoLibHRef); + lassoLibHRef, NULL); class = LASSO_NODE_GET_CLASS(lassoNode_request); xmlNode_request = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_request)), 1); diff --git a/lasso/Attic/protocols/name_identifier_mapping_response.c b/lasso/Attic/protocols/name_identifier_mapping_response.c index f99a6339..c37e635f 100644 --- a/lasso/Attic/protocols/name_identifier_mapping_response.c +++ b/lasso/Attic/protocols/name_identifier_mapping_response.c @@ -72,8 +72,8 @@ lasso_name_identifier_mapping_response_new(const xmlChar *providerID, LassoNode *request) { /* FIXME : change request type */ - LassoNode *response, *ss, *ssc, *request_providerID; - xmlChar *inResponseTo, *recipient; + LassoNode *response, *ss, *ssc; + xmlChar *inResponseTo, *request_providerID; xmlChar *id, *time; response = LASSO_NODE(g_object_new(LASSO_TYPE_NAME_IDENTIFIER_MAPPING_RESPONSE, NULL)); @@ -99,16 +99,15 @@ lasso_name_identifier_mapping_response_new(const xmlChar *providerID, lasso_lib_name_identifier_mapping_response_set_providerID(LASSO_LIB_NAME_IDENTIFIER_MAPPING_RESPONSE(response), providerID); - inResponseTo = xmlNodeGetContent((xmlNodePtr)lasso_node_get_attr(request, "RequestID")); + inResponseTo = lasso_node_get_attr_value(request, "RequestID", NULL); lasso_samlp_response_abstract_set_inResponseTo(LASSO_SAMLP_RESPONSE_ABSTRACT(response), inResponseTo); + xmlFree(inResponseTo); - request_providerID = lasso_node_get_child(request, "ProviderID", NULL); - recipient = lasso_node_get_content(request_providerID); + request_providerID = lasso_node_get_child_content(request, "ProviderID", NULL, NULL); lasso_samlp_response_abstract_set_recipient(LASSO_SAMLP_RESPONSE_ABSTRACT(response), - recipient); - lasso_node_destroy(request_providerID); - xmlFree(recipient); + request_providerID); + xmlFree(request_providerID); ss = lasso_samlp_status_new(); ssc = lasso_samlp_status_code_new(); @@ -211,7 +210,7 @@ lasso_name_identifier_mapping_response_new_from_soap(const xmlChar *buffer) envelope = lasso_node_new_from_dump(buffer); lassoNode_response = lasso_node_get_child(envelope, "NameIdentifierMappingResponse", - lassoLibHRef); + lassoLibHRef, NULL); class = LASSO_NODE_GET_CLASS(lassoNode_response); xmlNode_response = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_response)), 1); diff --git a/lasso/Attic/protocols/provider.c b/lasso/Attic/protocols/provider.c index 0cde6cb4..26a92f9f 100644 --- a/lasso/Attic/protocols/provider.c +++ b/lasso/Attic/protocols/provider.c @@ -89,25 +89,25 @@ lasso_provider_dump(LassoProvider *provider) gchar * lasso_provider_get_assertionConsumerServiceURL(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "AssertionConsumerServiceURL", NULL)); + return(lasso_node_get_child_content(provider->metadata, "AssertionConsumerServiceURL", NULL, NULL)); } gchar * lasso_provider_get_federationTerminationNotificationProtocolProfile(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "FederationTerminationNotificationProtocolProfile", NULL)); + return(lasso_node_get_child_content(provider->metadata, "FederationTerminationNotificationProtocolProfile", NULL, NULL)); } gchar * lasso_provider_get_federationTerminationReturnServiceURL(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "FederationTerminationReturnServiceURL", NULL)); + return(lasso_node_get_child_content(provider->metadata, "FederationTerminationReturnServiceURL", NULL, NULL)); } gchar * lasso_provider_get_federationTerminationServiceURL(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "FederationTerminationServiceURL", NULL)); + return(lasso_node_get_child_content(provider->metadata, "FederationTerminationServiceURL", NULL, NULL)); } gchar * @@ -188,46 +188,46 @@ lasso_provider_get_providerID(LassoProvider *provider, gchar * lasso_provider_get_registerNameIdentifierProtocolProfile(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "RegisterNameIdentifierProtocolProfile", NULL)); + return(lasso_node_get_child_content(provider->metadata, "RegisterNameIdentifierProtocolProfile", NULL, NULL)); } gchar * lasso_provider_get_registerNameIdentifierServiceURL(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "RegisterNameIdentifierServiceURL", NULL)); + return(lasso_node_get_child_content(provider->metadata, "RegisterNameIdentifierServiceURL", NULL, NULL)); } gchar * lasso_provider_get_singleSignOnProtocolProfile(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "SingleSignOnProtocolProfile", NULL)); + return(lasso_node_get_child_content(provider->metadata, "SingleSignOnProtocolProfile", NULL, NULL)); } gchar * lasso_provider_get_singleSignOnServiceURL(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "SingleSignOnServiceURL", NULL)); + return(lasso_node_get_child_content(provider->metadata, "SingleSignOnServiceURL", NULL, NULL)); } gchar *lasso_provider_get_singleLogoutProtocolProfile(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "SingleLogoutProtocolProfile", NULL)); + return(lasso_node_get_child_content(provider->metadata, "SingleLogoutProtocolProfile", NULL, NULL)); } gchar *lasso_provider_get_singleLogoutServiceURL(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "SingleLogoutServiceURL", NULL)); + return(lasso_node_get_child_content(provider->metadata, "SingleLogoutServiceURL", NULL, NULL)); } gchar *lasso_provider_get_singleLogoutServiceReturnURL(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "SingleLogoutServiceReturnURL", NULL)); + return(lasso_node_get_child_content(provider->metadata, "SingleLogoutServiceReturnURL", NULL, NULL)); } gchar * lasso_provider_get_soapEndpoint(LassoProvider *provider) { - return(lasso_node_get_child_content(provider->metadata, "SoapEndpoint", NULL)); + return(lasso_node_get_child_content(provider->metadata, "SoapEndpoint", NULL, NULL)); } void @@ -253,11 +253,11 @@ static gchar *lasso_provider_get_direct_child_content(LassoProvider *provider, LassoNode *node; xmlChar *content; - node = lasso_node_get_child(LASSO_NODE(provider), name, NULL); + node = lasso_node_get_child(LASSO_NODE(provider), name, NULL, NULL); if(node == NULL) { return(NULL); } - content = lasso_node_get_content(node); + content = lasso_node_get_content(node, NULL); lasso_node_destroy(node); return(content); diff --git a/lasso/Attic/protocols/register_name_identifier_request.c b/lasso/Attic/protocols/register_name_identifier_request.c index 908e1e29..443f5b6d 100644 --- a/lasso/Attic/protocols/register_name_identifier_request.c +++ b/lasso/Attic/protocols/register_name_identifier_request.c @@ -37,17 +37,20 @@ lasso_register_name_identifier_request_rename_attributes_for_query(LassoRegister g_return_if_fail (LASSO_IS_REGISTER_NAME_IDENTIFIER_REQUEST(request)); - idpidentifier = lasso_node_get_child(LASSO_NODE(request), "IDPProvidedNameIdentifier", NULL); + idpidentifier = lasso_node_get_child(LASSO_NODE(request), "IDPProvidedNameIdentifier", + NULL, NULL); lasso_node_rename_prop(idpidentifier, "NameQualifier", "IDPNameQualifier"); lasso_node_rename_prop(idpidentifier, "Format", "IDPFormat"); lasso_node_destroy(idpidentifier); - spidentifier = lasso_node_get_child(LASSO_NODE(request), "SPProvidedNameIdentifier", NULL); + spidentifier = lasso_node_get_child(LASSO_NODE(request), "SPProvidedNameIdentifier", + NULL, NULL); lasso_node_rename_prop(spidentifier, "NameQualifier", "SPNameQualifier"); lasso_node_rename_prop(spidentifier, "Format", "SPFormat"); lasso_node_destroy(spidentifier); - oldidentifier = lasso_node_get_child(LASSO_NODE(request), "OldProvidedNameIdentifier", NULL); + oldidentifier = lasso_node_get_child(LASSO_NODE(request), "OldProvidedNameIdentifier", + NULL, NULL); lasso_node_rename_prop(oldidentifier, "NameQualifier", "OldNameQualifier"); lasso_node_rename_prop(oldidentifier, "Format", "OldFormat"); lasso_node_destroy(oldidentifier); @@ -241,7 +244,7 @@ lasso_register_name_identifier_request_new_from_soap(const xmlChar *buffer) envelope = lasso_node_new_from_dump(buffer); lassoNode_request = lasso_node_get_child(envelope, "RegisterNameIdentifierRequest", - lassoLibHRef); + lassoLibHRef, NULL); class = LASSO_NODE_GET_CLASS(lassoNode_request); xmlNode_request = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_request)), 1); diff --git a/lasso/Attic/protocols/register_name_identifier_response.c b/lasso/Attic/protocols/register_name_identifier_response.c index ba64a2e7..2d401f71 100644 --- a/lasso/Attic/protocols/register_name_identifier_response.c +++ b/lasso/Attic/protocols/register_name_identifier_response.c @@ -94,7 +94,7 @@ lasso_register_name_identifier_response_new_from_soap(gchar *buffer) envelope = lasso_node_new_from_dump(buffer); lassoNode_response = lasso_node_get_child(envelope, "RegisterNameIdentifierResponse", - lassoLibHRef); + lassoLibHRef, NULL); class = LASSO_NODE_GET_CLASS(lassoNode_response); xmlNode_response = xmlCopyNode(class->get_xmlNode(LASSO_NODE(lassoNode_response)), 1); @@ -150,8 +150,8 @@ lasso_register_name_identifier_response_new(gchar *providerID, LassoNode *request) { /* FIXME : change request type */ - LassoNode *response, *ss, *ssc, *request_providerID, *request_relayState; - xmlChar *inResponseTo, *recipient, *relayState; + LassoNode *response, *ss, *ssc; + xmlChar *inResponseTo, *request_providerID, *request_relayState; xmlChar *id, *time; response = LASSO_NODE(g_object_new(LASSO_TYPE_REGISTER_NAME_IDENTIFIER_RESPONSE, NULL)); @@ -177,22 +177,21 @@ lasso_register_name_identifier_response_new(gchar *providerID, lasso_lib_status_response_set_providerID(LASSO_LIB_STATUS_RESPONSE(response), providerID); - inResponseTo = xmlNodeGetContent((xmlNodePtr)lasso_node_get_attr(request, "RequestID")); + inResponseTo = lasso_node_get_attr_value(request, "RequestID", NULL); lasso_samlp_response_abstract_set_inResponseTo(LASSO_SAMLP_RESPONSE_ABSTRACT(response), inResponseTo); + xmlFree(inResponseTo); - request_providerID = lasso_node_get_child(request, "ProviderID", NULL); - recipient = lasso_node_get_content(request_providerID); + request_providerID = lasso_node_get_child_content(request, "ProviderID", NULL, NULL); lasso_samlp_response_abstract_set_recipient(LASSO_SAMLP_RESPONSE_ABSTRACT(response), - recipient); - lasso_node_destroy(request_providerID); + request_providerID); + xmlFree(request_providerID); - request_relayState = lasso_node_get_child(request, "RelayState", NULL); + request_relayState = lasso_node_get_child_content(request, "RelayState", NULL, NULL); if (request_relayState != NULL) { - relayState = lasso_node_get_content(request_relayState); lasso_lib_status_response_set_relayState(LASSO_LIB_STATUS_RESPONSE(response), - relayState); - lasso_node_destroy(request_relayState); + request_relayState); + xmlFree(request_relayState); } ss = lasso_samlp_status_new(); diff --git a/lasso/Attic/protocols/request.c b/lasso/Attic/protocols/request.c index d1d0db04..a5f4ab9e 100644 --- a/lasso/Attic/protocols/request.c +++ b/lasso/Attic/protocols/request.c @@ -124,7 +124,8 @@ lasso_request_new_from_export(gchar *buffer, break; case lassoNodeExportTypeSoap: soap_node = lasso_node_new_from_dump(buffer); - request_node = lasso_node_get_child(soap_node, "Request", lassoSamlProtocolHRef); + request_node = lasso_node_get_child(soap_node, "Request", + lassoSamlProtocolHRef, NULL); export = lasso_node_export(request_node); lasso_node_import(request, export); xmlFree(export); diff --git a/lasso/Attic/protocols/response.c b/lasso/Attic/protocols/response.c index 4a159157..29273b91 100644 --- a/lasso/Attic/protocols/response.c +++ b/lasso/Attic/protocols/response.c @@ -129,7 +129,8 @@ lasso_response_new_from_export(xmlChar *buffer, break; case lassoNodeExportTypeSoap: soap_node = lasso_node_new_from_dump(buffer); - response_node = lasso_node_get_child(soap_node, "Response", lassoSamlProtocolHRef); + response_node = lasso_node_get_child(soap_node, "Response", + lassoSamlProtocolHRef, NULL); export = lasso_node_export(response_node); lasso_node_import(response, export); xmlFree(export); diff --git a/lasso/id-ff/federation_termination.c b/lasso/id-ff/federation_termination.c index 531ce9a9..a756b343 100644 --- a/lasso/id-ff/federation_termination.c +++ b/lasso/id-ff/federation_termination.c @@ -149,7 +149,7 @@ lasso_federation_termination_init_notification(LassoFederationTermination *defed } /* build the request */ - content = lasso_node_get_content(nameIdentifier); + content = lasso_node_get_content(nameIdentifier, NULL); nameQualifier = lasso_node_get_attr_value(nameIdentifier, "NameQualifier", NULL); format = lasso_node_get_attr_value(nameIdentifier, "Format", NULL); profile->request = lasso_federation_termination_notification_new(profile->server->providerID, @@ -206,11 +206,11 @@ lasso_federation_termination_load_notification_msg(LassoFederationTermination *d /* get the NameIdentifier to load identity dump */ profile->nameIdentifier = lasso_node_get_child_content(profile->request, - "NameIdentifier", NULL); + "NameIdentifier", NULL, NULL); /* get the RelayState */ profile->msg_relayState = lasso_node_get_child_content(profile->request, - "RelayState", NULL); + "RelayState", NULL, NULL); return(0); } @@ -230,13 +230,15 @@ lasso_federation_termination_process_notification(LassoFederationTermination *de } /* set the remote provider id from the request */ - profile->remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL); + profile->remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", + NULL, NULL); if(profile->remote_providerID == NULL) { message(G_LOG_LEVEL_ERROR, "Remote provider id not found\n"); return(-1); } - nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", NULL); + nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", + NULL, NULL); if(nameIdentifier == NULL) { message(G_LOG_LEVEL_ERROR, "Name identifier not found in request\n"); return(-1); diff --git a/lasso/id-ff/identity.c b/lasso/id-ff/identity.c index e8ce48b0..1d4c878d 100644 --- a/lasso/id-ff/identity.c +++ b/lasso/id-ff/identity.c @@ -378,7 +378,8 @@ lasso_identity_new_from_dump(gchar *dump) /* federations */ federations_node = lasso_node_get_child(identity_node, - LASSO_IDENTITY_FEDERATIONS_NODE, NULL); + LASSO_IDENTITY_FEDERATIONS_NODE, + NULL, NULL); if (federations_node != NULL) { federations_class = LASSO_NODE_GET_CLASS(federations_node); federations_xmlNode = federations_class->get_xmlNode(federations_node); @@ -403,22 +404,26 @@ lasso_identity_new_from_dump(gchar *dump) /* local name identifier */ local_nameIdentifier_node = lasso_node_get_child(federation_node, - LASSO_FEDERATION_LOCAL_NAME_IDENTIFIER_NODE, NULL); + LASSO_FEDERATION_LOCAL_NAME_IDENTIFIER_NODE, + NULL, NULL); if (local_nameIdentifier_node != NULL) { - nameIdentifier_node = lasso_node_get_child(local_nameIdentifier_node, "NameIdentifier", NULL); + nameIdentifier_node = lasso_node_get_child(local_nameIdentifier_node, "NameIdentifier", + NULL, NULL); lasso_federation_set_local_nameIdentifier(federation, nameIdentifier_node); - debug(" ... add local name identifier %s\n", lasso_node_get_content(nameIdentifier_node)); + debug(" ... add local name identifier %s\n", lasso_node_get_content(nameIdentifier_node, NULL)); lasso_node_destroy(nameIdentifier_node); lasso_node_destroy(local_nameIdentifier_node); } /* remote name identifier */ remote_nameIdentifier_node = lasso_node_get_child(federation_node, - LASSO_FEDERATION_REMOTE_NAME_IDENTIFIER_NODE, NULL); + LASSO_FEDERATION_REMOTE_NAME_IDENTIFIER_NODE, + NULL, NULL); if (remote_nameIdentifier_node != NULL) { - nameIdentifier_node = lasso_node_get_child(remote_nameIdentifier_node, "NameIdentifier", NULL); + nameIdentifier_node = lasso_node_get_child(remote_nameIdentifier_node, "NameIdentifier", + NULL, NULL); lasso_federation_set_remote_nameIdentifier(federation, nameIdentifier_node); - debug(" ... add remote name identifier %s\n", lasso_node_get_content(nameIdentifier_node)); + debug(" ... add remote name identifier %s\n", lasso_node_get_content(nameIdentifier_node, NULL)); lasso_node_destroy(nameIdentifier_node); lasso_node_destroy(remote_nameIdentifier_node); } diff --git a/lasso/id-ff/lecp.c b/lasso/id-ff/lecp.c index 97a267d7..38161097 100644 --- a/lasso/id-ff/lecp.c +++ b/lasso/id-ff/lecp.c @@ -132,15 +132,16 @@ lasso_lecp_init_authn_response_envelope(LassoLecp *lecp, g_return_val_if_fail(LASSO_IS_AUTHN_REQUEST(authnRequest), -1); lecp->server = lasso_server_copy(server); - providerID = lasso_node_get_child_content(LASSO_NODE(authnRequest), "ProviderID", NULL); - if(providerID==NULL){ + providerID = lasso_node_get_child_content(LASSO_NODE(authnRequest), "ProviderID", + NULL, NULL); + if(providerID == NULL) { message(G_LOG_LEVEL_CRITICAL, "ProviderID not found\n"); return(-1); } provider = lasso_server_get_provider(lecp->server, providerID); assertionConsumerServiceURL = lasso_provider_get_assertionConsumerServiceURL(provider); - if(providerID==NULL){ + if(providerID == NULL) { message(G_LOG_LEVEL_CRITICAL, "AssertionConsumerServiceURL not found\n"); return(-1); } diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c index b7dab056..3370dd6e 100644 --- a/lasso/id-ff/login.c +++ b/lasso/id-ff/login.c @@ -51,8 +51,9 @@ lasso_login_get_assertion_nameIdentifier(LassoNode *assertion) { xmlChar *ni, *idp_ni; - ni = lasso_node_get_child_content(assertion, "NameIdentifier", NULL); - idp_ni = lasso_node_get_child_content(assertion, "IDPProvidedNameIdentifier", NULL); + ni = lasso_node_get_child_content(assertion, "NameIdentifier", NULL, NULL); + idp_ni = lasso_node_get_child_content(assertion, "IDPProvidedNameIdentifier", + NULL, NULL); if (xmlStrEqual(ni, idp_ni) && idp_ni != NULL) { xmlFree(ni); @@ -64,7 +65,7 @@ lasso_login_get_assertion_nameIdentifier(LassoNode *assertion) return (ni); } else { - message(G_LOG_LEVEL_ERROR, "NameIdentifier value not found in AuthenticationStatement element.\n"); + message(G_LOG_LEVEL_CRITICAL, "NameIdentifier value not found in AuthenticationStatement element.\n"); return (NULL); } } @@ -85,7 +86,7 @@ lasso_login_add_response_assertion(LassoLogin *login, "RequestID", &err); if (requestID == NULL) { - message(G_LOG_LEVEL_ERROR, err->message); + message(G_LOG_LEVEL_CRITICAL, err->message); ret = err->code; g_error_free(err); return(ret); @@ -103,7 +104,7 @@ lasso_login_add_response_assertion(LassoLogin *login, LASSO_SAML_AUTHENTICATION_STATEMENT(authentication_statement)); } else { - message(G_LOG_LEVEL_ERROR, "Failed to build the AuthenticationStatement element of the Assertion.\n"); + message(G_LOG_LEVEL_CRITICAL, "Failed to build the AuthenticationStatement element of the Assertion.\n"); lasso_node_destroy(assertion); return(-3); } @@ -149,7 +150,7 @@ lasso_login_process_federation(LassoLogin *login) federation = lasso_identity_get_federation(LASSO_PROFILE(login)->identity, LASSO_PROFILE(login)->remote_providerID); nameIDPolicy = lasso_node_get_child_content(LASSO_PROFILE(login)->request, - "NameIDPolicy", NULL); + "NameIDPolicy", NULL, NULL); if (nameIDPolicy == NULL || xmlStrEqual(nameIDPolicy, lassoLibNameIDPolicyTypeNone)) { if (federation == NULL) { lasso_profile_set_response_status(LASSO_PROFILE(login), @@ -223,7 +224,8 @@ lasso_login_process_response_status_and_assertion(LassoLogin *login) { assertion = lasso_node_get_child(LASSO_PROFILE(login)->response, "Assertion", - lassoLibHRef); + lassoLibHRef, + NULL); idp = lasso_server_get_provider(LASSO_PROFILE(login)->server, LASSO_PROFILE(login)->remote_providerID); @@ -249,13 +251,13 @@ lasso_login_process_response_status_and_assertion(LassoLogin *login) { /* check StatusCode value */ status = lasso_node_get_child(LASSO_PROFILE(login)->response, - "Status", lassoSamlProtocolHRef); + "Status", lassoSamlProtocolHRef, NULL); if (status == NULL) { message(G_LOG_LEVEL_ERROR, "Status element not found in response.\n"); ret = -9; goto done; } - statusCode = lasso_node_get_child(status, "StatusCode", lassoSamlProtocolHRef); + statusCode = lasso_node_get_child(status, "StatusCode", lassoSamlProtocolHRef, NULL); if (statusCode == NULL) { message(G_LOG_LEVEL_ERROR, "StatusCode element not found in Status.\n"); @@ -306,7 +308,7 @@ lasso_login_accept_sso(LassoLogin *login) if (LASSO_PROFILE(login)->response != NULL) { assertion = lasso_node_get_child(LASSO_PROFILE(login)->response, - "Assertion", lassoLibHRef); + "Assertion", lassoLibHRef, NULL); if (assertion == NULL) { message(G_LOG_LEVEL_ERROR, "Assertion element not found in response.\n"); ret = -2; @@ -319,14 +321,16 @@ lasso_login_accept_sso(LassoLogin *login) assertion); /* put the 2 NameIdentifiers in identity object */ - nameIdentifier = lasso_node_get_child(assertion, "NameIdentifier", lassoSamlAssertionHRef); + nameIdentifier = lasso_node_get_child(assertion, "NameIdentifier", + lassoSamlAssertionHRef, NULL); if (nameIdentifier == NULL) { message(G_LOG_LEVEL_ERROR, "NameIdentifier element not found in assertion.\n"); ret = -3; goto done; } - idpProvidedNameIdentifier = lasso_node_get_child(assertion, "IDPProvidedNameIdentifier", lassoLibHRef); + idpProvidedNameIdentifier = lasso_node_get_child(assertion, "IDPProvidedNameIdentifier", + lassoLibHRef, NULL); if (idpProvidedNameIdentifier == NULL) { message(G_LOG_LEVEL_ERROR, "IDPProvidedNameIdentifier element not found in assertion.\n"); ret = -4; @@ -389,13 +393,13 @@ lasso_login_build_artifact_msg(LassoLogin *login, if (authentication_result == 0) { lasso_profile_set_response_status(LASSO_PROFILE(login), - lassoSamlStatusCodeRequestDenied); + lassoSamlStatusCodeRequestDenied); } else { /* federation */ lasso_login_process_federation(login); federation = lasso_identity_get_federation(LASSO_PROFILE(login)->identity, - LASSO_PROFILE(login)->remote_providerID); + LASSO_PROFILE(login)->remote_providerID); /* fill the response with the assertion */ if (federation != NULL) { lasso_login_add_response_assertion(login, @@ -422,7 +426,7 @@ lasso_login_build_artifact_msg(LassoLogin *login, b64_samlArt = (gchar *)xmlSecBase64Encode(samlArt, 42, 0); g_free(samlArt); relayState = lasso_node_get_child_content(LASSO_PROFILE(login)->request, - "RelayState", NULL); + "RelayState", NULL, NULL); switch (method) { case lassoHttpMethodRedirect: @@ -466,7 +470,9 @@ lasso_login_build_authn_request_msg(LassoLogin *login) LASSO_PROFILE(login)->remote_providerID); /* check if authnRequest must be signed */ - md_authnRequestsSigned = lasso_node_get_child_content(provider->metadata, "AuthnRequestsSigned", NULL); + md_authnRequestsSigned = lasso_node_get_child_content(provider->metadata, + "AuthnRequestsSigned", + NULL, NULL); if (md_authnRequestsSigned != NULL) { must_sign = xmlStrEqual(md_authnRequestsSigned, "true"); xmlFree(md_authnRequestsSigned); @@ -687,7 +693,7 @@ lasso_login_init_from_authn_request_msg(LassoLogin *login, /* get ProtocolProfile */ protocolProfile = lasso_node_get_child_content(LASSO_PROFILE(login)->request, - "ProtocolProfile", NULL); + "ProtocolProfile", NULL, NULL); if (protocolProfile == NULL) { login->protocolProfile = lassoLoginProtocolProfileBrwsArt; } @@ -716,12 +722,13 @@ lasso_login_init_from_authn_request_msg(LassoLogin *login, /* get remote ProviderID */ LASSO_PROFILE(login)->remote_providerID = lasso_node_get_child_content(LASSO_PROFILE(login)->request, - "ProviderID", NULL); + "ProviderID", NULL, NULL); remote_provider = lasso_server_get_provider(LASSO_PROFILE(login)->server, LASSO_PROFILE(login)->remote_providerID); /* Is authnRequest signed ? */ - md_authnRequestsSigned = lasso_node_get_child_content(remote_provider->metadata, "AuthnRequestsSigned", NULL); + md_authnRequestsSigned = lasso_node_get_child_content(remote_provider->metadata, + "AuthnRequestsSigned", NULL, NULL); if (md_authnRequestsSigned != NULL) { must_verify_signature = xmlStrEqual(md_authnRequestsSigned, "true"); xmlFree(md_authnRequestsSigned); @@ -819,7 +826,8 @@ lasso_login_must_authenticate(LassoLogin *login) gchar *str; /* verify if the user must be authenticated or not */ - str = lasso_node_get_child_content(LASSO_PROFILE(login)->request, "IsPassive", NULL); + str = lasso_node_get_child_content(LASSO_PROFILE(login)->request, "IsPassive", + NULL, NULL); if (str != NULL) { if (xmlStrEqual(str, "false")) { isPassive = FALSE; @@ -827,7 +835,8 @@ lasso_login_must_authenticate(LassoLogin *login) xmlFree(str); } - str = lasso_node_get_child_content(LASSO_PROFILE(login)->request, "ForceAuthn", NULL); + str = lasso_node_get_child_content(LASSO_PROFILE(login)->request, "ForceAuthn", + NULL, NULL); if (str != NULL) { if (xmlStrEqual(str, "true")) { forceAuthn = TRUE; @@ -866,7 +875,8 @@ lasso_login_process_request_msg(LassoLogin *login, LASSO_PROFILE(login)->request_type = lassoMessageTypeRequest; login->assertionArtifact = lasso_node_get_child_content(LASSO_PROFILE(login)->request, - "AssertionArtifact", lassoSamlProtocolHRef); + "AssertionArtifact", + lassoSamlProtocolHRef, NULL); return (0); } @@ -995,17 +1005,17 @@ lasso_login_new_from_dump(LassoServer *server, node_dump = lasso_node_new_from_dump(dump); /* profile attributes */ - LASSO_PROFILE(login)->nameIdentifier = lasso_node_get_child_content(node_dump, "NameIdentifier", NULL); - LASSO_PROFILE(login)->remote_providerID = lasso_node_get_child_content(node_dump, "RemoteProviderID", NULL); - LASSO_PROFILE(login)->msg_url = lasso_node_get_child_content(node_dump, "MsgUrl", NULL); - LASSO_PROFILE(login)->msg_body = lasso_node_get_child_content(node_dump, "MsgBody", NULL); - LASSO_PROFILE(login)->msg_relayState = lasso_node_get_child_content(node_dump, "MsgRelayState", NULL); + LASSO_PROFILE(login)->nameIdentifier = lasso_node_get_child_content(node_dump, "NameIdentifier", NULL, NULL); + LASSO_PROFILE(login)->remote_providerID = lasso_node_get_child_content(node_dump, "RemoteProviderID", NULL, NULL); + LASSO_PROFILE(login)->msg_url = lasso_node_get_child_content(node_dump, "MsgUrl", NULL, NULL); + LASSO_PROFILE(login)->msg_body = lasso_node_get_child_content(node_dump, "MsgBody", NULL, NULL); + LASSO_PROFILE(login)->msg_relayState = lasso_node_get_child_content(node_dump, "MsgRelayState", NULL, NULL); - type = lasso_node_get_child_content(node_dump, "RequestType", NULL); + type = lasso_node_get_child_content(node_dump, "RequestType", NULL, NULL); LASSO_PROFILE(login)->request_type = atoi(type); xmlFree(type); - request_node = lasso_node_get_child(node_dump, "Request", NULL); + request_node = lasso_node_get_child(node_dump, "Request", NULL, NULL); if (request_node != NULL) { export = lasso_node_export(request_node); switch (LASSO_PROFILE(login)->request_type) { @@ -1024,11 +1034,11 @@ lasso_login_new_from_dump(LassoServer *server, lasso_node_destroy(request_node); } - type = lasso_node_get_child_content(node_dump, "ResponseType", NULL); + type = lasso_node_get_child_content(node_dump, "ResponseType", NULL, NULL); LASSO_PROFILE(login)->response_type = atoi(type); xmlFree(type); - response_node = lasso_node_get_child(node_dump, "Response", NULL); + response_node = lasso_node_get_child(node_dump, "Response", NULL, NULL); if (response_node != NULL) { export = lasso_node_export(response_node); switch (LASSO_PROFILE(login)->response_type) { @@ -1047,18 +1057,18 @@ lasso_login_new_from_dump(LassoServer *server, lasso_node_destroy(response_node); } - type = lasso_node_get_child_content(node_dump, "ProviderType", NULL); + type = lasso_node_get_child_content(node_dump, "ProviderType", NULL, NULL); LASSO_PROFILE(login)->provider_type = atoi(type); xmlFree(type); /* login attributes */ - protocolProfile = lasso_node_get_child_content(node_dump, "ProtocolProfile", NULL); + protocolProfile = lasso_node_get_child_content(node_dump, "ProtocolProfile", NULL, NULL); if (protocolProfile != NULL) { login->protocolProfile = atoi(protocolProfile); xmlFree(protocolProfile); } - login->assertionArtifact = lasso_node_get_child_content(node_dump, "AssertionArtifact", NULL); - login->response_dump = lasso_node_get_child_content(node_dump, "ResponseDump", NULL); + login->assertionArtifact = lasso_node_get_child_content(node_dump, "AssertionArtifact", NULL, NULL); + login->response_dump = lasso_node_get_child_content(node_dump, "ResponseDump", NULL, NULL); lasso_node_destroy(node_dump); diff --git a/lasso/id-ff/logout.c b/lasso/id-ff/logout.c index 0145f1ec..15b95cb0 100644 --- a/lasso/id-ff/logout.c +++ b/lasso/id-ff/logout.c @@ -249,13 +249,15 @@ lasso_logout_init_request(LassoLogout *logout, } if(nameIdentifier == NULL) { - message(G_LOG_LEVEL_ERROR, "Name identifier not found for %s\n", profile->remote_providerID); + message(G_LOG_LEVEL_ERROR, "Name identifier not found for %s\n", + profile->remote_providerID); return(-5); } /* build the request */ - content = lasso_node_get_content(nameIdentifier); - nameQualifier = lasso_node_get_attr_value(nameIdentifier, "NameQualifier", NULL); + content = lasso_node_get_content(nameIdentifier, NULL); + nameQualifier = lasso_node_get_attr_value(nameIdentifier, "NameQualifier", + NULL); format = lasso_node_get_attr_value(nameIdentifier, "Format", NULL); profile->request = lasso_logout_request_new(profile->server->providerID, content, @@ -288,11 +290,13 @@ gint lasso_logout_load_request_msg(LassoLogout *logout, switch(request_method){ case lassoHttpMethodSoap: debug("Build a logout request from soap msg\n"); - profile->request = lasso_logout_request_new_from_export(request_msg, lassoNodeExportTypeSoap); + profile->request = lasso_logout_request_new_from_export(request_msg, + lassoNodeExportTypeSoap); break; case lassoHttpMethodRedirect: debug("Build a logout request from query msg\n"); - profile->request = lasso_logout_request_new_from_export(request_msg, lassoNodeExportTypeQuery); + profile->request = lasso_logout_request_new_from_export(request_msg, + lassoNodeExportTypeQuery); break; case lassoHttpMethodGet: debug("TODO, implement the get method\n"); @@ -308,11 +312,13 @@ gint lasso_logout_load_request_msg(LassoLogout *logout, /* get the NameIdentifier to load identity dump */ profile->nameIdentifier = lasso_node_get_child_content(profile->request, - "NameIdentifier", NULL); + "NameIdentifier", + NULL, NULL); /* get the RelayState */ profile->msg_relayState = lasso_node_get_child_content(profile->request, - "RelayState", NULL); + "RelayState", + NULL, NULL); return(0); } @@ -337,7 +343,8 @@ lasso_logout_process_request(LassoLogout *logout) } /* set the remote provider id from the request */ - remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL); + remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", + NULL, NULL); if(remote_providerID == NULL) { message(G_LOG_LEVEL_ERROR, "ProviderID in LogoutRequest not found\n"); return(-1); @@ -353,17 +360,19 @@ lasso_logout_process_request(LassoLogout *logout) return(-5); } - statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL); + statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL); statusCode_class = LASSO_NODE_GET_CLASS(statusCode); - nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", NULL); + nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", + NULL, NULL); if(nameIdentifier == NULL) { message(G_LOG_LEVEL_ERROR, "Name identifier not found in logout request\n"); statusCode_class->set_prop(statusCode, "Value", lassoLibStatusCodeFederationDoesNotExist); return(-6); } - remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL); + remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", + NULL, NULL); if(remote_providerID == NULL) { message(G_LOG_LEVEL_ERROR, "Provider id not found in logout request\n"); return(-7); @@ -457,7 +466,7 @@ lasso_logout_process_response_msg(LassoLogout *logout, message(G_LOG_LEVEL_ERROR, "LogoutResponse is NULL\n"); return(-1); } - statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL); + statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL); if(statusCode == NULL) { message(G_LOG_LEVEL_ERROR, "StatusCode node not found\n"); @@ -470,7 +479,8 @@ lasso_logout_process_response_msg(LassoLogout *logout, return(-1); } - profile->remote_providerID = lasso_node_get_child_content(profile->response, "ProviderID", NULL); + profile->remote_providerID = lasso_node_get_child_content(profile->response, "ProviderID", + NULL, NULL); /* response is ok, so delete the assertion */ switch(profile->provider_type) { case lassoProviderTypeSp: diff --git a/lasso/id-ff/name_identifier_mapping.c b/lasso/id-ff/name_identifier_mapping.c index 2a7b6f24..4c3ba3f4 100644 --- a/lasso/id-ff/name_identifier_mapping.c +++ b/lasso/id-ff/name_identifier_mapping.c @@ -32,7 +32,7 @@ gchar * lasso_name_identifier_mapping_dump(LassoNameIdentifierMapping *mapping) { - gchar *dump; + gchar *dump = NULL; g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), NULL); @@ -101,13 +101,13 @@ lasso_name_identifier_mapping_build_response_msg(LassoNameIdentifierMapping *map profile = LASSO_PROFILE(mapping); provider = lasso_server_get_provider(profile->server, profile->remote_providerID); - if(provider==NULL){ + if(provider == NULL) { message(G_LOG_LEVEL_ERROR, "Provider %s not found\n", profile->remote_providerID); return(-2); } protocolProfile = lasso_provider_get_nameIdentifierMappingProtocolProfile(provider, &err); - if(err != NULL){ + if(err != NULL) { message(G_LOG_LEVEL_ERROR, err->message); ret = err->code; g_error_free(err); @@ -144,7 +144,7 @@ lasso_name_identifier_mapping_init_request(LassoNameIdentifierMapping *mapping, xmlChar *content, *nameQualifier, *format; g_return_val_if_fail(LASSO_IS_NAME_IDENTIFIER_MAPPING(mapping), -1); - g_return_val_if_fail(remote_providerID!=NULL, -2); + g_return_val_if_fail(remote_providerID != NULL, -2); profile = LASSO_PROFILE(mapping); @@ -158,7 +158,7 @@ lasso_name_identifier_mapping_init_request(LassoNameIdentifierMapping *mapping, } /* get the name identifier (!!! depend on the provider type : SP or IDP !!!)*/ - switch(profile->provider_type){ + switch(profile->provider_type) { case lassoProviderTypeSp: debug("service provider\n"); nameIdentifier = LASSO_NODE(lasso_federation_get_local_nameIdentifier(federation)); @@ -167,23 +167,24 @@ lasso_name_identifier_mapping_init_request(LassoNameIdentifierMapping *mapping, break; case lassoProviderTypeIdp: debug("federation provider\n"); - /* get the next assertion ( next authenticated service provider ) */ + /* get the next assertion (next authenticated service provider) */ nameIdentifier = LASSO_NODE(lasso_federation_get_remote_nameIdentifier(federation)); - if(!nameIdentifier) + if(nameIdentifier == NULL) { nameIdentifier = LASSO_NODE(lasso_federation_get_local_nameIdentifier(federation)); + } break; default: message(G_LOG_LEVEL_ERROR, "Unknown provider type\n"); return(-4); } - if(!nameIdentifier){ + if(nameIdentifier == NULL) { message(G_LOG_LEVEL_ERROR, "Name identifier not found\n"); return(-5); } /* build the request */ - content = lasso_node_get_content(nameIdentifier); + content = lasso_node_get_content(nameIdentifier, NULL); nameQualifier = lasso_node_get_attr_value(nameIdentifier, "NameQualifier", NULL); format = lasso_node_get_attr_value(nameIdentifier, "Format", NULL); profile->request = lasso_name_identifier_mapping_request_new(profile->server->providerID, @@ -231,7 +232,8 @@ lasso_name_identifier_mapping_process_request_msg(LassoNameIdentifierMapping *ma } /* set the remote provider id from the request */ - remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL); + remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", + NULL, NULL); profile->remote_providerID = remote_providerID; /* set Name_Identifier_MappingResponse */ @@ -241,16 +243,17 @@ lasso_name_identifier_mapping_process_request_msg(LassoNameIdentifierMapping *ma g_return_val_if_fail(profile->response!=NULL, -4); - statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL); + statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL); statusCode_class = LASSO_NODE_GET_CLASS(statusCode); - nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", NULL); + nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", NULL, NULL); if(nameIdentifier == NULL) { statusCode_class->set_prop(statusCode, "Value", lassoLibStatusCodeFederationDoesNotExist); return(-5); } - remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL); + remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", + NULL, NULL); /* Verify federation */ federation = lasso_identity_get_federation(profile->identity, remote_providerID); @@ -294,7 +297,7 @@ lasso_name_identifier_mapping_process_response_msg(LassoNameIdentifierMapping *m return(-3); } - statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL); + statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL); statusCodeValue = lasso_node_get_attr_value(statusCode, "Value", &err); if (err == NULL) { if(!xmlStrEqual(statusCodeValue, lassoSamlStatusCodeSuccess)) { diff --git a/lasso/id-ff/profile.c b/lasso/id-ff/profile.c index 71fbed06..b4acbe99 100644 --- a/lasso/id-ff/profile.c +++ b/lasso/id-ff/profile.c @@ -52,27 +52,27 @@ lasso_profile_get_request_type_from_soap_msg(gchar *soap) int type = 0; soap_node = lasso_node_new_from_dump(soap); - if(soap_node==NULL){ + if (soap_node == NULL) { message(G_LOG_LEVEL_ERROR, "Error while build node from soap msg\n"); return(-1); } - body_node = lasso_node_get_child(soap_node, "Body", NULL); - if(body_node==NULL){ + body_node = lasso_node_get_child(soap_node, "Body", NULL, NULL); + if(body_node == NULL) { message(G_LOG_LEVEL_ERROR, "Body node not found\n"); return(-2); } children = lasso_node_get_children(body_node); - if(children->len>0){ + if(children->len>0) { request_node = g_ptr_array_index(children, 0); name = lasso_node_get_name(request_node); - if(xmlStrEqual(name, "Request")){ + if(xmlStrEqual(name, "Request")) { debug("A Request node found\n"); type = lassoRequestTypeLogin; } - else if(xmlStrEqual(name, "LogoutRequest")){ + else if(xmlStrEqual(name, "LogoutRequest")) { type = lassoRequestTypeLogout; } else if(xmlStrEqual(name, "FederationTerminationNotification")){ diff --git a/lasso/id-ff/register_name_identifier.c b/lasso/id-ff/register_name_identifier.c index 5e19c89f..7aca6b41 100644 --- a/lasso/id-ff/register_name_identifier.c +++ b/lasso/id-ff/register_name_identifier.c @@ -181,7 +181,7 @@ lasso_register_name_identifier_init_request(LassoRegisterNameIdentifier *registe /* set the old name identifier */ nameIdentifier_node = lasso_federation_get_local_nameIdentifier(federation); if(nameIdentifier_node != NULL) { - oldNameIdentifier = lasso_node_get_content(nameIdentifier_node); + oldNameIdentifier = lasso_node_get_content(nameIdentifier_node, NULL); oldNameQualifier = lasso_node_get_attr_value(nameIdentifier_node, "NameQualifier", NULL); oldFormat = lasso_node_get_attr_value(nameIdentifier_node, "Format", NULL); } @@ -193,7 +193,7 @@ lasso_register_name_identifier_init_request(LassoRegisterNameIdentifier *registe message(G_LOG_LEVEL_ERROR, "Remote NameIdentifier for service provider not found\n"); return(-1); } - idpNameIdentifier = lasso_node_get_content(nameIdentifier_node); + idpNameIdentifier = lasso_node_get_content(nameIdentifier_node, NULL); idpNameQualifier = lasso_node_get_attr_value(nameIdentifier_node, "NameQualifier", NULL); idpFormat = lasso_node_get_attr_value(nameIdentifier_node, "Format", NULL); lasso_node_destroy(nameIdentifier_node); @@ -213,13 +213,13 @@ lasso_register_name_identifier_init_request(LassoRegisterNameIdentifier *registe idpFormat = "federated"; nameIdentifier_node = lasso_federation_get_local_nameIdentifier(federation); - oldNameIdentifier = lasso_node_get_content(nameIdentifier_node); + oldNameIdentifier = lasso_node_get_content(nameIdentifier_node, NULL); oldNameQualifier = lasso_node_get_attr_value(nameIdentifier_node, "NameQualifier", NULL); oldFormat = lasso_node_get_attr_value(nameIdentifier_node, "Format", NULL); nameIdentifier_node = lasso_federation_get_remote_nameIdentifier(federation); if(nameIdentifier_node != NULL) { - spNameIdentifier = lasso_node_get_content(nameIdentifier_node); + spNameIdentifier = lasso_node_get_content(nameIdentifier_node, NULL); spNameQualifier = lasso_node_get_attr_value(nameIdentifier_node, "NameQualifier", NULL); spFormat = lasso_node_get_attr_value(nameIdentifier_node, "Format", NULL); } @@ -292,11 +292,11 @@ gint lasso_register_name_identifier_load_request_msg(LassoRegisterNameIdentifier /* get the NameIdentifier to load identity dump */ profile->nameIdentifier = lasso_node_get_child_content(profile->request, - "NameIdentifier", NULL); + "NameIdentifier", NULL, NULL); /* get the RelayState */ profile->msg_relayState = lasso_node_get_child_content(profile->request, - "RelayState", NULL); + "RelayState", NULL, NULL); return(0); } @@ -316,12 +316,12 @@ lasso_register_name_identifier_process_request(LassoRegisterNameIdentifier *regi profile = LASSO_PROFILE(register_name_identifier); /* set the remote provider id from the request */ - remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL); + remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL, NULL); profile->remote_providerID = remote_providerID; /* set RegisterNameIdentifierResponse */ profile->response = lasso_register_name_identifier_response_new(profile->server->providerID, - lassoSamlStatusCodeSuccess, + (gchar *)lassoSamlStatusCodeSuccess, profile->request); if(profile->response == NULL) { @@ -329,17 +329,17 @@ lasso_register_name_identifier_process_request(LassoRegisterNameIdentifier *regi return(-4); } - statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL); + statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL); statusCode_class = LASSO_NODE_GET_CLASS(statusCode); - nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", NULL); + nameIdentifier = lasso_node_get_child(profile->request, "NameIdentifier", NULL, NULL); if(nameIdentifier == NULL) { message(G_LOG_LEVEL_ERROR, "No name identifier found in register_name_identifier request\n"); statusCode_class->set_prop(statusCode, "Value", lassoLibStatusCodeFederationDoesNotExist); return(-5); } - remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL); + remote_providerID = lasso_node_get_child_content(profile->request, "ProviderID", NULL, NULL); if(remote_providerID == NULL) { message(G_LOG_LEVEL_ERROR, "No provider id found in register_name_identifier request\n"); return(-6); @@ -400,7 +400,7 @@ lasso_register_name_identifier_process_response_msg(LassoRegisterNameIdentifier return(-3); } - statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL); + statusCode = lasso_node_get_child(profile->response, "StatusCode", NULL, NULL); statusCodeValue = lasso_node_get_attr_value(statusCode, "Value", &err); if (err == NULL) { if(!xmlStrEqual(statusCodeValue, lassoSamlStatusCodeSuccess)) { diff --git a/lasso/id-ff/server.c b/lasso/id-ff/server.c index 762d7a72..c9bf01b8 100644 --- a/lasso/id-ff/server.c +++ b/lasso/id-ff/server.c @@ -407,7 +407,7 @@ lasso_server_new_from_dump(gchar *dump) } /* metadata */ - server_metadata_node = lasso_node_get_child(server_node, "EntityDescriptor", NULL); + server_metadata_node = lasso_node_get_child(server_node, "EntityDescriptor", NULL, NULL); LASSO_PROVIDER(server)->metadata = lasso_node_copy(server_metadata_node); lasso_node_destroy(server_metadata_node); @@ -418,7 +418,7 @@ lasso_server_new_from_dump(gchar *dump) LASSO_PROVIDER(server)->ca_certificate = lasso_node_get_attr_value(server_node, LASSO_PROVIDER_CA_CERTIFICATE_NODE, NULL); /* providers */ - providers_node = lasso_node_get_child(server_node, LASSO_SERVER_PROVIDERS_NODE, NULL); + providers_node = lasso_node_get_child(server_node, LASSO_SERVER_PROVIDERS_NODE, NULL, NULL); if(providers_node != NULL) { providers_class = LASSO_NODE_GET_CLASS(providers_node); providers_xmlNode = providers_class->get_xmlNode(providers_node); @@ -430,7 +430,7 @@ lasso_server_new_from_dump(gchar *dump) provider_node = lasso_node_new_from_xmlNode(provider_xmlNode); /* metadata */ - entity_node = lasso_node_get_child(provider_node, "EntityDescriptor", NULL); + entity_node = lasso_node_get_child(provider_node, "EntityDescriptor", NULL, NULL); /* public key */ public_key = lasso_node_get_attr_value(provider_node, LASSO_PROVIDER_PUBLIC_KEY_NODE, NULL); diff --git a/lasso/id-ff/session.c b/lasso/id-ff/session.c index 0c8b2dae..1d555bc8 100644 --- a/lasso/id-ff/session.c +++ b/lasso/id-ff/session.c @@ -218,7 +218,7 @@ lasso_session_get_authentication_method(LassoSession *session, if (remote_providerID == NULL) { g_free(providerID); } - as = lasso_node_get_child(assertion, "AuthenticationStatement", NULL); + as = lasso_node_get_child(assertion, "AuthenticationStatement", NULL, NULL); authentication_method = lasso_node_get_attr_value(as, "AuthenticationMethod", &err); if (authentication_method == NULL) { message(G_LOG_LEVEL_ERROR, err->message); @@ -403,7 +403,8 @@ lasso_session_new_from_dump(gchar *dump) /* get assertions */ assertions_node = lasso_node_get_child(session_node, - LASSO_SESSION_ASSERTIONS_NODE, NULL); + LASSO_SESSION_ASSERTIONS_NODE, + NULL, NULL); if (assertions_node != NULL) { assertions_xmlNode = LASSO_NODE_GET_CLASS(assertions_node)->get_xmlNode(assertions_node); assertion_xmlNode = assertions_xmlNode->children; diff --git a/lasso/xml/errors.c b/lasso/xml/errors.c index 073f8a95..df152193 100644 --- a/lasso/xml/errors.c +++ b/lasso/xml/errors.c @@ -29,8 +29,14 @@ const char* lasso_strerror(int error_code) { switch (error_code) { + case LASSO_XML_ERROR_NODE_NOTFOUND: + return "Unable to get '%s' child of '%s' element.\n"; + case LASSO_XML_ERROR_NODE_CONTENT_NOTFOUND: + return "Unable to get content of '%s' element.\n"; + case LASSO_XML_ERROR_ATTR_NOTFOUND: + return "Unable to get '%s' attribute of '%s' element.\n"; case LASSO_XML_ERROR_ATTR_VALUE_NOTFOUND: - return "Unable to get '%s' attribute value in '%s' element.\n"; + return "Unable to get '%s' attribute value of '%s' element.\n"; default: return "Undefined error code !!!\n"; } diff --git a/lasso/xml/errors.h b/lasso/xml/errors.h index 8593d34e..61e0a844 100644 --- a/lasso/xml/errors.h +++ b/lasso/xml/errors.h @@ -23,6 +23,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define LASSO_XML_ERROR_ATTR_VALUE_NOTFOUND -1 +#define LASSO_XML_ERROR_NODE_NOTFOUND -1 +#define LASSO_XML_ERROR_NODE_CONTENT_NOTFOUND -2 +#define LASSO_XML_ERROR_ATTR_NOTFOUND -3 +#define LASSO_XML_ERROR_ATTR_VALUE_NOTFOUND -4 const char* lasso_strerror(int error_code); diff --git a/lasso/xml/lib_scoping.c b/lasso/xml/lib_scoping.c index ffb50ac0..acc637c8 100644 --- a/lasso/xml/lib_scoping.c +++ b/lasso/xml/lib_scoping.c @@ -23,6 +23,9 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include <glib.h> +#include <glib/gprintf.h> + #include <lasso/xml/lib_scoping.h> /* diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 63ffc7ef..ff11a045 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -186,13 +186,14 @@ lasso_node_export_to_soap(LassoNode *node) * Return value: the attribute or NULL if not found. **/ LassoAttr * -lasso_node_get_attr(LassoNode *node, - const xmlChar *name) +lasso_node_get_attr(LassoNode *node, + const xmlChar *name, + GError **err) { g_return_val_if_fail (LASSO_IS_NODE(node), NULL); LassoNodeClass *class = LASSO_NODE_GET_CLASS(node); - return (class->get_attr(node, name)); + return (class->get_attr(node, name, err)); } /** @@ -245,14 +246,15 @@ lasso_node_get_attrs(LassoNode *node) * Return value: a child node **/ LassoNode * -lasso_node_get_child(LassoNode *node, - const xmlChar *name, - const xmlChar *href) +lasso_node_get_child(LassoNode *node, + const xmlChar *name, + const xmlChar *href, + GError **err) { g_return_val_if_fail (LASSO_IS_NODE(node), NULL); LassoNodeClass *class = LASSO_NODE_GET_CLASS(node); - return (class->get_child(node, name, href)); + return (class->get_child(node, name, href, err)); } /** @@ -267,14 +269,15 @@ lasso_node_get_child(LassoNode *node, * available. It's up to the caller to free the memory with xmlFree(). **/ xmlChar * -lasso_node_get_child_content(LassoNode *node, - const xmlChar *name, - const xmlChar *href) +lasso_node_get_child_content(LassoNode *node, + const xmlChar *name, + const xmlChar *href, + GError **err) { g_return_val_if_fail (LASSO_IS_NODE(node), NULL); LassoNodeClass *class = LASSO_NODE_GET_CLASS(node); - return (class->get_child_content(node, name, href)); + return (class->get_child_content(node, name, href, err)); } /** @@ -307,12 +310,13 @@ lasso_node_get_children(LassoNode *node) * It's up to the caller to free the memory with xmlFree(). **/ xmlChar * -lasso_node_get_content(LassoNode *node) +lasso_node_get_content(LassoNode *node, + GError **err) { g_return_val_if_fail (LASSO_IS_NODE(node), NULL); LassoNodeClass *class = LASSO_NODE_GET_CLASS(node); - return (class->get_content(node)); + return (class->get_content(node, err)); } /** @@ -552,7 +556,6 @@ lasso_node_impl_dump(LassoNode *node, int format) { xmlChar *ret; - int len; xmlOutputBufferPtr buf; xmlCharEncodingHandlerPtr handler = NULL; @@ -570,16 +573,16 @@ lasso_node_impl_dump(LassoNode *node, if (buf == NULL) { return (NULL); } - xmlNodeDumpOutput(buf, node->private->node->doc, node->private->node, + xmlNodeDumpOutput(buf, NULL, node->private->node, 0, format, encoding); xmlOutputBufferFlush(buf); if (buf->conv != NULL) { - len = buf->conv->use; + /* ret = g_strdup(buf->conv->content); */ ret = buf->conv->content; buf->conv->content = NULL; } else { - len = buf->buffer->use; + /* ret = g_strdup(buf->buffer->content); */ ret = buf->buffer->content; buf->buffer->content = NULL; } @@ -603,7 +606,7 @@ lasso_node_impl_export_to_base64(LassoNode *node) buffer = lasso_node_impl_dump(node, "utf-8", 0); ret = xmlSecBase64Encode((const xmlSecByte *) buffer, (xmlSecSize)strlen((const char *)buffer), 0); - xmlFree(buffer); + g_free(buffer); return (ret); } @@ -701,13 +704,15 @@ lasso_node_impl_export_to_soap(LassoNode *node) } static LassoAttr* -lasso_node_impl_get_attr(LassoNode *node, - const xmlChar *name) +lasso_node_impl_get_attr(LassoNode *node, + const xmlChar *name, + GError **err) { LassoAttr *prop; g_return_val_if_fail (LASSO_IS_NODE(node), NULL); g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (err == NULL || *err == NULL, NULL); prop = node->private->node->properties; while (prop != NULL) { @@ -717,6 +722,11 @@ lasso_node_impl_get_attr(LassoNode *node, prop = prop->next; } + /* attr not found */ + g_set_error(err, g_quark_from_string("Lasso"), + LASSO_XML_ERROR_ATTR_NOTFOUND, + lasso_strerror(LASSO_XML_ERROR_ATTR_NOTFOUND), + name, node->private->node->name); return (NULL); } @@ -762,12 +772,14 @@ lasso_node_impl_get_attrs(LassoNode *node) } static LassoNode * -lasso_node_impl_get_child(LassoNode *node, - const xmlChar *name, - const xmlChar *href) +lasso_node_impl_get_child(LassoNode *node, + const xmlChar *name, + const xmlChar *href, + GError **err) { g_return_val_if_fail (LASSO_IS_NODE(node), NULL); g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (err == NULL || *err == NULL, NULL); /* /\* No recurssive version *\/ */ /* xmlNodePtr cur; */ @@ -805,8 +817,9 @@ lasso_node_impl_get_child(LassoNode *node, xmlNodePtr child; - if (href != NULL) + if (href != NULL) { child = xmlSecFindNode(node->private->node, name, href); + } else { child = xmlSecFindNode(node->private->node, name, href); if (child == NULL) @@ -820,26 +833,41 @@ lasso_node_impl_get_child(LassoNode *node, if (child == NULL) child = xmlSecFindNode(node->private->node, name, lassoMetadataHRef); } - if (child != NULL) + if (child != NULL) { return (lasso_node_new_from_xmlNode(child)); - else + } + else { + g_set_error(err, g_quark_from_string("Lasso"), + LASSO_XML_ERROR_NODE_NOTFOUND, + lasso_strerror(LASSO_XML_ERROR_NODE_NOTFOUND), + name, node->private->node->name); return (NULL); + } } static xmlChar * -lasso_node_impl_get_child_content(LassoNode *node, - const xmlChar *name, - const xmlChar *href) +lasso_node_impl_get_child_content(LassoNode *node, + const xmlChar *name, + const xmlChar *href, + GError **err) { g_return_val_if_fail (LASSO_IS_NODE(node), NULL); g_return_val_if_fail (name != NULL, NULL); + g_return_val_if_fail (err == NULL || *err == NULL, NULL); - LassoNode *child = lasso_node_get_child(node, name, href); + GError *tmp_err = NULL; + LassoNode *child = lasso_node_get_child(node, name, href, &tmp_err); xmlChar *content = NULL; if (child != NULL) { - content = lasso_node_get_content(child); + content = lasso_node_get_content(child, &tmp_err); lasso_node_destroy(child); + if (content == NULL) { + g_propagate_error (err, tmp_err); + } + } + else { + g_propagate_error (err, tmp_err); } return (content); @@ -866,11 +894,23 @@ lasso_node_impl_get_children(LassoNode *node) } static xmlChar * -lasso_node_impl_get_content(LassoNode *node) +lasso_node_impl_get_content(LassoNode *node, + GError **err) { + xmlChar *content; + g_return_val_if_fail (LASSO_IS_NODE(node), NULL); + g_return_val_if_fail (err == NULL || *err == NULL, NULL); + + content = xmlNodeGetContent(node->private->node); + if (content == NULL) { + g_set_error(err, g_quark_from_string("Lasso"), + LASSO_XML_ERROR_NODE_CONTENT_NOTFOUND, + lasso_strerror(LASSO_XML_ERROR_NODE_CONTENT_NOTFOUND), + node->private->node->name); + } - return (xmlNodeGetContent(node->private->node)); + return (content); } static xmlChar * @@ -922,7 +962,7 @@ lasso_node_impl_rename_prop(LassoNode *node, value = xmlGetProp(node->private->node, old_name); if (value != NULL) { - xmlRemoveProp(lasso_node_get_attr(node, old_name)); + xmlRemoveProp(lasso_node_get_attr(node, old_name, NULL)); lasso_node_set_prop(node, new_name, value); } } diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h index ec5e126a..c519bf1d 100644 --- a/lasso/xml/xml.h +++ b/lasso/xml/xml.h @@ -79,21 +79,25 @@ struct _LassoNodeClass { lassoSignatureMethod sign_method, const gchar *private_key_file); xmlChar* (* export_to_soap) (LassoNode *node); - LassoAttr* (* get_attr) (LassoNode *node, - const xmlChar *name); + LassoAttr* (* get_attr) (LassoNode *node, + const xmlChar *name, + GError **err); xmlChar* (* get_attr_value) (LassoNode *node, const xmlChar *name, GError **err); GPtrArray* (* get_attrs) (LassoNode *node); - LassoNode* (* get_child) (LassoNode *node, - const xmlChar *name, - const xmlChar *href); - xmlChar* (* get_child_content)(LassoNode *node, - const xmlChar *name, - const xmlChar *href); + LassoNode* (* get_child) (LassoNode *node, + const xmlChar *name, + const xmlChar *href, + GError **err); + xmlChar* (* get_child_content)(LassoNode *node, + const xmlChar *name, + const xmlChar *href, + GError **err); GPtrArray* (* get_children) (LassoNode *node); - xmlChar* (* get_content) (LassoNode *node); - const xmlChar* (* get_name) (LassoNode *node); + xmlChar* (* get_content) (LassoNode *node, + GError **err); + xmlChar* (* get_name) (LassoNode *node); void (* import) (LassoNode *node, const xmlChar *buffer); void (* import_from_node) (LassoNode *node, @@ -155,8 +159,9 @@ LASSO_EXPORT gchar* lasso_node_export_to_query (LassoNode *n LASSO_EXPORT xmlChar* lasso_node_export_to_soap (LassoNode *node); -LASSO_EXPORT LassoAttr* lasso_node_get_attr (LassoNode *node, - const xmlChar *name); +LASSO_EXPORT LassoAttr* lasso_node_get_attr (LassoNode *node, + const xmlChar *name, + GError **err); LASSO_EXPORT xmlChar* lasso_node_get_attr_value (LassoNode *node, const xmlChar *name, @@ -164,17 +169,20 @@ LASSO_EXPORT xmlChar* lasso_node_get_attr_value (LassoNode *node, LASSO_EXPORT GPtrArray* lasso_node_get_attrs (LassoNode *node); -LASSO_EXPORT LassoNode* lasso_node_get_child (LassoNode *node, - const xmlChar *name, - const xmlChar *href); +LASSO_EXPORT LassoNode* lasso_node_get_child (LassoNode *node, + const xmlChar *name, + const xmlChar *href, + GError **err); -LASSO_EXPORT xmlChar * lasso_node_get_child_content(LassoNode *node, - const xmlChar *name, - const xmlChar *href); +LASSO_EXPORT xmlChar * lasso_node_get_child_content(LassoNode *node, + const xmlChar *name, + const xmlChar *href, + GError **err); LASSO_EXPORT GPtrArray* lasso_node_get_children (LassoNode *node); -LASSO_EXPORT xmlChar* lasso_node_get_content (LassoNode *node); +LASSO_EXPORT xmlChar* lasso_node_get_content (LassoNode *node, + GError **err); LASSO_EXPORT xmlChar* lasso_node_get_name (LassoNode *node); diff --git a/python/xml/py_xml.c b/python/xml/py_xml.c index 814c2304..83636187 100644 --- a/python/xml/py_xml.c +++ b/python/xml/py_xml.c @@ -171,7 +171,8 @@ PyObject *node_get_child(PyObject *self, PyObject *args) { } else return NULL; - ret = lasso_node_get_child(LassoNode_get(node_obj), name, href); + ret = lasso_node_get_child(LassoNode_get(node_obj), name, href, NULL); + /* FIXME generate an exception here */ return (LassoNode_wrap(ret)); } @@ -187,7 +188,8 @@ PyObject *node_get_content(PyObject *self, PyObject *args) { } else return NULL; - ret = lasso_node_get_content(LassoNode_get(node_obj)); + ret = lasso_node_get_content(LassoNode_get(node_obj), NULL); + /* FIXME generate an exception here */ return (xmlCharPtr_wrap(ret)); } |
