summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValery Febvre <vfebvre at easter-eggs.com>2004-07-21 00:37:30 +0000
committerValery Febvre <vfebvre at easter-eggs.com>2004-07-21 00:37:30 +0000
commit4a5eb0dea46295b9797f75dd2ff6908aaa01cd05 (patch)
tree634878973257b246518f667c47c400a09eb0e4b7
parent4a37000286d12a58aeca6280a41c5aa2bd5b6b26 (diff)
downloadlasso-4a5eb0dea46295b9797f75dd2ff6908aaa01cd05.tar.gz
lasso-4a5eb0dea46295b9797f75dd2ff6908aaa01cd05.tar.xz
lasso-4a5eb0dea46295b9797f75dd2ff6908aaa01cd05.zip
Added error codes in lasso_login_add_response_assertion
-rw-r--r--lasso/id-ff/login.c42
1 files changed, 26 insertions, 16 deletions
diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c
index e942e678..99c882b8 100644
--- a/lasso/id-ff/login.c
+++ b/lasso/id-ff/login.c
@@ -65,18 +65,17 @@ lasso_login_add_response_assertion(LassoLogin *login,
{
xmlChar *providerID, *requestID;
LassoNode *assertion=NULL, *authentication_statement;
- xmlChar *ni, *idp_ni;
gint ret = 0;
providerID = lasso_provider_get_providerID(LASSO_PROVIDER(LASSO_PROFILE_CONTEXT(login)->server));
if (providerID == NULL) {
- ret = -1;
debug(ERROR, "The attribute 'ProviderID' is missing in metadata of server.\n");
+ return(-1);
}
requestID = lasso_node_get_attr_value(LASSO_NODE(LASSO_PROFILE_CONTEXT(login)->request), "RequestID");
if (providerID == NULL) {
- ret = -2;
debug(ERROR, "The attribute 'RequestID' is missing in request message.\n");
+ return(-2);
}
assertion = lasso_assertion_new(providerID, requestID);
@@ -86,23 +85,34 @@ lasso_login_add_response_assertion(LassoLogin *login,
reauthenticateOnOrAfter,
identity->remote_nameIdentifier,
identity->local_nameIdentifier);
- lasso_saml_assertion_add_authenticationStatement(LASSO_SAML_ASSERTION(assertion),
- LASSO_SAML_AUTHENTICATION_STATEMENT(authentication_statement));
-
+ if (authentication_statement != NULL) {
+ lasso_saml_assertion_add_authenticationStatement(LASSO_SAML_ASSERTION(assertion),
+ LASSO_SAML_AUTHENTICATION_STATEMENT(authentication_statement));
+ }
+ else {
+ debug(ERROR, "Failed to build the AuthenticationStatement element of the Assertion.\n");
+ lasso_node_destroy(assertion);
+ return(-3);
+ }
/* store NameIdentifier */
login->nameIdentifier = lasso_login_get_assertion_nameIdentifier(assertion);
- lasso_saml_assertion_set_signature(LASSO_SAML_ASSERTION(assertion),
- LASSO_PROFILE_CONTEXT(login)->server->signature_method,
- LASSO_PROFILE_CONTEXT(login)->server->private_key,
- LASSO_PROFILE_CONTEXT(login)->server->certificate);
- lasso_samlp_response_add_assertion(LASSO_SAMLP_RESPONSE(LASSO_PROFILE_CONTEXT(login)->response),
- assertion);
+ ret = lasso_saml_assertion_set_signature(LASSO_SAML_ASSERTION(assertion),
+ LASSO_PROFILE_CONTEXT(login)->server->signature_method,
+ LASSO_PROFILE_CONTEXT(login)->server->private_key,
+ LASSO_PROFILE_CONTEXT(login)->server->certificate);
+ if (ret == 0) {
+ lasso_samlp_response_add_assertion(LASSO_SAMLP_RESPONSE(LASSO_PROFILE_CONTEXT(login)->response),
+ assertion);
- /* store assertion in user object */
- lasso_user_add_assertion(LASSO_PROFILE_CONTEXT(login)->user,
- LASSO_PROFILE_CONTEXT(login)->remote_providerID,
- lasso_node_copy(assertion));
+ /* store assertion in user object */
+ lasso_user_add_assertion(LASSO_PROFILE_CONTEXT(login)->user,
+ LASSO_PROFILE_CONTEXT(login)->remote_providerID,
+ lasso_node_copy(assertion));
+ }
+
+ lasso_node_destroy(authentication_statement);
+ lasso_node_destroy(assertion);
return (ret);
}