summaryrefslogtreecommitdiffstats
path: root/lasso/id-wsf
diff options
context:
space:
mode:
authorFrederic Peters <fpeters@entrouvert.com>2006-12-28 10:45:39 +0000
committerFrederic Peters <fpeters@entrouvert.com>2006-12-28 10:45:39 +0000
commit7a78af3361d314541891fc30c4787a9d756844f9 (patch)
tree0a7bf3e4d63d634381be14bf5870dd704a8b8160 /lasso/id-wsf
parente6a82f5a9aadad82650f6b5114115d5174184d26 (diff)
downloadlasso-7a78af3361d314541891fc30c4787a9d756844f9.tar.gz
lasso-7a78af3361d314541891fc30c4787a9d756844f9.tar.xz
lasso-7a78af3361d314541891fc30c4787a9d756844f9.zip
replaced remaining LASSO_ERROR_UNDEFINED by appropriate error codes
Diffstat (limited to 'lasso/id-wsf')
-rw-r--r--lasso/id-wsf/data_service.c39
-rw-r--r--lasso/id-wsf/discovery.c33
-rw-r--r--lasso/id-wsf/wsf_profile.c67
3 files changed, 70 insertions, 69 deletions
diff --git a/lasso/id-wsf/data_service.c b/lasso/id-wsf/data_service.c
index d89ec8e2..cb1c9ff6 100644
--- a/lasso/id-wsf/data_service.c
+++ b/lasso/id-wsf/data_service.c
@@ -201,13 +201,15 @@ lasso_data_service_init_query(LassoDataService *service, const char *select,
lasso_wsf_profile_init_soap_request(LASSO_WSF_PROFILE(service), LASSO_NODE(query));
- if (!security_mech_id) {
+ if (security_mech_id == NULL) {
description = LASSO_DISCO_DESCRIPTION(offering->ServiceInstance->Description->data);
} else {
description = lasso_discovery_get_description_auto(offering, security_mech_id);
}
- if (!description)
- return LASSO_ERROR_UNDEFINED;
+
+ if (description == NULL) {
+ return LASSO_PROFILE_ERROR_MISSING_SERVICE_DESCRIPTION;
+ }
lasso_wsf_profile_set_description(LASSO_WSF_PROFILE(service), description);
if (description->Endpoint != NULL) {
@@ -339,11 +341,11 @@ lasso_data_service_process_query_msg(LassoDataService *service, const char *mess
}
query = LASSO_DST_QUERY(profile->request);
- if (query->ResourceID)
+ if (query->ResourceID) {
service->resource_id = g_object_ref(query->ResourceID);
- else if (query->EncryptedResourceID)
+ } else if (query->EncryptedResourceID) {
service->encrypted_resource_id = g_object_ref(query->EncryptedResourceID);
- else {
+ } else {
return LASSO_ERROR_UNIMPLEMENTED; /* implied ? */
}
@@ -624,15 +626,6 @@ lasso_data_service_process_query_response_msg(LassoDataService *service,
return LASSO_SOAP_FAULT_REDIRECT_REQUEST;
return 0;
-
- /*if (! LASSO_IS_DST_QUERY_RESPONSE(LASSO_WSF_PROFILE(service)->response))
- return LASSO_ERROR_UNDEFINED;
-
- response = LASSO_DST_QUERY_RESPONSE(LASSO_WSF_PROFILE(service)->response);
- if (response->Status == NULL || strcmp(response->Status->code, "OK") != 0)
- return LASSO_ERROR_UNDEFINED;*/
-
- return 0;
}
@@ -665,19 +658,17 @@ lasso_data_service_init_modify(LassoDataService *service, const gchar *select,
modify->hrefServiceType = g_strdup(offering->ServiceInstance->ServiceType);
modify->prefixServiceType = lasso_get_prefix_for_dst_service_href(
- modify->hrefServiceType);
+ modify->hrefServiceType);
if (modify->prefixServiceType == NULL) {
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_DATA_SERVICE_ERROR_UNREGISTERED_DST;
}
/* get ResourceID / EncryptedResourceID */
if (offering->ResourceID) {
modify->ResourceID = offering->ResourceID;
- }
- else if (offering->EncryptedResourceID) {
+ } else if (offering->EncryptedResourceID) {
modify->EncryptedResourceID = offering->EncryptedResourceID;
- }
- else {
+ } else {
/* XXX: no resource id, implied:resource, etc. */
return LASSO_ERROR_UNIMPLEMENTED;
}
@@ -713,11 +704,11 @@ lasso_data_service_process_modify_msg(LassoDataService *service,
}
modify = LASSO_DST_MODIFY(profile->request);
- if (modify->ResourceID)
+ if (modify->ResourceID) {
service->resource_id = g_object_ref(modify->ResourceID);
- else if (modify->EncryptedResourceID)
+ } else if (modify->EncryptedResourceID) {
service->encrypted_resource_id = g_object_ref(modify->EncryptedResourceID);
- else {
+ } else {
return LASSO_ERROR_UNIMPLEMENTED; /* implied ? */
}
diff --git a/lasso/id-wsf/discovery.c b/lasso/id-wsf/discovery.c
index efefcf3a..9f2d2feb 100644
--- a/lasso/id-wsf/discovery.c
+++ b/lasso/id-wsf/discovery.c
@@ -542,7 +542,7 @@ lasso_discovery_init_remove(LassoDiscovery *discovery, const char *entry_id)
/* get discovery service resource id from principal assertion */
offering = lasso_discovery_get_resource_offering_auto(discovery, LASSO_DISCO_HREF);
if (offering == NULL) {
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_PROFILE_ERROR_MISSING_RESOURCE_OFFERING;
}
description = lasso_discovery_get_description_auto(offering,
LASSO_SECURITY_MECH_NULL);
@@ -583,15 +583,15 @@ lasso_discovery_init_query(LassoDiscovery *discovery, const gchar *security_mech
/* get discovery service resource id from principal assertion */
offering = lasso_discovery_get_resource_offering_auto(discovery, LASSO_DISCO_HREF);
if (offering == NULL)
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_PROFILE_ERROR_MISSING_RESOURCE_OFFERING;
- if (!security_mech_id)
+ if (security_mech_id == NULL) {
description = LASSO_DISCO_DESCRIPTION(offering->ServiceInstance->Description->data);
- else {
+ } else {
description = lasso_discovery_get_description_auto(offering, security_mech_id);
}
- if (!description)
- return LASSO_ERROR_UNDEFINED;
+ if (description == NULL)
+ return LASSO_PROFILE_ERROR_MISSING_SERVICE_DESCRIPTION;
lasso_wsf_profile_set_description(LASSO_WSF_PROFILE(discovery), description);
@@ -692,8 +692,7 @@ lasso_discovery_build_modify_response_msg(LassoDiscovery *discovery)
if (lasso_identity_get_resource_offering(
LASSO_WSF_PROFILE(discovery)->identity,
entry->entryID) == NULL) {
- /* FIXME: Return a better code error. */
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_PROFILE_ERROR_MISSING_RESOURCE_OFFERING;
}
}
@@ -756,11 +755,14 @@ lasso_discovery_process_modify_response_msg(LassoDiscovery *discovery, const gch
LassoDiscoModifyResponse *response;
rc = lasso_wsf_profile_process_soap_response_msg(LASSO_WSF_PROFILE(discovery), message);
- if (rc) return rc;
+ if (rc) {
+ return rc;
+ }
response = LASSO_DISCO_MODIFY_RESPONSE(LASSO_WSF_PROFILE(discovery)->response);
- if (strcmp(response->Status->code, "OK") != 0)
- return LASSO_ERROR_UNDEFINED;
+ if (strcmp(response->Status->code, "OK") != 0) {
+ return LASSO_PROFILE_ERROR_STATUS_NOT_SUCCESS;
+ }
return 0;
}
@@ -897,11 +899,14 @@ lasso_discovery_process_query_response_msg(LassoDiscovery *discovery, const gcha
LassoDiscoQueryResponse *response;
rc = lasso_wsf_profile_process_soap_response_msg(LASSO_WSF_PROFILE(discovery), message);
- if (rc) return rc;
+ if (rc) {
+ return rc;
+ }
response = LASSO_DISCO_QUERY_RESPONSE(LASSO_WSF_PROFILE(discovery)->response);
- if (strcmp(response->Status->code, "OK") != 0)
- return LASSO_ERROR_UNDEFINED;
+ if (strcmp(response->Status->code, "OK") != 0) {
+ return LASSO_PROFILE_ERROR_STATUS_NOT_SUCCESS;
+ }
/* XXX: anything else to do ? */
diff --git a/lasso/id-wsf/wsf_profile.c b/lasso/id-wsf/wsf_profile.c
index 21c6394f..07f209e4 100644
--- a/lasso/id-wsf/wsf_profile.c
+++ b/lasso/id-wsf/wsf_profile.c
@@ -225,11 +225,14 @@ lasso_wsf_profile_verify_credential_signature(
/* Retrieve provider id of credential signer . Issuer could be the right place */
issuer = xmlGetProp(credential, (xmlChar*)"Issuer");
- if (!issuer)
- return LASSO_ERROR_UNDEFINED;
+ if (issuer == NULL) {
+ return LASSO_PROFILE_ERROR_MISSING_ISSUER;
+ }
+
lasso_provider = lasso_server_get_provider(profile->server, (char*)issuer);
- if (!lasso_provider)
- return LASSO_ERROR_UNDEFINED;
+ if (lasso_provider == NULL) {
+ return LASSO_SERVER_ERROR_PROVIDER_NOT_FOUND;
+ }
/* Set credential reference */
id_attr = xmlHasProp(credential, (xmlChar *)"AssertionID");
@@ -330,26 +333,26 @@ lasso_wsf_profile_add_credential_signature(LassoWsfProfile *profile,
/* Sign SOAP message */
sign_tmpl = xmlSecFindNode(credential, xmlSecNodeSignature, xmlSecDSigNs);
if (sign_tmpl == NULL)
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_DS_ERROR_SIGNATURE_TEMPLATE_NOT_FOUND;
dsigCtx = xmlSecDSigCtxCreate(NULL);
dsigCtx->signKey = xmlSecCryptoAppKeyLoad(profile->server->private_key,
xmlSecKeyDataFormatPem, NULL, NULL, NULL);
if (dsigCtx->signKey == NULL) {
xmlSecDSigCtxDestroy(dsigCtx);
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_DS_ERROR_PRIVATE_KEY_LOAD_FAILED;
}
if (profile->server->certificate != NULL && profile->server->certificate[0] != 0) {
if (xmlSecCryptoAppKeyCertLoad(dsigCtx->signKey, profile->server->certificate,
- xmlSecKeyDataFormatPem) < 0) {
- xmlSecDSigCtxDestroy(dsigCtx);
- return LASSO_ERROR_UNDEFINED;
+ xmlSecKeyDataFormatPem) < 0) {
+ xmlSecDSigCtxDestroy(dsigCtx);
+ return LASSO_DS_ERROR_CERTIFICATE_LOAD_FAILED;
}
}
if (xmlSecDSigCtxSign(dsigCtx, sign_tmpl) < 0) {
xmlSecDSigCtxDestroy(dsigCtx);
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_DS_ERROR_SIGNATURE_FAILED;
}
xmlSecDSigCtxDestroy(dsigCtx);
@@ -491,7 +494,7 @@ lasso_wsf_profile_verify_saml_authentication(LassoWsfProfile *profile, xmlDoc *d
/* FIXME: Need to consider more every credentials. */
if (xpathObj->nodesetval == NULL || xpathObj->nodesetval->nodeNr == 0) {
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_PROFILE_ERROR_MISSING_ASSERTION;
}
@@ -502,8 +505,9 @@ lasso_wsf_profile_verify_saml_authentication(LassoWsfProfile *profile, xmlDoc *d
public_key = lasso_wsf_profile_get_public_key_from_credential(profile, credential);
- if (public_key == NULL)
- return LASSO_ERROR_UNDEFINED;
+ if (public_key == NULL) {
+ return LASSO_DS_ERROR_PUBLIC_KEY_LOAD_FAILED;
+ }
res = lasso_wsf_profile_verify_x509_authentication(profile, doc, public_key);
if (res != 0)
@@ -534,9 +538,10 @@ lasso_wsf_profile_add_soap_signature(LassoWsfProfile *profile,
t = t->next;
}
if (header == NULL)
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_SOAP_ERROR_MISSING_HEADER;
+
if (body == NULL)
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_SOAP_ERROR_MISSING_BODY;
t = header->children;
while (t) {
@@ -549,9 +554,9 @@ lasso_wsf_profile_add_soap_signature(LassoWsfProfile *profile,
t = t->next;
}
if (correlation == NULL)
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_WSF_PROFILE_ERROR_MISSING_CORRELATION;
if (security == NULL)
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_WSF_PROFILE_ERROR_MISSING_SECURITY;
/* Add signature template */
if (sign_method == LASSO_SIGNATURE_METHOD_RSA_SHA1) {
@@ -608,9 +613,6 @@ lasso_wsf_profile_add_soap_signature(LassoWsfProfile *profile,
}
/* Sign SOAP message */
- /*sign_tmpl = xmlSecFindNode(security, xmlSecNodeSignature, xmlSecDSigNs);
- if (sign_tmpl == NULL)
- return LASSO_ERROR_UNDEFINED;*/
sign_tmpl = signature;
dsigCtx = xmlSecDSigCtxCreate(NULL);
@@ -618,18 +620,18 @@ lasso_wsf_profile_add_soap_signature(LassoWsfProfile *profile,
xmlSecKeyDataFormatPem, NULL, NULL, NULL);
if (dsigCtx->signKey == NULL) {
xmlSecDSigCtxDestroy(dsigCtx);
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_DS_ERROR_PRIVATE_KEY_LOAD_FAILED;
}
if (profile->server->certificate != NULL && profile->server->certificate[0] != 0) {
if (xmlSecCryptoAppKeyCertLoad(dsigCtx->signKey, profile->server->certificate,
- xmlSecKeyDataFormatPem) < 0) {
- xmlSecDSigCtxDestroy(dsigCtx);
- return LASSO_ERROR_UNDEFINED;
+ xmlSecKeyDataFormatPem) < 0) {
+ xmlSecDSigCtxDestroy(dsigCtx);
+ return LASSO_DS_ERROR_CERTIFICATE_LOAD_FAILED;
}
}
if (xmlSecDSigCtxSign(dsigCtx, sign_tmpl) < 0) {
xmlSecDSigCtxDestroy(dsigCtx);
- return LASSO_ERROR_UNDEFINED;
+ return LASSO_DS_ERROR_SIGNATURE_FAILED;
}
xmlSecDSigCtxDestroy(dsigCtx);
@@ -661,8 +663,10 @@ lasso_wsf_profile_verify_x509_authentication(LassoWsfProfile *profile,
if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr) {
correlation = xpathObj->nodesetval->nodeTab[0];
}
- if (!correlation)
- return LASSO_ERROR_UNDEFINED;
+ if (correlation == NULL) {
+ return LASSO_WSF_PROFILE_ERROR_MISSING_CORRELATION;
+ }
+
id_attr = xmlHasProp(correlation, (xmlChar *)"id");
id = xmlGetProp(correlation, (xmlChar *) "id");
xmlAddID(NULL, doc, id, id_attr);
@@ -674,8 +678,9 @@ lasso_wsf_profile_verify_x509_authentication(LassoWsfProfile *profile,
if (xpathObj->nodesetval && xpathObj->nodesetval->nodeNr) {
body = xpathObj->nodesetval->nodeTab[0];
}
- if (!body)
- return LASSO_ERROR_UNDEFINED;
+ if (body == NULL)
+ return LASSO_SOAP_ERROR_MISSING_BODY;
+
id_attr = xmlHasProp(body, (xmlChar *)"id");
id = xmlGetProp(body, (xmlChar *) "id");
xmlAddID(NULL, doc, id, id_attr);
@@ -1229,8 +1234,8 @@ lasso_wsf_profile_process_soap_request_msg(LassoWsfProfile *profile, const gchar
else
profile->private_data->description = NULL;
} else
- if (!si)
- return LASSO_ERROR_UNDEFINED;
+ if (si == NULL)
+ return LASSO_PROFILE_ERROR_MISSING_SERVICE_INSTANCE;
else
lasso_wsf_profile_get_description_auto(si, security_mech_id);