irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

rsAuthRequest.cpp
Go to the documentation of this file.
1 
4 /* See authRequest.h for a description of this API call.*/
5 
6 // =-=-=-=-=-=-=-
8 #include "irods_auth_object.hpp"
9 #include "irods_auth_factory.hpp"
10 #include "irods_auth_plugin.hpp"
11 #include "irods_auth_manager.hpp"
12 #include "irods_auth_constants.hpp"
13 #include "rsAuthRequest.hpp"
14 
15 // =-=-=-=-=-=-=-
16 // irods includes
17 #include "authRequest.h"
18 #include "authenticate.h"
19 
20 int get64RandomBytes( char *buf );
21 static char buf[CHALLENGE_LEN + MAX_PASSWORD_LEN + 1];
22 
23 // =-=-=-=-=-=-=-
24 // accessor for static challenge buf variable
26  return ( char * )&buf;
27 }
28 
29 // =-=-=-=-=-=-=-
30 // mutator for static challenge buf variable
31 void _rsSetAuthRequestGetChallenge( const char* _c ) {
32  if ( _c ) {
33  strncpy( buf, _c, CHALLENGE_LEN + 1 );
34  }
35 }
36 
37 
39  rsComm_t* _comm,
40  authRequestOut_t** _req ) {
41 
42  // =-=-=-=-=-=-=-
43  // check our incoming params
44  if ( !_comm ) {
45  rodsLog( LOG_ERROR, "rsAuthRequest - null comm pointer" );
47  }
48 
49  // =-=-=-=-=-=-=-
50  // handle old school memory allocation
51  ( *_req ) = ( authRequestOut_t* )malloc( sizeof( authRequestOut_t ) );
52  ( *_req )->challenge = ( char* )malloc( CHALLENGE_LEN + 2 );
53 
54  // =-=-=-=-=-=-=-
55  // construct an auth object given the native scheme
56  irods::auth_object_ptr auth_obj;
58  if ( !ret.ok() ) {
59  irods::log( PASS( ret ) );
60  return ret.code();
61  }
62 
63  // =-=-=-=-=-=-=-
64  // resolve an auth plugin given the auth object
66  ret = auth_obj->resolve( irods::AUTH_INTERFACE, ptr );
67  if ( !ret.ok() ) {
68  irods::log( PASS( ret ) );
69  return ret.code();
70  }
71  irods::auth_ptr auth_plugin = boost::dynamic_pointer_cast< irods::auth >( ptr );
72 
73  // =-=-=-=-=-=-=-
74  // call client side init - 'establish creds'
75  ret = auth_plugin->call( _comm, irods::AUTH_AGENT_AUTH_REQUEST, auth_obj );
76  if ( !ret.ok() ) {
77  irods::log( PASS( ret ) );
78  return ret.code();
79  }
80 
81  // =-=-=-=-=-=-=-
82  // send back the results
83  strncpy( ( *_req )->challenge, auth_obj->request_result().c_str(), auth_obj->request_result().size() + 1 );
84 
85  // =-=-=-=-=-=-=-
86  // win!
87  return 0;
88 
89 } // rsAuthRequest
rodsLog
void rodsLog(int level, const char *formatStr,...)
Definition: rodsLog.cpp:86
irods::plugin_ptr
boost::shared_ptr< plugin_base > plugin_ptr
Definition: irods_first_class_object.hpp:18
rsComm_t
Definition: rcConnect.h:145
_rsAuthRequestGetChallenge
char * _rsAuthRequestGetChallenge()
Definition: rsAuthRequest.cpp:25
irods_native_auth_object.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
authenticate.h
irods::auth_factory
irods::error auth_factory(const std::string &, rError_t *, irods::auth_object_ptr &)
Definition: irods_auth_factory.cpp:16
irods::auth_object_ptr
boost::shared_ptr< auth_object > auth_object_ptr
Definition: irods_auth_object.hpp:86
irods::AUTH_NATIVE_SCHEME
const std::string AUTH_NATIVE_SCHEME("native")
irods::AUTH_INTERFACE
const std::string AUTH_INTERFACE("irods_auth_interface")
LOG_ERROR
#define LOG_ERROR
Definition: rodsLog.h:43
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
authRequest.h
MAX_PASSWORD_LEN
#define MAX_PASSWORD_LEN
Definition: authenticate.h:9
irods::AUTH_AGENT_AUTH_REQUEST
const std::string AUTH_AGENT_AUTH_REQUEST("auth_agent_auth_request")
irods_auth_constants.hpp
irods_auth_object.hpp
_rsSetAuthRequestGetChallenge
void _rsSetAuthRequestGetChallenge(const char *_c)
Definition: rsAuthRequest.cpp:31
rsComm_t::rError
rError_t rError
Definition: rcConnect.h:158
irods::error::code
long long code() const
Definition: irods_error.cpp:194
irods_auth_factory.hpp
rsAuthRequest
int rsAuthRequest(rsComm_t *_comm, authRequestOut_t **_req)
Definition: rsAuthRequest.cpp:38
authRequestOut_t
Definition: authRequest.h:11
irods_auth_manager.hpp
irods::log
void log(const error &)
Definition: irods_log.cpp:13
irods::error
Definition: irods_error.hpp:23
rsAuthRequest.hpp
irods_auth_plugin.hpp
CHALLENGE_LEN
#define CHALLENGE_LEN
Definition: authenticate.h:10
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
get64RandomBytes
int get64RandomBytes(char *buf)
Definition: rcMisc.cpp:1371
buf
static char buf[64+50+1]
Definition: rsAuthRequest.cpp:21
irods::auth_ptr
boost::shared_ptr< auth > auth_ptr
Definition: irods_auth_types.hpp:19