summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2004-12-15 10:07:09 +0000
committerFrederic Peters <fpeters@entrouvert.com>2004-12-15 10:07:09 +0000
commit501da6b2b6ccdc9413c416d6ea5cb6541b648070 (patch)
tree87af31742c9f692e6609eb8d56d7f315823a7c18
parent3ee382c5c621ee3859830c9eeefba8bc48f6cb95 (diff)
coherent error handling for "identity not found" and "federation not found"
cases.
-rw-r--r--lasso/id-ff/defederation.c13
-rw-r--r--lasso/id-ff/lecp.c7
-rw-r--r--lasso/id-ff/login.c8
-rw-r--r--lasso/id-ff/logout.c12
-rw-r--r--lasso/id-ff/name_identifier_mapping.c14
-rw-r--r--lasso/id-ff/name_registration.c18
-rw-r--r--lasso/xml/errors.c4
-rw-r--r--lasso/xml/errors.h4
8 files changed, 31 insertions, 49 deletions
diff --git a/lasso/id-ff/defederation.c b/lasso/id-ff/defederation.c
index 1ff5a854..8b48f431 100644
--- a/lasso/id-ff/defederation.c
+++ b/lasso/id-ff/defederation.c
@@ -171,9 +171,7 @@ lasso_defederation_init_notification(LassoDefederation *defederation, gchar *rem
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (federation == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Federation not found for %s",
- profile->remote_providerID);
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
/* get the nameIdentifier to send the federation termination notification */
@@ -225,8 +223,7 @@ lasso_defederation_init_notification(LassoDefederation *defederation, gchar *rem
/* remove federation with remote provider id */
if (profile->identity == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Identity not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND);
}
lasso_identity_remove_federation(profile->identity, profile->remote_providerID);
@@ -383,15 +380,13 @@ lasso_defederation_validate_notification(LassoDefederation *defederation)
/* Verify federation */
if (profile->identity == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Identity not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND);
}
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (federation == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Federation not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
if (lasso_federation_verify_nameIdentifier(federation, nameIdentifier) == FALSE) {
diff --git a/lasso/id-ff/lecp.c b/lasso/id-ff/lecp.c
index 8c1d0e5a..27374548 100644
--- a/lasso/id-ff/lecp.c
+++ b/lasso/id-ff/lecp.c
@@ -220,9 +220,7 @@ lasso_lecp_process_authn_request_envelope_msg(LassoLecp *lecp, const char *reque
lecp->authnRequestEnvelope = lasso_lib_authn_request_envelope_new();
format = lasso_node_init_from_message(LASSO_NODE(lecp->authnRequestEnvelope), request_msg);
if (format == LASSO_MESSAGE_FORMAT_UNKNOWN || format == LASSO_MESSAGE_FORMAT_ERROR) {
- message(G_LOG_LEVEL_CRITICAL,
- "Error while building the authentication request envelope");
- return LASSO_PROFILE_ERROR_INVALID_MSG;
+ return critical_error(LASSO_PROFILE_ERROR_INVALID_MSG);
}
LASSO_PROFILE(lecp)->request = LASSO_NODE(g_object_ref(
@@ -250,8 +248,7 @@ lasso_lecp_process_authn_response_envelope_msg(LassoLecp *lecp, const char *resp
format = lasso_node_init_from_message(LASSO_NODE(lecp->authnResponseEnvelope),
response_msg);
if (format == LASSO_MESSAGE_FORMAT_UNKNOWN || format == LASSO_MESSAGE_FORMAT_ERROR) {
- message(G_LOG_LEVEL_CRITICAL, "Error while building AuthnResponseEnvelope");
- return LASSO_PROFILE_ERROR_INVALID_MSG;
+ return critical_error(LASSO_PROFILE_ERROR_INVALID_MSG);
}
profile->response = g_object_ref(lecp->authnResponseEnvelope->AuthnResponse);
diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c
index e24aea5e..4f9a8ff5 100644
--- a/lasso/id-ff/login.c
+++ b/lasso/id-ff/login.c
@@ -1124,9 +1124,7 @@ lasso_login_process_request_msg(LassoLogin *login, gchar *request_msg)
/* rebuild samlp:Request with request_msg */
profile->request = lasso_node_new_from_soap(request_msg);
if (profile->request == NULL) {
- message(G_LOG_LEVEL_CRITICAL,
- "Failed to rebuild samlp:Request with request message.");
- return LASSO_ERROR_UNDEFINED;
+ return critical_error(LASSO_PROFILE_ERROR_INVALID_MSG);
}
/* get AssertionArtifact */
login->assertionArtifact = g_strdup(
@@ -1149,9 +1147,9 @@ lasso_login_process_response_msg(LassoLogin *login, gchar *response_msg)
/* rebuild samlp:Response with response_msg */
LASSO_PROFILE(login)->response = lasso_node_new_from_soap(response_msg);
if (! LASSO_IS_SAMLP_RESPONSE(LASSO_PROFILE(login)->response) ) {
+ lasso_node_destroy(LASSO_PROFILE(login)->response);
LASSO_PROFILE(login)->response = NULL;
- message(G_LOG_LEVEL_CRITICAL, "Failed to rebuild samlp:Response from message.");
- return LASSO_ERROR_UNDEFINED;
+ return critical_error(LASSO_PROFILE_ERROR_INVALID_MSG);
}
return lasso_login_process_response_status_and_assertion(login);
diff --git a/lasso/id-ff/logout.c b/lasso/id-ff/logout.c
index 05fce4a4..55615573 100644
--- a/lasso/id-ff/logout.c
+++ b/lasso/id-ff/logout.c
@@ -298,14 +298,12 @@ lasso_logout_init_request(LassoLogout *logout, char *remote_providerID,
assertion->AuthenticationStatement)->Subject->NameIdentifier;
if (strcmp(nameIdentifier->Format, LASSO_LIB_NAME_IDENTIFIER_FORMAT_ONE_TIME) != 0) {
if (LASSO_IS_IDENTITY(profile->identity) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Identity not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND);
}
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (federation == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Federation not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
nameIdentifier = lasso_profile_get_nameIdentifier(profile);
@@ -706,18 +704,16 @@ lasso_logout_validate_request(LassoLogout *logout)
/* If name identifier is federated, then verify federation */
if (strcmp(nameIdentifier->Format, LASSO_LIB_NAME_IDENTIFIER_FORMAT_FEDERATED) == 0) {
if (LASSO_IS_IDENTITY(profile->identity) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Identity not found");
lasso_profile_set_response_status(profile,
LASSO_LIB_STATUS_CODE_FEDERATION_DOES_NOT_EXIST);
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND);
}
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (LASSO_IS_FEDERATION(federation) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Federation not found");
lasso_profile_set_response_status(profile,
LASSO_LIB_STATUS_CODE_FEDERATION_DOES_NOT_EXIST);
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
if (lasso_federation_verify_nameIdentifier(federation, nameIdentifier) == FALSE) {
diff --git a/lasso/id-ff/name_identifier_mapping.c b/lasso/id-ff/name_identifier_mapping.c
index 2a50e29d..6e0e80c3 100644
--- a/lasso/id-ff/name_identifier_mapping.c
+++ b/lasso/id-ff/name_identifier_mapping.c
@@ -126,8 +126,7 @@ lasso_name_identifier_mapping_init_request(LassoNameIdentifierMapping *mapping,
/* verify if the identity exists */
if (profile->identity == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Identity not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND);
}
/* set the remote provider id */
@@ -150,9 +149,8 @@ lasso_name_identifier_mapping_init_request(LassoNameIdentifierMapping *mapping,
/* get federation */
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
- if(federation == NULL) {
- message(G_LOG_LEVEL_CRITICAL, "Federation not found");
- return -1;
+ if (federation == NULL) {
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
/* name identifier */
@@ -343,8 +341,7 @@ lasso_name_identifier_mapping_validate_request(LassoNameIdentifierMapping *mappi
/* Verify identity attribute of mapping object */
if (LASSO_IS_IDENTITY(profile->identity) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Identity not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND);
}
/* verify federation of the SP request */
@@ -353,8 +350,7 @@ lasso_name_identifier_mapping_validate_request(LassoNameIdentifierMapping *mappi
if (LASSO_IS_FEDERATION(federation) == FALSE) {
lasso_profile_set_response_status(profile,
LASSO_LIB_STATUS_CODE_UNKNOWN_PRINCIPAL);
- message(G_LOG_LEVEL_CRITICAL, "Federation not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
nameIdentifier = federation->remote_nameIdentifier;
if (nameIdentifier == NULL)
diff --git a/lasso/id-ff/name_registration.c b/lasso/id-ff/name_registration.c
index 7c4b6c0b..ff4e9dd0 100644
--- a/lasso/id-ff/name_registration.c
+++ b/lasso/id-ff/name_registration.c
@@ -174,8 +174,7 @@ lasso_name_registration_init_request(LassoNameRegistration *name_registration,
/* verify if the identity and session exist */
if (LASSO_IS_IDENTITY(profile->identity) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Identity not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND);
}
/* set the remote provider id */
@@ -195,8 +194,7 @@ lasso_name_registration_init_request(LassoNameRegistration *name_registration,
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (LASSO_IS_FEDERATION(federation) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Federation not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
/* FIXME : depending on the requester provider type, verify the format
@@ -266,8 +264,7 @@ lasso_name_registration_init_request(LassoNameRegistration *name_registration,
LASSO_MD_PROTOCOL_TYPE_REGISTER_NAME_IDENTIFIER,
http_method,
TRUE) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "unsupported profile!");
- return LASSO_PROFILE_ERROR_UNSUPPORTED_PROFILE;
+ return critical_error(LASSO_PROFILE_ERROR_UNSUPPORTED_PROFILE);
}
}
@@ -402,15 +399,13 @@ lasso_name_registration_process_response_msg(LassoNameRegistration *name_registr
/* Update federation with the nameIdentifier attribute. NameQualifier
* is local ProviderID and format is Federated type */
if (LASSO_IS_IDENTITY(profile->identity) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Identity not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND);
}
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (LASSO_IS_FEDERATION(federation) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Federation not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
remote_provider = g_hash_table_lookup(profile->server->providers,
@@ -486,8 +481,7 @@ lasso_name_registration_validate_request(LassoNameRegistration *name_registratio
federation = g_hash_table_lookup(profile->identity->federations,
profile->remote_providerID);
if (LASSO_IS_FEDERATION(federation) == FALSE) {
- message(G_LOG_LEVEL_CRITICAL, "Federation not found");
- return -1;
+ return critical_error(LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND);
}
if (request->OldProvidedNameIdentifier == NULL) {
diff --git a/lasso/xml/errors.c b/lasso/xml/errors.c
index 2ba1f268..ec6a76de 100644
--- a/lasso/xml/errors.c
+++ b/lasso/xml/errors.c
@@ -89,6 +89,10 @@ lasso_strerror(int error_code)
return "Unsupported protocol profile";
case LASSO_PROFILE_ERROR_UNKNOWN_PROFILE_URL:
return "Unable to find Profile URL in metadata";
+ case LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND:
+ return "Identity not found";
+ case LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND:
+ return "Federation not found";
case LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ:
return "An object type provided as parameter "\
diff --git a/lasso/xml/errors.h b/lasso/xml/errors.h
index bd63d334..45d335d6 100644
--- a/lasso/xml/errors.h
+++ b/lasso/xml/errors.h
@@ -66,13 +66,15 @@
#define LASSO_PROFILE_ERROR_MISSING_REMOTE_PROVIDERID -408
#define LASSO_PROFILE_ERROR_UNSUPPORTED_PROFILE -409
#define LASSO_PROFILE_ERROR_UNKNOWN_PROFILE_URL -410
+#define LASSO_PROFILE_ERROR_IDENTITY_NOT_FOUND -411
+#define LASSO_PROFILE_ERROR_FEDERATION_NOT_FOUND -412
/* functions/methods parameters checking */
#define LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ -501
#define LASSO_PARAM_ERROR_INVALID_VALUE -502
#define LASSO_PARAM_ERROR_CHECK_FAILED -503
-/* login */
+/* Single Sign-On */
#define LASSO_LOGIN_ERROR_FEDERATION_NOT_FOUND 601
#define LASSO_LOGIN_ERROR_CONSENT_NOT_OBTAINED 602
#define LASSO_LOGIN_ERROR_INVALID_NAMEIDPOLICY -603