void CPermissionsCache::add( ISecUser& sec_user, IArrayOf<ISecResource>& resources ) { synchronized block(m_cachemonitor); const char* user = sec_user.getName(); MapResPermissionsCache::const_iterator i = m_resPermissionsMap.find( user ); CResPermissionsCache* pResPermissionsCache; if (i == m_resPermissionsMap.end()) { //DBGLOG("CACHE: Adding cache for %s", user); pResPermissionsCache = new CResPermissionsCache(this, user); m_resPermissionsMap.insert(pair<string, CResPermissionsCache*>(user, pResPermissionsCache)); } else pResPermissionsCache = (*i).second; pResPermissionsCache->add( resources ); }
int CPermissionsCache::lookup( ISecUser& sec_user, IArrayOf<ISecResource>& resources, bool* pFound) { synchronized block(m_cachemonitor); const char* userId = sec_user.getName(); int nFound; MapResPermissionsCache::const_iterator i = m_resPermissionsMap.find( userId ); if (i != m_resPermissionsMap.end()) { CResPermissionsCache* pResPermissionsCache = (*i).second; nFound = pResPermissionsCache->lookup( resources, pFound ); } else { nFound = 0; memset(pFound, 0, sizeof(bool)*resources.ordinality()); //DBGLOG("CACHE: Looking up %s:*", userId); } return nFound; }
int CPermissionsCache::lookup( ISecUser& sec_user, IArrayOf<ISecResource>& resources, bool* pFound) { const char* userId = sec_user.getName(); int nFound; ReadLockBlock readLock(m_resPermCacheRWLock); MapResPermissionsCache::const_iterator i = m_resPermissionsMap.find( userId ); if (i != m_resPermissionsMap.end()) { CResPermissionsCache* pResPermissionsCache = (*i).second; nFound = pResPermissionsCache->lookup( resources, pFound ); } else { nFound = 0; memset(pFound, 0, sizeof(bool)*resources.ordinality()); } #ifdef _DEBUG DBGLOG("CACHE: CPermissionsCache Looked up resources for %s:*, found %d of %d matches", userId, nFound, resources.ordinality()); #endif return nFound; }
void CPermissionsCache::add( ISecUser& sec_user, IArrayOf<ISecResource>& resources ) { const char* user = sec_user.getName(); WriteLockBlock writeLock(m_resPermCacheRWLock); MapResPermissionsCache::const_iterator i = m_resPermissionsMap.find( user ); CResPermissionsCache* pResPermissionsCache; if (i == m_resPermissionsMap.end()) { #ifdef _DEBUG DBGLOG("CACHE: CPermissionsCache Adding resources to cache for new user %s", user); #endif pResPermissionsCache = new CResPermissionsCache(this, user); m_resPermissionsMap.insert(pair<string, CResPermissionsCache*>(user, pResPermissionsCache)); } else { #ifdef _DEBUG DBGLOG("CACHE: CPermissionsCache Adding resources to cache for existing user %s", user); #endif pResPermissionsCache = (*i).second; } pResPermissionsCache->add( resources ); }