OmniSciDB  eb3a3d0a03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::GrantRoleStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::GrantRoleStmt:
+ Collaboration diagram for Parser::GrantRoleStmt:

Public Member Functions

 GrantRoleStmt (std::list< std::string * > *r, std::list< std::string * > *g)
 
 GrantRoleStmt (const rapidjson::Value &payload)
 
const std::vector< std::string > & get_roles () const
 
const std::vector< std::string > & get_grantees () const
 
void execute (const Catalog_Namespace::SessionInfo &session) override
 
- Public Member Functions inherited from Parser::DDLStmt
void setColumnDescriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Private Attributes

std::vector< std::string > roles_
 
std::vector< std::string > grantees_
 

Detailed Description

Definition at line 1639 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::GrantRoleStmt::GrantRoleStmt ( std::list< std::string * > *  r,
std::list< std::string * > *  g 
)
inline

Definition at line 1641 of file ParserNode.h.

References grantees_, Parser::parser_slistval_to_vector(), and roles_.

1641  {
1644  }
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1548
std::vector< std::string > roles_
Definition: ParserNode.h:1652
std::vector< std::string > grantees_
Definition: ParserNode.h:1653

+ Here is the call graph for this function:

Parser::GrantRoleStmt::GrantRoleStmt ( const rapidjson::Value &  payload)

Definition at line 5499 of file ParserNode.cpp.

References CHECK, grantees_, json_str(), and roles_.

5499  {
5500  if (payload.HasMember("roles")) {
5501  CHECK(payload["roles"].IsArray());
5502  for (auto& role : payload["roles"].GetArray()) {
5503  std::string r = json_str(role);
5504  roles_.emplace_back(r);
5505  }
5506  }
5507  if (payload.HasMember("grantees")) {
5508  CHECK(payload["grantees"].IsArray());
5509  for (auto& grantee : payload["grantees"].GetArray()) {
5510  std::string g = json_str(grantee);
5511  grantees_.emplace_back(g);
5512  }
5513  }
5514 }
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
std::vector< std::string > roles_
Definition: ParserNode.h:1652
std::vector< std::string > grantees_
Definition: ParserNode.h:1653
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

Member Function Documentation

void Parser::GrantRoleStmt::execute ( const Catalog_Namespace::SessionInfo session)
overridevirtual

Implements Parser::DDLStmt.

Definition at line 5516 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::get_currentUser(), get_grantees(), get_roles(), and OMNISCI_ROOT_USER.

Referenced by omnisci.cursor.Cursor::executemany().

5516  {
5517  const auto& currentUser = session.get_currentUser();
5518  if (!currentUser.isSuper) {
5519  throw std::runtime_error(
5520  "GRANT failed, because it can only be executed by super user.");
5521  }
5522  if (std::find(get_grantees().begin(), get_grantees().end(), OMNISCI_ROOT_USER) !=
5523  get_grantees().end()) {
5524  throw std::runtime_error(
5525  "Request to grant role failed because mapd root user has all privileges by "
5526  "default.");
5527  }
5528  SysCatalog::instance().grantRoleBatch(get_roles(), get_grantees());
5529 }
const std::vector< std::string > & get_roles() const
Definition: ParserNode.h:1647
const std::string OMNISCI_ROOT_USER
Definition: SysCatalog.h:60
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1648
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:73

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::vector<std::string>& Parser::GrantRoleStmt::get_grantees ( ) const
inline

Definition at line 1648 of file ParserNode.h.

References grantees_.

Referenced by execute().

1648 { return grantees_; }
std::vector< std::string > grantees_
Definition: ParserNode.h:1653

+ Here is the caller graph for this function:

const std::vector<std::string>& Parser::GrantRoleStmt::get_roles ( ) const
inline

Definition at line 1647 of file ParserNode.h.

References roles_.

Referenced by execute().

1647 { return roles_; }
std::vector< std::string > roles_
Definition: ParserNode.h:1652

+ Here is the caller graph for this function:

Member Data Documentation

std::vector<std::string> Parser::GrantRoleStmt::grantees_
private

Definition at line 1653 of file ParserNode.h.

Referenced by get_grantees(), and GrantRoleStmt().

std::vector<std::string> Parser::GrantRoleStmt::roles_
private

Definition at line 1652 of file ParserNode.h.

Referenced by get_roles(), and GrantRoleStmt().


The documentation for this class was generated from the following files: