X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=blobdiff_plain;f=xmltoolingtest%2FEncryptionTest.h;h=f3de66ab194470afc20cb321f2d98cb6c5f0686e;hp=4f6f0b5fa08bb6251335c7fd0c853d27f0d2b60f;hb=6505807a62569ce65803b448b07a6872c6af2512;hpb=e4d3ad9286b650c25c50b1b2226d1fda5e15f6a3 diff --git a/xmltoolingtest/EncryptionTest.h b/xmltoolingtest/EncryptionTest.h index 4f6f0b5..f3de66a 100644 --- a/xmltoolingtest/EncryptionTest.h +++ b/xmltoolingtest/EncryptionTest.h @@ -18,6 +18,8 @@ #include #include +#include +#include #include #include @@ -26,16 +28,6 @@ using namespace xmlencryption; -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 EncryptionTest : public CxxTest::TestSuite { CredentialResolver* m_resolver; public: @@ -61,14 +53,20 @@ public: TS_ASSERT(doc!=NULL); try { + CredentialCriteria cc; + cc.setUsage(CredentialCriteria::ENCRYPTION_CREDENTIAL); Locker locker(m_resolver); + const Credential* cred=m_resolver->resolve(&cc); + TSM_ASSERT("Retrieved credential was null", cred!=NULL); + Encrypter encrypter; Encrypter::EncryptionParams ep; - Encrypter::KeyEncryptionParams kep(DSIGConstants::s_unicodeStrURIRSA_1_5,m_resolver->getKey()); + Encrypter::KeyEncryptionParams kep(*cred,DSIGConstants::s_unicodeStrURIRSA_1_5); auto_ptr encData(encrypter.encryptElement(doc->getDocumentElement(),ep,&kep)); string buf; XMLHelper::serialize(encData->marshall(), buf); + //TS_TRACE(buf.c_str()); istringstream is(buf); DOMDocument* doc2=XMLToolingConfig::getConfig().getValidatingParser().parse(is); auto_ptr encData2(