/[pdpsoft]/trunk/grid-mw-security/ees/src/app/eic_test.c
ViewVC logotype

Contents of /trunk/grid-mw-security/ees/src/app/eic_test.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1569 - (show annotations) (download) (as text)
Tue Mar 16 17:35:17 2010 UTC (11 years, 10 months ago) by aramv
File MIME type: text/x-chdr
File size: 3405 byte(s)
Re-added AOS cleaning, so reduced memory leaks by quite a bit
1 #define _MULTI_THREADED
2 #define NUM_THREADS 40
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <pthread.h>
7
8 #include "ees_eics.h"
9 #include "xacml.h"
10 #include "xacml_server.h"
11 #include "eef_library.h"
12 #define PORT 1234
13
14 int process_xacml(int);
15
16 /********************************************************************
17 function: process_xacml
18 description:
19 This function is the start of the service. It initializes the XACML library
20 and will put the library in listen mode. In this case that I/O layer is hardwired to be secured
21 via my I/O handler function implementation, that brings you the SSL layer. And in effect, HTTPS.
22
23 paramters:
24 int listenport : The service will listen on this TCP port number
25 ********************************************************************/
26 int process_xacml (int listenport)
27 {
28 int rc = 0;
29 int done = 0;
30 char * logstr = "process_xacml";
31 xacml_server_t server;
32 unsigned short port = listenport;
33 /* xacml_response_t response; */
34
35
36 xacml_init();
37 xacml_server_init(&server, ees_xacml_authorize, NULL);
38
39 /* Set server object properties to listen to give en port */
40 xacml_server_set_port(server, listenport);
41
42 xacml_server_get_port(server, &port);
43 printf ( "SCAS ready... listening on port %hu.\n", port);
44
45
46 /* Set the I/O handler object */
47 /* xacml_server_set_io_descriptor(server, &xacml_io_ssl_descriptor); */
48
49 xacml_server_start(server);
50
51 while (!done)
52 {
53 pause();
54 printf ("SCAS service stop.\n");
55 }
56
57 /* fprintf(stderr, "SCAS: Shutting down... signal was: %d\n", gsig); */
58 /* scas_log (1, "Shutting down... signal was: %d\n", gsig); */
59
60 xacml_server_destroy(server);
61 fflush(stdout);
62 fflush(stderr);
63
64 /* Perfect ending */
65 return 0;
66 }
67
68 void signal_handler(sig){
69 switch(sig){
70 case SIGHUP:
71 eef_log(LOG_NOTICE, "Got SIGHUP - what to do? \n");
72 break;
73 case SIGTERM:
74 eef_log(LOG_NOTICE, "Got SIGTERM - shutting down\n");
75 EEF_Term();
76 exit(0);
77 break;
78 }
79 }
80
81 int main (int argc, char* argv[]){
82 char* config_file; /* config file path */
83 pthread_t threads[NUM_THREADS]; /* thread pool */
84 long t; /* thread iterator */
85 int rc; /* return code from pthread functions */
86 void* status; /* thread join status */
87
88 if(argc > 1){
89 config_file = argv[1];
90 } else {
91 config_file = "examples/example_1.pdl";
92 }
93
94 printf("Parsing config file %s\n", config_file);
95
96 /*#if !ENABLE_DEBUG*/
97 /*EEF_Daemonize();*/
98 signal(SIGHUP, signal_handler); /* catch hangup signal */
99 signal(SIGTERM, signal_handler); /* catch kill signal */
100 /*#endif*/
101
102 if(EEF_Init(config_file, NULL, 0, NULL) == EES_FAILURE){
103 eef_log(LOG_ERR, "Failed to parse config file (%s), exiting...", config_file);
104 } else {
105 /*make_socket();*/
106 aos_start_threading();
107 /* start threading */
108 for(t=0; t < NUM_THREADS; t++){
109 printf("Creating thread %li!\n", t);
110 /*rc = pthread_create(&threads[t], NULL, (void*)(void*) EEF_Run, (void*)(t));*/
111 /*rc = pthread_join(threads[t], &status);*/
112
113 /* Fire up SAML2-XACML2 */
114 process_xacml(PORT);
115
116 }
117 }
118 printf("terminated!\n");
119
120 pthread_exit(NULL);
121 return 0;
122 }
123
124

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28