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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1582 by aramv, Wed Mar 17 16:04:23 2010 UTC revision 1583 by aramv, Fri Mar 19 17:29:41 2010 UTC
# Line 33  int process_xacml (int listenport) Line 33  int process_xacml (int listenport)
33      /* xacml_response_t response; */      /* xacml_response_t response; */
34    
35    
36      xacml_init();      xacml_init(); /* if you look at the code, you'll see this function is empty */
37      xacml_server_init(&server, ees_xacml_authorize, NULL);      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    
     /* Set server object properties to listen to give en port */  
     xacml_server_set_port(server, listenport);  
43    
44      xacml_server_get_port(server, &port);        /* Set the I/O handler object */
45      eef_log(LOG_INFO, "SCAS ready... listening on port %hu.\n", port);        /* xacml_server_set_io_descriptor(server, &xacml_io_ssl_descriptor); */
46    
47          /* start server and block further execution */
48      /* Set the I/O handler object */        xacml_server_start(server);
49      /* xacml_server_set_io_descriptor(server, &xacml_io_ssl_descriptor); */        while (!done) {
   
     xacml_server_start(server);  
   
     while (!done)  
     {  
50          pause();          pause();
51          eef_log(LOG_INFO, "SCAS service stop.\n");          eef_log(LOG_INFO, "SCAS service stop.\n");
52          }
53      }      }
54        /* SIGTERM received */
55      xacml_server_destroy(server);      xacml_server_destroy(server);
56    
57      fflush(stdout);      fflush(stdout);
58      fflush(stderr);      fflush(stderr);
59    
# Line 65  int process_xacml (int listenport) Line 64  int process_xacml (int listenport)
64  void signal_handler(sig){  void signal_handler(sig){
65    switch(sig){    switch(sig){
66      case SIGHUP:      case SIGHUP:
67        eef_log(LOG_NOTICE, "Got SIGHUP - what to do? \n");        eef_log(LOG_NOTICE, "Got SIGHUP - restart \n");
68          EEF_Term();
69        break;        break;
70      case SIGTERM:      case SIGTERM:
71        eef_log(LOG_NOTICE, "Got SIGTERM - shutting down\n");        eef_log(LOG_NOTICE, "Got SIGTERM - shutting down\n");
72        printf("Got SIGTERM - shutting down\n");        printf("Got SIGTERM - shutting down\n");
73          AOS_Clean();
74        EEF_Term();        EEF_Term();
75        exit(0);        exit(0);
76        break;        break;
# Line 83  int main (int argc, char* argv[]){ Line 84  int main (int argc, char* argv[]){
84    int rc;                                 /* return code from pthread functions */    int rc;                                 /* return code from pthread functions */
85    void* status;                           /* thread join status */    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){    if(argc > 1){
96      config_file = argv[1];      config_file = argv[1];
97    } else {    } else {
98      config_file = "examples/example_1.pdl";      config_file = "examples/example_1.pdl";
99    }    }
100    
   printf("Parsing config file %s\n", config_file);  
   
101  #if !ENABLE_DEBUG  #if !ENABLE_DEBUG
102    EEF_Daemonize();    EEF_Daemonize();
103  #endif  #endif
# Line 98  int main (int argc, char* argv[]){ Line 105  int main (int argc, char* argv[]){
105    signal(SIGHUP, signal_handler); /* catch hangup signal */    signal(SIGHUP, signal_handler); /* catch hangup signal */
106    signal(SIGTERM, signal_handler); /* catch kill signal */    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){          if(EEF_Init(config_file, NULL, 0, NULL) == EES_FAILURE){
111      eef_log(LOG_ERR, "Failed to parse config file (%s), exiting...", config_file);      eef_log(LOG_ERR, "Failed to parse config file (%s), exiting...", config_file);
112    } else {    } else {
113      /*make_socket();*/      /*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();      aos_start_threading();
133      process_xacml(PORT);      process_xacml(PORT);
134      /* start threading */      /* start threading */
135      /*for(t=0; t < NUM_THREADS; t++){*/      /*for(t=0; t < NUM_THREADS; t++){*/
136      /*printf("Creating thread %li!\n", t);*/      /*printf("Creating thread %li!\n", t);*/
137        /*rc = pthread_create(&threads[t], NULL, (void*)(void*) EEF_Run, (void*)(t));*/      /*rc = pthread_create(&threads[t], NULL, (void*)(void*) EEF_Run, (void*)(t));*/
138        /*rc = pthread_join(threads[t], &status);*/      /*rc = pthread_join(threads[t], &status);*/
139    
140        /* Fire up SAML2-XACML2 */      /**//*Fire up SAML2-XACML2 */
141        /*process_xacml(PORT);*/      /**//*process_xacml(PORT);*/
142    
143        /*}*/      /*}*/
144    }    }
145    printf("terminated!\n");    printf("terminated!\n");
146    
147      aos_dump_argslist();
148    /*pthread_exit(NULL);*/    /*pthread_exit(NULL);*/
149    
150    return 0;    return 0;

Legend:
Removed from v.1582  
changed lines
  Added in v.1583

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