TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
rbac::RBACData Class Reference

#include <RBAC.h>

Public Member Functions

 RBACData (uint32 id, std::string const &name, int32 realmId, uint8 secLevel=255)
 
std::string constGetName () const
 Gets the Name of the Object. More...
 
uint32 GetId () const
 Gets the Id of the Object. More...
 
HasPermission

Checks if certain action is allowed

Checks if certain action can be performed.

Returns
grant or deny action

Example Usage:

bool Player::CanJoinArena(Battleground* bg)
{
return bg->isArena() && HasPermission(RBAC_PERM_JOIN_ARENA);
}
bool HasPermission (uint32 permission) const
 
RBACPermissionContainer constGetPermissions () const
 Returns all the granted permissions (after computation) More...
 
RBACPermissionContainer constGetGrantedPermissions () const
 Returns all the granted permissions. More...
 
RBACPermissionContainer constGetDeniedPermissions () const
 Returns all the denied permissions. More...
 
GrantRole

Grants a permission

Grants a permission to the account. If realm is 0 or the permission can not be added No save to db action will be performed.

Fails if permission Id does not exists or permission already granted or denied

Parameters
permissionIdpermission to be granted
realmIdrealm affected
Returns
Success or failure (with reason) to grant the permission

Example Usage:

// previously defined "RBACData* rbac" with proper initialization
uint32 permissionId = 2;
if (rbac->GrantRole(permissionId) == RBAC_IN_DENIED_LIST)
TC_LOG_DEBUG("entities.player", "Failed to grant permission %u, already denied", permissionId);
RBACCommandResult GrantPermission (uint32 permissionId, int32 realmId=0)
 
DenyPermission

Denies a permission

Denied a permission to the account. If realm is 0 or the permission can not be added No save to db action will be performed.

Fails if permission Id does not exists or permission already granted or denied

Parameters
permissionIdpermission to be denied
realmIdrealm affected
Returns
Success or failure (with reason) to deny the permission

Example Usage:

// previously defined "RBACData* rbac" with proper initialization
uint32 permissionId = 2;
if (rbac->DenyRole(permissionId) == RBAC_ID_DOES_NOT_EXISTS)
TC_LOG_DEBUG("entities.player", "Role Id %u does not exists", permissionId);
RBACCommandResult DenyPermission (uint32 permissionId, int32 realmId=0)
 

Private Member Functions

CalculateNewPermissions

Calculates new permissions

Calculates new permissions after some change The calculation is done Granted - Denied:

  • Granted permissions: through linked permissions and directly assigned
  • Denied permissions: through linked permissions and directly assigned
void CalculateNewPermissions ()
 
int32 GetRealmId () const
 
bool HasGrantedPermission (uint32 permissionId) const
 Checks if a permission is granted. More...
 
bool HasDeniedPermission (uint32 permissionId) const
 Checks if a permission is denied. More...
 
void AddGrantedPermission (uint32 permissionId)
 Adds a new granted permission. More...
 
void RemoveGrantedPermission (uint32 permissionId)
 Removes a granted permission. More...
 
void AddDeniedPermission (uint32 permissionId)
 Adds a new denied permission. More...
 
void RemoveDeniedPermission (uint32 permissionId)
 Removes a denied permission. More...
 
void AddPermissions (RBACPermissionContainer const &permsFrom, RBACPermissionContainer &permsTo)
 Adds a list of permissions to another list. More...
 
void RemovePermissions (RBACPermissionContainer &permsFrom, RBACPermissionContainer const &permsToRemove)
 Removes a list of permissions from another list. More...
 

RevokePermission

Removes a permission

Removes a permission from the account. If realm is 0 or the permission can not be removed No save to db action will be performed. Any delete operation will always affect "all realms (-1)" in addition to the realm specified

Fails if permission not present

Parameters
permissionIdpermission to be removed
realmIdrealm affected
Returns
Success or failure (with reason) to remove the permission

Example Usage:

// previously defined "RBACData* rbac" with proper initialization
uint32 permissionId = 2;
if (rbac->RevokeRole(permissionId) == RBAC_OK)
TC_LOG_DEBUG("entities.player", "Permission %u succesfully removed", permissionId);
RBACCommandResult RevokePermission (uint32 permissionId, int32 realmId=0)
 
void LoadFromDB ()
 Loads all permissions assigned to current account. More...
 
PreparedQueryResultFuture LoadFromDBAsync ()
 
void LoadFromDBCallback (PreparedQueryResult result)
 
void SetSecurityLevel (uint8 id)
 Sets security level. More...
 
uint8 GetSecurityLevel () const
 Returns the security level assigned. More...
 
void SavePermission (uint32 role, bool granted, int32 realm)
 Saves a permission to DB, Granted or Denied. More...
 
void ClearData ()
 Clears roles, groups and permissions - Used for reload. More...
 

ExpandPermissions

Adds the list of linked permissions to the original list

Given a list of permissions, gets all the inherited permissions

Parameters
permissionsThe list of permissions to expand
uint32 _id
 
std::string _name
 

Account id

More...
 
int32 _realmId
 

Account name

More...
 
uint8 _secLevel
 

RealmId Affected

More...
 
RBACPermissionContainer _grantedPerms
 

Account SecurityLevel

More...
 
RBACPermissionContainer _deniedPerms
 

Granted permissions

More...
 
RBACPermissionContainer _globalPerms
 

Denied permissions

More...
 
void ExpandPermissions (RBACPermissionContainer &permissions)
 

Constructor & Destructor Documentation

rbac::RBACData::RBACData ( uint32  id,
std::string const name,
int32  realmId,
uint8  secLevel = 255 
)
inline
786  :
787  _id(id), _name(name), _realmId(realmId), _secLevel(secLevel),
uint8 _secLevel
RealmId Affected
Definition: RBAC.h:987
int32 _realmId
Account name
Definition: RBAC.h:986
RBACPermissionContainer _deniedPerms
Granted permissions
Definition: RBAC.h:989
RBACPermissionContainer _grantedPerms
Account SecurityLevel
Definition: RBAC.h:988
std::string _name
Account id
Definition: RBAC.h:985
RBACPermissionContainer _globalPerms
Denied permissions
Definition: RBAC.h:990
uint32 _id
Definition: RBAC.h:984

Member Function Documentation

void rbac::RBACData::AddDeniedPermission ( uint32  permissionId)
inlineprivate

Adds a new denied permission.

959  {
960  _deniedPerms.insert(permissionId);
961  }
RBACPermissionContainer _deniedPerms
Granted permissions
Definition: RBAC.h:989

+ Here is the caller graph for this function:

void rbac::RBACData::AddGrantedPermission ( uint32  permissionId)
inlineprivate

Adds a new granted permission.

947  {
948  _grantedPerms.insert(permissionId);
949  }
RBACPermissionContainer _grantedPerms
Account SecurityLevel
Definition: RBAC.h:988

+ Here is the caller graph for this function:

void rbac::RBACData::AddPermissions ( RBACPermissionContainer const permsFrom,
RBACPermissionContainer permsTo 
)
private

Adds a list of permissions to another list.

234 {
235  for (RBACPermissionContainer::const_iterator itr = permsFrom.begin(); itr != permsFrom.end(); ++itr)
236  permsTo.insert(*itr);
237 }
void rbac::RBACData::CalculateNewPermissions ( )
private
222 {
223  TC_LOG_TRACE("rbac", "RBACData::CalculateNewPermissions [Id: %u Name: %s]", GetId(), GetName().c_str());
224 
225  // Get the list of granted permissions
229  ExpandPermissions(revoked);
231 }
RBACPermissionContainer const & GetDeniedPermissions() const
Returns all the denied permissions.
Definition: RBAC.h:822
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
std::string const & GetName() const
Gets the Name of the Object.
Definition: RBAC.h:791
void RemovePermissions(RBACPermissionContainer &permsFrom, RBACPermissionContainer const &permsToRemove)
Removes a list of permissions from another list.
Definition: RBAC.cpp:239
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
RBACPermissionContainer const & GetGrantedPermissions() const
Returns all the granted permissions.
Definition: RBAC.h:820
RBACPermissionContainer _globalPerms
Denied permissions
Definition: RBAC.h:990
void ExpandPermissions(RBACPermissionContainer &permissions)
Definition: RBAC.cpp:245
std::set< uint32 > RBACPermissionContainer
Definition: RBAC.h:746

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rbac::RBACData::ClearData ( )
private

Clears roles, groups and permissions - Used for reload.

274 {
275  _grantedPerms.clear();
276  _deniedPerms.clear();
277  _globalPerms.clear();
278 }
RBACPermissionContainer _deniedPerms
Granted permissions
Definition: RBAC.h:989
RBACPermissionContainer _grantedPerms
Account SecurityLevel
Definition: RBAC.h:988
RBACPermissionContainer _globalPerms
Denied permissions
Definition: RBAC.h:990

+ Here is the caller graph for this function:

RBACCommandResult rbac::RBACData::DenyPermission ( uint32  permissionId,
int32  realmId = 0 
)
86 {
87  // Check if permission Id exists
88  RBACPermission const* perm = sAccountMgr->GetRBACPermission(permissionId);
89  if (!perm)
90  {
91  TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission does not exists",
92  GetId(), GetName().c_str(), permissionId, realmId);
94  }
95 
96  // Check if already added in granted list
97  if (HasGrantedPermission(permissionId))
98  {
99  TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission in grant list",
100  GetId(), GetName().c_str(), permissionId, realmId);
101  return RBAC_IN_GRANTED_LIST;
102  }
103 
104  // Already added?
105  if (HasDeniedPermission(permissionId))
106  {
107  TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission already denied",
108  GetId(), GetName().c_str(), permissionId, realmId);
110  }
111 
112  AddDeniedPermission(permissionId);
113 
114  // Do not save to db when loading data from DB (realmId = 0)
115  if (realmId)
116  {
117  TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
118  GetId(), GetName().c_str(), permissionId, realmId);
119  SavePermission(permissionId, false, realmId);
121  }
122  else
123  TC_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
124  GetId(), GetName().c_str(), permissionId, realmId);
125 
126  return RBAC_OK;
127 }
Definition: RBAC.h:743
void AddDeniedPermission(uint32 permissionId)
Adds a new denied permission.
Definition: RBAC.h:958
Definition: RBAC.h:738
bool HasGrantedPermission(uint32 permissionId) const
Checks if a permission is granted.
Definition: RBAC.h:934
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
bool HasDeniedPermission(uint32 permissionId) const
Checks if a permission is denied.
Definition: RBAC.h:940
std::string const & GetName() const
Gets the Name of the Object.
Definition: RBAC.h:791
void SavePermission(uint32 role, bool granted, int32 realm)
Saves a permission to DB, Granted or Denied.
Definition: RBAC.cpp:129
void CalculateNewPermissions()
Definition: RBAC.cpp:221
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
Definition: RBAC.h:739
Definition: RBAC.h:741
#define sAccountMgr
Definition: AccountMgr.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rbac::RBACData::ExpandPermissions ( RBACPermissionContainer permissions)
private
246 {
247  RBACPermissionContainer toCheck = permissions;
248  permissions.clear();
249 
250  while (!toCheck.empty())
251  {
252  // remove the permission from original list
253  uint32 permissionId = *toCheck.begin();
254  toCheck.erase(toCheck.begin());
255 
256  RBACPermission const* permission = sAccountMgr->GetRBACPermission(permissionId);
257  if (!permission)
258  continue;
259 
260  // insert into the final list (expanded list)
261  permissions.insert(permissionId);
262 
263  // add all linked permissions (that are not already expanded) to the list of permissions to be checked
264  RBACPermissionContainer const& linkedPerms = permission->GetLinkedPermissions();
265  for (RBACPermissionContainer::const_iterator itr = linkedPerms.begin(); itr != linkedPerms.end(); ++itr)
266  if (permissions.find(*itr) == permissions.end())
267  toCheck.insert(*itr);
268  }
269 
270  TC_LOG_DEBUG("rbac", "RBACData::ExpandPermissions: Expanded: %s", GetDebugPermissionString(permissions).c_str());
271 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32_t uint32
Definition: Define.h:150
#define sAccountMgr
Definition: AccountMgr.h:98
std::set< uint32 > RBACPermissionContainer
Definition: RBAC.h:746
std::string GetDebugPermissionString(RBACPermissionContainer const &perms)
Definition: RBAC.cpp:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RBACPermissionContainer const& rbac::RBACData::GetDeniedPermissions ( ) const
inline

Returns all the denied permissions.

822 { return _deniedPerms; }
RBACPermissionContainer _deniedPerms
Granted permissions
Definition: RBAC.h:989

+ Here is the caller graph for this function:

RBACPermissionContainer const& rbac::RBACData::GetGrantedPermissions ( ) const
inline

Returns all the granted permissions.

820 { return _grantedPerms; }
RBACPermissionContainer _grantedPerms
Account SecurityLevel
Definition: RBAC.h:988

+ Here is the caller graph for this function:

uint32 rbac::RBACData::GetId ( ) const
inline

Gets the Id of the Object.

793 { return _id; }
uint32 _id
Definition: RBAC.h:984

+ Here is the caller graph for this function:

std::string const& rbac::RBACData::GetName ( ) const
inline

Gets the Name of the Object.

791 { return _name; }
std::string _name
Account id
Definition: RBAC.h:985

+ Here is the caller graph for this function:

RBACPermissionContainer const& rbac::RBACData::GetPermissions ( ) const
inline

Returns all the granted permissions (after computation)

818 { return _globalPerms; }
RBACPermissionContainer _globalPerms
Denied permissions
Definition: RBAC.h:990
int32 rbac::RBACData::GetRealmId ( ) const
inlineprivate
928 { return _realmId; }
int32 _realmId
Account name
Definition: RBAC.h:986

+ Here is the caller graph for this function:

uint8 rbac::RBACData::GetSecurityLevel ( ) const
inline

Returns the security level assigned.

910 { return _secLevel; }
uint8 _secLevel
RealmId Affected
Definition: RBAC.h:987

+ Here is the caller graph for this function:

RBACCommandResult rbac::RBACData::GrantPermission ( uint32  permissionId,
int32  realmId = 0 
)
42 {
43  // Check if permission Id exists
44  RBACPermission const* perm = sAccountMgr->GetRBACPermission(permissionId);
45  if (!perm)
46  {
47  TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission does not exists",
48  GetId(), GetName().c_str(), permissionId, realmId);
50  }
51 
52  // Check if already added in denied list
53  if (HasDeniedPermission(permissionId))
54  {
55  TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission in deny list",
56  GetId(), GetName().c_str(), permissionId, realmId);
57  return RBAC_IN_DENIED_LIST;
58  }
59 
60  // Already added?
61  if (HasGrantedPermission(permissionId))
62  {
63  TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission already granted",
64  GetId(), GetName().c_str(), permissionId, realmId);
66  }
67 
68  AddGrantedPermission(permissionId);
69 
70  // Do not save to db when loading data from DB (realmId = 0)
71  if (realmId)
72  {
73  TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
74  GetId(), GetName().c_str(), permissionId, realmId);
75  SavePermission(permissionId, true, realmId);
77  }
78  else
79  TC_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
80  GetId(), GetName().c_str(), permissionId, realmId);
81 
82  return RBAC_OK;
83 }
Definition: RBAC.h:743
void AddGrantedPermission(uint32 permissionId)
Adds a new granted permission.
Definition: RBAC.h:946
Definition: RBAC.h:738
bool HasGrantedPermission(uint32 permissionId) const
Checks if a permission is granted.
Definition: RBAC.h:934
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
bool HasDeniedPermission(uint32 permissionId) const
Checks if a permission is denied.
Definition: RBAC.h:940
std::string const & GetName() const
Gets the Name of the Object.
Definition: RBAC.h:791
Definition: RBAC.h:742
void SavePermission(uint32 role, bool granted, int32 realm)
Saves a permission to DB, Granted or Denied.
Definition: RBAC.cpp:129
void CalculateNewPermissions()
Definition: RBAC.cpp:221
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
Definition: RBAC.h:739
#define sAccountMgr
Definition: AccountMgr.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool rbac::RBACData::HasDeniedPermission ( uint32  permissionId) const
inlineprivate

Checks if a permission is denied.

941  {
942  return _deniedPerms.find(permissionId) != _deniedPerms.end();
943  }
RBACPermissionContainer _deniedPerms
Granted permissions
Definition: RBAC.h:989

+ Here is the caller graph for this function:

bool rbac::RBACData::HasGrantedPermission ( uint32  permissionId) const
inlineprivate

Checks if a permission is granted.

935  {
936  return _grantedPerms.find(permissionId) != _grantedPerms.end();
937  }
RBACPermissionContainer _grantedPerms
Account SecurityLevel
Definition: RBAC.h:988

+ Here is the caller graph for this function:

bool rbac::RBACData::HasPermission ( uint32  permission) const
inline
812  {
813  return _globalPerms.find(permission) != _globalPerms.end();
814  }
RBACPermissionContainer _globalPerms
Denied permissions
Definition: RBAC.h:990

+ Here is the caller graph for this function:

void rbac::RBACData::LoadFromDB ( )

Loads all permissions assigned to current account.

173 {
174  ClearData();
175 
176  TC_LOG_DEBUG("rbac", "RBACData::LoadFromDB [Id: %u Name: %s]: Loading permissions", GetId(), GetName().c_str());
177  // Load account permissions (granted and denied) that affect current realm
179  stmt->setUInt32(0, GetId());
180  stmt->setInt32(1, GetRealmId());
181 
183 }
Definition: LoginDatabase.h:106
void LoadFromDBCallback(PreparedQueryResult result)
Definition: RBAC.cpp:198
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: PreparedStatement.h:74
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
std::string const & GetName() const
Gets the Name of the Object.
Definition: RBAC.h:791
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:151
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
int32 GetRealmId() const
Definition: RBAC.h:928
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
void ClearData()
Clears roles, groups and permissions - Used for reload.
Definition: RBAC.cpp:273

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PreparedQueryResultFuture rbac::RBACData::LoadFromDBAsync ( )
186 {
187  ClearData();
188 
189  TC_LOG_DEBUG("rbac", "RBACData::LoadFromDB [Id: %u Name: %s]: Loading permissions", GetId(), GetName().c_str());
190  // Load account permissions (granted and denied) that affect current realm
192  stmt->setUInt32(0, GetId());
193  stmt->setInt32(1, GetRealmId());
194 
195  return LoginDatabase.AsyncQuery(stmt);
196 }
Definition: LoginDatabase.h:106
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
Definition: PreparedStatement.h:74
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
std::string const & GetName() const
Gets the Name of the Object.
Definition: RBAC.h:791
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:151
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
int32 GetRealmId() const
Definition: RBAC.h:928
void ClearData()
Clears roles, groups and permissions - Used for reload.
Definition: RBAC.cpp:273

+ Here is the call graph for this function:

void rbac::RBACData::LoadFromDBCallback ( PreparedQueryResult  result)
199 {
200  if (result)
201  {
202  do
203  {
204  Field* fields = result->Fetch();
205  if (fields[1].GetBool())
206  GrantPermission(fields[0].GetUInt32());
207  else
208  DenyPermission(fields[0].GetUInt32());
209  } while (result->NextRow());
210  }
211 
212  // Add default permissions
213  RBACPermissionContainer const& permissions = sAccountMgr->GetRBACDefaultPermissions(_secLevel);
214  for (RBACPermissionContainer::const_iterator itr = permissions.begin(); itr != permissions.end(); ++itr)
215  GrantPermission(*itr);
216 
217  // Force calculation of permissions
219 }
Class used to access individual fields of database query result.
Definition: Field.h:56
uint8 _secLevel
RealmId Affected
Definition: RBAC.h:987
RBACCommandResult GrantPermission(uint32 permissionId, int32 realmId=0)
Definition: RBAC.cpp:41
void CalculateNewPermissions()
Definition: RBAC.cpp:221
#define sAccountMgr
Definition: AccountMgr.h:98
std::set< uint32 > RBACPermissionContainer
Definition: RBAC.h:746
RBACCommandResult DenyPermission(uint32 permissionId, int32 realmId=0)
Definition: RBAC.cpp:85

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rbac::RBACData::RemoveDeniedPermission ( uint32  permissionId)
inlineprivate

Removes a denied permission.

965  {
966  _deniedPerms.erase(permissionId);
967  }
RBACPermissionContainer _deniedPerms
Granted permissions
Definition: RBAC.h:989

+ Here is the caller graph for this function:

void rbac::RBACData::RemoveGrantedPermission ( uint32  permissionId)
inlineprivate

Removes a granted permission.

953  {
954  _grantedPerms.erase(permissionId);
955  }
RBACPermissionContainer _grantedPerms
Account SecurityLevel
Definition: RBAC.h:988

+ Here is the caller graph for this function:

void rbac::RBACData::RemovePermissions ( RBACPermissionContainer permsFrom,
RBACPermissionContainer const permsToRemove 
)
private

Removes a list of permissions from another list.

240 {
241  for (RBACPermissionContainer::const_iterator itr = permsToRemove.begin(); itr != permsToRemove.end(); ++itr)
242  permsFrom.erase(*itr);
243 }

+ Here is the caller graph for this function:

RBACCommandResult rbac::RBACData::RevokePermission ( uint32  permissionId,
int32  realmId = 0 
)
140 {
141  // Check if it's present in any list
142  if (!HasGrantedPermission(permissionId) && !HasDeniedPermission(permissionId))
143  {
144  TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Not granted or revoked",
145  GetId(), GetName().c_str(), permissionId, realmId);
147  }
148 
149  RemoveGrantedPermission(permissionId);
150  RemoveDeniedPermission(permissionId);
151 
152  // Do not save to db when loading data from DB (realmId = 0)
153  if (realmId)
154  {
155  TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok and DB updated",
156  GetId(), GetName().c_str(), permissionId, realmId);
158  stmt->setUInt32(0, GetId());
159  stmt->setUInt32(1, permissionId);
160  stmt->setInt32(2, realmId);
161  LoginDatabase.Execute(stmt);
162 
164  }
165  else
166  TC_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
167  GetId(), GetName().c_str(), permissionId, realmId);
168 
169  return RBAC_OK;
170 }
Definition: LoginDatabase.h:108
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: RBAC.h:738
bool HasGrantedPermission(uint32 permissionId) const
Checks if a permission is granted.
Definition: RBAC.h:934
void RemoveGrantedPermission(uint32 permissionId)
Removes a granted permission.
Definition: RBAC.h:952
Definition: PreparedStatement.h:74
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
bool HasDeniedPermission(uint32 permissionId) const
Checks if a permission is denied.
Definition: RBAC.h:940
std::string const & GetName() const
Gets the Name of the Object.
Definition: RBAC.h:791
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
void CalculateNewPermissions()
Definition: RBAC.cpp:221
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:151
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void RemoveDeniedPermission(uint32 permissionId)
Removes a denied permission.
Definition: RBAC.h:964

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rbac::RBACData::SavePermission ( uint32  role,
bool  granted,
int32  realm 
)
private

Saves a permission to DB, Granted or Denied.

130 {
132  stmt->setUInt32(0, GetId());
133  stmt->setUInt32(1, permission);
134  stmt->setBool(2, granted);
135  stmt->setInt32(3, realmId);
136  LoginDatabase.Execute(stmt);
137 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: PreparedStatement.h:74
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
Definition: LoginDatabase.h:107
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
void setBool(const uint8 index, const bool value)
Definition: PreparedStatement.cpp:88
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:151
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void rbac::RBACData::SetSecurityLevel ( uint8  id)
inline

Sets security level.

904  {
905  _secLevel = id;
906  LoadFromDB();
907  }
uint8 _secLevel
RealmId Affected
Definition: RBAC.h:987
void LoadFromDB()
Loads all permissions assigned to current account.
Definition: RBAC.cpp:172

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

RBACPermissionContainer rbac::RBACData::_deniedPerms
private

Granted permissions

RBACPermissionContainer rbac::RBACData::_globalPerms
private

Denied permissions

RBACPermissionContainer rbac::RBACData::_grantedPerms
private

Account SecurityLevel

uint32 rbac::RBACData::_id
private
std::string rbac::RBACData::_name
private

Account id

int32 rbac::RBACData::_realmId
private

Account name

uint8 rbac::RBACData::_secLevel
private

RealmId Affected


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