From efe9ca9abb2a9e7b3e28b2d95a7e0b932085c4fd Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Thu, 11 Aug 2011 18:56:12 +0000 Subject: [PATCH] Add dummy credential resolver. --- xmltooling/Makefile.am | 1 + xmltooling/security/CredentialResolver.h | 3 ++ xmltooling/security/impl/CredentialResolver.cpp | 4 +- .../security/impl/DummyCredentialResolver.cpp | 63 ++++++++++++++++++++++ xmltooling/xmltooling.vcxproj | 1 + xmltooling/xmltooling.vcxproj.filters | 3 ++ 6 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 xmltooling/security/impl/DummyCredentialResolver.cpp diff --git a/xmltooling/Makefile.am b/xmltooling/Makefile.am index 035e2af..e6e946a 100644 --- a/xmltooling/Makefile.am +++ b/xmltooling/Makefile.am @@ -137,6 +137,7 @@ xmlsec_sources = \ security/impl/ChainingTrustEngine.cpp \ security/impl/CredentialCriteria.cpp \ security/impl/CredentialResolver.cpp \ + security/impl/DummyCredentialResolver.cpp \ security/impl/ExplicitKeyTrustEngine.cpp \ security/impl/FilesystemCredentialResolver.cpp \ security/impl/InlineKeyResolver.cpp \ diff --git a/xmltooling/security/CredentialResolver.h b/xmltooling/security/CredentialResolver.h index c828487..89be8c2 100644 --- a/xmltooling/security/CredentialResolver.h +++ b/xmltooling/security/CredentialResolver.h @@ -74,6 +74,9 @@ namespace xmltooling { /** CredentialResolver based on local files with no criteria support. */ #define FILESYSTEM_CREDENTIAL_RESOLVER "File" + /** CredentialResolver that returns nothing, for use with some APIs. */ + #define DUMMY_CREDENTIAL_RESOLVER "Dummy" + /** CredentialResolver based on chaining together other resolvers. */ #define CHAINING_CREDENTIAL_RESOLVER "Chaining" }; diff --git a/xmltooling/security/impl/CredentialResolver.cpp b/xmltooling/security/impl/CredentialResolver.cpp index e77304d..e00b22c 100644 --- a/xmltooling/security/impl/CredentialResolver.cpp +++ b/xmltooling/security/impl/CredentialResolver.cpp @@ -30,7 +30,8 @@ using namespace xmltooling; namespace xmltooling { - XMLTOOL_DLLLOCAL PluginManager::Factory FilesystemCredentialResolverFactory; + XMLTOOL_DLLLOCAL PluginManager::Factory FilesystemCredentialResolverFactory; + XMLTOOL_DLLLOCAL PluginManager::Factory DummyCredentialResolverFactory; XMLTOOL_DLLLOCAL PluginManager::Factory ChainingCredentialResolverFactory; }; @@ -38,6 +39,7 @@ void XMLTOOL_API xmltooling::registerCredentialResolvers() { XMLToolingConfig& conf=XMLToolingConfig::getConfig(); conf.CredentialResolverManager.registerFactory(FILESYSTEM_CREDENTIAL_RESOLVER, FilesystemCredentialResolverFactory); + conf.CredentialResolverManager.registerFactory(DUMMY_CREDENTIAL_RESOLVER, DummyCredentialResolverFactory); conf.CredentialResolverManager.registerFactory(CHAINING_CREDENTIAL_RESOLVER, ChainingCredentialResolverFactory); } diff --git a/xmltooling/security/impl/DummyCredentialResolver.cpp b/xmltooling/security/impl/DummyCredentialResolver.cpp new file mode 100644 index 0000000..8ce16bb --- /dev/null +++ b/xmltooling/security/impl/DummyCredentialResolver.cpp @@ -0,0 +1,63 @@ +/** + * Licensed to the University Corporation for Advanced Internet + * Development, Inc. (UCAID) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + * + * UCAID licenses this file to you 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. + */ + +/** + * DummyCredentialResolver.cpp + * + * CredentialResolver that returns nothing. + */ + +#include "internal.h" +#include "XMLToolingConfig.h" +#include "security/CredentialResolver.h" +#include "util/NDC.h" + +using namespace xmltooling; +using namespace std; + +using xercesc::DOMElement; + +namespace xmltooling { + + class XMLTOOL_DLLLOCAL DummyCredentialResolver : public CredentialResolver + { + public: + DummyCredentialResolver(const DOMElement*) {} + virtual ~DummyCredentialResolver() {} + + Lockable* lock() {return this;} + void unlock() {} + + const Credential* resolve(const CredentialCriteria* criteria=nullptr) const { + return nullptr; + } + vector::size_type resolve( + vector& results, const CredentialCriteria* criteria=nullptr + ) const { + return 0; + } + }; + + CredentialResolver* XMLTOOL_DLLLOCAL DummyCredentialResolverFactory(const DOMElement* const & e) + { + return new DummyCredentialResolver(e); + } + +}; diff --git a/xmltooling/xmltooling.vcxproj b/xmltooling/xmltooling.vcxproj index 9f352f9..2e204be 100644 --- a/xmltooling/xmltooling.vcxproj +++ b/xmltooling/xmltooling.vcxproj @@ -230,6 +230,7 @@ + diff --git a/xmltooling/xmltooling.vcxproj.filters b/xmltooling/xmltooling.vcxproj.filters index 987c007..c8c0c38 100644 --- a/xmltooling/xmltooling.vcxproj.filters +++ b/xmltooling/xmltooling.vcxproj.filters @@ -219,6 +219,9 @@ Source Files\security\impl + + Source Files\security\impl + Source Files\security\impl -- 2.1.4