2011-06-03 18:58:42 +04:00
/* -------------------------------------------------------------------------- */
2014-01-09 14:51:20 +04:00
/* Copyright 2002-2014, OpenNebula Project (OpenNebula.org), C12G Labs */
2011-06-03 18:58:42 +04:00
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
# ifndef REQUEST_MANAGER_USER_H
# define REQUEST_MANAGER_USER_H
# include "Request.h"
# include "Nebula.h"
using namespace std ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class RequestManagerUser : public Request
{
protected :
RequestManagerUser ( const string & method_name ,
const string & help ,
const string & params )
: Request ( method_name , params , help )
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_upool ( ) ;
2012-01-03 05:58:23 +04:00
auth_object = PoolObjectSQL : : USER ;
2011-10-20 19:46:33 +04:00
2011-06-03 18:58:42 +04:00
} ;
~ RequestManagerUser ( ) { } ;
/* -------------------------------------------------------------------- */
2013-08-23 19:46:46 +04:00
void request_execute (
xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att ) ;
2011-06-03 18:58:42 +04:00
2011-12-20 01:42:33 +04:00
virtual int user_action ( int user_id ,
2011-06-03 18:58:42 +04:00
xmlrpc_c : : paramList const & _paramList ,
string & error_str ) = 0 ;
/* -------------------------------------------------------------------- */
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserChangePassword : public RequestManagerUser
{
public :
UserChangePassword ( ) :
RequestManagerUser ( " UserChangePassword " ,
" Changes user's password " ,
2011-10-20 19:46:33 +04:00
" A:sis " )
{
auth_op = AuthRequest : : MANAGE ;
} ;
2011-06-03 18:58:42 +04:00
~ UserChangePassword ( ) { } ;
2011-12-20 01:42:33 +04:00
int user_action ( int user_id ,
2013-08-30 18:50:04 +04:00
xmlrpc_c : : paramList const & _paramList ,
2011-06-03 18:58:42 +04:00
string & err ) ;
2012-10-02 18:25:57 +04:00
void log_xmlrpc_param (
const xmlrpc_c : : value & v ,
ostringstream & oss ,
const int & index ) ;
2011-06-03 18:58:42 +04:00
} ;
2011-10-17 17:08:00 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserChangeAuth : public RequestManagerUser
{
public :
UserChangeAuth ( ) :
RequestManagerUser ( " UserChangeAuth " ,
" Changes user's authentication driver " ,
2011-10-20 20:58:40 +04:00
" A:siss " )
2011-10-20 19:46:33 +04:00
{
2012-01-02 07:53:22 +04:00
auth_op = AuthRequest : : ADMIN ;
2011-10-20 19:46:33 +04:00
} ;
2011-10-17 17:08:00 +04:00
~ UserChangeAuth ( ) { } ;
2011-12-20 01:42:33 +04:00
int user_action ( int user_id ,
2011-10-17 17:08:00 +04:00
xmlrpc_c : : paramList const & _paramList ,
string & err ) ;
2012-10-02 18:25:57 +04:00
void log_xmlrpc_param (
const xmlrpc_c : : value & v ,
ostringstream & oss ,
const int & index ) ;
2011-10-17 17:08:00 +04:00
} ;
2012-06-07 02:04:08 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserSetQuota : public RequestManagerUser
{
public :
UserSetQuota ( ) :
RequestManagerUser ( " UserSetQuota " ,
" Sets user quota limits " ,
" A:sis " )
{
auth_op = AuthRequest : : ADMIN ;
} ;
~ UserSetQuota ( ) { } ;
int user_action ( int user_id ,
2013-08-30 18:50:04 +04:00
xmlrpc_c : : paramList const & _paramList ,
2012-06-07 02:04:08 +04:00
string & err ) ;
} ;
2013-08-23 15:30:06 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2013-08-23 19:46:46 +04:00
class UserEditGroup : public Request
2013-08-23 15:30:06 +04:00
{
public :
2013-08-23 19:46:46 +04:00
UserEditGroup (
const string & method_name ,
const string & help ,
const string & params ) :
Request ( method_name , params , help )
2013-08-23 15:30:06 +04:00
{
2013-08-23 19:46:46 +04:00
auth_object = PoolObjectSQL : : USER ;
2013-08-30 18:50:04 +04:00
auth_op = AuthRequest : : MANAGE ;
2013-08-23 19:46:46 +04:00
Nebula & nd = Nebula : : instance ( ) ;
gpool = nd . get_gpool ( ) ;
upool = nd . get_upool ( ) ;
2013-08-23 15:30:06 +04:00
} ;
2013-08-23 19:46:46 +04:00
~ UserEditGroup ( ) { } ;
void request_execute (
xmlrpc_c : : paramList const & _paramList ,
RequestAttributes & att ) ;
2013-08-30 18:50:04 +04:00
protected :
2013-08-23 19:46:46 +04:00
virtual int secondary_group_action (
int user_id ,
int group_id ,
xmlrpc_c : : paramList const & _paramList ,
string & error_str ) = 0 ;
GroupPool * gpool ;
2013-08-30 18:50:04 +04:00
2013-08-23 19:46:46 +04:00
UserPool * upool ;
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserAddGroup : public UserEditGroup
{
public :
UserAddGroup ( ) :
UserEditGroup ( " UserAddGroup " ,
" Adds the user to a secondary group " ,
" A:sii " ) { } ;
2013-08-23 15:30:06 +04:00
~ UserAddGroup ( ) { } ;
2013-08-23 19:46:46 +04:00
int secondary_group_action (
int user_id ,
int group_id ,
xmlrpc_c : : paramList const & _paramList ,
string & error_str ) ;
2013-08-23 15:30:06 +04:00
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2013-08-23 19:46:46 +04:00
class UserDelGroup : public UserEditGroup
2013-08-23 15:30:06 +04:00
{
public :
UserDelGroup ( ) :
2013-08-23 19:46:46 +04:00
UserEditGroup ( " UserDelGroup " ,
" Deletes the user from a secondary group " ,
" A:sii " ) { } ;
2013-08-23 15:30:06 +04:00
~ UserDelGroup ( ) { } ;
2013-08-23 19:46:46 +04:00
int secondary_group_action (
int user_id ,
int group_id ,
xmlrpc_c : : paramList const & _paramList ,
string & error_str ) ;
2013-08-23 15:30:06 +04:00
} ;
2011-06-03 18:58:42 +04:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
# endif