示例#1
0
// =============================================================================
xbool Xen::CException::HandleError(xstring sMessage, xstring sCondition, xstring sFunction, xstring sFile, xint iLine)
{
	xstring sExceptionMessage;

#if !XRETAIL
	sExceptionMessage = XFORMAT
	(
		"Failed Condition: %s" XENDL "Function: %s" XENDL "Line: %d" XENDL XENDL "%s" XENDL XENDL "Would you like to debug?", 
		sCondition.c_str(), sFunction.c_str(), iLine, sMessage.c_str()
	);
#else
	sExceptionMessage = sMessage;
#endif

XLOG(sExceptionMessage.c_str());

#if XWINDOWS
	#if !XRETAIL
		xint iDialogResult = MessageBox(NULL, sExceptionMessage.c_str(), "Application Error", MB_YESNO | MB_ICONERROR | MB_APPLMODAL | MB_SETFOREGROUND | MB_DEFBUTTON1);

		if (iDialogResult == IDYES)
			return true;
	#endif
#endif
	
	throw CException(sExceptionMessage);
	return false;
}
示例#2
0
void CCacheEntry::populate(const char* resource_url)
{
    // Can we use what we have?
    if (m_assertion && m_assertion->getNotOnOrAfter())
    {
        // This is awful, but the XMLDateTime class is truly horrible.
        time_t now=time(NULL);
#ifdef WIN32
        struct tm* ptime=gmtime(&now);
#else
	struct tm res;
	struct tm* ptime=gmtime_r(&now,&res);
#endif
	char timebuf[32];
	strftime(timebuf,32,"%Y-%m-%dT%H:%M:%SZ",ptime);
	auto_ptr<XMLCh> timeptr(XMLString::transcode(timebuf));
	XMLDateTime curDateTime(timeptr.get());
	int result=XMLDateTime::compareOrder(&curDateTime,m_assertion->getNotOnOrAfter());
	if (XMLDateTime::LESS_THAN)
	    return;

	delete m_response;
	delete[] m_serialized;
	m_assertion=NULL;
        m_response=NULL;
	m_serialized=NULL;
    }

    if (!m_binding)
        return;

    auto_ptr<XMLCh> resource(XMLString::transcode(resource_url));    
    static const XMLCh* policies[] = { shibboleth::Constants::POLICY_CLUBSHIB };
    static const saml::QName* respondWiths[] = { &g_respondWith };

    // Build a SAML Request and send it to the AA.
    SAMLSubject* subject=new SAMLSubject(m_handle.c_str(),m_originSite.c_str());
    SAMLAttributeQuery* q=new SAMLAttributeQuery(subject,resource.get());
    SAMLRequest* req=new SAMLRequest(q,respondWiths);
    SAMLBinding* pBinding=CCache::g_Cache->getBinding(m_binding->getBinding());
    m_response=pBinding->send(*m_binding,*req);
    delete req;

    // Store off the assertion for quick access. Memory mgmt is based on the response pointer.
    Iterator<SAMLAssertion*> i=m_response->getAssertions();
    if (i.hasNext())
        m_assertion=i.next();

    auto_ptr<char> h(XMLString::transcode(m_handle.c_str()));
    auto_ptr<char> d(XMLString::transcode(m_originSite.c_str()));
    std::fprintf(stderr,"CCacheEntry::populate() fetched and stored SAML response for %s@%s\n",
		 h.get(),d.get());
}