diff --git a/bindings/overrides.xml b/bindings/overrides.xml index e30c97a1..451199c6 100644 --- a/bindings/overrides.xml +++ b/bindings/overrides.xml @@ -198,6 +198,11 @@ + + + + + diff --git a/docs/reference/lasso/lasso-sections.txt b/docs/reference/lasso/lasso-sections.txt index 72d00312..a0e70e1b 100644 --- a/docs/reference/lasso/lasso-sections.txt +++ b/docs/reference/lasso/lasso-sections.txt @@ -1058,6 +1058,7 @@ lasso_node_export_to_base64 lasso_node_export_to_query lasso_node_export_to_query_with_password lasso_node_export_to_soap +lasso_node_export_to_soap_with_headers lasso_node_export_to_xml lasso_node_export_to_paos_request lasso_node_export_to_ecp_soap_response diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index d6e29eda..397a1b06 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -470,6 +470,72 @@ lasso_node_export_to_soap(LassoNode *node) return ret; } +/** + * lasso_node_export_to_soap_with_headers: + * @node: a #LassoNode, becomes the SOAP body + * @headers: (allow-none): #GList of #LassNode + * + * Exports @node to a SOAP message. The @node becomes the SOAP body. + * each header in the #headers list is added to the SOAP header if non-NULL. + * @headers is permitted to be an empty list (e.g. NULL). + * + * + * Create SOAP envelope with variable number of header nodes + * + * You need to form a SOAP message with authn_request as the body and + * paos_request, ecp_request and ecp_relaystate as SOAP header elements. + * It is possible one or more of these may be NULL and should be skipped. + * + * char *text = NULL; + * LassoNode *paos_request = NULL; + * LassoNode *ecp_request = NULL; + * LassoNode *ecp_relaystate = NULL; + * GList *headers = NULL; + * + * paos_request = lasso_paos_request_new(responseConsumerURL, message_id); + * ecp_request = lasso_ecp_request_new(issuer, is_passive, provider_name, idp_list); + * + * lasso_list_add_new_gobject(headers, paos_request); + * lasso_list_add_new_gobject(headers, ecp_request); + * lasso_list_add_new_gobject(headers, ecp_relaystate); + * + * text = lasso_node_export_to_soap_with_headers(node, headers); + * + * lasso_release_list_of_gobjects(headers); + * + * + * + * Return value: a SOAP export of @node. The string must be freed by the + * caller. + **/ +char* +lasso_node_export_to_soap_with_headers(LassoNode *node, GList *headers) +{ + GList *i; + LassoSoapEnvelope *envelope = NULL; + LassoNode *header = NULL; + char *ret = NULL; + + g_return_val_if_fail(LASSO_IS_NODE(node), NULL); + + envelope = lasso_soap_envelope_new_full(); + lasso_list_add_gobject(envelope->Body->any, node); + + lasso_foreach(i, headers) { + header = i->data; + if (!header) continue; + + goto_cleanup_if_fail(LASSO_IS_NODE(header)); + lasso_list_add_gobject(envelope->Header->Other, header); /* adds ref */ + } + + ret = lasso_node_export_to_xml((LassoNode*)envelope); + + cleanup: + lasso_release_gobject(envelope); + return ret; +} + /** * lasso_node_encrypt: * @lasso_node: a #LassoNode to encrypt @@ -643,7 +709,7 @@ lasso_node_encrypt(LassoNode *lasso_node, xmlSecKey *encryption_public_key, message(G_LOG_LEVEL_WARNING, "Encryption failed"); goto cleanup; } - + /* Create a new EncryptedElement */ encrypted_element = LASSO_SAML2_ENCRYPTED_ELEMENT(lasso_saml2_encrypted_element_new()); diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h index c4e42795..848f1449 100644 --- a/lasso/xml/xml.h +++ b/lasso/xml/xml.h @@ -162,6 +162,8 @@ LASSO_EXPORT char* lasso_node_export_to_query_with_password(LassoNode *node, LASSO_EXPORT char* lasso_node_export_to_soap(LassoNode *node); +LASSO_EXPORT char* lasso_node_export_to_soap_with_headers(LassoNode *node, GList *headers); + LASSO_EXPORT gchar* lasso_node_export_to_xml(LassoNode *node); LASSO_EXPORT char* lasso_node_export_to_paos_request(LassoNode *node, const char *issuer,