diff --git a/lasso/id-ff/profile.c b/lasso/id-ff/profile.c index 5e9b7cb6..a0b24aa9 100644 --- a/lasso/id-ff/profile.c +++ b/lasso/id-ff/profile.c @@ -749,7 +749,7 @@ LassoProviderRole lasso_profile_sso_role_with(LassoProfile *profile, const char return LASSO_PROVIDER_ROLE_NONE; /* coherency check */ - g_return_val_if_fail(g_strcmp0(federation->remote_providerID, remote_provider_id) == 0, + g_return_val_if_fail(lasso_strisequal(federation->remote_providerID,remote_provider_id), LASSO_PROVIDER_ROLE_NONE); if (LASSO_IS_SAML2_NAME_ID(federation->local_nameIdentifier)) { @@ -764,9 +764,9 @@ LassoProviderRole lasso_profile_sso_role_with(LassoProfile *profile, const char message(G_LOG_LEVEL_WARNING, "a federation without a NameID was found"); return LASSO_PROVIDER_ROLE_NONE; } - if (g_strcmp0(remote_provider_id, name_qualifier) == 0) { + if (lasso_strisequal(remote_provider_id,name_qualifier)) { return LASSO_PROVIDER_ROLE_SP; - } else if (g_strcmp0(provider_id, name_qualifier) == 0) { + } else if (lasso_strisequal(provider_id,name_qualifier)) { return LASSO_PROVIDER_ROLE_IDP; } return LASSO_PROVIDER_ROLE_NONE; diff --git a/lasso/id-ff/provider.c b/lasso/id-ff/provider.c index 7269191a..fe3f42be 100644 --- a/lasso/id-ff/provider.c +++ b/lasso/id-ff/provider.c @@ -632,7 +632,7 @@ _lasso_provider_load_key_descriptor(LassoProvider *provider, xmlNode *key_descri private_data = provider->private_data; use = xmlGetProp(key_descriptor, (xmlChar*)"use"); - if (use == NULL || g_strcmp0((char*)use, "signing") == 0) { + if (use == NULL || lasso_strisequal((char *)use,"signing")) { lasso_assign_xml_node(private_data->signing_key_descriptor, key_descriptor); } if (use == NULL || strcmp((char*)use, "encryption") == 0) { diff --git a/lasso/id-ff/session.c b/lasso/id-ff/session.c index 0c103268..3e60c015 100644 --- a/lasso/id-ff/session.c +++ b/lasso/id-ff/session.c @@ -376,7 +376,7 @@ lasso_session_is_dirty(LassoSession *session) gint lasso_session_remove_assertion(LassoSession *session, const gchar *providerID) { - if (! LASSO_IS_SESSION(session) || lasso_is_empty_string(providerID)) { + if (! LASSO_IS_SESSION(session) || lasso_strisempty(providerID)) { return LASSO_PARAM_ERROR_INVALID_VALUE; } diff --git a/lasso/id-wsf-2.0/data_service.c b/lasso/id-wsf-2.0/data_service.c index 6c6ed11c..8f4012e6 100644 --- a/lasso/id-wsf-2.0/data_service.c +++ b/lasso/id-wsf-2.0/data_service.c @@ -100,8 +100,8 @@ gint lasso_idwsf2_data_service_set_service_type(LassoIdWsf2DataService *service, const char *prefix, const char *service_type) { - if (!LASSO_IS_IDWSF2_DATA_SERVICE(service) || lasso_is_empty_string(prefix) - || lasso_is_empty_string(service_type)) + if (!LASSO_IS_IDWSF2_DATA_SERVICE(service) || lasso_strisempty(prefix) + || lasso_strisempty(service_type)) return LASSO_PARAM_ERROR_INVALID_VALUE; lasso_assign_string(service->private_data->service_type_prefix, prefix); lasso_assign_string(service->private_data->service_type, service_type); @@ -259,7 +259,7 @@ lasso_idwsf2_data_service_add_query_item(LassoIdWsf2DataService *service, const /* Check duplicates */ lasso_foreach(i, service->private_data->query_items) { LassoIdWsf2DstRefQueryItem *old_item = (LassoIdWsf2DstRefQueryItem *)i->data; - if (g_strcmp0(old_item->parent.parent.itemID, item_id) == 0) { + if (lasso_strisequal(old_item->parent.parent.itemID,item_id)) { return LASSO_IDWSF2_DST_ERROR_DUPLICATE_ITEM; } } @@ -298,7 +298,7 @@ lasso_idwsf2_data_service_add_modify_item(LassoIdWsf2DataService *service, const } lasso_foreach(i, service->private_data->modify_items) { LassoIdWsf2DstRefModifyItem *old_item = (LassoIdWsf2DstRefModifyItem *)i->data; - if (g_strcmp0(old_item->id, item_id) == 0) { + if (lasso_strisequal(old_item->id,item_id)) { return LASSO_IDWSF2_DST_ERROR_DUPLICATE_ITEM; } } @@ -391,7 +391,7 @@ lasso_idwsf2_data_service_get_item(LassoIdWsf2DataService *service, } lasso_foreach(i, service->private_data->query_items) { LassoIdWsf2DstRefQueryItem *old_item = (LassoIdWsf2DstRefQueryItem *)i->data; - if (g_strcmp0(old_item->parent.parent.itemID, item_id) == 0) { + if (lasso_strisequal(old_item->parent.parent.itemID,item_id)) { return (LassoNode*)old_item; } } @@ -405,7 +405,7 @@ lasso_idwsf2_data_service_get_item(LassoIdWsf2DataService *service, } lasso_foreach(i, service->private_data->modify_items) { LassoIdWsf2DstRefModifyItem *old_item = (LassoIdWsf2DstRefModifyItem *)i->data; - if (g_strcmp0(old_item->id, item_id) == 0) { + if (lasso_strisequal(old_item->id,item_id)) { return (LassoNode*)old_item; } } @@ -428,12 +428,12 @@ gint lasso_idwsf2_data_service_add_namespace(LassoIdWsf2DataService *service, const char *prefix, const char *href) { - if (xmlValidateNCName(BAD_CAST prefix, 0) && ! lasso_is_empty_string(href)) + if (xmlValidateNCName(BAD_CAST prefix, 0) && ! lasso_strisempty(href)) return LASSO_PARAM_ERROR_INVALID_VALUE; if (g_hash_table_lookup(service->private_data->namespaces, prefix) != NULL || - g_strcmp0(service->private_data->service_type_prefix, prefix) == 0 || - g_strcmp0(prefix, LASSO_IDWSF2_DSTREF_PREFIX) == 0) { + lasso_strisequal(service->private_data->service_type_prefix,prefix) || + lasso_strisequal(prefix,LASSO_IDWSF2_DSTREF_PREFIX)) { return LASSO_PARAM_ERROR_INVALID_VALUE; } @@ -833,13 +833,13 @@ lasso_idwsf2_data_service_process_response_msg( if (! status || ! status->code) { goto_cleanup_with_rc(LASSO_PROFILE_ERROR_MISSING_STATUS_CODE); } - if (g_strcmp0(status->code, LASSO_DST2_STATUS_CODE1_FAILED) == 0) { + if (lasso_strisequal(status->code,LASSO_DST2_STATUS_CODE1_FAILED)) { goto_cleanup_with_rc(LASSO_PROFILE_ERROR_STATUS_NOT_SUCCESS); } - if (g_strcmp0(status->code, LASSO_DST2_STATUS_CODE1_PARTIAL) == 0) { + if (lasso_strisequal(status->code,LASSO_DST2_STATUS_CODE1_PARTIAL)) { rc = LASSO_IDWSF2_DST_ERROR_PARTIAL_FAILURE; } - if (g_strcmp0(status->code, LASSO_DST2_STATUS_CODE1_OK) != 0) { + if (lasso_strisnotequal(status->code,LASSO_DST2_STATUS_CODE1_OK)) { rc = LASSO_IDWSF2_DST_ERROR_UNKNOWN_STATUS_CODE; } @@ -910,7 +910,7 @@ lasso_idwsf2_data_service_get_query_item_result(LassoIdWsf2DataService *service, } lasso_foreach(i, service->private_data->query_datas) { LassoIdWsf2DstRefData *data = (LassoIdWsf2DstRefData*)i->data; - if (g_strcmp0(data->parent.itemIDRef, item_id) == 0) { + if (lasso_strisequal(data->parent.itemIDRef,item_id)) { return data; } } diff --git a/lasso/id-wsf-2.0/discovery.c b/lasso/id-wsf-2.0/discovery.c index 4b8f0388..bc8e58fe 100644 --- a/lasso/id-wsf-2.0/discovery.c +++ b/lasso/id-wsf-2.0/discovery.c @@ -227,7 +227,7 @@ lasso_idwsf2_discovery_status2rc(LassoIdWsf2UtilStatus *status) return LASSO_PROFILE_ERROR_MISSING_STATUS_CODE; for (i = 0; i < G_N_ELEMENTS(code2rc); ++i) { - if (g_strcmp0(status->code, code2rc[i].code) == 0) { + if (lasso_strisequal(status->code,code2rc[i].code)) { rc = code2rc[i].rc; } } @@ -572,7 +572,7 @@ lasso_idwsf2_discovery_build_request_msg(LassoIdWsf2Discovery *discovery, GList *i; lasso_foreach(i, discovery->private_data->metadatas) { LassoIdWsf2DiscoSvcMetadata *metadata = (LassoIdWsf2DiscoSvcMetadata *)i->data; - if (lasso_is_empty_string(metadata->svcMDID)) { + if (lasso_strisempty(metadata->svcMDID)) { message(G_LOG_LEVEL_WARNING, "disco:MetadataReplace method called with " \ "non registered metadatas " \ "(svcMDID attribute is missing)"); @@ -827,7 +827,7 @@ _string_list_intersect(GList *a, GList *b) lasso_foreach(i, a) { lasso_foreach(j, b) - if (g_strcmp0(i->data, j->data) == 0) { + if (lasso_strisequal(i->data,j->data)) { return TRUE; } } @@ -842,7 +842,7 @@ _string_list_contains(GList *a, const char *str) if (a == NULL) return TRUE; lasso_foreach(i, a) - if (g_strcmp0(i->data, str) == 0) { + if (lasso_strisequal(i->data,str)) { return TRUE; } return FALSE; @@ -917,7 +917,7 @@ lasso_idwsf2_discovery_match_request_service_and_metadata2( gboolean has20 = FALSE; lasso_foreach (k, endpoint_context->Framework) { LassoIdWsf2SbfFramework *framework = k->data; - if (LASSO_IS_IDWSF2_SBF_FRAMEWORK(framework) && g_strcmp0(framework->version, "2.0") == 0) + if (LASSO_IS_IDWSF2_SBF_FRAMEWORK(framework) && lasso_strisequal(framework->version,"2.0")) has20 = TRUE; } result = result && has20; diff --git a/lasso/id-wsf-2.0/idwsf2_helper.c b/lasso/id-wsf-2.0/idwsf2_helper.c index 8e5b6e01..f8577ed9 100644 --- a/lasso/id-wsf-2.0/idwsf2_helper.c +++ b/lasso/id-wsf-2.0/idwsf2_helper.c @@ -115,7 +115,7 @@ lasso_wsa_endpoint_reference_get_idwsf2_security_context_for_security_mechanism( lasso_foreach_full_begin(LassoIdWsf2DiscoSecurityContext*, context, it1, epr->Metadata->any); if (LASSO_IS_IDWSF2_DISCO_SECURITY_CONTEXT (context)) { lasso_foreach_full_begin(char*, textnode, it2, context->SecurityMechID); - if (g_strcmp0 (textnode, security_mech_id) == 0 || sech_mech_predicate(textnode)) { + if (lasso_strisequal(textnode,security_mech_id) || sech_mech_predicate(textnode)) { return context; } lasso_foreach_full_end() @@ -165,7 +165,7 @@ lasso_wsa_endpoint_reference_get_token_by_usage( epr, sec_mech_predicate, security_mech_id, TRUE); lasso_foreach_full_begin (LassoIdWsf2SecToken*, token, iter, security_context->Token); if (LASSO_IS_IDWSF2_SEC_TOKEN (token)) { - if (usage && g_strcmp0(token->usage, usage) == 0) { + if (usage && lasso_strisequal(token->usage,usage)) { if (LASSO_IS_NODE(token->any)) { return (LassoNode*)token->any; } else if (token->ref) { diff --git a/lasso/id-wsf-2.0/profile.c b/lasso/id-wsf-2.0/profile.c index 6fce0b01..489c5899 100644 --- a/lasso/id-wsf-2.0/profile.c +++ b/lasso/id-wsf-2.0/profile.c @@ -435,7 +435,7 @@ lasso_idwsf2_profile_check_security_mechanism(LassoIdWsf2Profile *profile, name_qualifier = assertion->Subject->NameID->NameQualifier; sp_name_qualifier = assertion->Subject->NameID->SPNameQualifier; } - if (! name_qualifier || g_strcmp0(name_qualifier, issuer->ProviderID) != 0) + if (! name_qualifier || lasso_strisnotequal(name_qualifier,issuer->ProviderID)) goto_cleanup_with_rc(LASSO_PROFILE_ERROR_INVALID_ASSERTION); /* There is two cases for the NameID of the security assertion: * - we are the IdP and the Wsp, so the NameQualifier is us and the SPNameQualifier is the @@ -449,10 +449,10 @@ lasso_idwsf2_profile_check_security_mechanism(LassoIdWsf2Profile *profile, sender_id = lasso_soap_envelope_sb2_get_provider_id(envelope); if (! sender_id) goto_cleanup_with_rc(LASSO_WSF_PROFILE_ERROR_MISSING_SENDER_ID); - if (local_service_id && g_strcmp0(local_service_id, name_qualifier) == 0 && - sp_name_qualifier && g_strcmp0(sp_name_qualifier, sender_id) == 0) { + if (local_service_id && lasso_strisequal(local_service_id,name_qualifier) && + sp_name_qualifier && lasso_strisequal(sp_name_qualifier,sender_id)) { /* Ok. */ - } else if (sp_name_qualifier && g_strcmp0(sp_name_qualifier, local_service_id) == 0) { + } else if (sp_name_qualifier && lasso_strisequal(sp_name_qualifier,local_service_id)) { /* Ok. */ } else { goto_cleanup_with_rc(LASSO_PROFILE_ERROR_INVALID_ASSERTION); diff --git a/lasso/id-wsf-2.0/saml2_login.c b/lasso/id-wsf-2.0/saml2_login.c index f7bee3ad..fc0f074b 100644 --- a/lasso/id-wsf-2.0/saml2_login.c +++ b/lasso/id-wsf-2.0/saml2_login.c @@ -241,7 +241,7 @@ lasso_saml2_assertion_idwsf2_get_discovery_bootstrap_epr(LassoSaml2Assertion *as continue; attribute = LASSO_SAML2_ATTRIBUTE(j->data); - if (g_strcmp0(attribute->Name, LASSO_SAML2_ATTRIBUTE_NAME_EPR) != 0) + if (lasso_strisnotequal(attribute->Name,LASSO_SAML2_ATTRIBUTE_NAME_EPR)) continue; /* There should only one attribute value, and the EPR should be the first * contained node */ diff --git a/lasso/id-wsf-2.0/soap_binding.c b/lasso/id-wsf-2.0/soap_binding.c index ea922dae..347a1513 100644 --- a/lasso/id-wsf-2.0/soap_binding.c +++ b/lasso/id-wsf-2.0/soap_binding.c @@ -240,7 +240,7 @@ lasso_soap_envelope_get_action(LassoSoapEnvelope *soap_envelope) lasso_foreach(i, soap_envelope->Header->Other) { if (LASSO_IS_WSA_ATTRIBUTED_URI(i->data) - && g_strcmp0(lasso_node_get_name((LassoNode*)i->data), "Action")) { + && lasso_strisequal(lasso_node_get_name((LassoNode *)i->data),"Action")) { return ((LassoWsAddrAttributedURI*)i->data)->content; } } @@ -273,9 +273,9 @@ _get_node(GList **list, GType node_type, const char *node_name, const char *node if (LASSO_IS_NODE(node) && (! node_type || ( G_IS_OBJECT(node) && G_OBJECT_TYPE(node) == node_type)) && - (! node_name || g_strcmp0(lasso_node_get_name(node), node_name) == 0) && + (! node_name || lasso_strisequal(lasso_node_get_name(node),node_name)) && (! node_namespace || - g_strcmp0(lasso_node_get_namespace(node), node_namespace) == 0)) { + lasso_strisequal(lasso_node_get_namespace(node),node_namespace))) { return node; } } @@ -284,10 +284,10 @@ _get_node(GList **list, GType node_type, const char *node_name, const char *node if (! node) { return NULL; } - if (g_strcmp0(lasso_node_get_name(node), node_name) != 0) { + if (lasso_strisnotequal(lasso_node_get_name(node),node_name)) { lasso_node_set_custom_nodename(node, node_name); } - if (g_strcmp0(lasso_node_get_namespace(node), node_namespace) == 0) { + if (lasso_strisequal(lasso_node_get_namespace(node),node_namespace)) { lasso_node_set_custom_namespace(node, node_namespace, node_prefix); } lasso_list_add_new_gobject(*list, node); @@ -437,11 +437,11 @@ lasso_soap_envelope_get_sb2_user_interaction_hint(LassoSoapEnvelope *soap_envelo header = lasso_soap_envelope_get_sb2_user_interaction_header(soap_envelope, FALSE); if (header) { hint = header->interact; - if (g_strcmp0(hint, LASSO_SB2_USER_INTERACTION_INTERACT_IF_NEEDED) == 0) + if (lasso_strisequal(hint,LASSO_SB2_USER_INTERACTION_INTERACT_IF_NEEDED)) return LASSO_IDWSF2_SB2_USER_INTERACTION_HINT_INTERACT_IF_NEEDED; - if (g_strcmp0(hint, LASSO_SB2_USER_INTERACTION_DO_NOT_INTERACT) == 0) + if (lasso_strisequal(hint,LASSO_SB2_USER_INTERACTION_DO_NOT_INTERACT)) return LASSO_IDWSF2_SB2_USER_INTERACTION_HINT_DO_NOT_INTERACT; - if (g_strcmp0(hint, LASSO_SB2_USER_INTERACTION_DO_NOT_INTERACT_FOR_DATA) == 0) + if (lasso_strisequal(hint,LASSO_SB2_USER_INTERACTION_DO_NOT_INTERACT_FOR_DATA)) return LASSO_IDWSF2_SB2_USER_INTERACTION_HINT_DO_NOT_INTERACT_FOR_DATA; } diff --git a/lasso/id-wsf/data_service.c b/lasso/id-wsf/data_service.c index 1ab655cf..3a404e03 100644 --- a/lasso/id-wsf/data_service.c +++ b/lasso/id-wsf/data_service.c @@ -237,8 +237,8 @@ lasso_data_service_get_query_item(LassoDataService *service, { LassoDstQueryItem *query_item = NULL; lasso_extract_node_or_fail(query_item, query_items->data, DST_QUERY_ITEM, LASSO_ERROR_CAST_FAILED); - if ((select && g_strcmp0(select, query_item->Select) == 0) || - (item_id && g_strcmp0(item_id, query_item->itemID) == 0)) + if ((select && lasso_strisequal(select,query_item->Select)) || + (item_id && lasso_strisequal(item_id,query_item->itemID))) { if (output) { lasso_assign_new_gobject(*output, query_item); @@ -431,7 +431,7 @@ lasso_data_service_get_answers_by_select(LassoDataService *service, const char * if (datas) { lasso_extract_node_or_fail(data, datas->data, DST_DATA, LASSO_ERROR_CAST_FAILED); - if (g_strcmp0(select, query_item->Select) != 0) { + if (lasso_strisnotequal(select,query_item->Select)) { data = NULL; rc = LASSO_DST_ERROR_QUERY_NOT_FOUND; } @@ -444,7 +444,7 @@ lasso_data_service_get_answers_by_select(LassoDataService *service, const char * while (iter) { lasso_extract_node_or_fail(query_item, iter->data, DST_QUERY_ITEM, LASSO_ERROR_CAST_FAILED); - if (g_strcmp0(query_item->Select, select) == 0) { + if (lasso_strisequal(query_item->Select,select)) { break; } query_item = NULL; @@ -457,7 +457,7 @@ lasso_data_service_get_answers_by_select(LassoDataService *service, const char * while (datas) { lasso_extract_node_or_fail(data, datas->data, DST_DATA, LASSO_ERROR_CAST_FAILED); - if (g_strcmp0(data->itemIDRef, query_item->itemID) == 0) { + if (lasso_strisequal(data->itemIDRef,query_item->itemID)) { break; } data = NULL; @@ -510,7 +510,7 @@ lasso_data_service_get_answers_by_item_id(LassoDataService *service, const char datas = query_response->Data; while (datas) { lasso_extract_node_or_fail(data, datas->data, DST_DATA, LASSO_ERROR_CAST_FAILED); - if (g_strcmp0(data->itemIDRef, item_id) == 0) { + if (lasso_strisequal(data->itemIDRef,item_id)) { break; } data = NULL; diff --git a/lasso/id-wsf/wsf_profile.c b/lasso/id-wsf/wsf_profile.c index 96ed11bc..f1840bb7 100644 --- a/lasso/id-wsf/wsf_profile.c +++ b/lasso/id-wsf/wsf_profile.c @@ -990,12 +990,14 @@ lasso_wsf_profile_process_soap_response_msg(LassoWsfProfile *profile, const gcha LASSO_WSF_PROFILE_ERROR_MISSING_CORRELATION); /* Check message ID */ - goto_cleanup_if_fail_with_rc( - g_strcmp0(lasso_wsf_profile_utils_get_message_id( - profile->soap_envelope_request), - lasso_wsf_profile_utils_get_ref_message_id( - profile->soap_envelope_response)) == 0, - LASSO_WSF_PROFILE_ERROR_INVALID_OR_MISSING_REFERENCE_TO_MESSAGE_ID); + { + const char *message_id = + lasso_wsf_profile_utils_get_message_id(profile->soap_envelope_request); + const char *ref_message_id = + lasso_wsf_profile_utils_get_ref_message_id(profile->soap_envelope_response); + goto_cleanup_if_fail_with_rc(lasso_strisequal(message_id, ref_message_id), + LASSO_WSF_PROFILE_ERROR_INVALID_OR_MISSING_REFERENCE_TO_MESSAGE_ID); + } /* Signal soap fault specifically, * find soap redirects. */ diff --git a/lasso/lasso.c b/lasso/lasso.c index d35e072d..28e60fb6 100644 --- a/lasso/lasso.c +++ b/lasso/lasso.c @@ -286,23 +286,23 @@ void lasso_set_flag(char *flag) { } do { - if (g_strcmp0(flag, "verify-signature") == 0) { + if (lasso_strisequal(flag,"verify-signature")) { lasso_flag_verify_signature = value; continue; } - if (g_strcmp0(flag,"memory-debug") == 0) { + if (lasso_strisequal(flag,"memory-debug")) { lasso_flag_memory_debug = value; continue; } - if (g_strcmp0(flag,"strict-checking") == 0) { + if (lasso_strisequal(flag,"strict-checking")) { lasso_flag_strict_checking = value; continue; } - if (g_strcmp0(flag,"add-signature") == 0) { + if (lasso_strisequal(flag,"add-signature")) { lasso_flag_add_signature = value; continue; } - if (g_strcmp0(flag, "sign-messages") == 0) { + if (lasso_strisequal(flag,"sign-messages")) { lasso_flag_sign_messages = value; continue; } diff --git a/lasso/registry.c b/lasso/registry.c index 9b3f338c..0816c0c1 100644 --- a/lasso/registry.c +++ b/lasso/registry.c @@ -96,7 +96,8 @@ void lasso_registry_default_shutdown() * * Return value: TRUE if all field of record1 are equal to record2. */ -gboolean lasso_registry_direct_mapping_equal(LassoRegistryDirectMappingRecord *record1, LassoRegistryDirectMappingRecord *record2) +gboolean lasso_registry_direct_mapping_equal(LassoRegistryDirectMappingRecord *record1, + LassoRegistryDirectMappingRecord *record2) { return record1->from_namespace == record2->from_namespace && record1->from_name == record2->from_name @@ -113,7 +114,8 @@ gboolean lasso_registry_direct_mapping_equal(LassoRegistryDirectMappingRecord *r * * Return value: TRUE if record1 is equal to record2 */ -gboolean lasso_registry_functional_mapping_equal(LassoRegistryFunctionalMappingRecord *record1, LassoRegistryFunctionalMappingRecord *record2) +gboolean lasso_registry_functional_mapping_equal(LassoRegistryFunctionalMappingRecord *record1, + LassoRegistryFunctionalMappingRecord *record2) { return record1->from_namespace == record2->from_namespace && record1->to_namespace == record2->to_namespace; diff --git a/lasso/saml-2.0/assertion_query.c b/lasso/saml-2.0/assertion_query.c index 8af6776d..3e08d5bc 100644 --- a/lasso/saml-2.0/assertion_query.c +++ b/lasso/saml-2.0/assertion_query.c @@ -406,8 +406,8 @@ lasso_assertion_query_lookup_attribute(LassoAssertionQuery *assertion_query, cha lasso_foreach_full_begin(LassoSaml2Attribute*, attribute, it, query->Attribute) { if (LASSO_IS_SAML2_ATTRIBUTE(attribute) && - g_strcmp0(attribute->NameFormat, format) == 0 && - g_strcmp0(attribute->Name, name) == 0) + lasso_strisequal(attribute->NameFormat,format) && + lasso_strisequal(attribute->Name,name)) { result = attribute; break; diff --git a/lasso/saml-2.0/login.c b/lasso/saml-2.0/login.c index 99b6683b..c080faca 100644 --- a/lasso/saml-2.0/login.c +++ b/lasso/saml-2.0/login.c @@ -116,7 +116,7 @@ static gboolean want_authn_request_signed(LassoProvider *provider) { s = lasso_provider_get_metadata_one_for_role(provider, LASSO_PROVIDER_ROLE_IDP, LASSO_SAML2_METADATA_ATTRIBUTE_WANT_AUTHN_REQUEST_SIGNED); - if (g_strcmp0(s, "false") == 0) { + if (lasso_strisequal(s,"false")) { rc = FALSE; } lasso_release_string(s); @@ -129,7 +129,7 @@ static gboolean authn_request_signed(LassoProvider *provider) { s = lasso_provider_get_metadata_one_for_role(provider, LASSO_PROVIDER_ROLE_SP, LASSO_SAML2_METADATA_ATTRIBUTE_AUTHN_REQUEST_SIGNED); - if (g_strcmp0(s, "true") == 0) { + if (lasso_strisequal(s,"true")) { rc = TRUE; } lasso_release_string(s); @@ -247,8 +247,7 @@ lasso_saml20_login_build_authn_request_msg(LassoLogin *login) /* support old way of doing PAOS */ if (login->http_method == LASSO_HTTP_METHOD_SOAP - && g_strcmp0(authn_request->ProtocolBinding, - LASSO_SAML2_METADATA_BINDING_PAOS) == 0) { + && lasso_strisequal(authn_request->ProtocolBinding,LASSO_SAML2_METADATA_BINDING_PAOS)) { login->http_method = LASSO_HTTP_METHOD_PAOS; /* PAOS is special, the url passed to build_request is the AssertionConsumerServiceURL of * this SP, not the destination. */ @@ -336,15 +335,15 @@ lasso_saml20_login_process_authn_request_msg(LassoLogin *login, const char *auth if (binding == NULL) { if (service_index == -1) return LASSO_LOGIN_ERROR_NO_DEFAULT_ENDPOINT; - } else if (g_strcmp0(binding, "HTTP-Artifact") == 0) { + } else if (lasso_strisequal(binding,"HTTP-Artifact")) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_ART; - } else if (g_strcmp0(binding, "HTTP-POST") == 0) { + } else if (lasso_strisequal(binding,"HTTP-POST")) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_POST; - } else if (g_strcmp0(binding, "HTTP-Redirect") == 0) { + } else if (lasso_strisequal(binding,"HTTP-Redirect")) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_REDIRECT; - } else if (g_strcmp0(binding, "SOAP") == 0) { + } else if (lasso_strisequal(binding,"SOAP")) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_LECP; - } else if (g_strcmp0(binding, "PAOS") == 0) { + } else if (lasso_strisequal(binding,"PAOS")) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_LECP; } lasso_release_string(binding); @@ -356,17 +355,16 @@ lasso_saml20_login_process_authn_request_msg(LassoLogin *login, const char *auth remote_provider, authn_request->AssertionConsumerServiceURL); } - if (g_strcmp0(protocol_binding, LASSO_SAML2_METADATA_BINDING_ARTIFACT) == 0) { + if (lasso_strisequal(protocol_binding,LASSO_SAML2_METADATA_BINDING_ARTIFACT)) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_ART; - } else if (g_strcmp0(protocol_binding, LASSO_SAML2_METADATA_BINDING_POST) == 0) { + } else if (lasso_strisequal(protocol_binding,LASSO_SAML2_METADATA_BINDING_POST)) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_POST; - } else if (g_strcmp0(protocol_binding, LASSO_SAML2_METADATA_BINDING_SOAP) == 0) { + } else if (lasso_strisequal(protocol_binding,LASSO_SAML2_METADATA_BINDING_SOAP)) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_LECP; - } else if (g_strcmp0(protocol_binding, - LASSO_SAML2_METADATA_BINDING_REDIRECT) == 0) { + } else if (lasso_strisequal(protocol_binding,LASSO_SAML2_METADATA_BINDING_REDIRECT)) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_REDIRECT; goto_cleanup_with_rc(LASSO_PROFILE_ERROR_INVALID_PROTOCOLPROFILE); - } else if (g_strcmp0(protocol_binding, LASSO_SAML2_METADATA_BINDING_PAOS) == 0) { + } else if (lasso_strisequal(protocol_binding,LASSO_SAML2_METADATA_BINDING_PAOS)) { login->protocolProfile = LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_LECP; } else { rc = LASSO_PROFILE_ERROR_INVALID_PROTOCOLPROFILE; @@ -415,15 +413,15 @@ lasso_saml20_login_must_authenticate(LassoLogin *login) GList *t1, *t2; int compa; - if (comparison == NULL || g_strcmp0(comparison, "exact") == 0) { + if (comparison == NULL || lasso_strisequal(comparison,"exact")) { compa = 0; - } else if (g_strcmp0(comparison, "minimum") == 0) { + } else if (lasso_strisequal(comparison,"minimum")) { message(G_LOG_LEVEL_CRITICAL, "'minimum' comparison is not implemented"); compa = 0; - } else if (g_strcmp0(comparison, "better") == 0) { + } else if (lasso_strisequal(comparison,"better")) { message(G_LOG_LEVEL_CRITICAL, "'better' comparison is not implemented"); compa = 0; - } else if (g_strcmp0(comparison, "maximum") == 0) { + } else if (lasso_strisequal(comparison,"maximum")) { message(G_LOG_LEVEL_CRITICAL, "'maximum' comparison is not implemented"); compa = 0; } @@ -463,7 +461,7 @@ lasso_saml20_login_must_authenticate(LassoLogin *login) method = as->AuthnContext->AuthnContextClassRef; if (compa == 0) { /* exact */ - if (g_strcmp0(method, class_ref) == 0) { + if (lasso_strisequal(method,class_ref)) { matched = TRUE; break; } @@ -511,7 +509,7 @@ lasso_saml20_login_must_ask_for_consent_private(LassoLogin *login) if (name_id_policy) { char *format = name_id_policy->Format; - if (g_strcmp0(format, LASSO_SAML2_NAME_IDENTIFIER_FORMAT_TRANSIENT) == 0) { + if (lasso_strisequal(format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_TRANSIENT)) { goto_cleanup_with_rc (FALSE) } if (name_id_policy->AllowCreate == FALSE) { @@ -538,22 +536,22 @@ lasso_saml20_login_must_ask_for_consent_private(LassoLogin *login) if (consent == NULL) goto_cleanup_with_rc (FALSE) - if (g_strcmp0(consent, LASSO_SAML2_CONSENT_OBTAINED) == 0) + if (lasso_strisequal(consent,LASSO_SAML2_CONSENT_OBTAINED)) goto_cleanup_with_rc (FALSE) - if (g_strcmp0(consent, LASSO_SAML2_CONSENT_PRIOR) == 0) + if (lasso_strisequal(consent,LASSO_SAML2_CONSENT_PRIOR)) goto_cleanup_with_rc (FALSE) - if (g_strcmp0(consent, LASSO_SAML2_CONSENT_IMPLICIT) == 0) + if (lasso_strisequal(consent,LASSO_SAML2_CONSENT_IMPLICIT)) goto_cleanup_with_rc (FALSE) - if (g_strcmp0(consent, LASSO_SAML2_CONSENT_EXPLICIT) == 0) + if (lasso_strisequal(consent,LASSO_SAML2_CONSENT_EXPLICIT)) goto_cleanup_with_rc (FALSE) - if (g_strcmp0(consent, LASSO_SAML2_CONSENT_UNAVAILABLE) == 0) + if (lasso_strisequal(consent,LASSO_SAML2_CONSENT_UNAVAILABLE)) goto_cleanup_with_rc (TRUE) - if (g_strcmp0(consent, LASSO_SAML2_CONSENT_INAPPLICABLE) == 0) + if (lasso_strisequal(consent,LASSO_SAML2_CONSENT_INAPPLICABLE)) goto_cleanup_with_rc (TRUE) cleanup: @@ -656,8 +654,7 @@ lasso_saml20_login_process_federation(LassoLogin *login, gboolean is_consent_obt if (lasso_saml20_login_must_ask_for_consent_private(login) && !is_consent_obtained) { goto_cleanup_with_rc (LASSO_LOGIN_ERROR_CONSENT_NOT_OBTAINED) } - if (g_strcmp0(name_id_policy_format, - LASSO_SAML2_NAME_IDENTIFIER_FORMAT_PERSISTENT) != 0) { + if (lasso_strisnotequal(name_id_policy_format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_PERSISTENT)) { /* non persistent case, TRANSIENT is handled by lasso_login_build_assertion() and * other format are the sole responsibility of the caller */ goto_cleanup_with_rc (0) @@ -782,10 +779,8 @@ lasso_saml20_login_build_assertion(LassoLogin *login, } /* TRANSIENT */ if (!name_id_policy || name_id_policy->Format == NULL || - g_strcmp0(name_id_policy->Format, - LASSO_SAML2_NAME_IDENTIFIER_FORMAT_UNSPECIFIED) == 0 || - g_strcmp0(name_id_policy->Format, - LASSO_SAML2_NAME_IDENTIFIER_FORMAT_TRANSIENT) == 0) { + lasso_strisequal(name_id_policy->Format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_UNSPECIFIED) || + lasso_strisequal(name_id_policy->Format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_TRANSIENT)) { char *id = lasso_build_unique_id(32); name_id = (LassoSaml2NameID*)lasso_saml2_name_id_new_with_string(id); @@ -795,18 +790,18 @@ lasso_saml20_login_build_assertion(LassoLogin *login, lasso_assign_string(name_id->Format, LASSO_SAML2_NAME_IDENTIFIER_FORMAT_TRANSIENT); assertion->Subject->NameID = name_id; /* FEDERATED */ - } else if (g_strcmp0(name_id_policy->Format, - LASSO_SAML2_NAME_IDENTIFIER_FORMAT_PERSISTENT) == 0 || - g_strcmp0(name_id_policy->Format, - LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENCRYPTED) == 0) { + } else if (lasso_strisequal(name_id_policy->Format, + LASSO_SAML2_NAME_IDENTIFIER_FORMAT_PERSISTENT) || + lasso_strisequal(name_id_policy->Format, + LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENCRYPTED)) + { LassoFederation *federation; federation = _lasso_login_saml20_get_federation(login); goto_cleanup_if_fail_with_rc(federation != NULL, LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND); - if (g_strcmp0(name_id_policy->Format, - LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENCRYPTED) == 0) { + if (lasso_strisequal(name_id_policy->Format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENCRYPTED)) { do_encrypt_nameid = TRUE; } lasso_assign_gobject(assertion->Subject->NameID, @@ -1114,7 +1109,7 @@ lasso_saml20_login_check_assertion_signature(LassoLogin *login, if (! Issuer || /* No issuer */ ! Issuer->content || /* No issuer content */ (Issuer->Format && - g_strcmp0(Issuer->Format, LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENTITY) != 0)) + lasso_strisnotequal(Issuer->Format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENTITY))) /* Issuer format is not entity */ { rc = LASSO_PROFILE_ERROR_MISSING_ISSUER; @@ -1162,7 +1157,7 @@ _lasso_check_assertion_issuer(LassoSaml2Assertion *assertion, const gchar *provi if (! assertion->Issuer || ! assertion->Issuer->content) return FALSE; - return g_strcmp0(assertion->Issuer->content, provider_id) == 0; + return lasso_strisequal(assertion->Issuer->content,provider_id); } static gint @@ -1243,21 +1238,19 @@ lasso_saml20_login_process_response_status_and_assertion(LassoLogin *login) } status_value = response->Status->StatusCode->Value; - if (status_value && g_strcmp0(status_value, LASSO_SAML2_STATUS_CODE_SUCCESS) != 0) { - if (g_strcmp0(status_value, LASSO_SAML2_STATUS_CODE_REQUEST_DENIED) == 0) + if (status_value && lasso_strisnotequal(status_value,LASSO_SAML2_STATUS_CODE_SUCCESS)) { + if (lasso_strisequal(status_value,LASSO_SAML2_STATUS_CODE_REQUEST_DENIED)) return LASSO_LOGIN_ERROR_REQUEST_DENIED; - if (g_strcmp0(status_value, LASSO_SAML2_STATUS_CODE_RESPONDER) == 0 || - g_strcmp0(status_value, LASSO_SAML2_STATUS_CODE_REQUESTER)) { + if (lasso_strisequal(status_value,LASSO_SAML2_STATUS_CODE_RESPONDER) || + lasso_strisequal(status_value,LASSO_SAML2_STATUS_CODE_REQUESTER)) { /* samlp:Responder */ if (response->Status->StatusCode->StatusCode && response->Status->StatusCode->StatusCode->Value) { status_value = response->Status->StatusCode->StatusCode->Value; - if (g_strcmp0(status_value, - LASSO_LIB_STATUS_CODE_FEDERATION_DOES_NOT_EXIST) == 0) { + if (lasso_strisequal(status_value,LASSO_LIB_STATUS_CODE_FEDERATION_DOES_NOT_EXIST)) { return LASSO_LOGIN_ERROR_FEDERATION_NOT_FOUND; } - if (g_strcmp0(status_value, - LASSO_LIB_STATUS_CODE_UNKNOWN_PRINCIPAL) == 0) { + if (lasso_strisequal(status_value,LASSO_LIB_STATUS_CODE_UNKNOWN_PRINCIPAL)) { return LASSO_LOGIN_ERROR_UNKNOWN_PRINCIPAL; } } @@ -1300,7 +1293,7 @@ lasso_saml20_login_process_response_status_and_assertion(LassoLogin *login) if (login->private_data->request_id) { const char *in_response_to = lasso_saml2_assertion_get_in_response_to(assertion); - if (g_strcmp0(in_response_to, login->private_data->request_id) != 0) { + if (lasso_strisnotequal(in_response_to,login->private_data->request_id)) { rc = LASSO_LOGIN_ERROR_ASSERTION_DOES_NOT_MATCH_REQUEST_ID; goto cleanup; } @@ -1357,7 +1350,7 @@ lasso_saml20_login_accept_sso(LassoLogin *login) ta = t->data; - if (g_strcmp0(ta->ID, assertion->ID) == 0) { + if (lasso_strisequal(ta->ID,assertion->ID)) { lasso_release_list(previous_assertions); return LASSO_LOGIN_ERROR_ASSERTION_REPLAY; } @@ -1375,8 +1368,7 @@ lasso_saml20_login_accept_sso(LassoLogin *login) /* create federation, only if nameidentifier format is Federated */ if (ni && ni->Format - && g_strcmp0(ni->Format, - LASSO_SAML2_NAME_IDENTIFIER_FORMAT_PERSISTENT) == 0) { + && lasso_strisequal(ni->Format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_PERSISTENT)) { federation = lasso_federation_new(LASSO_PROFILE(login)->remote_providerID); lasso_assign_gobject(federation->local_nameIdentifier, ni); diff --git a/lasso/saml-2.0/logout.c b/lasso/saml-2.0/logout.c index eb9969fa..7f677aa2 100644 --- a/lasso/saml-2.0/logout.c +++ b/lasso/saml-2.0/logout.c @@ -222,7 +222,7 @@ lasso_saml20_logout_validate_request(LassoLogout *logout) } assertion_SessionIndex = ((LassoSaml2AuthnStatement*)assertion->AuthnStatement->data)->SessionIndex; - if (g_strcmp0(logout_request->SessionIndex, assertion_SessionIndex) != 0) { + if (lasso_strisnotequal(logout_request->SessionIndex,assertion_SessionIndex)) { lasso_saml20_profile_set_response_status_responder(profile, LASSO_SAML2_STATUS_CODE_REQUEST_DENIED); return LASSO_LOGOUT_ERROR_UNKNOWN_PRINCIPAL; @@ -392,11 +392,11 @@ cleanup: value = sub_status_code->Value; - if (g_strcmp0(value, LASSO_SAML2_STATUS_CODE_REQUEST_DENIED) == 0) { + if (lasso_strisequal(value,LASSO_SAML2_STATUS_CODE_REQUEST_DENIED)) { rc = LASSO_LOGOUT_ERROR_REQUEST_DENIED; break; } - if (g_strcmp0(value, LASSO_SAML2_STATUS_CODE_UNKNOWN_PRINCIPAL) == 0) { + if (lasso_strisequal(value,LASSO_SAML2_STATUS_CODE_UNKNOWN_PRINCIPAL)) { rc = LASSO_LOGOUT_ERROR_UNKNOWN_PRINCIPAL; break; } diff --git a/lasso/saml-2.0/profile.c b/lasso/saml-2.0/profile.c index f8039dd1..18f7d64c 100644 --- a/lasso/saml-2.0/profile.c +++ b/lasso/saml-2.0/profile.c @@ -1284,7 +1284,9 @@ _lasso_saml20_is_valid_issuer(LassoSaml2NameID *name_id) { if (! LASSO_IS_SAML2_NAME_ID(name_id)) return FALSE; - if (name_id->Format && g_strcmp0(name_id->Format, LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENTITY) != 0) { + if (name_id->Format && + lasso_strisnotequal(name_id->Format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENTITY)) + { return FALSE; } return TRUE; @@ -1385,8 +1387,7 @@ lasso_saml20_profile_process_any_response(LassoProfile *profile, LASSO_PROFILE_ERROR_MISSING_STATUS_CODE); lasso_extract_node_or_fail(status_code1, status->StatusCode, SAMLP2_STATUS_CODE, LASSO_PROFILE_ERROR_MISSING_STATUS_CODE); - if (g_strcmp0(status_code1->Value, - LASSO_SAML2_STATUS_CODE_SUCCESS) != 0) + if (lasso_strisnotequal(status_code1->Value,LASSO_SAML2_STATUS_CODE_SUCCESS)) { LassoSamlp2StatusCode *status_code2 = status_code1->StatusCode; rc = LASSO_PROFILE_ERROR_STATUS_NOT_SUCCESS; diff --git a/lasso/saml-2.0/provider.c b/lasso/saml-2.0/provider.c index cd1acfe0..bc9e70f1 100644 --- a/lasso/saml-2.0/provider.c +++ b/lasso/saml-2.0/provider.c @@ -186,10 +186,10 @@ compare_endpoint_type(const EndpointType *a, const EndpointType *b) { return -1; if (a->role > b->role) return +1; - c = g_strcmp0(a->kind, b->kind); + c = g_strcmp0(a->kind,b->kind); if (c != 0) return c; - c = g_strcmp0(a->binding, b->binding); + c = g_strcmp0(a->binding,b->binding); if (c != 0) return c; if (a->is_default && ! b->is_default) @@ -347,7 +347,7 @@ load_descriptor(xmlNode *xmlnode, LassoProvider *provider, LassoProviderRole rol break; token = strtok_r(NULL, " ", &saveptr); } - if (g_strcmp0(token, LASSO_SAML2_PROTOCOL_HREF) != 0) { + if (lasso_strisnotequal(token,LASSO_SAML2_PROTOCOL_HREF)) { lasso_release_xml_string(value); return FALSE; } @@ -507,7 +507,7 @@ lasso_saml20_provider_get_first_http_method(G_GNUC_UNUSED LassoProvider *provide lasso_foreach(t, remote_provider->private_data->endpoints) { EndpointType *endpoint_type = (EndpointType*)t->data; - if (endpoint_type && g_strcmp0(endpoint_type->kind, kind) == 0) { + if (endpoint_type && lasso_strisequal(endpoint_type->kind, kind)) { result = binding_uri_to_http_method(endpoint_type->binding); if (result) break; } @@ -535,7 +535,7 @@ lasso_saml20_provider_accept_http_method(G_GNUC_UNUSED LassoProvider *provider, lasso_foreach(t, remote_provider->private_data->endpoints) { EndpointType *endpoint_type = (EndpointType*)t->data; if (endpoint_type && endpoint_type->role == remote_provider->role && - g_strcmp0(endpoint_type->kind, kind) == 0) { + lasso_strisequal(endpoint_type->kind, kind)) { if (binding_uri_to_http_method(endpoint_type->binding) == http_method) { return TRUE; } @@ -553,8 +553,8 @@ lasso_saml20_provider_check_assertion_consumer_service_url(LassoProvider *provid lasso_foreach (t, provider->private_data->endpoints) { EndpointType *endpoint_type = (EndpointType*) t->data; if (endpoint_type && endpoint_type->role == LASSO_PROVIDER_ROLE_SP - && g_strcmp0(endpoint_type->url, url) == 0 - && g_strcmp0(endpoint_type->binding, binding) == 0) + && lasso_strisequal(endpoint_type->url,url) + && lasso_strisequal(endpoint_type->binding,binding)) { return TRUE; } @@ -569,7 +569,7 @@ static gboolean match_any(const char *key, const char *array[]) { const char **t = array; while (*t) { - if (g_strcmp0(key, *t) == 0) { + if (lasso_strisequal(key,*t)) { return TRUE; } t++; @@ -590,7 +590,7 @@ lasso_saml20_provider_get_assertion_consumer_service(LassoProvider *provider, in if (! endpoint_type) continue; if (endpoint_type->role == LASSO_PROVIDER_ROLE_SP && - g_strcmp0(endpoint_type->kind, kind) == 0 && + lasso_strisequal(endpoint_type->kind,kind) && endpoint_type->index == service_id) { result = endpoint_type; @@ -603,7 +603,7 @@ lasso_saml20_provider_get_assertion_consumer_service(LassoProvider *provider, in if (! endpoint_type) continue; if (endpoint_type->role == LASSO_PROVIDER_ROLE_SP && - g_strcmp0(endpoint_type->kind, kind) == 0 && + lasso_strisequal(endpoint_type->kind,kind) && match_any(endpoint_type->binding, supported_assertion_consumer_bindings)) { @@ -651,8 +651,8 @@ lasso_saml20_provider_get_assertion_consumer_service_binding_by_url(LassoProvide if (! endpoint_type) continue; if (endpoint_type->role == LASSO_PROVIDER_ROLE_SP && - g_strcmp0(endpoint_type->kind, kind) == 0 && - g_strcmp0(endpoint_type->url, url) == 0) + lasso_strisequal(endpoint_type->kind,kind) && + lasso_strisequal(endpoint_type->url,url)) { return endpoint_type->binding; } @@ -672,8 +672,8 @@ lasso_saml20_provider_get_assertion_consumer_service_url_by_binding(LassoProvide if (! endpoint_type) continue; if (endpoint_type->role == LASSO_PROVIDER_ROLE_SP && - g_strcmp0(endpoint_type->kind, kind) == 0 && - g_strcmp0(endpoint_type->binding, binding) == 0) + lasso_strisequal(endpoint_type->kind,kind) && + lasso_strisequal(endpoint_type->binding,binding)) { return endpoint_type->url; } diff --git a/lasso/saml-2.0/saml2_helper.c b/lasso/saml-2.0/saml2_helper.c index cccc293c..3d835962 100644 --- a/lasso/saml-2.0/saml2_helper.c +++ b/lasso/saml-2.0/saml2_helper.c @@ -87,7 +87,7 @@ lasso_saml2_assertion_is_audience_restricted(LassoSaml2Assertion *saml2_assertio if (LASSO_IS_SAML2_AUDIENCE_RESTRICTION(it->data)) { LassoSaml2AudienceRestriction *saml2_audience_restriction; saml2_audience_restriction = (LassoSaml2AudienceRestriction*)it->data; - if (g_strcmp0(saml2_audience_restriction->Audience, providerID) == 0) + if (lasso_strisequal(saml2_audience_restriction->Audience,providerID)) return TRUE; } } @@ -564,7 +564,7 @@ lasso_saml2_assertion_allows_proxying_to(LassoSaml2Assertion *saml2_assertion, c return LASSO_SAML2_ASSERTION_VALID; /* FIXME: Change saml2:ProxyRestriction class */ - if (g_strcmp0(proxy_restriction->Audience, audience) != 0) { + if (lasso_strisnotequal(proxy_restriction->Audience,audience)) { return LASSO_SAML2_ASSERTION_INVALID; } @@ -597,7 +597,7 @@ lasso_saml2_assertion_validate_audience(LassoSaml2Assertion *saml2_assertion, lasso_foreach_full_begin (LassoSaml2AudienceRestriction*, saml2_audience_restriction, it, saml2_conditions->AudienceRestriction) did_audience = TRUE; - if (g_strcmp0(saml2_audience_restriction->Audience, audience) == 0) { + if (lasso_strisequal(saml2_audience_restriction->Audience,audience)) { found_audience = TRUE; } lasso_foreach_full_end() @@ -654,10 +654,11 @@ lasso_saml2_assertion_get_issuer_provider(const LassoSaml2Assertion *saml2_asser g_return_val_if_fail (LASSO_IS_SAML2_ASSERTION (saml2_assertion), NULL); issuer = saml2_assertion->Issuer; g_return_val_if_fail (LASSO_IS_SAML2_NAME_ID (issuer), NULL); - g_return_val_if_fail (issuer->Format == NULL || g_strcmp0(issuer->Format, - LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENTITY) == 0, NULL); + g_return_val_if_fail (issuer->Format == NULL || + lasso_strisequal(issuer->Format,LASSO_SAML2_NAME_IDENTIFIER_FORMAT_ENTITY), + NULL); g_return_val_if_fail (LASSO_IS_SERVER(server), NULL); - if (g_strcmp0(server->parent.ProviderID, issuer->content) == 0) { + if (lasso_strisequal(server->parent.ProviderID,issuer->content)) { return (LassoProvider*)&server->parent; } return lasso_server_get_provider (server, issuer->content); diff --git a/lasso/utils.h b/lasso/utils.h index 2a843817..3c840963 100644 --- a/lasso/utils.h +++ b/lasso/utils.h @@ -485,7 +485,7 @@ * LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ. */ #define lasso_check_non_empty_string(str) \ - goto_cleanup_if_fail_with_rc(! lasso_is_empty_string(str), \ + goto_cleanup_if_fail_with_rc(! lasso_strisempty(str), \ LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ); /* diff --git a/lasso/xml/saml-2.0/saml2_name_id.c b/lasso/xml/saml-2.0/saml2_name_id.c index 698cec0d..8405c47d 100644 --- a/lasso/xml/saml-2.0/saml2_name_id.c +++ b/lasso/xml/saml-2.0/saml2_name_id.c @@ -163,13 +163,13 @@ lasso_saml2_name_id_equals(LassoSaml2NameID *name_id, LassoSaml2NameID *other_na return FALSE; /* check optional content */ - if (g_strcmp0(name_id->Format, other_name_id->Format) != 0) + if (lasso_strisnotequal(name_id->Format,other_name_id->Format)) return FALSE; - if (g_strcmp0(name_id->SPProvidedID, other_name_id->SPProvidedID) != 0) + if (lasso_strisnotequal(name_id->SPProvidedID,other_name_id->SPProvidedID)) return FALSE; - if (g_strcmp0(name_id->NameQualifier, other_name_id->NameQualifier) != 0) + if (lasso_strisnotequal(name_id->NameQualifier,other_name_id->NameQualifier)) return FALSE; - if (g_strcmp0(name_id->SPNameQualifier, other_name_id->SPNameQualifier) != 0) + if (lasso_strisnotequal(name_id->SPNameQualifier,other_name_id->SPNameQualifier)) return FALSE; return TRUE; diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c index d521a4c6..f73e93e4 100644 --- a/lasso/xml/tools.c +++ b/lasso/xml/tools.c @@ -823,7 +823,7 @@ lasso_saml2_query_verify_signature(const char *query, const xmlSecKey *sender_pu goto done; } usig_alg = xmlURIUnescapeString(sig_alg, 0, NULL); - if (g_strcmp0(usig_alg, (char*)xmlSecHrefRsaSha1) == 0) { + if (lasso_strisequal(usig_alg,(char *)xmlSecHrefRsaSha1)) { if (sender_public_key->value->id != xmlSecOpenSSLKeyDataRsaId) { ret = critical_error(LASSO_DS_ERROR_PUBLIC_KEY_LOAD_FAILED); goto done; @@ -834,7 +834,7 @@ lasso_saml2_query_verify_signature(const char *query, const xmlSecKey *sender_pu goto done; } key_size = RSA_size(rsa); - } else if (g_strcmp0(usig_alg, (char*)xmlSecHrefDsaSha1) == 0) { + } else if (lasso_strisequal(usig_alg,(char *)xmlSecHrefDsaSha1)) { if (sender_public_key->value->id != xmlSecOpenSSLKeyDataDsaId) { ret = critical_error(LASSO_DS_ERROR_PUBLIC_KEY_LOAD_FAILED); goto done; diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c index e3c1db30..e143bbff 100644 --- a/lasso/xml/xml.c +++ b/lasso/xml/xml.c @@ -1566,7 +1566,7 @@ _xmlnode_add_custom_namespace(const char *prefix, const char *href, xmlNode *xml existing = xmlSearchNs(NULL, xmlnode, BAD_CAST prefix); if (existing) { - if (g_strcmp0((char*)existing->href, href) != 0) { + if (lasso_strisnotequal((char *)existing->href,href)) { message(G_LOG_LEVEL_CRITICAL, "Cannot add namespace %s='%s' to node %s, " "namespace already exists with another href", prefix, href, (char*)xmlnode->name); @@ -2172,16 +2172,19 @@ lasso_node_new_from_xmlNode(xmlNode *xmlnode) if (! fromXsi) { /* if the typename was not obtained via xsi:type but through mapping of the element * name then keep the element name */ - if (LASSO_NODE_GET_CLASS(node)->node_data && LASSO_NODE_GET_CLASS(node)->node_data->node_name && g_strcmp0((char*)xmlnode->name, - LASSO_NODE_GET_CLASS(node)->node_data->node_name) != 0) { + if (LASSO_NODE_GET_CLASS(node)->node_data && + LASSO_NODE_GET_CLASS(node)->node_data->node_name && + lasso_strisnotequal((char*)xmlnode->name, + LASSO_NODE_GET_CLASS(node)->node_data->node_name)) + { lasso_node_set_custom_nodename(node, (char*)xmlnode->name); } if (xmlnode->ns && (LASSO_NODE_GET_CLASS(node)->node_data == NULL || LASSO_NODE_GET_CLASS(node)->node_data->ns == NULL || - g_strcmp0((char*)xmlnode->ns->href, - (char*)LASSO_NODE_GET_CLASS(node)->node_data->ns->href) - != 0)) { + lasso_xmlstrisnotequal(xmlnode->ns->href, + LASSO_NODE_GET_CLASS(node)->node_data->ns->href))) + { lasso_node_set_custom_namespace(node, (char*)xmlnode->ns->prefix, (char*)xmlnode->ns->href); } @@ -3128,7 +3131,7 @@ xml_insure_namespace(xmlNode *xmlnode, xmlNs *ns, gboolean force, gchar *ns_href if (ns == NULL) { for (ns = xmlnode->nsDef; ns; ns = ns->next) { - if (ns->href && g_strcmp0((gchar*)ns->href, ns_href) == 0) { + if (ns->href && lasso_strisequal((gchar *)ns->href,ns_href)) { break; } } diff --git a/tests/login_tests.c b/tests/login_tests.c index 54a2d554..43718620 100644 --- a/tests/login_tests.c +++ b/tests/login_tests.c @@ -196,7 +196,7 @@ START_TEST(test02_serviceProviderLogin) "lasso_login_must_ask_for_consent() should be FALSE"); fail_unless(idpLoginContext->parent.msg_relayState != NULL, "lasso_login_process_authn_request_msg should restore the RelayState parameter"); - fail_unless(g_strcmp0(idpLoginContext->parent.msg_relayState, relayState) == 0, + fail_unless(lasso_strisequal(idpLoginContext->parent.msg_relayState,relayState), "lasso_login_process_authn_request_msg should restore the same RelayState thant sent in the request"); rc = lasso_login_validate_request_msg(idpLoginContext, 1, /* authentication_result */ @@ -242,7 +242,7 @@ START_TEST(test02_serviceProviderLogin) LASSO_HTTP_METHOD_REDIRECT); fail_unless(spLoginContext->parent.msg_relayState != NULL, "lasso_login_init_request should restore the RelayState parameter"); - fail_unless(g_strcmp0(spLoginContext->parent.msg_relayState, relayState) == 0, + fail_unless(lasso_strisequal(spLoginContext->parent.msg_relayState,relayState), "lasso_login_init_request should restore the same RelayState thant sent in the request"); fail_unless(rc == 0, "lasso_login_init_request failed"); rc = lasso_login_build_request_msg(spLoginContext); diff --git a/tests/login_tests_saml2.c b/tests/login_tests_saml2.c index 7f026f2c..0864ec17 100644 --- a/tests/login_tests_saml2.c +++ b/tests/login_tests_saml2.c @@ -197,7 +197,7 @@ START_TEST(test02_saml2_serviceProviderLogin) check_equals(idpLoginContext->protocolProfile, LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_ART); check_false(lasso_login_must_ask_for_consent(idpLoginContext)); check_not_null(idpLoginContext->parent.msg_relayState); - check_equals(g_strcmp0(idpLoginContext->parent.msg_relayState, relayState), 0); + check_equals(lasso_strisnotequal(idpLoginContext->parent.msg_relayState,relayState), 0); check_good_rc(lasso_login_validate_request_msg(idpLoginContext, 1, /* authentication_result */ 0 /* is_consent_obtained */ @@ -239,7 +239,7 @@ START_TEST(test02_saml2_serviceProviderLogin) responseQuery, LASSO_HTTP_METHOD_ARTIFACT_GET)); check_not_null(spLoginContext->parent.msg_relayState); - check_equals(g_strcmp0(spLoginContext->parent.msg_relayState, relayState), 0); + check_equals(lasso_strisnotequal(spLoginContext->parent.msg_relayState,relayState), 0); check_good_rc(lasso_login_build_request_msg(spLoginContext)); soapRequestMsg = LASSO_PROFILE(spLoginContext)->msg_body; check_not_null(soapRequestMsg); @@ -543,7 +543,7 @@ START_TEST(test04_sso_then_slo_soap) check_equals(idpLoginContext->protocolProfile, LASSO_LOGIN_PROTOCOL_PROFILE_BRWS_ART); check_false(lasso_login_must_ask_for_consent(idpLoginContext)); check_not_null(idpLoginContext->parent.msg_relayState); - check_equals(g_strcmp0(idpLoginContext->parent.msg_relayState, relayState), 0); + check_equals(lasso_strisnotequal(idpLoginContext->parent.msg_relayState,relayState), 0); check_good_rc(lasso_login_validate_request_msg(idpLoginContext, 1, /* authentication_result */ 0 /* is_consent_obtained */ @@ -585,7 +585,7 @@ START_TEST(test04_sso_then_slo_soap) responseQuery, LASSO_HTTP_METHOD_ARTIFACT_GET)); check_not_null(spLoginContext->parent.msg_relayState); - check_equals(g_strcmp0(spLoginContext->parent.msg_relayState, relayState), 0); + check_equals(lasso_strisnotequal(spLoginContext->parent.msg_relayState,relayState), 0); check_good_rc(lasso_login_build_request_msg(spLoginContext)); soapRequestMsg = LASSO_PROFILE(spLoginContext)->msg_body; check_not_null(soapRequestMsg);