00001
00002
00003
00004
00005
00006 #include "authPluginRequest.h"
00007 #include "eirods_native_auth_object.h"
00008 #include "eirods_auth_object.h"
00009 #include "eirods_auth_factory.h"
00010 #include "eirods_auth_plugin.h"
00011 #include "eirods_auth_manager.h"
00012 #include "eirods_auth_constants.h"
00013 #include "eirods_pluggable_auth_scheme.h"
00014
00015 void _rsSetAuthRequestGetChallenge( const char* );
00016
00017
00018
00019
00020
00021 int rsAuthPluginRequest(
00022 rsComm_t* _comm,
00023 authPluginReqInp_t* _req_inp,
00024 authPluginReqOut_t** _req_out ) {
00025
00026
00027 if( !_comm ) {
00028 rodsLog( LOG_ERROR, "rsAuthPluginRequest - null comm pointer" );
00029 return SYS_INVALID_INPUT_PARAM;
00030
00031 } else if( !_req_inp ) {
00032 rodsLog( LOG_ERROR, "rsAuthPluginRequest - null input pointer" );
00033 return SYS_INVALID_INPUT_PARAM;
00034
00035 }
00036
00037
00038
00039 std::string auth_scheme = eirods::AUTH_NATIVE_SCHEME;
00040 if( _req_inp->auth_scheme_ &&
00041 strlen( _req_inp->auth_scheme_ ) > 0 ) {
00042 auth_scheme = _req_inp->auth_scheme_;
00043 }
00044
00045
00046
00047 eirods::pluggable_auth_scheme& plug_a = eirods::pluggable_auth_scheme::get_instance();
00048 plug_a.set( auth_scheme );
00049
00050
00051
00052 (*_req_out) = (authPluginReqOut_t*)malloc( sizeof( authPluginReqOut_t ) );
00053
00054
00055
00056 eirods::auth_object_ptr auth_obj;
00057 eirods::error ret = eirods::auth_factory(
00058 auth_scheme,
00059 &_comm->rError,
00060 auth_obj );
00061 if( !ret.ok() ){
00062 eirods::log( PASS( ret ) );
00063 return ret.code();
00064 }
00065
00066
00067
00068
00069 if( _req_inp->context_ ) {
00070 auth_obj->context( _req_inp->context_ );
00071 }
00072
00073
00074
00075 eirods::plugin_ptr ptr;
00076 ret = auth_obj->resolve(
00077 eirods::AUTH_INTERFACE,
00078 ptr );
00079 if( !ret.ok() ){
00080 eirods::log( PASS( ret ) );
00081 return ret.code();
00082 }
00083 eirods::auth_ptr auth_plugin = boost::dynamic_pointer_cast<
00084 eirods::auth >( ptr );
00085
00086
00087
00088 ret = auth_plugin->call<
00089 rsComm_t* >(
00090 eirods::AUTH_AGENT_AUTH_REQUEST,
00091 auth_obj,
00092 _comm );
00093 if( !ret.ok() ){
00094 eirods::log( PASS( ret ) );
00095 return ret.code();
00096 }
00097
00098
00099
00100 strncpy(
00101 (*_req_out)->result_,
00102 auth_obj->request_result().c_str(),
00103 auth_obj->request_result().size()+1 );
00104
00105
00106
00107 return 0;
00108
00109 }
00110
00111
00112