2011-06-03 18:58:42 +04:00
/* -------------------------------------------------------------------------- */
2020-04-30 16:00:02 +03:00
/* Copyright 2002-2020, OpenNebula Project, OpenNebula Systems */
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-06-03 18:58:42 +04:00
} ;
~ RequestManagerUser ( ) { } ;
/* -------------------------------------------------------------------- */
2013-08-23 19:46:46 +04:00
void request_execute (
xmlrpc_c : : paramList const & _paramList ,
2019-07-05 18:23:21 +03:00
RequestAttributes & att ) override ;
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 ,
2016-06-29 18:17:18 +03:00
RequestAttributes & att ,
2011-06-03 18:58:42 +04:00
string & error_str ) = 0 ;
/* -------------------------------------------------------------------- */
} ;
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserChangePassword : public RequestManagerUser
{
public :
UserChangePassword ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUser ( " one.user.passwd " ,
2011-06-03 18:58:42 +04:00
" Changes user's password " ,
2011-10-20 19:46:33 +04:00
" A:sis " )
{
auth_op = AuthRequest : : MANAGE ;
2014-10-28 18:23:09 +03:00
hidden_params . insert ( 2 ) ; // password argument
2011-10-20 19:46:33 +04:00
} ;
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 ,
2016-06-29 18:17:18 +03:00
RequestAttributes & att ,
2019-07-05 18:23:21 +03:00
string & err ) override ;
2011-06-03 18:58:42 +04:00
} ;
2011-10-17 17:08:00 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserChangeAuth : public RequestManagerUser
{
public :
UserChangeAuth ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUser ( " one.user.chauth " ,
2011-10-17 17:08:00 +04:00
" 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 ;
2014-10-28 18:23:09 +03:00
hidden_params . insert ( 3 ) ; // new password argument
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 ,
2016-06-29 18:17:18 +03:00
RequestAttributes & att ,
2019-07-05 18:23:21 +03:00
string & err ) override ;
2011-10-17 17:08:00 +04:00
} ;
2012-06-07 02:04:08 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
class UserSetQuota : public RequestManagerUser
{
public :
UserSetQuota ( ) :
2017-05-07 22:52:34 +03:00
RequestManagerUser ( " one.user.quota " ,
2012-06-07 02:04:08 +04:00
" 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 ,
2016-06-29 18:17:18 +03:00
RequestAttributes & att ,
2019-07-05 18:23:21 +03:00
string & err ) override ;
2012-06-07 02:04:08 +04:00
} ;
2013-08-23 15:30:06 +04:00
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
2014-09-07 00:22:40 +04:00
class UserLogin : public Request
{
public :
2017-05-07 22:52:34 +03:00
UserLogin ( ) : Request ( " one.user.login " , " A:sssii " ,
" Generates or sets a login token " )
2014-09-07 00:22:40 +04:00
{
Nebula & nd = Nebula : : instance ( ) ;
pool = nd . get_upool ( ) ;
auth_object = PoolObjectSQL : : USER ;
auth_op = AuthRequest : : MANAGE ;
2014-10-28 18:23:09 +03:00
hidden_params . insert ( 2 ) ; // password argument
2014-09-07 00:22:40 +04:00
} ;
virtual ~ UserLogin ( ) { } ;
void request_execute (
xmlrpc_c : : paramList const & _paramList ,
2019-07-05 18:23:21 +03:00
RequestAttributes & att ) override ;
2014-09-07 00:22:40 +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 ,
2019-07-05 18:23:21 +03:00
RequestAttributes & att ) override ;
2013-08-23 19:46:46 +04:00
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 ( ) :
2017-05-07 22:52:34 +03:00
UserEditGroup ( " one.user.addgroup " ,
2013-08-23 19:46:46 +04:00
" 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 ,
2019-07-05 18:23:21 +03:00
string & error_str ) override ;
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 ( ) :
2017-05-07 22:52:34 +03:00
UserEditGroup ( " one.user.delgroup " ,
2013-08-23 19:46:46 +04:00
" 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 ,
2019-07-05 18:23:21 +03:00
string & error_str ) override ;
2013-08-23 15:30:06 +04:00
} ;
2011-06-03 18:58:42 +04:00
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
# endif