OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Role Class Reference

#include <Grantee.h>

+ Inheritance diagram for Role:
+ Collaboration diagram for Role:

Public Member Functions

 Role (const std::string &name)
 
 ~Role () override
 
bool isUser () const override
 
void updatePrivileges () override
 
void renameDbObject (const DBObject &object) override
 
virtual void addGrantee (Grantee *grantee)
 
virtual void removeGrantee (Grantee *grantee)
 
void revokeAllOnDatabase (int32_t dbId) override
 
std::vector< Grantee * > getGrantees () const
 
- Public Member Functions inherited from Grantee
 Grantee (const std::string &name)
 
virtual ~Grantee ()
 
virtual void grantPrivileges (const DBObject &object)
 
virtual DBObjectrevokePrivileges (const DBObject &object)
 
virtual void grantRole (Role *role)
 
virtual void revokeRole (Role *role)
 
virtual bool hasAnyPrivileges (const DBObject &objectRequested, bool only_direct) const
 
virtual bool checkPrivileges (const DBObject &objectRequested) const
 
virtual void updatePrivileges (Role *role)
 
void getPrivileges (DBObject &object, bool only_direct)
 
DBObjectfindDbObject (const DBObjectKey &objectKey, bool only_direct) const
 
bool hasAnyPrivilegesOnDb (int32_t dbId, bool only_direct) const
 
const std::string & getName () const
 
void setName (const std::string &name)
 
std::vector< std::string > getRoles (bool only_direct=true) const
 
bool hasRole (Role *role, bool only_direct) const
 
const DBObjectMapgetDbObjects (bool only_direct) const
 
void checkCycles (Role *newRole)
 
void reassignObjectOwners (const std::set< int32_t > &old_owner_ids, int32_t new_owner_id, int32_t db_id)
 
void reassignObjectOwner (DBObjectKey &object_key, int32_t new_owner_id)
 

Private Attributes

std::unordered_set< Grantee * > grantees_
 

Additional Inherited Members

- Protected Attributes inherited from Grantee
std::string name_
 
std::unordered_set< Role * > roles_
 
DBObjectMap effectivePrivileges_
 
DBObjectMap directPrivileges_
 

Detailed Description

Definition at line 81 of file Grantee.h.

Constructor & Destructor Documentation

Role::Role ( const std::string &  name)
inline

Definition at line 83 of file Grantee.h.

83 : Grantee(name) {}
Grantee(const std::string &name)
Definition: Grantee.cpp:26
string name
Definition: setup.in.py:72
Role::~Role ( )
override

Definition at line 362 of file Grantee.cpp.

References grantees_.

362  {
363  for (auto it = grantees_.begin(); it != grantees_.end();) {
364  auto current_grantee = *it;
365  ++it;
366  current_grantee->revokeRole(this);
367  }
368  grantees_.clear();
369 }
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:98

Member Function Documentation

void Role::addGrantee ( Grantee grantee)
virtual

Definition at line 371 of file Grantee.cpp.

References Grantee::getName(), and grantees_.

Referenced by Grantee::grantRole().

371  {
372  if (grantees_.find(grantee) == grantees_.end()) {
373  grantees_.insert(grantee);
374  } else {
375  throw runtime_error("Role " + getName() + " have been granted to " +
376  grantee->getName() + " already.");
377  }
378 }
const std::string & getName() const
Definition: Grantee.h:52
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector< Grantee * > Role::getGrantees ( ) const

Definition at line 389 of file Grantee.cpp.

References grantees_.

Referenced by Grantee::checkCycles().

389  {
390  std::vector<Grantee*> grantees;
391  for (const auto grantee : grantees_) {
392  grantees.push_back(grantee);
393  }
394  return grantees;
395 }
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:98

+ Here is the caller graph for this function:

bool Role::isUser ( ) const
inlineoverridevirtual

Implements Grantee.

Definition at line 86 of file Grantee.h.

86 { return false; }
void Role::removeGrantee ( Grantee grantee)
virtual

Definition at line 380 of file Grantee.cpp.

References Grantee::getName(), and grantees_.

Referenced by Grantee::revokeRole().

380  {
381  if (grantees_.find(grantee) != grantees_.end()) {
382  grantees_.erase(grantee);
383  } else {
384  throw runtime_error("Role " + getName() + " have not been granted to " +
385  grantee->getName() + " .");
386  }
387 }
const std::string & getName() const
Definition: Grantee.h:52
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Role::renameDbObject ( const DBObject object)
overridevirtual

Reimplemented from Grantee.

Definition at line 412 of file Grantee.cpp.

References grantees_, and Grantee::renameDbObject().

412  {
413  Grantee::renameDbObject(object);
414  for (auto grantee : grantees_) {
415  grantee->renameDbObject(object);
416  }
417 }
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:98
virtual void renameDbObject(const DBObject &object)
Definition: Grantee.cpp:121

+ Here is the call graph for this function:

void Role::revokeAllOnDatabase ( int32_t  dbId)
overridevirtual

Reimplemented from Grantee.

Definition at line 397 of file Grantee.cpp.

References grantees_, and Grantee::revokeAllOnDatabase().

397  {
399  for (auto grantee : grantees_) {
400  grantee->revokeAllOnDatabase(dbId);
401  }
402 }
virtual void revokeAllOnDatabase(int32_t dbId)
Definition: Grantee.cpp:296
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:98

+ Here is the call graph for this function:

void Role::updatePrivileges ( )
overridevirtual

Reimplemented from Grantee.

Definition at line 405 of file Grantee.cpp.

References grantees_, and Grantee::updatePrivileges().

405  {
407  for (auto grantee : grantees_) {
408  grantee->updatePrivileges();
409  }
410 }
virtual void updatePrivileges()
Definition: Grantee.cpp:268
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:98

+ Here is the call graph for this function:

Member Data Documentation

std::unordered_set<Grantee*> Role::grantees_
private

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