Assertion::Assertion(const Assertion &a)
{
  msg_m = new char[strlen(a.what())+1];
  strcpy(msg_m, a.what());
  file_m = new char[strlen(a.file())+1];
  strcpy(file_m, a.file());
  line_m = a.line();
}
void DebugUncaughtExceptionHandler::handleAssertion(const Assertion& ex) const {
    StringBuffer buf;
    buf << "Assertion failed: "<<ex.name()<<": "<<ex.what()<<'\n';
    if(ex.tracemsg != null) {
        buf << "Trace messages: \n";
        Exception::TraceMessage * msg = ex.tracemsg;
        do {
            buf << "    " << String(msg->message) << '\n';
        } while((msg->next != null) && (msg = msg->next));
    }
    thisapp->fail(buf, ex._file, ex._line, false);
}
void AssertionValidator::validateAssertion(const Assertion& assertion) const
{
#ifdef _DEBUG
    xmltooling::NDC ndc("validate");
#endif

    const Conditions* conds = assertion.getConditions();
    if (!conds)
        return;
    
    // First verify the time conditions, using the specified timestamp, if non-zero.
    if (m_ts>0) {
        unsigned int skew = XMLToolingConfig::getConfig().clock_skew_secs;
        time_t t=conds->getNotBeforeEpoch();
        if (m_ts+skew < t)
            throw ValidationException("Assertion is not yet valid.");
        t=conds->getNotOnOrAfterEpoch();
        if (t <= m_ts-skew)
            throw ValidationException("Assertion is no longer valid.");
    }

    // Now we process conditions, starting with the known types and then extensions.
    const vector<AudienceRestriction*>& acvec = conds->getAudienceRestrictions();
    for (vector<AudienceRestriction*>::const_iterator ac = acvec.begin(); ac!=acvec.end(); ++ac)
        validateCondition(*ac);

    const vector<OneTimeUse*>& dncvec = conds->getOneTimeUses();
    for (vector<OneTimeUse*>::const_iterator dnc = dncvec.begin(); dnc!=dncvec.end(); ++dnc)
        validateCondition(*dnc);

    const vector<Condition*>& convec = conds->getConditions();
    for (vector<Condition*>::const_iterator c = convec.begin(); c!=convec.end(); ++c)
        validateCondition(*c);
}
    bool DoAssert(const Assertion &e, bool processHook)
    {
        if (processHook) ProcessHook(&e);

        Platform::ExitWithMessage(e.what());

        // never goes here
        return true;
    }
void BrowserSSOProfileValidator::validateAssertion(const Assertion& assertion) const
{
#ifdef _DEBUG
    xmltooling::NDC ndc("validate");
#endif

    // Make sure the assertion is bounded.
    const Conditions* conds = assertion.getConditions();
    if (!conds || !conds->getNotBefore() || !conds->getNotOnOrAfter())
        throw ValidationException("SSO assertions MUST contain NotBefore/NotOnOrAfter attributes.");

    // Each statement MUST have proper confirmation requirements.
    const vector<AuthenticationStatement*>& authn = assertion.getAuthenticationStatements();
    for_each(authn.begin(), authn.end(), _checkMethod());
    const vector<AttributeStatement*>& attr = assertion.getAttributeStatements();
    for_each(attr.begin(), attr.end(), _checkMethod());
    const vector<SubjectStatement*>& sub = assertion.getSubjectStatements();
    for_each(sub.begin(), sub.end(), _checkMethod());

    // Pass up for additional checking.
    AssertionValidator::validateAssertion(assertion);
}
Exemple #6
0
void
AntXMLListener::testAsserted(const std::string &suite, const std::string &test,
                             const Assertion &assertion)
{
    if (test != "<invariant>") {
        TestSuiteInfo &suiteInfo = m_testSuites[suite];
        TestInfo &testInfo = suiteInfo.tests[test];
        ++suiteInfo.failures;
        suiteInfo.end = testInfo.end = TimerManager::now();
        testInfo.exceptionType = "Assertion";
        testInfo.exceptionMessage = assertion.what();
        replace(testInfo.exceptionMessage, "\"", "&quot;");
        testInfo.exceptionDetails = boost::current_exception_diagnostic_information();
    }
}