Commit Graph

162 Commits

Author SHA1 Message Date
Benjamin Dauvergne 8598c1327a Core: add a level argument to lasso_xmlnode_to_string and _lasso_node_export_to_xml 2010-03-02 11:57:29 +00:00
Benjamin Dauvergne 46a823ff85 Add lasso_string_to_xsd_integer, to parse xsd:integer values 2010-02-22 13:30:41 +00:00
Benjamin Dauvergne 5d9e6f550a Core: add a lasso_xmlnode_to_string function
* lasso/xml/tools.c lasso/xml/private.h:
   lots of functions duplicate this code, so we factorized it there.
   It has two parameters, the xmlnode and boolean deciding whether to
   format the resulting content (good for reading but bad for
   signatures).
2010-02-17 10:15:24 +00:00
Benjamin Dauvergne 39d4444475 in tools.c, add defines to permit import of timegm 2010-02-17 10:14:44 +00:00
Benjamin Dauvergne b13ddc086b Core: fix lasso_iso_8601_gmt_to_time_t, use timegm instead of mktime
* lasso/xml/tools.c:
   mktime convert works on local time, we need timegm to work with GMT
   time.
2010-02-17 10:14:41 +00:00
Benjamin Dauvergne 7041018303 Core: in lasso_verify_signature, fix conditional about single reference
* lasso/xml/toosl.c:
   verify that reference is unique if NO_SINGLE_REFERENCE is disabled.
2010-02-15 10:37:42 +00:00
Benjamin Dauvergne dad75ee5f1 Fix lasso_get_relaystate_from_query, support semi-colon and parameter at beginning
* lasso/xml/tools.c:
  getting first parameter was broken (query_string does not contain '?'
  at the beginning) and semi-colon support was missing.
2010-02-12 09:48:20 +00:00
Benjamin Dauvergne 6b601b55ee Documentation: complete non finished documentation comments
* too much warnings when generating doc, now we can concentrate on
   undocumented symbols (in
   lasso/docs/reference/lasso/lasso-undocumented.txt).
2010-02-10 13:58:40 +00:00
Benjamin Dauvergne f648941f01 SAML 2.0: when verifying query signature, do not presume order of field and separator
* lasso/xml/tools.c:
   in lasso_saml2_verify_query_signature, extract needed field and order
   them appropriately before computing digest, expect ';' as well as '&'
   as separator.
 * tests/random_test.c:
   add non-regression tests for query signature validation.
 * tests/Makefile.am:
   make tests link agains static version of liblasso, to get access to
   private functions.
2010-02-10 00:34:55 +00:00
Benjamin Dauvergne f176cde783 Core: in tools.c, enhance urlencoded_to_string to support semu-colon separator 2010-02-10 00:34:47 +00:00
Benjamin Dauvergne 72dc2ff63d Add a function to validate query signatures using SAML 2.0 semantic
* lasso/xml/tools.c:
   this new function is a placeholder for the new SAML 2.0 semantic
   following query signature validation function. It will start with the
   old code of lasso_query_verify_signature.
2010-02-10 00:33:45 +00:00
Benjamin Dauvergne 2800779b4c in lasso_xmlsec_load_private_key_from_buffer, do not let xmlSecBase64Decode show warnings 2010-02-08 09:34:08 +00:00
Benjamin Dauvergne e6a07df2bc Core: Finish support for all XMLDsig key formats
* lasso/xml/tools.c:
   xmlsec is not able to load a certificate public key without checking
   it against trusted root certificate, so we must work around and load
   the key by hand.
   lasso_xmlsec_load_private_key_from_buffer is made more robust in the
   same (loading of the key was extracted inside
   _lasso_xmlsec_load_key_from_buffer) and now can load certificates and
   keys directly embedded inside KeyValue nodes (in total opposition to
   the XMLDsig specification but...), with or without PEM headers.
 * tests/metadata/Makefile.am tests/metadata/metadata_06.xml
   tests/metadata_tests.c:
   add test case for RSAKeyValue public keys.
2010-02-04 22:24:04 +00:00
Benjamin Dauvergne 2a3ada925c Core: in lasso_xmlsec_load_key_info add flag to let xmlSec load certificates
* lasso/xml/tools.c:
   adding the flag XMLSEC_KEYINFO_FLAGS_X509DATA_DONT_VERIFY_CERTS make
   xmlSec able to load certificate, the 'hand made' code to load
   certificate is then useless.
2010-02-04 01:23:43 +00:00
Benjamin Dauvergne 845eb26d6a Core: in tools.c, add function to load XML files and KeyInfo nodes
* tools.c:
   add lasso_xml_parse_file, based on g_file_get_contents and
   lasso_xml_parse_memory.
   add lasso_xml_parse_memory_with_error which instead of logging
   errors, can return the xmlError structure.
   add lasso_xmlsec_load_key_info, which allows to load keys from
   ds:KeyInfo XML nodes. It also support the "Lasso" bug of using
   ds:KeyValue directly to store base64 encoded keys and certificates.
2010-02-04 00:02:19 +00:00
Benjamin Dauvergne b780bd2376 Fix leaks
* lasso/id-wsf-2.0/profile.c: release private data object.
 * lasso/saml-2.0/login.c: free NameID content after construction.
 * lasso/xml/tools.c: free algorithm attribute content in
   lasso_node_decrypt_xmlnode.
 * lasso/xml/xml.c: release cutom_element->nodename in destructor.
   remove useless finalize method.
 * tests/basic_tests.c: release xmldoc after use.
 * tests/random_tests.c: free resut of lasso_node_dump.
2010-02-04 00:02:07 +00:00
Benjamin Dauvergne c9068fee45 in lasso/xml/tools.c, remove leaks of xmlSecKey and xmlNode 2010-02-04 00:02:03 +00:00
Benjamin Dauvergne 5b8b096341 in lasso_xmlsec_load_private_key, do not leak the file buffer, in lasso_node_encrypt do not leak the keys manager 2010-02-04 00:02:00 +00:00
Benjamin Dauvergne 413932306d Core: rewrite lasso_assertion_encrypt using lasso_xmlsect_load_key and add recipient argument 2010-01-12 15:40:01 +00:00
Benjamin Dauvergne a237cd1057 Core: add simple function to load key from any format 2010-01-12 15:39:59 +00:00
Benjamin Dauvergne d42c16e239 Core Node: add args to lasso_node_encrypt to set recipient of an encrypted element 2010-01-12 15:39:57 +00:00
Benjamin Dauvergne 255962cc35 Core: in tools.c, complete documentation of lasso_verify_signature 2010-01-04 09:14:03 +00:00
Benjamin Dauvergne 1d8bd498cd Core XML: in xml/tools.c, add conversion method from iso8601 to time_t
* lasso/xml/tools.c:
   add function lasso_iso_8601_gmt_to_time_t
 * lasso/xml/private.h:
   declare new function.
2010-01-04 09:13:55 +00:00
Benjamin Dauvergne 1deaa13210 Core XML: in xml/tools.c, improve lasso_eval_xpath_expression, do not fail when nodeset is empty
* lasso/xml/tools.c:
   only check that the query returned a nodeset object, do not check its
   content size.
2010-01-04 09:13:49 +00:00
Benjamin Dauvergne 21db237e81 Augment query string limit for relaystate extraction to 8192 bytes
* lasso/xml/tools.c:
   some application transfer relaystate longer thant the specification
   advised 80 bytes, try to cater for their needs.
2009-11-02 15:18:08 +00:00
Benjamin Dauvergne b3aa580267 Add documentation for lasso_get_relaystate_from_query
* lasso/xml/tools.c:
   add documentation on the internal function
   lasso_get_relaystate_from_query
2009-11-02 15:18:06 +00:00
Benjamin Dauvergne 77a1233080 Fix bugs found via coverity (thanks to Bhaskar Jain)
* lasso/id-wsf-2.0/data_service.c: fix uninitialized res variable in
   lasso_idwsf2_data_service_process_query_response_soap_fault_msg.
 * lasso/xml/saml-2.0/saml2_assertion.c: fix uninitialized rc variable
   in get_xmlNode.
 * lasso/saml-2.0/login.c:
   in lasso_saml20_login_accept_sso check for ni and ni->Format
   null-ness before dereferencing, remove idp_ni which is not used
   anymore.
   remote all use of federation->remote_nameIdentifier, SAML 2.0 only
   need one NameID, and it will be local_nameIdentifier.
 * lasso/xml/xml.c:
   in lasso_node_traversal, check null-ness of node before dereferencing
   it, add check for class null-ness also.
 * lasso/id-ff/provider.c:
   in lasso_provider_get_first_http_method, remove useless check for t2
   null-ness -- if found is TRUE, t1 and t2 cannot be null.
 * lasso/xml/tools.c:
   in lasso_sign_node, add documentation, check for private_key_file and
   xmlnode null-ness.
   in lasso_get_public_key_from_private_key_file, add a cleanup phase,
   check for cert variabl null-ness befor appending, count the number of
   certificates added.
   in lasso_query_verify_signature, check that URL unescaping and base64
   decoding are succesfull before using the decoded strings.
 * lasso/saml-2.0/name_id_management.c:
   in lasso_name_id_management_validate_request, fix mis-handling of
   federation, if federation does not match request name_id, return
   UNKNOWN_PRINCIPAL.
2009-09-17 15:05:50 +00:00
Benjamin Dauvergne fd256b2269 Docs: change the doc production and lot of other fixes
* lasso/Makefile.am:
   distribute extract_sections.py
 * docs/references/lasso/lasso.types.in: add missing class (mainly SAML2
   and ID-WSF 1.0/2.0) from docs/references/lasso.types.in

 * lasso/xml/strings.h:
   add lots of documentation, or at least documentation template to
   strings constants.
 * id-ff/login.h:
 * saml-2.0/assertion_query.h:
 * xml/xml.h:
   document undocumented enumerations.
 * lasso/errors.h:
   add proper documentation about error codes.
 * lasso/errors.c:
   new version of the lasso_strerror function
 * lasso/build_strerror.py:
   update the script that generater lasso_strerror from the
   documentation comments.

   Remove usage of OFTYPE

 * lasso/id-ff/session.c:
 * lasso/id-ff/session.h:
   remove usage of oftype, prefer gtk-introspection annotations instead.
 * lasso/id-wsf/data_service.h:
 * lasso/id-wsf/data_service.c:
   do the same.

   Add a script to build lasso-sections.txt

 * lasso/extract_sections.py:
   this script parses header files and generated lasso-sections.txt
   content for GObject class descriptions.

   Add a template file for the lasso-section.txt file

 * docs/references/lasso-sections.txt.in:
   this file serves as a base for the generation of lasso-sections.txt

   Update docs/references/Makefile.am for generating lasso-sections.txt

 * docs/references/Makefile.am:
   always rebuild template, using out of source build directory is too
   weird without it.
   call new script extract_sections.py to regenerate lasso-sections.txt
   if header files changed.

   Update lasso.sgml file with all missing sections

 * docs/reference/lasso.sgml:
   add all missing sections, mainly objects from XML schemas.

 * docs/reference/lasso-sections.txt: update it

 * *.c: add section documentation to some files.
 * lasso/xml/strings.h: fix bad usage or docbook markup
2009-08-26 15:15:07 +00:00
Benjamin Dauvergne 7231771856 All: Rework include files handling, separated ID-WSF code from SAML2/ID-FF code
* nearly all C files: change includes for relative paths.
 * lasso/id-wsf/id_wsf.h, lasso/id-wsf-2.0/id_wsf_2.h: add top level
   public include files for ID-WSF 1.0 and ID-WSF 2.0.
 * lasso/id-ff/server.*, lasso/id-ff/session.*, lasso/id-ff/identity.*:
   remove most of the code related to ID-WSF and push into
   lasso/id-wsf/id_ff_extensions.* and lasso/id-wsf-2.0/identity.c,
   lasso/id-wsf-2.0/server.c, lasso/id-wsf-2.0/session.c.
 * lasso/id-wsf-2.0/saml2_login.c,
   lasso/id-wsf-2.0/saml2_login_private.h: same change but for ID-WSF
   2.0 support in SAML2 SSO profile.
2009-08-26 15:14:32 +00:00
Benjamin Dauvergne de375da682 XML: Add time formatting function for ISO 8601 format
* xml/private.h:
 * xml/tools.c:
   add util function to format time_t values in the ISO 8601 format.
2009-08-26 15:13:41 +00:00
Benjamin Dauvergne 713ae637a8 XML: add documentation for lasso_eval_xpath_expression
* lasso/xml/tools.c: add documentation for xpath helper evaluation
  function lasso_eval_xpath_expression.
2009-08-26 15:13:36 +00:00
Benjamin Dauvergne 28bdebee52 XML: add API to simplify evaluation of XPath expressions
* lasso/xml/tools.c,lasso/xml/private.h:
  - lasso_eval_xpath_expression(xmlXPathContextPtr xpathCtx,
    const char *expression, xmlXPathObjectPtr *xpathObjectPtr,
    int *xpathErrorCode) is a boolean returning function handling call
    to libxml API to evaluate en XPath expression in the xpathCtx
    context. It eventually save the returned nodeset in the variable
    pointed by xpathObjectPtr if it is not-NULL
    (and eventually deallocate previous value)
    and if an error happend it copy its code into the variable
    pointed to by xpathErrorCode if it is not NULL.
2009-08-26 15:12:46 +00:00
Benjamin Dauvergne 70b466c6c2 Fix leak in lasso_url_add_parameters
* lasso/xml/tools.c:
   in lasso_url_add_parameters free intermediate strings.
2009-04-30 14:58:03 +00:00
Benjamin Dauvergne ecb84ebd1d fix: in lasso_verify_signature() only look for the first direct child Signature element
* lasso/xml/tools.c:
   in SAML message signatures are usually envelopped signatures, so just
   lookup for the first direct child which is a Signature node.
2009-04-27 08:19:28 +00:00
Benjamin Dauvergne 52e60ecb09 Rework cleanup handling
* lasso/utils.h:
   change 'goto exit' for 'goto cleanup'. rename all goto_exit macros to
   goto_cleanup_.  rename goto_cleanup_if_fail to
   goto_cleanup_if_fail_with_rc and add a
   goto_cleanup_if_fail for function which do not return an integer
   value. add documentation for goto_cleanup macro family.
 * lasso/id-ff/login.c:
 * lasso/id-ff/provider.c:
 * lasso/id-ff/server.c:
 * lasso/id-ff/session.c:
 * lasso/id-wsf/discovery.c:
 * lasso/id-wsf/wsf_profile.c:
 * lasso/saml-2.0/profile.c:
 * lasso/utils.h:
 * lasso/xml/lib_logout_request.c:
 * lasso/xml/tools.c:
 * lasso/xml/xml.c:
   update name of goto_exit_if_fail macros. rename 'exit' labels to
   'cleanup'.
2009-04-22 23:49:29 +00:00
Benjamin Dauvergne ed5e0fce15 Add a new internal API for parameters building
* xml/tools.c:
   add lasso_url_add_parameter that concat the string &key=value to an
   existing URL where key and value are url-encoded.
 * xml/private.h:
   declare lasso_url_add_parameter.
2009-04-22 23:49:19 +00:00
Benjamin Dauvergne dac53715ea Core: Add cast to first argument of isalnum
* lasso/xml/xml.c:
 * lasso/xml/tools.c:
   isalnum takes a int as first arg.
2009-04-14 07:51:25 +00:00
Benjamin Dauvergne 60018bbb4d XML: fix memory leaks
* lasso/xml/tools.c:
 * lasso/xml/xml.c:
   release xmlDoc, properly steal nodes by using xmlSetTreeDoc(xmlnode, NULL);
2009-03-27 15:06:30 +00:00
Benjamin Dauvergne 71ca7129a6 XML: Add const modifiers to lasso_concat_url_query arguments
* lasso/xml/private.h, lasso/xml/tools.c: add const modifier to
   lasso_concat_url_query arguments.
2009-03-27 15:05:42 +00:00
Benjamin Dauvergne 96594a8ede XML: Tool function to extract relaystate from query
* lasso/xml/tools.c, lasso/xml/private.h: new function
   lasso_get_relaystate_from_query to help in relaystate handling.
2009-03-27 15:05:39 +00:00
Benjamin Dauvergne 642dcfdfbb Core: use lasso_xml_parse_memory instead of xmlParseDoc
* lasso/id-ff/provider.c:
   use internal wrapper instead of direct call to libxml for parsing.
2009-03-27 15:05:21 +00:00
Benjamin Dauvergne 580239d233 Core: move parse xml wrapper from xml.c to tools.c
* lasso/xml/xml.c:
   remove lasso_xml_parse_memory.
 * lasso/xml/tools.c:
   add lasso_xml_parse_memory to wrap xmlParseDocument.
 * lasso/saml-2.0/name_id_management.c:
   use lasso_xml_parse_memory
2009-03-27 15:05:19 +00:00
Benjamin Dauvergne d81f986451 SAML 2.0: replace lasso_node_decrypt by lasso_node_decrypt_xmlnode
* lasso/xml/private.h:
 * lasso/xml/tools.c:
   replace implementation of lasso_node_decrypt by a new one called
   lasso_node_decrypt_xmlnode, and use it where old one was used.
2009-03-27 15:05:10 +00:00
Benjamin Dauvergne a475d9eb00 Core: add new internal API lasso_provider_verify_query_signature
* lasso/id-ff/provider.c:
   try to keep some homgeneity between lasso_verify_signature and
   lasso_verify_query_signature functions, by having mirror methods
   inside the LassoProvider class. this new methods comes with complete
   documentation.
 * lasso/xml/tools.c:
   add a xmlDoc argument to lasso_verify_signature, in order to
   reuse an already built message context, and possible problems with
   interned string in parsed xml documents.
2009-03-27 15:05:00 +00:00
Benjamin Dauvergne 9bd1c6a446 Core: new init method with format limit and xmlDoc output argument
* lasso/xml/private.h:
 * lasso/xml/xml.c:
   lasso_node_init_from_message_with_format permit to initialize a node
   and to keep the corresponding xml document, in order for example to
   validate a signature.
 * lasso/xml/tools.c:
   lasso_xml_parse_message is able to parse a message of any type, or of
   a given type. If a message of another than the one specified is
   found, the call fails, and a LASSO_MESSAGE_FORMAT_ERROR is returned.
2009-03-27 15:04:53 +00:00
Benjamin Dauvergne 6109e1b71b Core: add function to extract SOAP message content
* lasso/xml/tools.c:
   add lasso_xml_is_soap, to verify that a message is SOAP.
   add lasso_xml_get_soap_content, to retrieve the first child of the
   SOAP body, whatever the SOAP content version.
2009-03-27 15:04:51 +00:00
Benjamin Dauvergne d4e218dfeb Core: handle g_io_channel creation failure
* lasso/xml/tools.c:
   in lasso_load_certs_from_pem_certs_chain_file if
   g_io_channel_new_file fails return NULL and print a warning.
   If path is NULL or 0-length also returns NULL.
2009-03-27 15:04:33 +00:00
Benjamin Dauvergne b09ef2e015 Core: do not mix public and private headers
* lots of files:
   explicitely load the internal header xml/private.h where needed.
2009-03-27 15:04:26 +00:00
Benjamin Dauvergne 7da0401919 Core: enforce flag verify-signature in function lasso_verify_signature
* lasso/xml/tools.c: in lasso_verify_signature always return success if
   lasso_flag_verify_signature is FALSE.
 * lasso/xml/private.h: change return type to int.
2009-03-03 20:52:37 +00:00
Benjamin Dauvergne 68eaafa6e7 Core: synchronize lasso_verify_signature with new macros 2009-01-24 09:34:16 +00:00