Commit Graph

86 Commits

Author SHA1 Message Date
Benjamin Dauvergne 3e597eedb9 Add support for SHA-2 family of hash functions for RSA and HMAC signatures 2015-02-09 18:53:02 +01:00
Benjamin Dauvergne a27d1686b3 xml: support xsd:choices by allowing to rewind or advance after match or miss of a snippet 2014-09-02 12:04:42 +02:00
Simo Sorce 3a6b2fdee7 Fix license boilerplates
Instad of referring to an old FSF address, point the reader to the FSF
website where the latest licenses and addresses are published.

Signed-off-by: Simo Sorce <simo@redhat.com>
2013-12-03 21:55:06 +01:00
Benjamin Dauvergne 8e98e432ff xml: really enforce elements cardinality when parsing messages
- add a new SNIPPET_MANDATORY:
	 we could only indicate 0-1 and 0-* cardinalities, now we can also
	 indicate 1-1 and 1-* cardinalities.
 - repect cadinalities when parsing an xmlNode tree into a LassoNode
	 tree.
2013-01-25 18:30:55 +01:00
Benjamin Dauvergne f42bef0836 [key] add methods to send message using SAML 2.0 redirect and post bindings 2012-03-17 15:26:21 +01:00
Benjamin Dauvergne 154812b401 [xml] rewrite schema directed serialization/deserialization methods
The new implementations of lasso_node_impl_init_from_xml now validate
namespace of all child nodes befores parsing. It stops on any error. For
node which implement their own parsing of an attribute or a node, it
must declare an XmlSnippet with an offset field set to 0. The 0 value is
invalid for public GObject structure (it's the place of the GObject
machinery like the reference count). The 0 offset can be used for
XmlSnippet in a private structure, so never set the offset to 0 with the
flag SNIPPET_PRIVATE, for a field which is parsed by you get_xmlNode
virtual method.

Other ameliorations in this commit is the possibility to set attributes
with namespace when using the flags SNIPPET_ATTRIBUTE|SNIPPET_ANY. The
syntax for an attribute is inspired by the element tree API from Python:

	{namespace}attribute_name

an example:

	{http://www.w3.org/2001/XMLSchema-instance}type

for the classic xsi:type attribute.
2011-12-16 11:39:24 +01:00
Benjamin Dauvergne 5ba292521b [core] add the HMAC-SHA1 shared secret signature method 2011-12-05 13:11:53 +01:00
Benjamin Dauvergne cd017964d0 [core] introduce the LassoSignatureContext context, to pass around signature parameters
This structure is used to pass around the signature algorithm
and the signature key.
2011-12-05 12:03:13 +01:00
Benjamin Dauvergne 71721b370c [core] add a lasso_base64_decode function 2011-12-05 12:03:13 +01:00
Benjamin Dauvergne 9de6450f4c [tools] add a LassoSignatureContext structure to pass signature parameters around
Signature parameters are mainly a LassoSignatureMethod and a xmlSecKey.
2011-12-05 12:03:12 +01:00
Benjamin Dauvergne 3ec4a2f294 [xml] allow to store XSchema data into a private stucture
- added new macros SNIPPET_STRUCT_MEMBER and SNIPPET_STRUCT_MEMBER_P
   replaces use of G_STRUCT_MEMBER/_P macros.
 - we use the GType of the class containing a given XmlSnippet to find
   the proper private structure.
 - added flag SNIPPET_PRIVATE to state XmlSnippet whose value
   should be extracted from the private structure and not the public
   one.
2011-11-18 15:36:41 +01:00
Benjamin Dauvergne 04dd5610b0 [xml] allow empty reference in XML signature (document signature) 2011-03-29 18:43:47 +02:00
Benjamin Dauvergne ec5ec161f7 [xml] add field to contains encryption parameters inside CustomElement structure 2010-12-14 01:55:09 +01:00
Benjamin Dauvergne 21ca128532 [Core] add password parameter to lasso_sign_node 2010-07-16 19:34:24 +00:00
Benjamin Dauvergne c939427f21 [Core] add a password parameter to lasso_query_sign
We force use of the password through a custom OpenSSL password callback.
2010-07-16 19:34:21 +00:00
Benjamin Dauvergne 8198294c55 [Core] add lasso_node_set_signature and lasso_node_get_signature
Those two methods allows to associate signature parameters to any node.
They keep it inside the CustomElement quark. Using a private structure
may be more performant.
2010-07-16 19:34:14 +00:00
Benjamin Dauvergne 9d9cf60aca [Core] extract signature adding into base class method lasso_node_get_xmlNode
In order to permit subclass to modify the base xmlNode created by
lasso_node_impl_get_xmlNode we must defer the concrete to the virtual
method wrapper, lasso_node_get_xmlNode.

To do that it whas needed to make id_attribute another virtual field of
LassoNode subclasses (it can be accessed through an offset registered in
the class object).

This commit solves signature validation error since the patch for
managing more than one SessionIndex element in samlp2:LogoutRequest.

It also factorize the creation of signatures in one place.
2010-07-12 14:09:17 +00:00
Benjamin Dauvergne a9b673cd4a Core: move logging function and macros to their own module, adapt perl binding 2010-06-12 00:43:49 +00:00
Benjamin Dauvergne 93bea17474 Core: update lasso_iso_8601_gmt_to_time_t to support milliseconds
* We now support the two possible formats for xsdtime XSchema datatype:
    - dddd-dd-ddTdd:dd:ddZ
    - dddd-dd-ddTdd:dd:dd.d*Z

   Where d denotes a digit, and * is the kleene star.

   XSD datetime also supports negative years, but as we cannot represent
   them with time_t, we can reject it at the lexical level.
2010-06-10 21:26:10 +00:00
Benjamin Dauvergne 779200ca4c Fix collision between defined symbols in tools.h and private.h 2010-06-10 13:37:53 +00:00
Benjamin Dauvergne d26bdfaef7 XML: add custom namespace definition handling 2010-04-06 13:11:30 +00:00
Benjamin Dauvergne 43bb65157c Core: add a SNIPPET_COLLECT_NAMESPACE snippet type
* lasso/xml/private.h lasso/xml/xml.c:
   add a new primary XmlSnippet type for collecting all namespace
   declaration, following parent relation on current node or one of the
   child nodes.
2010-04-06 13:11:10 +00:00
Benjamin Dauvergne 4b9f6d8305 Core: add lasso_set_string_from_prop(char**,xmlNode*,..) function 2010-03-27 16:51:50 +00:00
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 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 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 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 ac3a687518 XML Core: in xml.c, private.h, add a lasso_node_remove_signature function 2010-01-12 15:39:42 +00:00
Benjamin Dauvergne d461fe3957 Core: in xml/private.h, add new field to LassoNodeClassData for private_key and certificate handling 2010-01-12 15:39:38 +00:00
Benjamin Dauvergne 4497b166bf XML: in private.h, remove duplicate declaration of lasso_xml_parse_memory 2010-01-04 09:14:29 +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 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 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 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 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 f604d63268 XML: Remove static modifier on lasso_node_build_query
* lasso/xml/private.h, lasso/xml/xml.c: remove static modifier to
   lasso_node_build_query and export it for use in id-ff profiles.
2009-03-27 15:05:41 +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 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 12744e44fe SAML 2.0: API for Saml2EncryptedElement decrypt
* lasso/xml/xml_enc.h:
   remove old functions
 * lasso/xml/private.h:
   remove lasso_node_(de/en)crypt from public headers API, they were not
   exported anyway. move them to internal header.
 * lasso/xml/saml-2.0/saml2_encrypted_element.{c,h}:
   add a new decrypt function to convert a EncryptedElement to the
   contained encrypted node objects.
 * bindings/overrrides.xml:
   do not export the new method, wait for implementation of output
   arguments.
 * lasso/id-ff/server.c:
   remove lasso_decrypt_nameid from lasso/id-ff/server.c
2009-03-27 15:04:49 +00:00
Benjamin Dauvergne 7f09fe60de Fix bug #94: permit any content for AttributeValue
* lasso/xml/private.h:
 * lasso/xml/xml.h
 * lassoi/xml/xml.c:
   add an implementation helper for the AttributeValue objects
   implementation of get_xmlNode.
   make lasso_node_set_original_xmlnode public API.
 * lasso/xml/saml-2.0/samlp2_extensions.c:
 * lasso/xml/saml-2.0/saml2_attribute_value.c:
 * lasso/xml/saml_attribute_value.c:
   implement get_xmlNode for the AttributeValue and Extensions objects.
   If the any field is empty, use the original_xmlnode value.  In order
   to support free-style content, you must use the method
   lasso_node_set_original_xmlnode, properties and children are
   extracted from the given node and added to the node created by the
   generic get_xmlNode virtual method.
2009-03-27 15:04:41 +00:00
Benjamin Dauvergne a017ddc81e XML Core: add new snippet type SNIPPET_KEEP_XMLNODE
* private.h:
   add the new constant to the enum type
 * xml.c:
   fix lasso_node_traversal, add support for the new contanst in
   lasso_node_imp_init_from_xmlNode.
2009-03-27 15:04:40 +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