diff --git a/docs/reference/lasso/lasso-sections.txt b/docs/reference/lasso/lasso-sections.txt index d34ffd85..d1342e7e 100644 --- a/docs/reference/lasso/lasso-sections.txt +++ b/docs/reference/lasso/lasso-sections.txt @@ -1024,6 +1024,7 @@ lasso_node_new_from_xmlNode lasso_node_cleanup_original_xmlnodes lasso_node_destroy lasso_node_dump +lasso_node_debug lasso_node_export_to_base64 lasso_node_export_to_query lasso_node_export_to_soap diff --git a/lasso/xml/private.h b/lasso/xml/private.h index ef7e6efa..6927229e 100644 --- a/lasso/xml/private.h +++ b/lasso/xml/private.h @@ -227,7 +227,7 @@ xmlSecKey* lasso_xmlsec_load_private_key(const char *filename_or_buffer, const c xmlDocPtr lasso_xml_parse_file(const char *filepath); xmlDocPtr lasso_xml_parse_memory_with_error(const char *buffer, int size, xmlError *error); xmlSecKeyPtr lasso_xmlsec_load_key_info(xmlNode *key_descriptor); -char* lasso_xmlnode_to_string(xmlNode *node, gboolean format); +char* lasso_xmlnode_to_string(xmlNode *node, gboolean format, int level); gboolean lasso_string_to_xsd_integer(const char *str, long int *integer); #ifdef __cplusplus diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c index b5e75167..17a19f1d 100644 --- a/lasso/xml/tools.c +++ b/lasso/xml/tools.c @@ -2111,7 +2111,7 @@ cleanup: * Return value: a newly allocated C string */ char* -lasso_xmlnode_to_string(xmlNode *node, gboolean format) +lasso_xmlnode_to_string(xmlNode *node, gboolean format, int level) { xmlOutputBufferPtr buf; xmlCharEncodingHandlerPtr handler = NULL; @@ -2123,7 +2123,7 @@ lasso_xmlnode_to_string(xmlNode *node, gboolean format) handler = xmlFindCharEncodingHandler("utf-8"); buf = xmlAllocOutputBuffer(handler); - xmlNodeDumpOutput(buf, NULL, node, 0, format ? 1 : 0, "utf-8"); + xmlNodeDumpOutput(buf, NULL, node, level, format ? 1 : 0, "utf-8"); xmlOutputBufferFlush(buf); buffer = buf->conv ? buf->conv->content : buf->buffer->content; /* do not mix XML and GLib strings, so we must copy */ diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index 80310458..50a3aa82 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -141,7 +141,7 @@ lasso_get_prefix_for_idwsf2_dst_service_href(const gchar *href) /*****************************************************************************/ static char* -_lasso_node_export_to_xml(LassoNode *node, gboolean format, gboolean dump) +_lasso_node_export_to_xml(LassoNode *node, gboolean format, gboolean dump, int level) { xmlNode *xmlnode; char *ret; @@ -149,7 +149,7 @@ _lasso_node_export_to_xml(LassoNode *node, gboolean format, gboolean dump) g_return_val_if_fail (LASSO_IS_NODE(node), NULL); xmlnode = lasso_node_get_xmlNode(node, dump); - ret = lasso_xmlnode_to_string(xmlnode, format); + ret = lasso_xmlnode_to_string(xmlnode, format, level); xmlFreeNode(xmlnode); return ret; @@ -167,7 +167,23 @@ _lasso_node_export_to_xml(LassoNode *node, gboolean format, gboolean dump) char* lasso_node_dump(LassoNode *node) { - return _lasso_node_export_to_xml(node, FALSE, TRUE); + return _lasso_node_export_to_xml(node, FALSE, TRUE, 0); +} + +/** + * laso_node_debug: + * @node: a #LassoNode + * + * Create a debug dump for @node, it is pretty printed so any contained signature will be + * uncheckable. + * + * Return value: a full indented and so human readable dump of @node. The string must be freed by + * the caller. + */ +char* +lasso_node_debug(LassoNode *node) +{ + return _lasso_node_export_to_xml(node, TRUE, TRUE, 5); } /** @@ -254,7 +270,7 @@ lasso_node_export_to_ecp_soap_response(LassoNode *node, const char *assertionCon xmlAddChild(body, message); /* dump */ - ret = lasso_xmlnode_to_string(envelope, FALSE); + ret = lasso_xmlnode_to_string(envelope, FALSE, 0); xmlFreeNode(envelope); return ret; @@ -331,7 +347,7 @@ lasso_node_export_to_paos_request(LassoNode *node, const char *issuer, body = xmlNewTextChild(envelope, NULL, (xmlChar*)"Body", NULL); xmlAddChild(body, message); - ret = lasso_xmlnode_to_string(envelope, FALSE); + ret = lasso_xmlnode_to_string(envelope, FALSE, 0); xmlFreeNode(envelope); @@ -381,7 +397,7 @@ lasso_node_export_to_query(LassoNode *node, gchar* lasso_node_export_to_xml(LassoNode *node) { - return _lasso_node_export_to_xml(node, FALSE, FALSE); + return _lasso_node_export_to_xml(node, FALSE, FALSE, 0); } /** diff --git a/lasso/xml/xml.h b/lasso/xml/xml.h index 50575b7b..2f3d7d19 100644 --- a/lasso/xml/xml.h +++ b/lasso/xml/xml.h @@ -171,11 +171,14 @@ LASSO_EXPORT int lasso_node_init_from_xml(LassoNode *node, xmlNode *xmlnode); LASSO_EXPORT const char* lasso_strerror(int error_code); LASSO_EXPORT void lasso_register_dst_service(const char *prefix, const char *href); + LASSO_EXPORT char* lasso_get_prefix_for_dst_service_href(const char *href); LASSO_EXPORT void lasso_register_idwsf2_dst_service(const gchar *prefix, const gchar *href); + LASSO_EXPORT gchar* lasso_get_prefix_for_idwsf2_dst_service_href(const gchar *href); +LASSO_EXPORT char* lasso_node_debug(LassoNode *node); #ifdef __cplusplus }