Back to index

nordugrid-arc-nox  1.1.0~rc6
test_ClientX509Delegation_GridSite.cpp
Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #include <config.h>
00003 #endif
00004 
00005 #include <iostream>
00006 #include <signal.h>
00007 #include <stdexcept>
00008 
00009 #include <arc/GUID.h>
00010 #include <arc/ArcConfig.h>
00011 #include <arc/Logger.h>
00012 #include <arc/URL.h>
00013 #include <arc/message/PayloadSOAP.h>
00014 #include <arc/message/MCC.h>
00015 #include <arc/client/ClientX509Delegation.h>
00016 #ifdef WIN32
00017 #include <arc/win32.h>
00018 #endif
00019 
00020 int main(void) {
00021   signal(SIGTTOU,SIG_IGN);
00022   signal(SIGTTIN,SIG_IGN);
00023   Arc::Logger logger(Arc::Logger::rootLogger, "Test");
00024   Arc::LogStream logcerr(std::cerr);
00025   Arc::Logger::rootLogger.addDestination(logcerr);
00026 
00027 
00028   /******** Test to gridsite delegation service **********/
00029   std::string gs_deleg_url_str("https://cream.grid.upjs.sk:8443/ce-cream/services/gridsite-delegation");
00030   Arc::URL gs_deleg_url(gs_deleg_url_str);
00031   Arc::MCCConfig gs_deleg_mcc_cfg;
00032  
00033   //Use voms-proxy-init or arcproxy to generate a gsi legacy proxy, and 
00034   //put put it into mcc configuraton by using "AddProxy"
00035   gs_deleg_mcc_cfg.AddProxy("proxy.pem");
00036 
00037   //gs_deleg_mcc_cfg.AddPrivateKey("../echo/userkey-nopass.pem");
00038   //gs_deleg_mcc_cfg.AddCertificate("../echo/usercert.pem");
00039   gs_deleg_mcc_cfg.AddCADir("../echo/certificates");
00040   //Create a delegation SOAP client
00041   logger.msg(Arc::INFO, "Creating a delegation soap client");
00042   Arc::ClientX509Delegation *gs_deleg_client = NULL;
00043   gs_deleg_client = new Arc::ClientX509Delegation(gs_deleg_mcc_cfg, gs_deleg_url);
00044   std::string gs_delegation_id;
00045   gs_delegation_id = Arc::UUID();
00046   if(gs_deleg_client) {
00047     if(!(gs_deleg_client->createDelegation(Arc::DELEG_GRIDSITE, gs_delegation_id))) {
00048       logger.msg(Arc::ERROR, "Delegation to gridsite delegation service failed");
00049       throw std::runtime_error("Delegation to gridsite delegation service failed");
00050     }
00051   }
00052   logger.msg(Arc::INFO, "Delegation ID: %s", gs_delegation_id.c_str());
00053   if(gs_deleg_client) delete gs_deleg_client;
00054 
00055   return 0;
00056 }