lasso/lasso/id-wsf/utils.c

146 lines
4.6 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
*/
/**
* 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;
}