00001
00002
00003
00004
00005
00006
00007
00008 #include "eirods_native_auth_object.h"
00009 #include "eirods_auth_object.h"
00010 #include "eirods_auth_factory.h"
00011 #include "eirods_auth_plugin.h"
00012 #include "eirods_auth_manager.h"
00013 #include "eirods_auth_constants.h"
00014
00015
00016
00017 #include "authRequest.h"
00018
00019 int get64RandomBytes(char *buf);
00020 static char buf[CHALLENGE_LEN+MAX_PASSWORD_LEN+1];
00021
00022
00023 char* _rsAuthRequestGetChallenge() {
00024 return ((char *)&buf);
00025 }
00026
00027
00028
00029 void _rsSetAuthRequestGetChallenge( const char* _c ) {
00030 if( _c ) {
00031 strncpy(
00032 buf,
00033 _c,
00034 CHALLENGE_LEN+1 );
00035 }
00036 }
00037
00038
00039 int rsAuthRequest(
00040 rsComm_t* _comm,
00041 authRequestOut_t** _req ) {
00042
00043
00044 if( !_comm ) {
00045 rodsLog( LOG_ERROR, "rsAuthRequest - null comm pointer" );
00046 return SYS_INVALID_INPUT_PARAM;
00047 }
00048
00049
00050
00051 (*_req) = (authRequestOut_t*)malloc( sizeof( authRequestOut_t ) );
00052 (*_req)->challenge = (char*)malloc( CHALLENGE_LEN+2 );
00053
00054
00055
00056 eirods::auth_object_ptr auth_obj;
00057 eirods::error ret = eirods::auth_factory(
00058 eirods::AUTH_NATIVE_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 eirods::plugin_ptr ptr;
00069 ret = auth_obj->resolve(
00070 eirods::AUTH_INTERFACE,
00071 ptr );
00072 if( !ret.ok() ){
00073 eirods::log( PASS( ret ) );
00074 return ret.code();
00075 }
00076 eirods::auth_ptr auth_plugin = boost::dynamic_pointer_cast< eirods::auth >( ptr );
00077
00078
00079
00080 ret = auth_plugin->call<
00081 rsComm_t* >(
00082 eirods::AUTH_AGENT_AUTH_REQUEST,
00083 auth_obj,
00084 _comm );
00085 if( !ret.ok() ){
00086 eirods::log( PASS( ret ) );
00087 return ret.code();
00088 }
00089
00090
00091
00092 strncpy(
00093 (*_req)->challenge,
00094 auth_obj->request_result().c_str(),
00095 auth_obj->request_result().size()+1 );
00096
00097
00098
00099 return 0;
00100
00101 }
00102
00103