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

#include <ParserNode.h>

+ Inheritance diagram for Parser::RevokeRoleStmt:
+ Collaboration diagram for Parser::RevokeRoleStmt:

Public Member Functions

 RevokeRoleStmt (std::list< std::string * > *r, std::list< std::string * > *g)
 
 RevokeRoleStmt (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, bool read_only_mode) 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 1670 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1672 of file ParserNode.h.

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

1672  {
1675  }
std::vector< std::string > grantees_
Definition: ParserNode.h:1685
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1554
std::vector< std::string > roles_
Definition: ParserNode.h:1684

+ Here is the call graph for this function:

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

Definition at line 6102 of file ParserNode.cpp.

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

6102  {
6103  if (payload.HasMember("roles")) {
6104  CHECK(payload["roles"].IsArray());
6105  for (auto& role : payload["roles"].GetArray()) {
6106  std::string r = json_str(role);
6107  roles_.emplace_back(r);
6108  }
6109  }
6110  if (payload.HasMember("grantees")) {
6111  CHECK(payload["grantees"].IsArray());
6112  for (auto& grantee : payload["grantees"].GetArray()) {
6113  std::string g = json_str(grantee);
6114  grantees_.emplace_back(g);
6115  }
6116  }
6117 }
std::vector< std::string > grantees_
Definition: ParserNode.h:1685
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
std::vector< std::string > roles_
Definition: ParserNode.h:1684
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

Member Function Documentation

void Parser::RevokeRoleStmt::execute ( const Catalog_Namespace::SessionInfo session,
bool  read_only_mode 
)
overridevirtual

Implements Parser::DDLStmt.

Definition at line 6119 of file ParserNode.cpp.

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

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

6120  {
6121  if (read_only_mode) {
6122  throw std::runtime_error("REVOKE ROLE invalid in read only mode.");
6123  }
6124  const auto& currentUser = session.get_currentUser();
6125  if (!currentUser.isSuper) {
6126  throw std::runtime_error(
6127  "REVOKE failed, because it can only be executed by super user.");
6128  }
6129  if (std::find(get_grantees().begin(), get_grantees().end(), shared::kRootUsername) !=
6130  get_grantees().end()) {
6131  throw std::runtime_error(
6132  "Request to revoke role failed because privileges can not be revoked from "
6133  "mapd root user.");
6134  }
6135  SysCatalog::instance().revokeRoleBatch(get_roles(), get_grantees());
6136 }
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1679
const std::vector< std::string > & get_roles() const
Definition: ParserNode.h:1678
const std::string kRootUsername
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1679 of file ParserNode.h.

References grantees_.

Referenced by execute().

1679 { return grantees_; }
std::vector< std::string > grantees_
Definition: ParserNode.h:1685

+ Here is the caller graph for this function:

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

Definition at line 1678 of file ParserNode.h.

References roles_.

Referenced by execute().

1678 { return roles_; }
std::vector< std::string > roles_
Definition: ParserNode.h:1684

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 1685 of file ParserNode.h.

Referenced by get_grantees(), and RevokeRoleStmt().

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

Definition at line 1684 of file ParserNode.h.

Referenced by get_roles(), and RevokeRoleStmt().


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