OmniSciDB  c07336695a
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 () const
 
bool hasRole (Role *role, bool only_direct) const
 
const DBObjectMapgetDbObjects (bool only_direct) const
 
void checkCycles (Role *newRole)
 

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 76 of file Grantee.h.

Constructor & Destructor Documentation

◆ Role()

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

Definition at line 78 of file Grantee.h.

78 : Grantee(name) {}
Grantee(const std::string &name)
Definition: Grantee.cpp:23

◆ ~Role()

Role::~Role ( )
override

Definition at line 313 of file Grantee.cpp.

313  {
314  for (auto it = grantees_.begin(); it != grantees_.end();) {
315  auto current_grantee = *it;
316  ++it;
317  current_grantee->revokeRole(this);
318  }
319  grantees_.clear();
320 }
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:93

Member Function Documentation

◆ addGrantee()

void Role::addGrantee ( Grantee grantee)
virtual

Definition at line 322 of file Grantee.cpp.

References Grantee::getName().

Referenced by Grantee::grantRole().

322  {
323  if (grantees_.find(grantee) == grantees_.end()) {
324  grantees_.insert(grantee);
325  } else {
326  throw runtime_error("Role " + getName() + " have been granted to " +
327  grantee->getName() + " already.");
328  }
329 }
const std::string & getName() const
Definition: Grantee.h:52
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:93
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getGrantees()

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

Definition at line 340 of file Grantee.cpp.

Referenced by Grantee::checkCycles().

340  {
341  std::vector<Grantee*> grantees;
342  for (const auto grantee : grantees_) {
343  grantees.push_back(grantee);
344  }
345  return grantees;
346 }
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:93
+ Here is the caller graph for this function:

◆ isUser()

bool Role::isUser ( ) const
inlineoverridevirtual

Implements Grantee.

Definition at line 81 of file Grantee.h.

References Grantee::renameDbObject(), Grantee::revokeAllOnDatabase(), and Grantee::updatePrivileges().

81 { return false; }
+ Here is the call graph for this function:

◆ removeGrantee()

void Role::removeGrantee ( Grantee grantee)
virtual

Definition at line 331 of file Grantee.cpp.

References Grantee::getName().

Referenced by Grantee::revokeRole().

331  {
332  if (grantees_.find(grantee) != grantees_.end()) {
333  grantees_.erase(grantee);
334  } else {
335  throw runtime_error("Role " + getName() + " have not been granted to " +
336  grantee->getName() + " .");
337  }
338 }
const std::string & getName() const
Definition: Grantee.h:52
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:93
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renameDbObject()

void Role::renameDbObject ( const DBObject object)
overridevirtual

Reimplemented from Grantee.

Definition at line 363 of file Grantee.cpp.

References Grantee::renameDbObject().

363  {
364  Grantee::renameDbObject(object);
365  for (auto grantee : grantees_) {
366  grantee->renameDbObject(object);
367  }
368 }
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:93
virtual void renameDbObject(const DBObject &object)
Definition: Grantee.cpp:108
+ Here is the call graph for this function:

◆ revokeAllOnDatabase()

void Role::revokeAllOnDatabase ( int32_t  dbId)
overridevirtual

Reimplemented from Grantee.

Definition at line 348 of file Grantee.cpp.

References Grantee::revokeAllOnDatabase().

348  {
350  for (auto grantee : grantees_) {
351  grantee->revokeAllOnDatabase(dbId);
352  }
353 }
virtual void revokeAllOnDatabase(int32_t dbId)
Definition: Grantee.cpp:279
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:93
+ Here is the call graph for this function:

◆ updatePrivileges()

void Role::updatePrivileges ( )
overridevirtual

Reimplemented from Grantee.

Definition at line 356 of file Grantee.cpp.

References Grantee::updatePrivileges().

356  {
358  for (auto grantee : grantees_) {
359  grantee->updatePrivileges();
360  }
361 }
virtual void updatePrivileges()
Definition: Grantee.cpp:255
std::unordered_set< Grantee * > grantees_
Definition: Grantee.h:93
+ Here is the call graph for this function:

Member Data Documentation

◆ grantees_

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

Definition at line 93 of file Grantee.h.


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