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