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 00039 /*\@{*/ 00040 00041 /***************************************************************************** 00042 Include header files 00043 ******************************************************************************/ 00044 #include "lcas_config.h" 00045 #include <stdio.h> 00046 #include <stdlib.h> 00047 #include <string.h> 00048 #include "lcas_modules.h" 00049 00050 /****************************************************************************** 00051 Definitions 00052 ******************************************************************************/ 00053 00054 /****************************************************************************** 00055 Module specific prototypes 00056 ******************************************************************************/ 00057 00058 /****************************************************************************** 00059 Define module specific variables 00060 ******************************************************************************/ 00061 00062 /****************************************************************************** 00063 Function: plugin_initialize 00064 Description: 00065 Initialize plugin 00066 Parameters: 00067 argc, argv 00068 argv[0]: the name of the plugin 00069 Returns: 00070 LCAS_MOD_SUCCESS : succes 00071 LCAS_MOD_FAIL : failure 00072 LCAS_MOD_NOFILE : db file not found (will halt LCAS initialization) 00073 ******************************************************************************/ 00091 int plugin_initialize( 00092 int argc, 00093 char ** argv 00094 ) 00095 { 00096 int i; 00097 00098 lcas_log_debug(1,"lcas_plugin_example-plugin_initialize(): passed arguments:\n"); 00099 for (i=0; i < argc; i++) 00100 { 00101 lcas_log_debug(2,"lcas_plugin_example-plugin_initialize(): arg %d is %s\n", 00102 i,argv[i]); 00103 } 00104 00105 return LCAS_MOD_SUCCESS; 00106 } 00107 00108 /****************************************************************************** 00109 Function: plugin_confirm_authorization 00110 Description: 00111 Ask for authorization by passing RSL(JDL) and user credential 00112 Parameters: 00113 request: RSL request 00114 lcas_cred: user credential 00115 Returns: 00116 LCAS_MOD_SUCCESS: authorization succeeded 00117 LCAS_MOD_FAIL : authorization failed 00118 LCAS_MOD_NOFILE : db file not found (LCAS will deny authorization) 00119 ******************************************************************************/ 00139 int plugin_confirm_authorization( 00140 lcas_request_t request, 00141 lcas_cred_id_t lcas_cred 00142 ) 00143 { 00144 char * username = NULL; 00145 00146 lcas_log_debug(1,"\tlcas_plugin_example-plugin_confirm_authorization():\n"); 00147 00148 /* 00149 * check credential and get the globus name 00150 */ 00151 if ( (username = lcas_get_dn(lcas_cred)) == NULL) 00152 { 00153 lcas_log(0, "lcas.mod-lcas_get_fabric_authorization() error: user DN empty\n"); 00154 goto fail_example; 00155 } 00156 00157 if (username != NULL) 00158 { 00159 lcas_log_debug(0, 00160 "\tlcas_plugin_example-plugin_confirm_authorization(): OK, what the heck, I'll authorize Mr/Mrs %s\n", 00161 username); 00162 } 00163 else 00164 { 00165 lcas_log_debug(0, 00166 "\tlcas_plugin_example-plugin_confirm_authorization(): Authorization failure: invalid username (%s)\n",username); 00167 goto fail_example; 00168 } 00169 00170 /* succes */ 00171 return LCAS_MOD_SUCCESS; 00172 00173 fail_example: 00174 return LCAS_MOD_FAIL; 00175 } 00176 00177 /****************************************************************************** 00178 Function: plugin_terminate 00179 Description: 00180 Terminate plugin 00181 Parameters: 00182 00183 Returns: 00184 LCAS_MOD_SUCCESS : succes 00185 LCAS_MOD_FAIL : failure 00186 ******************************************************************************/ 00193 int plugin_terminate() 00194 { 00195 lcas_log_debug(1,"lcas_plugin_example-plugin_terminate(): terminating\n"); 00196 00197 return LCAS_MOD_SUCCESS; 00198 } 00199 /*\@}*/ 00200 00201 /****************************************************************************** 00202 CVS Information: 00203 $Source: /cvs/jra1mw/org.glite.security.lcas/examples/lcas_plugin_example.c,v $ 00204 $Date: 2004/10/14 16:05:27 $ 00205 $Revision: 2.9 $ 00206 $Author: msteenba $ 00207 ******************************************************************************/