lasso/lasso/id-wsf/utils.c

153 lines
4.8 KiB
C
Raw Normal View History

2008-09-12 17:06:58 +02:00
/* $Id$
*
* Lasso - A free implementation of the Liberty Alliance specifications.
*
* Copyright (C) 2004-2007 Entr'ouvert
* http://lasso.entrouvert.org
2008-09-12 17:06:58 +02:00
*
* Authors: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
2008-09-12 17:06:58 +02:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2008-09-12 17:06:58 +02:00
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
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 17:15:07 +02:00
/**
* SECTION:id_wsf_utils
* @short_description: Misc functions used in the implementation of ID-WSF 1.0
* @stability: Internal
*/
/**
* lasso_security_mech_is_saml_authentication:
* @security_mech_id: the URI of an authentication mechanism
*
2008-08-01 16:08:54 +02:00
* Return value: %TRUE if @security_mech_id is one of
* urn:liberty:security:2003-08:null:SAML,
* urn:liberty:security:2003-08:TLS:SAML or
2008-09-12 17:06:58 +02:00
* urn:liberty:security:2003-08:ClientTLS:SAML, FALSE otherwise.
*/
2008-08-01 16:08:54 +02:00
#include "../xml/private.h"
2008-08-01 16:08:54 +02:00
#include <glib.h>
#include <string.h>
#include "../xml/strings.h"
2008-10-01 11:55:40 +02:00
/**
* lasso_security_mech_id_is_null_authentication:
* @security_mech_id: the URI of an authentication mechanism
*
* Return value: %TRUE if @security_mech_id is null or one of
* urn:liberty:security:2003-08:null:null,
* urn:liberty:security:2003-08:TLS:null,
* urn:liberty:security:2003-08:ClientTLS:null,
* FALSE otherwise.
*/
gboolean
lasso_security_mech_id_is_null_authentication(const char *security_mech_id)
{
if (security_mech_id == NULL ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_CLIENT_TLS) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_TLS) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_NULL) == 0) {
return TRUE;
2008-10-01 11:55:40 +02:00
}
return FALSE;
}
2008-09-12 17:06:58 +02:00
/**
* lasso_security_mech_id_is_x509_authentication:
* @security_mech_id: the URI of an authentication mechanism
*
2008-08-01 16:08:54 +02:00
* Return value: %TRUE if @security_mech_id is one of
* urn:liberty:security:2003-08:null:X509,
* urn:liberty:security:2003-08:TLS:X509,
* urn:liberty:security:2003-08:ClientTLS:X509,
* FALSE otherwise.
*/
gboolean
lasso_security_mech_id_is_x509_authentication(const char *security_mech_id)
{
2008-10-01 11:55:40 +02:00
if (!security_mech_id) {
return FALSE;
}
if (strcmp(security_mech_id, LASSO_SECURITY_MECH_CLIENT_TLS_X509) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_TLS_X509) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_X509) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY11_MECH_TLS_X509) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY11_MECH_X509) == 0) {
return TRUE;
}
return FALSE;
}
2008-09-12 17:06:58 +02:00
/**
* lasso_security_mech_id_is_saml_authentication:
* lasso/id-wsf/discovery.c: - include utils.h - move lasso_wsf_profile_build_key_info_node here - add a comment for future review of lasso_discovery_build_credential - remove direct use of lasso_wsf_profile_build_soap_envelope, use lasso_wsf_profile_init_soap_request instead. * lasso/id-wsf/utils.{c,h}: - new file with security mech id matching functions * lasso/id-wsf/wsf_profile.c: - remove all credentials related static functions - empty all credentials related public functions - move function related to matching security mechanism into utils.{c,h} and xml/disco_description.h - add static function lasso_wsf_profile_comply_with_saml_authentication that tries to add credential to the request to a web service using the SAML WS-Security mechanism - add static function lasso_wsf_profile_comply_with_security_mechanism to dispatch upon the current chosen securirt mechanism. - extract build_soap_envelope to the static function build_soap_envelope_internal to remove warning of usage of a deprecated function. - remove lasso_wsf_profile_set_public_key - remove lasso_wsf_profile_set_security_mech_id - add lasso_wsf_profile_get_security_mechanism - add lasso_wsf_profile_set_description - empty function about online status of the principal - remove all (non-working) handling of the x509 security mechanism - add a new constructor function LassoWsfProfile* lasso_wsf_profile_new_full(LassoServer *server, LassoDiscoResourceOffering *offering) - and a new init function (for subclass): gint lasso_wsf_profile_init(LassoWsfProfile *profile, LassoServer *server, LassoDiscoResourceOffering *offering) * lasso/id-wsf/wsf_profile.h: - mark as deprecated: lasso_wsf_profile_move_credentials lasso_wsf_profile_build_soap_envelope lasso_wsf_profile_set_provider_soap_request lasso_wsf_profile_principal_is_online lasso_wsf_profile_add_credential lasso_wsf_profile_set_principal_status lasso_wsf_profile_set_principal_online lasso_wsf_profile_set_principal_offline * lasso/id-wsf/wsf_profile_private.h: - remove fields from LassoWsfProfilePrivate structure: - GList *credentials; - gchar *public_key; - add fields: - char *security_mech_id; - LassoDiscoResourceOffering *offering;
2008-08-01 16:08:41 +02:00
* @security_mech_id: the URI of an authentication mechanism
*
2008-08-01 16:08:54 +02:00
* Return value: %TRUE if @security_mech_id is one of
* urn:liberty:security:2003-08:null:SAML,
* urn:liberty:security:2003-08:TLS:SAML,
* urn:liberty:security:2003-08:ClientTLS:SAML,
* urn:liberty:security:2005-02:null:SAML,
* urn:liberty:security:2005-02:TLS:SAML,
* FALSE otherwise.
* lasso/id-wsf/discovery.c: - include utils.h - move lasso_wsf_profile_build_key_info_node here - add a comment for future review of lasso_discovery_build_credential - remove direct use of lasso_wsf_profile_build_soap_envelope, use lasso_wsf_profile_init_soap_request instead. * lasso/id-wsf/utils.{c,h}: - new file with security mech id matching functions * lasso/id-wsf/wsf_profile.c: - remove all credentials related static functions - empty all credentials related public functions - move function related to matching security mechanism into utils.{c,h} and xml/disco_description.h - add static function lasso_wsf_profile_comply_with_saml_authentication that tries to add credential to the request to a web service using the SAML WS-Security mechanism - add static function lasso_wsf_profile_comply_with_security_mechanism to dispatch upon the current chosen securirt mechanism. - extract build_soap_envelope to the static function build_soap_envelope_internal to remove warning of usage of a deprecated function. - remove lasso_wsf_profile_set_public_key - remove lasso_wsf_profile_set_security_mech_id - add lasso_wsf_profile_get_security_mechanism - add lasso_wsf_profile_set_description - empty function about online status of the principal - remove all (non-working) handling of the x509 security mechanism - add a new constructor function LassoWsfProfile* lasso_wsf_profile_new_full(LassoServer *server, LassoDiscoResourceOffering *offering) - and a new init function (for subclass): gint lasso_wsf_profile_init(LassoWsfProfile *profile, LassoServer *server, LassoDiscoResourceOffering *offering) * lasso/id-wsf/wsf_profile.h: - mark as deprecated: lasso_wsf_profile_move_credentials lasso_wsf_profile_build_soap_envelope lasso_wsf_profile_set_provider_soap_request lasso_wsf_profile_principal_is_online lasso_wsf_profile_add_credential lasso_wsf_profile_set_principal_status lasso_wsf_profile_set_principal_online lasso_wsf_profile_set_principal_offline * lasso/id-wsf/wsf_profile_private.h: - remove fields from LassoWsfProfilePrivate structure: - GList *credentials; - gchar *public_key; - add fields: - char *security_mech_id; - LassoDiscoResourceOffering *offering;
2008-08-01 16:08:41 +02:00
*/
gboolean
lasso_security_mech_id_is_saml_authentication(const gchar *security_mech_id)
* lasso/id-wsf/discovery.c: - include utils.h - move lasso_wsf_profile_build_key_info_node here - add a comment for future review of lasso_discovery_build_credential - remove direct use of lasso_wsf_profile_build_soap_envelope, use lasso_wsf_profile_init_soap_request instead. * lasso/id-wsf/utils.{c,h}: - new file with security mech id matching functions * lasso/id-wsf/wsf_profile.c: - remove all credentials related static functions - empty all credentials related public functions - move function related to matching security mechanism into utils.{c,h} and xml/disco_description.h - add static function lasso_wsf_profile_comply_with_saml_authentication that tries to add credential to the request to a web service using the SAML WS-Security mechanism - add static function lasso_wsf_profile_comply_with_security_mechanism to dispatch upon the current chosen securirt mechanism. - extract build_soap_envelope to the static function build_soap_envelope_internal to remove warning of usage of a deprecated function. - remove lasso_wsf_profile_set_public_key - remove lasso_wsf_profile_set_security_mech_id - add lasso_wsf_profile_get_security_mechanism - add lasso_wsf_profile_set_description - empty function about online status of the principal - remove all (non-working) handling of the x509 security mechanism - add a new constructor function LassoWsfProfile* lasso_wsf_profile_new_full(LassoServer *server, LassoDiscoResourceOffering *offering) - and a new init function (for subclass): gint lasso_wsf_profile_init(LassoWsfProfile *profile, LassoServer *server, LassoDiscoResourceOffering *offering) * lasso/id-wsf/wsf_profile.h: - mark as deprecated: lasso_wsf_profile_move_credentials lasso_wsf_profile_build_soap_envelope lasso_wsf_profile_set_provider_soap_request lasso_wsf_profile_principal_is_online lasso_wsf_profile_add_credential lasso_wsf_profile_set_principal_status lasso_wsf_profile_set_principal_online lasso_wsf_profile_set_principal_offline * lasso/id-wsf/wsf_profile_private.h: - remove fields from LassoWsfProfilePrivate structure: - GList *credentials; - gchar *public_key; - add fields: - char *security_mech_id; - LassoDiscoResourceOffering *offering;
2008-08-01 16:08:41 +02:00
{
if (!security_mech_id) {
return FALSE;
}
if (strcmp(security_mech_id, LASSO_SECURITY_MECH_SAML) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_TLS_SAML) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_CLIENT_TLS_SAML) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY11_MECH_SAML) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY11_MECH_TLS_SAML) == 0) {
* lasso/id-wsf/discovery.c: - include utils.h - move lasso_wsf_profile_build_key_info_node here - add a comment for future review of lasso_discovery_build_credential - remove direct use of lasso_wsf_profile_build_soap_envelope, use lasso_wsf_profile_init_soap_request instead. * lasso/id-wsf/utils.{c,h}: - new file with security mech id matching functions * lasso/id-wsf/wsf_profile.c: - remove all credentials related static functions - empty all credentials related public functions - move function related to matching security mechanism into utils.{c,h} and xml/disco_description.h - add static function lasso_wsf_profile_comply_with_saml_authentication that tries to add credential to the request to a web service using the SAML WS-Security mechanism - add static function lasso_wsf_profile_comply_with_security_mechanism to dispatch upon the current chosen securirt mechanism. - extract build_soap_envelope to the static function build_soap_envelope_internal to remove warning of usage of a deprecated function. - remove lasso_wsf_profile_set_public_key - remove lasso_wsf_profile_set_security_mech_id - add lasso_wsf_profile_get_security_mechanism - add lasso_wsf_profile_set_description - empty function about online status of the principal - remove all (non-working) handling of the x509 security mechanism - add a new constructor function LassoWsfProfile* lasso_wsf_profile_new_full(LassoServer *server, LassoDiscoResourceOffering *offering) - and a new init function (for subclass): gint lasso_wsf_profile_init(LassoWsfProfile *profile, LassoServer *server, LassoDiscoResourceOffering *offering) * lasso/id-wsf/wsf_profile.h: - mark as deprecated: lasso_wsf_profile_move_credentials lasso_wsf_profile_build_soap_envelope lasso_wsf_profile_set_provider_soap_request lasso_wsf_profile_principal_is_online lasso_wsf_profile_add_credential lasso_wsf_profile_set_principal_status lasso_wsf_profile_set_principal_online lasso_wsf_profile_set_principal_offline * lasso/id-wsf/wsf_profile_private.h: - remove fields from LassoWsfProfilePrivate structure: - GList *credentials; - gchar *public_key; - add fields: - char *security_mech_id; - LassoDiscoResourceOffering *offering;
2008-08-01 16:08:41 +02:00
return TRUE;
}
* lasso/id-wsf/discovery.c: - include utils.h - move lasso_wsf_profile_build_key_info_node here - add a comment for future review of lasso_discovery_build_credential - remove direct use of lasso_wsf_profile_build_soap_envelope, use lasso_wsf_profile_init_soap_request instead. * lasso/id-wsf/utils.{c,h}: - new file with security mech id matching functions * lasso/id-wsf/wsf_profile.c: - remove all credentials related static functions - empty all credentials related public functions - move function related to matching security mechanism into utils.{c,h} and xml/disco_description.h - add static function lasso_wsf_profile_comply_with_saml_authentication that tries to add credential to the request to a web service using the SAML WS-Security mechanism - add static function lasso_wsf_profile_comply_with_security_mechanism to dispatch upon the current chosen securirt mechanism. - extract build_soap_envelope to the static function build_soap_envelope_internal to remove warning of usage of a deprecated function. - remove lasso_wsf_profile_set_public_key - remove lasso_wsf_profile_set_security_mech_id - add lasso_wsf_profile_get_security_mechanism - add lasso_wsf_profile_set_description - empty function about online status of the principal - remove all (non-working) handling of the x509 security mechanism - add a new constructor function LassoWsfProfile* lasso_wsf_profile_new_full(LassoServer *server, LassoDiscoResourceOffering *offering) - and a new init function (for subclass): gint lasso_wsf_profile_init(LassoWsfProfile *profile, LassoServer *server, LassoDiscoResourceOffering *offering) * lasso/id-wsf/wsf_profile.h: - mark as deprecated: lasso_wsf_profile_move_credentials lasso_wsf_profile_build_soap_envelope lasso_wsf_profile_set_provider_soap_request lasso_wsf_profile_principal_is_online lasso_wsf_profile_add_credential lasso_wsf_profile_set_principal_status lasso_wsf_profile_set_principal_online lasso_wsf_profile_set_principal_offline * lasso/id-wsf/wsf_profile_private.h: - remove fields from LassoWsfProfilePrivate structure: - GList *credentials; - gchar *public_key; - add fields: - char *security_mech_id; - LassoDiscoResourceOffering *offering;
2008-08-01 16:08:41 +02:00
return FALSE;
}
2008-09-12 17:06:58 +02:00
/**
* lasso_security_mech_id_is_bearer_authentication:
* @security_mech_id: the URI of an authentication mechanism
*
* Return value: %TRUE if @security_mech_id is one of
* urn:liberty:security:2003-08:null:Bearer,
* urn:liberty:security:2003-08:TLS:Bearer,
2008-09-12 17:06:58 +02:00
* urn:liberty:security:2003-08:ClientTLS:Bearer,
* urn:liberty:security:2005-02:null:Bearer,
* urn:liberty:security:2005-02:TLS:Bearer,
* FALSE otherwise.
*/
gboolean
lasso_security_mech_id_is_bearer_authentication(const gchar *security_mech_id)
{
2008-10-01 11:55:40 +02:00
if (!security_mech_id) {
return FALSE;
2008-10-01 11:55:40 +02:00
}
if (strcmp(security_mech_id, LASSO_SECURITY_MECH_BEARER) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_TLS_BEARER) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY_MECH_CLIENT_TLS_BEARER) == 0 ||
strcmp(security_mech_id, LASSO_SECURITY11_MECH_BEARER) == 0 ||
2008-10-01 11:55:40 +02:00
strcmp(security_mech_id, LASSO_SECURITY11_MECH_TLS_BEARER) == 0) {
return TRUE;
2008-10-01 11:55:40 +02:00
}
return FALSE;
}