Replace custom code with CredentialResolver.
[shibboleth/cpp-opensaml.git] / samltest / signature / SAMLSignatureTestBase.h
1 /*\r
2  *  Copyright 2001-2005 Internet2\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 #include "internal.h"\r
18 #include <saml/signature/SignatureProfileValidator.h>\r
19 \r
20 #include <xmltooling/signature/CredentialResolver.h>\r
21 #include <xmltooling/signature/SignatureValidator.h>\r
22 \r
23 using namespace xmlsignature;\r
24 \r
25 class _addcert : public std::binary_function<X509Data*,XSECCryptoX509*,void> {\r
26 public:\r
27     void operator()(X509Data* bag, XSECCryptoX509* cert) const {\r
28         safeBuffer& buf=cert->getDEREncodingSB();\r
29         X509Certificate* x=X509CertificateBuilder::buildX509Certificate();\r
30         x->setValue(buf.sbStrToXMLCh());\r
31         bag->getX509Certificates().push_back(x);\r
32     }\r
33 };\r
34 \r
35 class SAMLSignatureTestBase : public SAMLObjectBaseTestCase {\r
36 protected:\r
37     CredentialResolver* m_resolver;\r
38 public:\r
39     void setUp() {\r
40         m_resolver=NULL;\r
41         SAMLObjectBaseTestCase::setUp();\r
42         string config = data_path + "FilesystemCredentialResolver.xml";\r
43         ifstream in(config.c_str());\r
44         DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);\r
45         XercesJanitor<DOMDocument> janitor(doc);\r
46         m_resolver = XMLToolingConfig::getConfig().CredentialResolverManager.newPlugin(\r
47             FILESYSTEM_CREDENTIAL_RESOLVER,doc->getDocumentElement()\r
48             );\r
49     }\r
50 \r
51     void tearDown() {\r
52         delete m_resolver;\r
53         SAMLObjectBaseTestCase::tearDown();\r
54     }\r
55 };\r