X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltoolingtest%2FSignatureTest.h;h=fc682e1afacb2a8100a0b83dad7b6b7a85cdc38d;hb=b383e021ae585cf97bf24285f65ae1e451b893e8;hp=394583ecc9b4a895e355647e411ed38e87eb9b99;hpb=541d19734b9caa36cd29e017808d5292b25dc107;p=shibboleth%2Fxmltooling.git diff --git a/xmltoolingtest/SignatureTest.h b/xmltoolingtest/SignatureTest.h index 394583e..fc682e1 100644 --- a/xmltoolingtest/SignatureTest.h +++ b/xmltoolingtest/SignatureTest.h @@ -16,6 +16,8 @@ #include "XMLObjectBaseTestCase.h" +#include +#include #include #include #include @@ -49,7 +51,7 @@ class TestValidator : public SignatureValidator XMLCh* m_uri; public: - TestValidator(const XMLCh* uri) : SignatureValidator(XMLToolingConfig::getConfig().KeyResolverManager.newPlugin(INLINE_KEY_RESOLVER,NULL)) { + TestValidator(const XMLCh* uri, const Credential* credential) : SignatureValidator(credential) { m_uri=XMLString::replicate(uri); } @@ -67,16 +69,6 @@ public: } }; -class _addcert : public std::binary_function { -public: - void operator()(X509Data* bag, XSECCryptoX509* cert) const { - safeBuffer& buf=cert->getDEREncodingSB(); - X509Certificate* x=X509CertificateBuilder::buildX509Certificate(); - x->setValue(buf.sbStrToXMLCh()); - bag->getX509Certificates().push_back(x); - } -}; - class SignatureTest : public CxxTest::TestSuite { CredentialResolver* m_resolver; public: @@ -126,20 +118,16 @@ public: sxObject->setSignature(sig); sig->setContentReference(new TestContext(&chNull)); + CredentialCriteria cc; + cc.setUsage(Credential::SIGNING_CREDENTIAL); Locker locker(m_resolver); - sig->setSigningKey(m_resolver->getKey()); - - // Build KeyInfo. - KeyInfo* keyInfo=KeyInfoBuilder::buildKeyInfo(); - X509Data* x509Data=X509DataBuilder::buildX509Data(); - keyInfo->getX509Datas().push_back(x509Data); - for_each(m_resolver->getCertificates().begin(),m_resolver->getCertificates().end(),bind1st(_addcert(),x509Data)); - sig->setKeyInfo(keyInfo); + const Credential* cred = m_resolver->resolve(&cc); + TSM_ASSERT("Retrieved credential was null", cred!=NULL); DOMElement* rootElement = NULL; try { - rootElement=sxObject->marshall((DOMDocument*)NULL); - sig->sign(); + vector sigs(1,sig); + rootElement=sxObject->marshall((DOMDocument*)NULL,&sigs,cred); } catch (XMLToolingException& e) { TS_TRACE(e.what()); @@ -157,7 +145,7 @@ public: TS_ASSERT(sxObject2->getSignature()!=NULL); try { - TestValidator tv(&chNull); + TestValidator tv(&chNull, cred); tv.validate(sxObject2->getSignature()); } catch (XMLToolingException& e) {