Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

lcas_voms_utils.c

Go to the documentation of this file.
00001 /*                                                                                                            
00002  * Copyright (c) Members of the EGEE Collaboration. 2004.
00003  * See http://eu-egee.org/partners/ for details on the copyright holders.
00004  * For license conditions see the license file or
00005  * http://eu-egee.org/license.html
00006  */
00007 
00008 /*                                                                                                            
00009  * Copyright (c) 2001 EU DataGrid.                                                                             
00010  * For license conditions see http://www.eu-datagrid.org/license.html                                          
00011  *
00012  * Copyright (c) 2001, 2002 by 
00013  *     Martijn Steenbakkers <martijn@nikhef.nl>,
00014  *     David Groep <davidg@nikhef.nl>,
00015  *     NIKHEF Amsterdam, the Netherlands
00016  */
00017 
00028 /*****************************************************************************
00029                             Include header files
00030 ******************************************************************************/
00031 #include <stdlib.h>
00032 #include <stdio.h>
00033 #include <errno.h>
00034 #include "lcas_defines.h"
00035 #include "lcas_types.h"
00036 #include "lcas_log.h"
00037 
00038 /* For X509 and STACK_OF(X509) structs (output) */
00039 #include <openssl/x509.h>
00040 
00041 /* For the gss_cred_id_t struct (input) */
00042 #include <gssapi.h>
00043 
00044 /* Internal globus header:
00045  * defines gss_cred_id_desc (= internal structure of gss_cred_id_t)
00046  */
00047 #include "gssapi_openssl.h"
00048 
00049 
00050 /* Defines globus_gsi_cred_handle_t (GSI (globus) credential,
00051  * part of gss_cred_id_desc)
00052  * and interface functions to globus_gsi_cred_handle_t:
00053  * globus_gsi_cred_get_cert() and globus_gsi_cred_get_cert_chain()
00054  */
00055 #include "globus_gsi_credential.h"
00056 
00057 /* Internal globus header:
00058  * describes internal structure of globus_gsi_cred_get_cert
00059  * not needed if interface functions to globus_gsi_cred_handle_t are used
00060  */
00061 //#include "globus_i_gsi_credential.h"
00062 
00063 /******************************************************************************
00064                              Define constants
00065 ******************************************************************************/
00066 
00067 /******************************************************************************
00068                           Module specific prototypes
00069 ******************************************************************************/
00070 
00071 
00072 /******************************************************************************
00073 Function:       lcas_cred_to_x509()
00074 Description:    Return the pointer to X509 structure from gss credential
00075 Parameters:
00076                 cred: globus credential
00077 Returns:        pointer to X509 struct or NULL
00078 ******************************************************************************/
00092 X509 * lcas_cred_to_x509(
00093         gss_cred_id_t cred
00094 )
00095 {
00096     /* Internally a gss_cred_id_t type is a pointer to a gss_cred_id_desc */
00097     gss_cred_id_desc *       cred_desc = NULL;
00098     globus_gsi_cred_handle_t gsi_cred_handle;
00099     X509 * px509=NULL;
00100 
00101     /* cast to gss_cred_id_desc */
00102     if (cred != GSS_C_NO_CREDENTIAL)
00103     {
00104         cred_desc = (gss_cred_id_desc *) cred;
00105         if (globus_module_activate(GLOBUS_GSI_CREDENTIAL_MODULE) ==GLOBUS_SUCCESS)
00106         {
00107             gsi_cred_handle = cred_desc->cred_handle;
00108             if (globus_gsi_cred_get_cert(gsi_cred_handle, &px509) == GLOBUS_SUCCESS)
00109             {
00110                 globus_module_deactivate(GLOBUS_GSI_CREDENTIAL_MODULE);
00111                 return px509;
00112             }
00113             else
00114             {
00115                 globus_module_deactivate(GLOBUS_GSI_CREDENTIAL_MODULE);
00116                 return NULL;
00117             }
00118         }
00119         else
00120         {
00121             globus_module_deactivate(GLOBUS_GSI_CREDENTIAL_MODULE);
00122             return NULL;
00123         }
00124     }
00125     else
00126     {
00127         return NULL;
00128     }
00129 }
00130 
00131 
00132 /******************************************************************************
00133 Function:       lcas_cred_to_x509_chain()
00134 Description:    Return the pointer to X509 chain from gss credential
00135 Parameters:
00136                 cred: globus credential
00137 Returns:        pointer to X509 chain or NULL
00138 ******************************************************************************/
00152 STACK_OF(X509) * lcas_cred_to_x509_chain(
00153         gss_cred_id_t cred
00154 )
00155 {
00156     /* Internally a gss_cred_id_t type is a pointer to a gss_cred_id_desc */
00157     gss_cred_id_desc *       cred_desc = NULL;
00158     globus_gsi_cred_handle_t gsi_cred_handle;
00159     STACK_OF(X509) * px509_chain=NULL;
00160 
00161     /* cast to gss_cred_id_desc */
00162     if (cred != GSS_C_NO_CREDENTIAL)
00163     {
00164         cred_desc = (gss_cred_id_desc *) cred;
00165         if (globus_module_activate(GLOBUS_GSI_CREDENTIAL_MODULE) ==GLOBUS_SUCCESS)
00166         {
00167             gsi_cred_handle = cred_desc->cred_handle;
00168             if (globus_gsi_cred_get_cert_chain(gsi_cred_handle, &px509_chain) == GLOBUS_SUCCESS)
00169             {
00170                 globus_module_deactivate(GLOBUS_GSI_CREDENTIAL_MODULE);
00171                 return px509_chain;
00172             }
00173             else
00174             {
00175                 globus_module_deactivate(GLOBUS_GSI_CREDENTIAL_MODULE);
00176                 return NULL;
00177             }
00178         }
00179         else
00180         {
00181             globus_module_deactivate(GLOBUS_GSI_CREDENTIAL_MODULE);
00182             return NULL;
00183         }
00184     }
00185     else
00186     {
00187         return NULL;
00188     }
00189 }
00190 
00191 /******************************************************************************
00192 CVS Information:
00193     $Source: /cvs/jra1mw/org.glite.security.lcas-plugins-voms/src/voms/lcas_voms_utils.c,v $
00194     $Date: 2004/10/14 16:05:28 $
00195     $Revision: 1.4 $
00196     $Author: msteenba $
00197 ******************************************************************************/

Generated on Fri May 27 18:10:48 2005 for lcas by doxygen 1.3.5