/[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 1583 - (show annotations) (download) (as text)
Fri Mar 19 17:29:41 2010 UTC (12 years, 6 months ago) by aramv
File MIME type: text/x-chdr
File size: 4296 byte(s)
Fixed a read error. Added signature for fork function
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(); /* if you look at the code, you'll see this function is empty */
37 if(xacml_server_init(&server, ees_xacml_authorize, NULL) == XACML_RESULT_SUCCESS){
38 /* Set server object properties to listen to give en port */
39 xacml_server_set_port(server, listenport);
40 xacml_server_get_port(server, &port);
41 eef_log(LOG_INFO, "SCAS ready... listening on port %hu.\n", port);
42
43
44 /* Set the I/O handler object */
45 /* xacml_server_set_io_descriptor(server, &xacml_io_ssl_descriptor); */
46
47 /* start server and block further execution */
48 xacml_server_start(server);
49 while (!done) {
50 pause();
51 eef_log(LOG_INFO, "SCAS service stop.\n");
52 }
53 }
54 /* SIGTERM received */
55 xacml_server_destroy(server);
56
57 fflush(stdout);
58 fflush(stderr);
59
60 /* Perfect ending */
61 return 0;
62 }
63
64 void signal_handler(sig){
65 switch(sig){
66 case SIGHUP:
67 eef_log(LOG_NOTICE, "Got SIGHUP - restart \n");
68 EEF_Term();
69 break;
70 case SIGTERM:
71 eef_log(LOG_NOTICE, "Got SIGTERM - shutting down\n");
72 printf("Got SIGTERM - shutting down\n");
73 AOS_Clean();
74 EEF_Term();
75 exit(0);
76 break;
77 }
78 }
79
80 int main (int argc, char* argv[]){
81 char* config_file; /* config file path */
82 pthread_t threads[NUM_THREADS]; /* thread pool */
83 long t; /* thread iterator */
84 int rc; /* return code from pthread functions */
85 void* status; /* thread join status */
86
87 aos_attribute_t* pemstring;
88 aos_context_t* _context;
89 aos_attribute_t *_uid, *_gid;
90
91 char* _uid_str = "1234";
92 char* _gid_str = "1234";
93
94
95 if(argc > 1){
96 config_file = argv[1];
97 } else {
98 config_file = "examples/example_1.pdl";
99 }
100
101 #if !ENABLE_DEBUG
102 EEF_Daemonize();
103 #endif
104
105 signal(SIGHUP, signal_handler); /* catch hangup signal */
106 signal(SIGTERM, signal_handler); /* catch kill signal */
107
108 /* reuse this part when implementing SIGHUP */
109 printf("Parsing config file %s\n", config_file);
110 if(EEF_Init(config_file, NULL, 0, NULL) == EES_FAILURE){
111 eef_log(LOG_ERR, "Failed to parse config file (%s), exiting...", config_file);
112 } else {
113 /*make_socket();*/
114 /* fill aos */
115 _uid = createAttribute();
116 _gid = createAttribute();
117
118 setAttributeId(_uid, "posix-uid");
119 setAttributeValue(_uid, _uid_str, strlen(_uid_str));
120 setAttributeId(_gid, "posix-gid");
121 setAttributeValue(_gid, _gid_str, strlen(_gid_str));
122
123 if((_context = createContext(OBLIGATION)) != NULL){
124 setContextObligationId(_context, "uidgid");
125
126 addAttribute(_context, _uid);
127 addAttribute(_context, _gid);
128
129 addContext(_context);
130 }
131 aos_dump_argslist();
132 aos_start_threading();
133 process_xacml(PORT);
134 /* start threading */
135 /*for(t=0; t < NUM_THREADS; t++){*/
136 /*printf("Creating thread %li!\n", t);*/
137 /*rc = pthread_create(&threads[t], NULL, (void*)(void*) EEF_Run, (void*)(t));*/
138 /*rc = pthread_join(threads[t], &status);*/
139
140 /**//*Fire up SAML2-XACML2 */
141 /**//*process_xacml(PORT);*/
142
143 /*}*/
144 }
145 printf("terminated!\n");
146
147 aos_dump_argslist();
148 /*pthread_exit(NULL);*/
149
150 return 0;
151 }
152
153

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