--- /dev/null
+/*\r
+ * Copyright 2001-2006 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
+ * @file xmltooling/signature/CachingKeyResolver.h\r
+ * \r
+ * A KeyResolver that caches content across method calls.\r
+ */\r
+\r
+#if !defined(__xmltooling_cachekeyres_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
+#define __xmltooling_cachekeyres_h__\r
+\r
+#include <xmltooling/signature/KeyResolver.h>\r
+\r
+namespace xmlsignature {\r
+\r
+ /**\r
+ * An API for resolving encrypted decryption keys.\r
+ */\r
+ class XMLTOOL_API CachingKeyResolver : public xmlsignature::KeyResolver {\r
+ public:\r
+ virtual ~CachingKeyResolver() {}\r
+ \r
+ /**\r
+ * Clears any cache state.\r
+ */\r
+ virtual void clearCache()=0;\r
+ };\r
+\r
+};\r
+\r
+#endif /* __xmltooling_cachekeyres_h__ */\r
*/\r
\r
#include "internal.h"\r
-#include "signature/KeyResolver.h"\r
+#include "signature/CachingKeyResolver.h"\r
#include "util/NDC.h"\r
#include "util/Threads.h"\r
\r
using namespace std;\r
\r
namespace xmlsignature {\r
- class XMLTOOL_DLLLOCAL InlineKeyResolver : public KeyResolver\r
+ class XMLTOOL_DLLLOCAL InlineKeyResolver : public CachingKeyResolver\r
{\r
public:\r
InlineKeyResolver(const DOMElement* e);\r
vector<XSECCryptoX509*>::size_type resolveCertificates(const KeyInfo* keyInfo, vector<XSECCryptoX509*>& certs) const;\r
vector<XSECCryptoX509*>::size_type resolveCertificates(DSIGKeyInfoList* keyInfo, vector<XSECCryptoX509*>& certs) const;\r
\r
+ void clearCache() {\r
+ if (m_lock)\r
+ m_lock->wrlock();\r
+ m_cache.clear();\r
+ if (m_lock)\r
+ m_lock->unlock();\r
+ }\r
+ \r
private:\r
struct XMLTOOL_DLLLOCAL CacheEntry {\r
CacheEntry() : m_key(NULL) {}\r
\r
InlineKeyResolver::~InlineKeyResolver()\r
{\r
- m_cache.clear();\r
+ clearCache();\r
delete m_lock;\r
}\r
\r