-/*\r
- * Copyright 2001-2005 Internet2\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * ChainingTrustEngine.cpp\r
- * \r
- * TrustEngine that uses multiple engines in sequence.\r
- */\r
-\r
-#include "internal.h"\r
-#include "exceptions.h"\r
-#include "security/ChainingTrustEngine.h"\r
-\r
-using namespace opensaml::saml2md;\r
-using namespace opensaml;\r
-using namespace xmlsignature;\r
-using namespace std;\r
-\r
-namespace opensaml {\r
- TrustEngine* SAML_DLLLOCAL ChainingTrustEngineFactory(const DOMElement* const & e)\r
- {\r
- return new ChainingTrustEngine(e);\r
- }\r
-};\r
-\r
-static const XMLCh GenericTrustEngine[] = UNICODE_LITERAL_11(T,r,u,s,t,E,n,g,i,n,e);\r
-static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e);\r
-\r
-ChainingTrustEngine::ChainingTrustEngine(const DOMElement* e) {\r
- try {\r
- e = e ? xmltooling::XMLHelper::getFirstChildElement(e, GenericTrustEngine) : NULL;\r
- while (e) {\r
- xmltooling::auto_ptr_char temp(e->getAttributeNS(NULL,type));\r
- if (temp.get()) {\r
- auto_ptr<TrustEngine> engine(\r
- SAMLConfig::getConfig().TrustEngineManager.newPlugin(temp.get(), e)\r
- );\r
- X509TrustEngine* x509 = dynamic_cast<X509TrustEngine*>(engine.get());\r
- if (x509) {\r
- m_engines.push_back(x509);\r
- engine.release();\r
- }\r
- else {\r
- throw xmltooling::UnknownExtensionException("Embedded trust engine does not support required interface.");\r
- }\r
- }\r
- e = xmltooling::XMLHelper::getNextSiblingElement(e, GenericTrustEngine);\r
- }\r
- }\r
- catch (xmltooling::XMLToolingException&) {\r
- for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup<X509TrustEngine>());\r
- throw;\r
- }\r
-}\r
-\r
-ChainingTrustEngine::~ChainingTrustEngine() {\r
- for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup<X509TrustEngine>());\r
-}\r
-\r
-bool ChainingTrustEngine::validate(\r
- Signature& sig,\r
- const RoleDescriptor& role,\r
- const KeyResolver* keyResolver\r
- ) const\r
-{\r
- for (vector<X509TrustEngine*>::const_iterator i=m_engines.begin(); i!=m_engines.end(); ++i) {\r
- if (static_cast<TrustEngine*>(*i)->validate(sig,role,keyResolver))\r
- return true;\r
- }\r
- return false;\r
-}\r
-\r
-bool ChainingTrustEngine::validate(\r
- XSECCryptoX509* certEE,\r
- const vector<XSECCryptoX509*>& certChain,\r
- const RoleDescriptor& role,\r
- bool checkName,\r
- const KeyResolver* keyResolver\r
- ) const\r
-{\r
- for (vector<X509TrustEngine*>::const_iterator i=m_engines.begin(); i!=m_engines.end(); ++i) {\r
- if ((*i)->validate(certEE,certChain,role,checkName,keyResolver))\r
- return true;\r
- }\r
- return false;\r
-}\r
+/*
+ * Copyright 2001-2005 Internet2
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * ChainingTrustEngine.cpp
+ *
+ * TrustEngine that uses multiple engines in sequence.
+ */
+
+#include "internal.h"
+#include "exceptions.h"
+#include "security/ChainingTrustEngine.h"
+
+using namespace opensaml::saml2md;
+using namespace opensaml;
+using namespace xmlsignature;
+using namespace std;
+
+namespace opensaml {
+ TrustEngine* SAML_DLLLOCAL ChainingTrustEngineFactory(const DOMElement* const & e)
+ {
+ return new ChainingTrustEngine(e);
+ }
+};
+
+static const XMLCh GenericTrustEngine[] = UNICODE_LITERAL_11(T,r,u,s,t,E,n,g,i,n,e);
+static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e);
+
+ChainingTrustEngine::ChainingTrustEngine(const DOMElement* e) {
+ try {
+ e = e ? xmltooling::XMLHelper::getFirstChildElement(e, GenericTrustEngine) : NULL;
+ while (e) {
+ xmltooling::auto_ptr_char temp(e->getAttributeNS(NULL,type));
+ if (temp.get()) {
+ auto_ptr<TrustEngine> engine(
+ SAMLConfig::getConfig().TrustEngineManager.newPlugin(temp.get(), e)
+ );
+ X509TrustEngine* x509 = dynamic_cast<X509TrustEngine*>(engine.get());
+ if (x509) {
+ m_engines.push_back(x509);
+ engine.release();
+ }
+ else {
+ throw xmltooling::UnknownExtensionException("Embedded trust engine does not support required interface.");
+ }
+ }
+ e = xmltooling::XMLHelper::getNextSiblingElement(e, GenericTrustEngine);
+ }
+ }
+ catch (xmltooling::XMLToolingException&) {
+ for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup<X509TrustEngine>());
+ throw;
+ }
+}
+
+ChainingTrustEngine::~ChainingTrustEngine() {
+ for_each(m_engines.begin(), m_engines.end(), xmltooling::cleanup<X509TrustEngine>());
+}
+
+bool ChainingTrustEngine::validate(
+ Signature& sig,
+ const RoleDescriptor& role,
+ const KeyResolver* keyResolver
+ ) const
+{
+ for (vector<X509TrustEngine*>::const_iterator i=m_engines.begin(); i!=m_engines.end(); ++i) {
+ if (static_cast<TrustEngine*>(*i)->validate(sig,role,keyResolver))
+ return true;
+ }
+ return false;
+}
+
+bool ChainingTrustEngine::validate(
+ XSECCryptoX509* certEE,
+ const vector<XSECCryptoX509*>& certChain,
+ const RoleDescriptor& role,
+ bool checkName,
+ const KeyResolver* keyResolver
+ ) const
+{
+ for (vector<X509TrustEngine*>::const_iterator i=m_engines.begin(); i!=m_engines.end(); ++i) {
+ if ((*i)->validate(certEE,certChain,role,checkName,keyResolver))
+ return true;
+ }
+ return false;
+}