looks like compiling against lasso 0.4.1

This commit is contained in:
fpeters 2004-09-08 09:52:57 +00:00
parent 9505812309
commit 09ce1abcb5
4 changed files with 47 additions and 18 deletions

View File

@ -68,9 +68,8 @@ int defederation_http(LassoDefederation *termination)
return error_page("build notification msg");
}
/* XXX: redirect to SP return URL */
/* missing lasso support; impossible to get return URL */
printf("Location: %s\n\nRedirected", "XXX");
printf("Location: %s\n\nRedirected",
LASSO_PROFILE(termination)->msg_url);
return 0;
}
@ -125,8 +124,8 @@ int defederation_init(LassoDefederation *termination,
session_dump = NULL;
}
rc = lasso_defederation_init_notification(
termination, serviceProviderId);
rc = lasso_defederation_init_notification(termination,
serviceProviderId, lassoHttpMethodSoap);
if (rc) {
return error_page("init_notification failed");
}

View File

@ -35,6 +35,7 @@
#include <openssl/ocsp.h>
#include <openssl/ssl.h>
#include <lasso/lasso.h>
#include <lasso/xml/errors.h> /* lasso bug; shouldn't have to include this */
int error_page(char *msg);
int handle_args(int argc, char *argv[]);
@ -60,7 +61,7 @@ int db_remove_response_dump(char *assertion);
int db_get_user_id(char *name_identifier, char **user_id);
void db_finish();
int soap_request(char *url, char *body, char *content_type);
char* soap_request(char *url, char *body, char *content_type);
char* soap_error(char *msg);
struct authentication {

View File

@ -23,17 +23,27 @@
#include <neon/ne_request.h>
#include <neon/ne_socket.h>
int soap_request(char *url, char *body, char *content_type)
/* takes response body chunks and appends them to a buffer. */
static void collector(void *ud, const char *data, size_t len)
{
ne_buffer *buf = ud;
ne_buffer_append(buf, data, len);
}
char* soap_request(char *url, char *body, char *content_type)
{
ne_session *sess;
ne_uri parsed_uri;
ne_request *req;
ne_buffer *buf = ne_buffer_create();
char *answer;
const ne_status *status;
int rc;
rc = ne_uri_parse(url, &parsed_uri);
if (!rc) {
return 1;
return NULL;
}
ne_sock_init();
@ -41,27 +51,30 @@ int soap_request(char *url, char *body, char *content_type)
parsed_uri.port);
req = ne_request_create(sess, "POST", parsed_uri.path);
ne_add_response_body_reader(req, ne_accept_2xx, collector, buf);
ne_add_request_header(req, "Content-type",
content_type ? content_type : "text/xml");
ne_set_request_body_buffer(req, body, strlen(body));
rc = ne_request_dispatch(req);
if (!rc) {
ne_request_destroy(req);
ne_session_destroy(sess);
return 1;
return NULL;
}
status = ne_get_status(req);
if (status->code != 200) {
ne_request_destroy(req);
ne_session_destroy(sess);
return 1;
return NULL;
}
/* XXX we totally ignored the answer body */
return 0;
answer = malloc(buf->used);
answer = strdup(buf->data);
ne_buffer_destroy(buf);
return answer;
}
char* soap_error(char *msg)

View File

@ -84,6 +84,7 @@ char* req_logout(LassoServer *server, char *soap_msg)
int rc;
char *other_sp;
char *answer = NULL;
char *soap_answer = NULL;
logout = lasso_logout_new(server, lassoProviderTypeIdp);
@ -101,6 +102,12 @@ char* req_logout(LassoServer *server, char *soap_msg)
}
rc = lasso_logout_validate_request(logout);
if (rc == LASSO_LOGOUT_ERROR_UNSUPPORTED_PROFILE) {
/* some SP don't support SOAP logout; fuck off */
rc = lasso_logout_build_request_msg(logout);
answer = LASSO_PROFILE(logout)->msg_body;
goto cleanup;
}
if (rc) {
fprintf(stderr, "logout validate request failed\n");
goto cleanup;
@ -115,7 +122,8 @@ char* req_logout(LassoServer *server, char *soap_msg)
other_sp = lasso_logout_get_next_providerID(logout);
while (other_sp) {
fprintf(stderr, "Other SP: %s\n", other_sp);
rc = lasso_logout_init_request(logout, other_sp);
rc = lasso_logout_init_request(logout, other_sp,
lassoHttpMethodAny);
if (rc) {
fprintf(stderr, "init_request failed\n");
goto cleanup;
@ -126,13 +134,21 @@ char* req_logout(LassoServer *server, char *soap_msg)
goto cleanup;
}
rc = soap_request(LASSO_PROFILE(logout)->msg_url,
LASSO_PROFILE(logout)->msg_body,
NULL);
if (rc) {
soap_answer = soap_request(LASSO_PROFILE(logout)->msg_url,
LASSO_PROFILE(logout)->msg_body, NULL);
if (soap_answer == NULL) {
fprintf(stderr, "soap_request failed\n");
goto cleanup;
}
rc = lasso_logout_process_response_msg(logout,
soap_answer, lassoHttpMethodSoap);
if (rc) {
free(soap_answer);
fprintf(stderr, "logout_process_response_msg failed\n");
goto cleanup;
}
free(soap_answer);
other_sp = lasso_logout_get_next_providerID(logout);
}