2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
24 * Registration of factories for built-in engines.
28 #include "security/KeyInfoResolver.h"
29 #include "security/SignatureTrustEngine.h"
30 #include "security/OpenSSLTrustEngine.h"
31 #include "util/XMLHelper.h"
33 #include <xercesc/util/XMLUniDefs.hpp>
35 using namespace xmltooling;
38 using xercesc::DOMElement;
40 namespace xmltooling {
41 XMLTOOL_DLLLOCAL PluginManager<TrustEngine,string,const DOMElement*>::Factory ExplicitKeyTrustEngineFactory;
42 XMLTOOL_DLLLOCAL PluginManager<TrustEngine,string,const DOMElement*>::Factory StaticPKIXTrustEngineFactory;
43 XMLTOOL_DLLLOCAL PluginManager<TrustEngine,string,const DOMElement*>::Factory ChainingTrustEngineFactory;
46 void XMLTOOL_API xmltooling::registerTrustEngines()
48 XMLToolingConfig& conf=XMLToolingConfig::getConfig();
49 conf.TrustEngineManager.registerFactory(EXPLICIT_KEY_TRUSTENGINE, ExplicitKeyTrustEngineFactory);
50 conf.TrustEngineManager.registerFactory(STATIC_PKIX_TRUSTENGINE, StaticPKIXTrustEngineFactory);
51 conf.TrustEngineManager.registerFactory(CHAINING_TRUSTENGINE, ChainingTrustEngineFactory);
54 static const XMLCh _KeyInfoResolver[] = UNICODE_LITERAL_15(K,e,y,I,n,f,o,R,e,s,o,l,v,e,r);
55 static const XMLCh type[] = UNICODE_LITERAL_4(t,y,p,e);
57 TrustEngine::TrustEngine(const DOMElement* e) : m_keyInfoResolver(nullptr)
59 DOMElement* child = e ? XMLHelper::getFirstChildElement(e, _KeyInfoResolver) : nullptr;
61 string t = XMLHelper::getAttrString(child, nullptr, type);
63 m_keyInfoResolver = XMLToolingConfig::getConfig().KeyInfoResolverManager.newPlugin(t.c_str(), child);
65 throw UnknownExtensionException("<KeyInfoResolver> element found with no type attribute");
69 TrustEngine::~TrustEngine()
71 delete m_keyInfoResolver;
74 SignatureTrustEngine::SignatureTrustEngine(const DOMElement* e) : TrustEngine(e)
78 SignatureTrustEngine::~SignatureTrustEngine()
82 X509TrustEngine::X509TrustEngine(const DOMElement* e) : TrustEngine(e)
86 X509TrustEngine::~X509TrustEngine()
90 OpenSSLTrustEngine::OpenSSLTrustEngine(const DOMElement* e) : X509TrustEngine(e)
94 OpenSSLTrustEngine::~OpenSSLTrustEngine()