OmniSciDB  d2f719934e
 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) {}
string name
Definition: setup.in.py:72
Grantee(const std::string &name)
Definition: Grantee.cpp:26
Role::~Role ( )
override

Definition at line 358 of file Grantee.cpp.

References grantees_.

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

Member Function Documentation

void Role::addGrantee ( Grantee grantee)
virtual

Definition at line 367 of file Grantee.cpp.

References Grantee::getName(), and grantees_.

Referenced by Grantee::grantRole().

367  {
368  if (grantees_.find(grantee) == grantees_.end()) {
369  grantees_.insert(grantee);
370  } else {
371  throw runtime_error("Role " + getName() + " have been granted to " +
372  grantee->getName() + " already.");
373  }
374 }
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 385 of file Grantee.cpp.

References grantees_.

Referenced by Grantee::checkCycles().

385  {
386  std::vector<Grantee*> grantees;
387  for (const auto grantee : grantees_) {
388  grantees.push_back(grantee);
389  }
390  return grantees;
391 }
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 376 of file Grantee.cpp.

References Grantee::getName(), and grantees_.

Referenced by Grantee::revokeRole().

376  {
377  if (grantees_.find(grantee) != grantees_.end()) {
378  grantees_.erase(grantee);
379  } else {
380  throw runtime_error("Role " + getName() + " have not been granted to " +
381  grantee->getName() + " .");
382  }
383 }
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 408 of file Grantee.cpp.

References grantees_, and Grantee::renameDbObject().

408  {
409  Grantee::renameDbObject(object);
410  for (auto grantee : grantees_) {
411  grantee->renameDbObject(object);
412  }
413 }
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 393 of file Grantee.cpp.

References grantees_, and Grantee::revokeAllOnDatabase().

393  {
395  for (auto grantee : grantees_) {
396  grantee->revokeAllOnDatabase(dbId);
397  }
398 }
virtual void revokeAllOnDatabase(int32_t dbId)
Definition: Grantee.cpp:292
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 401 of file Grantee.cpp.

References grantees_, and Grantee::updatePrivileges().

401  {
403  for (auto grantee : grantees_) {
404  grantee->updatePrivileges();
405  }
406 }
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: