/[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 1571 - (show annotations) (download) (as text)
Wed Mar 17 11:44:14 2010 UTC (11 years, 10 months ago) by aramv
File MIME type: text/x-chdr
File size: 3294 byte(s)
Only cleaning TLS in AOS through callback from pthreads lib
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 eef_log(LOG_INFO, "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 eef_log(LOG_INFO, "SCAS service stop.\n");
55 }
56
57 xacml_server_destroy(server);
58 fflush(stdout);
59 fflush(stderr);
60
61 /* Perfect ending */
62 return 0;
63 }
64
65 void signal_handler(sig){
66 switch(sig){
67 case SIGHUP:
68 eef_log(LOG_NOTICE, "Got SIGHUP - what to do? \n");
69 break;
70 case SIGTERM:
71 eef_log(LOG_NOTICE, "Got SIGTERM - shutting down\n");
72 EEF_Term();
73 exit(0);
74 break;
75 }
76 }
77
78 int main (int argc, char* argv[]){
79 char* config_file; /* config file path */
80 pthread_t threads[NUM_THREADS]; /* thread pool */
81 long t; /* thread iterator */
82 int rc; /* return code from pthread functions */
83 void* status; /* thread join status */
84
85 if(argc > 1){
86 config_file = argv[1];
87 } else {
88 config_file = "examples/example_1.pdl";
89 }
90
91 printf("Parsing config file %s\n", config_file);
92
93 #if !ENABLE_DEBUG
94 EEF_Daemonize();
95 #endif
96
97 signal(SIGHUP, signal_handler); /* catch hangup signal */
98 signal(SIGTERM, signal_handler); /* catch kill signal */
99
100 if(EEF_Init(config_file, NULL, 0, NULL) == EES_FAILURE){
101 eef_log(LOG_ERR, "Failed to parse config file (%s), exiting...", config_file);
102 } else {
103 /*make_socket();*/
104 aos_start_threading();
105 process_xacml(PORT);
106 /* start threading */
107 /*for(t=0; t < NUM_THREADS; t++){*/
108 /*printf("Creating thread %li!\n", t);*/
109 /*rc = pthread_create(&threads[t], NULL, (void*)(void*) EEF_Run, (void*)(t));*/
110 /*rc = pthread_join(threads[t], &status);*/
111
112 /* Fire up SAML2-XACML2 */
113 /*process_xacml(PORT);*/
114
115 /*}*/
116 }
117 printf("terminated!\n");
118
119 pthread_exit(NULL);
120
121 return 0;
122 }
123
124

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