This repository has been archived on 2023-02-21. You can view files and clone it, but cannot push or open issues or pull requests.
idpc/src/soap_end_point.c

75 lines
2.1 KiB
C

/*
* idpc - IDP as a C CGI program
* Copyright (C) 2004 Entr'ouvert
*
* Author: Frederic Peters <fpeters@entrouvert.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "idpc.h"
#define DATADIR "/home/fred/src/idpc/idpc/data/"
/* FIXME; should be defined from ./configure */
int soap_end_point()
{
LassoServer* server_context;
LassoLogin* login_context;
int clen = 0;
char *soap_msg, *soap_answer;
FILE *f;
int request_type;
int rc;
server_context = lasso_server_new(
DATADIR "idp-metadata.xml",
DATADIR "idp-public-key.pem",
DATADIR "idp-private-key.pem",
DATADIR "idp-crt.pem",
lassoSignatureMethodRsaSha1);
lasso_server_add_provider(server_context,
DATADIR "sp-metadata.xml",
DATADIR "sp-public-key.pem",
DATADIR "ca-cert.pem");
clen = atoi(getenv("CONTENT_LENGTH"));
soap_msg = malloc(clen+1);
fgets(soap_msg, clen+1, stdin);
request_type = lasso_profile_context_get_request_type_from_soap_msg(soap_msg);
if (request_type == lassoRequestTypeLogin) {
login_context = lasso_login_new(server_context);
rc = lasso_login_process_request_msg(login_context, soap_msg);
f = fopen("/tmp/response_dump", "r");
fseek(f, 0, SEEK_END);
clen = ftell(f);
rewind(f);
soap_answer = malloc(clen);
fread(soap_answer, clen, 1, f);
fclose(f);
}
/* TODO: handle other request_type */
free(soap_msg);
printf("Content-type: text/xml\n\n");
fputs(soap_answer, stdout);
free(soap_answer);
return 0;
}