本文整理汇总了C++中IEspContext::setAuthStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ IEspContext::setAuthStatus方法的具体用法?C++ IEspContext::setAuthStatus怎么用?C++ IEspContext::setAuthStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEspContext
的用法示例。
在下文中一共展示了IEspContext::setAuthStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onCleanSession
bool CWSESPControlEx::onCleanSession(IEspContext& context, IEspCleanSessionRequest& req, IEspCleanSessionResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to clean session. Permission denied.");
}
#endif
StringBuffer id, userID, fromIP;
bool allSessions = req.getAllSessions();
if (!allSessions)
{
id.set(req.getID());
userID.set(req.getUserID());
fromIP.set(req.getFromIP());
if ((id.trim().isEmpty()) && (userID.trim().isEmpty()) && (fromIP.trim().isEmpty()))
throw MakeStringException(ECLWATCH_INVALID_INPUT, "ID, userID or FromIP has to be specified.");
}
cleanSessions(allSessions, id.str(), userID.str(), fromIP.str());
resp.setStatus(0);
resp.setMessage("Session is cleaned.");
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例2: onSetLogging
bool CWSESPControlEx::onSetLogging(IEspContext& context, IEspSetLoggingRequest& req, IEspSetLoggingResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to change log settings. Permission denied.");
}
#endif
if (!m_container)
throw MakeStringException(ECLWATCH_INTERNAL_ERROR, "Failed to access container.");
if (!req.getLoggingLevel_isNull())
m_container->setLogLevel(req.getLoggingLevel());
if (!req.getLogRequests_isNull())
m_container->setLogRequests(req.getLogRequests());
if (!req.getLogResponses_isNull())
m_container->setLogResponses(req.getLogResponses());
resp.setStatus(0);
resp.setMessage("Logging settings are updated.");
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例3: onSetSessionTimeout
bool CWSESPControlEx::onSetSessionTimeout(IEspContext& context, IEspSetSessionTimeoutRequest& req, IEspSetSessionTimeoutResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to set session timeout. Permission denied.");
}
#endif
StringBuffer id, userID, fromIP;
bool allSessions = req.getAllSessions();
if (!allSessions)
{
id.set(req.getID());
userID.set(req.getUserID());
fromIP.set(req.getFromIP());
if ((id.trim().isEmpty()) && (userID.trim().isEmpty()) && (fromIP.trim().isEmpty()))
throw MakeStringException(ECLWATCH_INVALID_INPUT, "ID, userID or FromIP has to be specified.");
}
int timeoutMinutes = req.getTimeoutMinutes_isNull() ? 0 : req.getTimeoutMinutes();
if (timeoutMinutes <= 0)
cleanSessions(allSessions, id.str(), userID.str(), fromIP.str());
else
{
StringBuffer searchPath;
setSessionXPath(allSessions, id.str(), userID.str(), fromIP.str(), searchPath);
Owned<IRemoteConnection> globalLock = querySDSConnectionForESPSession(RTM_LOCK_WRITE, SESSION_SDS_LOCK_TIMEOUT);
Owned<IPropertyTreeIterator> iter = globalLock->queryRoot()->getElements("*");
ForEach(*iter)
{
Owned<IPropertyTreeIterator> iter1 = iter->query().getElements(searchPath.str());
ForEach(*iter1)
setSessionTimeout(timeoutMinutes, iter1->query());
}
}
resp.setStatus(0);
resp.setMessage("Session timeout is updated.");
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例4: onSessionInfo
bool CWSESPControlEx::onSessionInfo(IEspContext& context, IEspSessionInfoRequest& req, IEspSessionInfoResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to get session information. Permission denied.");
}
#endif
StringBuffer id = req.getID();
if (id.trim().isEmpty())
throw MakeStringException(ECLWATCH_INVALID_INPUT, "ID not specified.");
unsigned port = 8010;
if (!req.getPort_isNull())
port = req.getPort();
Owned<IRemoteConnection> globalLock;
VStringBuffer xpath("/%s/%s[@name='%s']/%s[@port='%d']/%s*[%s='%s']", PathSessionRoot, PathSessionProcess, espProcess.get(),
PathSessionApplication, port, PathSessionSession, PropSessionExternalID, id.str());
try
{
globalLock.setown(querySDSConnection(xpath.str(), RTM_LOCK_READ, SESSION_SDS_LOCK_TIMEOUT));
}
catch(IException* e)
{
VStringBuffer msg("Failed to get session info for id %s on port %u: ", id.str(), port);
e->errorMessage(msg);
e->Release();
throw MakeStringException(ECLWATCH_INVALID_INPUT, "%s", msg.str());
}
setSessionInfo(globalLock->queryRoot(), port, &resp.updateSession());
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}
示例5: onSessionQuery
bool CWSESPControlEx::onSessionQuery(IEspContext& context, IEspSessionQueryRequest& req, IEspSessionQueryResponse& resp)
{
try
{
#ifdef _USE_OPENLDAP
CLdapSecManager* secmgr = dynamic_cast<CLdapSecManager*>(context.querySecManager());
if(secmgr && !secmgr->isSuperUser(context.queryUser()))
{
context.setAuthStatus(AUTH_STATUS_NOACCESS);
throw MakeStringException(ECLWATCH_SUPER_USER_ACCESS_DENIED, "Failed to query session. Permission denied.");
}
#endif
StringBuffer xpath;
setSessionXPath(false, nullptr, req.getUserID(), req.getFromIP(), xpath);
IArrayOf<IEspSession> sessions;
Owned<IRemoteConnection> globalLock = querySDSConnectionForESPSession(RTM_LOCK_READ, SESSION_SDS_LOCK_TIMEOUT);
Owned<IPropertyTreeIterator> iter = globalLock->queryRoot()->getElements("*");
ForEach(*iter)
{
IPropertyTree& appSessionTree = iter->query();
unsigned port = appSessionTree.getPropInt("@port");
Owned<IPropertyTreeIterator> iter1 = appSessionTree.getElements(xpath.str());
ForEach(*iter1)
{
IPropertyTree& sessionTree = iter1->query();
Owned<IEspSession> s = createSession();
setSessionInfo(&sessionTree, port, s);
sessions.append(*s.getLink());
}
}
resp.setSessions(sessions);
}
catch(IException* e)
{
FORWARDEXCEPTION(context, e, ECLWATCH_INTERNAL_ERROR);
}
return true;
}