本文整理汇总了C++中ISecUser::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ ISecUser::getName方法的具体用法?C++ ISecUser::getName怎么用?C++ ISecUser::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISecUser
的用法示例。
在下文中一共展示了ISecUser::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onMyAccount
bool Cws_accountEx::onMyAccount(IEspContext &context, IEspMyAccountRequest &req, IEspMyAccountResponse &resp)
{
try
{
ISecUser* user = context.queryUser();
if(user != NULL)
{
CDateTime dt;
user->getPasswordExpiration(dt);
StringBuffer sb;
if (dt.isNull())
sb.append("Never");
else
{
dt.getString(sb);
sb.replace('T', (char)0);//chop off timestring
}
resp.setPasswordExpiration(sb.str());
resp.setPasswordDaysRemaining(user->getPasswordDaysRemaining());
resp.setFirstName(user->getFirstName());
resp.setLastName(user->getLastName());
resp.setUsername(user->getName());
}
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例2: removePermissions
void CPermissionsCache::removePermissions( ISecUser& sec_user)
{
synchronized block(m_cachemonitor);
const char* user = sec_user.getName();
if(user != NULL && *user != '\0')
{
m_resPermissionsMap.erase(user);
}
}
示例3: lookup
bool CPermissionsCache::lookup(ISecUser& sec_user)
{
if(!isCacheEnabled())
return false;
const char* username = sec_user.getName();
if(!username || !*username)
return false;
string key(username);
ReadLockBlock readLock(m_userCacheRWLock );
MapUserCache::iterator it = m_userCache.find(key);
if (it == m_userCache.end())
return false;
CachedUser* user = (CachedUser*)(it->second);
time_t now;
time(&now);
if(user->getTimestamp() < (now - m_cacheTimeout))
{
m_userCache.erase(username);
delete user;
return false;
}
const char* cachedpw = user->queryUser()->credentials().getPassword();
StringBuffer pw(sec_user.credentials().getPassword());
if(cachedpw && pw.length() > 0)
{
StringBuffer md5pbuf;
md5_string(pw, md5pbuf);
if(strcmp(cachedpw, md5pbuf.str()) == 0)
{
#ifdef _DEBUG
DBGLOG("CACHE: CPermissionsCache Found validated user %s", username);
#endif
// Copy cached user to the sec_user structure, but still keep the original clear text password.
user->queryUser()->copyTo(sec_user);
sec_user.credentials().setPassword(pw.str());
return true;
}
else
{
m_userCache.erase(username);
delete user;
return false;
}
}
return false;
}
示例4: removePermissions
void CPermissionsCache::removePermissions( ISecUser& sec_user)
{
const char* user = sec_user.getName();
if(user != NULL && *user != '\0')
{
#ifdef _DEBUG
DBGLOG("CACHE: CPermissionsCache Removing permissions for user %s", user);
#endif
WriteLockBlock writeLock(m_resPermCacheRWLock);
m_resPermissionsMap.erase(user);
}
}
示例5: IsPasswordValid
bool CLocalSecurityManager::IsPasswordValid(ISecUser& sec_user)
{
IAuthenticatedUser* au = createAuthenticatedUser();
StringBuffer userbuf;
#ifdef _WIN32
const char* realm = sec_user.getRealm();
if(realm&&*realm)
userbuf.append(realm).append("\\");
#endif
userbuf.append(sec_user.getName());
return au->login(userbuf.str(), sec_user.credentials().getPassword());
}
示例6: removeFromUserCache
void CPermissionsCache::removeFromUserCache(ISecUser& sec_user)
{
const char* username = sec_user.getName();
if(username && *username)
{
synchronized block(m_userCacheMonitor);
CachedUser* user = m_userCache[username];
if(user)
{
m_userCache.erase(username);
delete user;
}
}
}
示例7: onUpdateUserInput
bool Cws_accountEx::onUpdateUserInput(IEspContext &context, IEspUpdateUserInputRequest &req, IEspUpdateUserInputResponse &resp)
{
try
{
ISecUser* user = context.queryUser();
if(user != NULL)
{
resp.setUsername(user->getName());
}
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例8: removeFromUserCache
void CPermissionsCache::removeFromUserCache(ISecUser& sec_user)
{
const char* username = sec_user.getName();
if(username && *username)
{
synchronized block(m_userCacheMonitor);
string key(username);
MapUserCache::iterator it = m_userCache.find(key);
if (it != m_userCache.end())
{
CachedUser* user = (CachedUser*)(it->second);
m_userCache.erase(username);
delete user;
}
}
}
示例9: lookup
bool CPermissionsCache::lookup(ISecUser& sec_user)
{
if(!isCacheEnabled())
return false;
const char* username = sec_user.getName();
if(!username || !*username)
return false;
synchronized block(m_userCacheMonitor);
CachedUser* user = m_userCache[username];
if(user == NULL)
return false;
time_t now;
time(&now);
if(user->getTimestamp() < (now - m_cacheTimeout))
{
m_userCache.erase(username);
delete user;
return false;
}
const char* cachedpw = user->queryUser()->credentials().getPassword();
StringBuffer pw(sec_user.credentials().getPassword());
if(cachedpw && pw.length() > 0)
{
StringBuffer md5pbuf;
md5_string(pw, md5pbuf);
if(strcmp(cachedpw, md5pbuf.str()) == 0)
{
// Copy cached user to the sec_user structure, but still keep the original clear text password.
user->queryUser()->copyTo(sec_user);
sec_user.credentials().setPassword(pw.str());
return true;
}
else
{
m_userCache.erase(username);
delete user;
return false;
}
}
return false;
}
示例10: add
void CPermissionsCache::add(ISecUser& sec_user)
{
if(!isCacheEnabled() || &sec_user == NULL)
return;
const char* username = sec_user.getName();
if(!username || !*username)
return;
synchronized block(m_userCacheMonitor);
CachedUser* user = m_userCache[username];
if(user)
{
m_userCache.erase(username);
delete user;
}
m_userCache[username] = new CachedUser(sec_user.clone());
}
示例11: add
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 );
}
示例12: removeFromUserCache
void CPermissionsCache::removeFromUserCache(ISecUser& sec_user)
{
const char* username = sec_user.getName();
if(username && *username)
{
string key(username);
WriteLockBlock writeLock(m_userCacheRWLock );
MapUserCache::iterator it = m_userCache.find(key);
if (it != m_userCache.end())
{
CachedUser* user = (CachedUser*)(it->second);
m_userCache.erase(username);
delete user;
#ifdef _DEBUG
DBGLOG("CACHE: CPermissionsCache Removing cached user %s", username);
#endif
}
}
}
示例13: onEcho
bool CWsPackageProcessEx::onEcho(IEspContext &context, IEspEchoRequest &req, IEspEchoResponse &resp)
{
StringBuffer respMsg;
ISecUser* user = context.queryUser();
if(user != NULL)
{
const char* name = user->getName();
if (name && *name)
respMsg.appendf("%s: ", name);
}
const char* reqMsg = req.getRequest();
if (reqMsg && *reqMsg)
respMsg.append(reqMsg);
else
respMsg.append("??");
resp.setResponse(respMsg.str());
return true;
}
示例14: lookup
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;
}
示例15: IsPasswordValid
bool IsPasswordValid(ISecUser& sec_user)
{
StringBuffer user;
user.append(sec_user.getName());
if (0 == user.length())
throw MakeStringException(-1, "htpasswd User name is NULL");
CriticalBlock block(crit);
if (!apr_initialized)
initAPR();
loadPwds();//reload password file if modified
StringBuffer *encPW = userMap.getValue(user.str());
if (encPW && encPW->length())
{
apr_status_t rc = apr_password_validate(sec_user.credentials().getPassword(), encPW->str());
if (rc != APR_SUCCESS)
DBGLOG("htpasswd authentication for user %s failed - APR RC %d", user.str(), rc );
return rc == APR_SUCCESS;
}
DBGLOG("User %s not in htpasswd file", user.str());
return false;
}