当前位置: 首页>>代码示例>>C++>>正文


C++ ISecUser类代码示例

本文整理汇总了C++中ISecUser的典型用法代码示例。如果您正苦于以下问题:C++ ISecUser类的具体用法?C++ ISecUser怎么用?C++ ISecUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ISecUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MakeStringException

const StringBuffer &CEspApplicationPort::getAppFrameHtml(time_t &modified, const char *inner, StringBuffer &html, IEspContext* ctx)
{
    if (!xslp)
       throw MakeStringException(0,"Error - CEspApplicationPort XSLT processor not initialized");

    bool embedded_url=(inner&&*inner);

    StringBuffer params;
    bool needRefresh = true;
    if (!getUrlParams(ctx->queryRequestParameters(), params))
    {
        if (params.length()==0)
            needRefresh = false;
        if (ctx->getClientVersion()>0)
        {
            params.appendf("%cver_=%g", params.length()?'&':'?', ctx->getClientVersion());
            needRefresh = true;
        }
    }

    if (needRefresh || embedded_url || !appFrameHtml.length())
    {
        int passwordDaysRemaining = scPasswordExpired;//-1 means dont display change password screen
#ifdef _USE_OPENLDAP
        ISecUser* user = ctx->queryUser();
        ISecManager* secmgr = ctx->querySecManager();
        if(user && secmgr)
        {
            passwordDaysRemaining = user->getPasswordDaysRemaining();//-1 if expired, -2 if never expires
            int passwordExpirationDays = (int)secmgr->getPasswordExpirationWarningDays();
            if (passwordDaysRemaining == scPasswordNeverExpires || passwordDaysRemaining > passwordExpirationDays)
                passwordDaysRemaining = scPasswordExpired;
        }
#endif
        StringBuffer xml;
        StringBuffer encoded_inner;
        if(inner && *inner)
            encodeXML(inner, encoded_inner);

        // replace & with &amps;
        params.replaceString("&","&");

        xml.appendf("<EspApplicationFrame title=\"%s\" navWidth=\"%d\" navResize=\"%d\" navScroll=\"%d\" inner=\"%s\" params=\"%s\" passwordDays=\"%d\"/>",
            getESPContainer()->getFrameTitle(), navWidth, navResize, navScroll, (inner&&*inner) ? encoded_inner.str() : "?main", params.str(), passwordDaysRemaining);

        Owned<IXslTransform> xform = xslp->createXslTransform();
        xform->loadXslFromFile(StringBuffer(getCFD()).append("./xslt/appframe.xsl").str());
        xform->setXmlSource(xml.str(), xml.length()+1);
        xform->transform( (needRefresh || embedded_url) ? html.clear() : appFrameHtml.clear());
    }

    if (!needRefresh && !embedded_url)
        html.clear().append(appFrameHtml.str());

    static time_t startup_time = time(NULL);
    modified = startup_time;
    return html;
}
开发者ID:GordonSmith,项目名称:HPCC-Platform,代码行数:58,代码来源:espprotocol.cpp

示例2: 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;
}
开发者ID:bolaria,项目名称:HPCC-Platform,代码行数:53,代码来源:caching.cpp

示例3: 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());
}
开发者ID:jamienoss,项目名称:HPCC-Platform,代码行数:12,代码来源:defaultsecuritymanager.cpp

示例4: 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;
}
开发者ID:AlexLuya,项目名称:HPCC-Platform,代码行数:16,代码来源:ws_accountService.cpp

示例5: 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;
}
开发者ID:AsherBond,项目名称:HPCC-Platform,代码行数:47,代码来源:caching.cpp

示例6: UserInfo

 UserInfo(ISecUser& userInfo, unsigned TimeoutPeriod=60000)
 {
     _UserInfo = &userInfo;
     if(_UserInfo)
         _UserInfo->Link();
     _timeCreated = msTick();
     _timeOut = TimeoutPeriod; 
 }
开发者ID:rclakmal,项目名称:HPCC-Platform,代码行数:8,代码来源:basesecurity.hpp

示例7: 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); 
    }
}
开发者ID:AvijitGhosh82,项目名称:HPCC-Platform,代码行数:9,代码来源:caching.cpp

示例8: 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());
}
开发者ID:AsherBond,项目名称:HPCC-Platform,代码行数:18,代码来源:caching.cpp

示例9: authorize

bool CBaseSecurityManager::authorize(ISecUser & sec_user, ISecResourceList * Resources)
{   
    if(sec_user.getAuthenticateStatus() != AS_AUTHENTICATED)
    {
        bool bOk = ValidateUser(sec_user);
        if(bOk == false)
            return false;
    }
    return ValidateResources(sec_user,Resources);
}
开发者ID:mokerjoke,项目名称:HPCC-Platform,代码行数:10,代码来源:basesecurity.cpp

示例10: 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;
}
开发者ID:ruidafu,项目名称:HPCC-Platform,代码行数:20,代码来源:ws_packageprocessService.cpp

示例11: 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); 
    }
}
开发者ID:bolaria,项目名称:HPCC-Platform,代码行数:12,代码来源:caching.cpp

示例12: add

void CPermissionsCache::add(ISecUser& sec_user)
{
    if(!isCacheEnabled())
        return;
    
    const char* username = sec_user.getName();
    if(!username || !*username)
        return;
    
    synchronized block(m_userCacheMonitor);     
    string key(username);
    MapUserCache::iterator it = m_userCache.find(key);
    CachedUser* user = NULL;
    if (it != m_userCache.end())
    {
        user = (CachedUser*)(it->second);
        m_userCache.erase(username);
        delete user;
    }
    m_userCache[username] = new CachedUser(sec_user.clone());
}
开发者ID:AvijitGhosh82,项目名称:HPCC-Platform,代码行数:21,代码来源:caching.cpp

示例13: 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;
}
开发者ID:AlexLuya,项目名称:HPCC-Platform,代码行数:30,代码来源:ws_accountService.cpp

示例14: 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;
	}
开发者ID:anandjun,项目名称:HPCC-Platform,代码行数:22,代码来源:htpasswdSecurity.cpp

示例15: 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;
        }
    }
}
开发者ID:AsherBond,项目名称:HPCC-Platform,代码行数:14,代码来源:caching.cpp


注:本文中的ISecUser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。