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)  

irods_native_auth_object.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
3 #include "irods_auth_manager.hpp"
4 #include "irods_auth_plugin.hpp"
5 
6 // =-=-=-=-=-=-=-
7 // irods includes
8 #include "rcMisc.h"
9 
10 extern int ProcessType;
11 
12 namespace irods {
13 
14 // =-=-=-=-=-=-=-
15 // public - ctor
17  rError_t* _r_error ) :
18  auth_object( _r_error ) {
19  } // ctor
20 
21 // =-=-=-=-=-=-=-
22 // public - dtor
24  } // dtor
25 
26 // =-=-=-=-=-=-=-
27 // public - cctor
29  const native_auth_object& _rhs ) :
30  auth_object( _rhs ) {
31  user_name_ = _rhs.user_name_;
32  zone_name_ = _rhs.zone_name_;
33  digest_ = _rhs.digest_;
34  } // cctor
35 
36 // =-=-=-=-=-=-=-
37 // public - assignment operator
39  const native_auth_object& _rhs ) {
40  auth_object::operator=( _rhs );
41  user_name_ = _rhs.user_name_;
42  zone_name_ = _rhs.zone_name_;
43  digest_ = _rhs.digest_;
44  return *this;
45  }
46 
47 // =-=-=-=-=-=-=-
48 // public - equality operator
50  const native_auth_object& ) const {
51  return false;
52  }
53 
54 // =-=-=-=-=-=-=-
55 // public - resolve a plugin given an interface
57  const std::string& _interface,
58  plugin_ptr& _ptr ) {
59  // =-=-=-=-=-=-=-
60  // check the interface type and error out if it
61  // isnt a auth interface
62  if ( AUTH_INTERFACE != _interface ) {
63  std::stringstream msg;
64  msg << "native_auth_object does not support a [";
65  msg << _interface;
66  msg << "] plugin interface";
67  return ERROR( SYS_INVALID_INPUT_PARAM, msg.str() );
68 
69  }
70 
71  // =-=-=-=-=-=-=-
72  // ask the auth manager for a native auth plugin
73  auth_ptr a_ptr;
74  error ret = auth_mgr.resolve(
76  a_ptr );
77  if ( !ret.ok() ) {
78  // =-=-=-=-=-=-=-
79  // attempt to load the plugin, in this case the type,
80  // instance name, key etc are all native as there is only
81  // the need for one instance of a native object, etc.
82  std::string empty_context( "" );
88  empty_context,
89  a_ptr );
90  if ( !ret.ok() ) {
91  return PASS( ret );
92 
93  }
94  else {
95  // =-=-=-=-=-=-=-
96  // upcast for out variable
97  _ptr = boost::dynamic_pointer_cast< plugin_base >( a_ptr );
98  return SUCCESS();
99 
100  }
101 
102  } // if !ok
103 
104  // =-=-=-=-=-=-=-
105  // upcast for out variable
106  _ptr = boost::dynamic_pointer_cast< plugin_base >( a_ptr );
107 
108  return SUCCESS();
109 
110  } // resolve
111 
112 // =-=-=-=-=-=-=-
113 // public - serialize object to kvp
115  rule_engine_vars_t& _kvp ) {
116  // =-=-=-=-=-=-=-
117  // all we have in this object is the auth results
118  _kvp["zone_name"] = zone_name_.c_str();
119  _kvp["user_name"] = user_name_.c_str();
120  _kvp["digest"] = digest_.c_str();
121 
122  return SUCCESS();
123 
124  } // get_re_vars
125 
126 }; // namespace irods
irods::plugin_ptr
boost::shared_ptr< plugin_base > plugin_ptr
Definition: irods_first_class_object.hpp:18
irods::auth_object
Definition: irods_auth_object.hpp:16
irods::auth_manager::init_from_type
error init_from_type(const int &, const std::string &_type, const std::string &_key, const std::string &_inst, const std::string &_ctx, auth_ptr &_rtn_auth)
Definition: irods_auth_manager.cpp:65
irods::native_auth_object::native_auth_object
native_auth_object(rError_t *_r_error)
Definition: irods_native_auth_object.cpp:16
irods::auth_object::operator=
virtual auth_object & operator=(const auth_object &_rhs)
Definition: irods_auth_object.cpp:22
irods::auth_object::zone_name_
std::string zone_name_
Definition: irods_auth_object.hpp:77
irods_native_auth_object.hpp
PASS
#define PASS(prev_error_)
Definition: irods_error.hpp:118
irods::native_auth_object
Definition: irods_native_auth_object.hpp:21
rcMisc.h
irods::AUTH_NATIVE_SCHEME
const std::string AUTH_NATIVE_SCHEME("native")
irods::AUTH_INTERFACE
const std::string AUTH_INTERFACE("irods_auth_interface")
SYS_INVALID_INPUT_PARAM
@ SYS_INVALID_INPUT_PARAM
Definition: rodsErrorTable.h:195
ProcessType
int ProcessType
Definition: rcGlobal.cpp:16
SUCCESS
#define SUCCESS()
Definition: irods_error.hpp:121
rError_t
Definition: rodsError.h:24
irods
Definition: apiHandler.hpp:35
irods::native_auth_object::resolve
virtual error resolve(const std::string &, plugin_ptr &)
Definition: irods_native_auth_object.cpp:56
irods::native_auth_object::~native_auth_object
virtual ~native_auth_object()
Definition: irods_native_auth_object.cpp:23
irods::auth_object::user_name_
std::string user_name_
Definition: irods_auth_object.hpp:73
irods_auth_manager.hpp
irods::native_auth_object::get_re_vars
virtual error get_re_vars(rule_engine_vars_t &)
Definition: irods_native_auth_object.cpp:114
irods::auth_manager::resolve
error resolve(const std::string &_key, auth_ptr &_value)
Definition: irods_auth_manager.cpp:22
irods::native_auth_object::operator==
virtual bool operator==(const native_auth_object &) const
Definition: irods_native_auth_object.cpp:49
ERROR
#define ERROR(code_, message_)
Definition: irods_error.hpp:117
irods::error
Definition: irods_error.hpp:23
irods::native_auth_object::operator=
virtual native_auth_object & operator=(const native_auth_object &)
Definition: irods_native_auth_object.cpp:38
irods_auth_plugin.hpp
irods::native_auth_object::digest_
std::string digest_
Definition: irods_native_auth_object.hpp:62
irods::auth_mgr
auth_manager auth_mgr
Definition: irods_auth_manager.cpp:7
irods::error::ok
bool ok()
Definition: irods_error.cpp:258
irods::auth_ptr
boost::shared_ptr< auth > auth_ptr
Definition: irods_auth_types.hpp:19
irods::rule_engine_vars_t
std::map< std::string, std::string > rule_engine_vars_t
Definition: irods_first_class_object.hpp:20