Expose key resolver caching.
authorScott Cantor <cantor.2@osu.edu>
Sun, 13 Aug 2006 03:16:48 +0000 (03:16 +0000)
committerScott Cantor <cantor.2@osu.edu>
Sun, 13 Aug 2006 03:16:48 +0000 (03:16 +0000)
xmltooling/Makefile.am
xmltooling/signature/CachingKeyResolver.h [new file with mode: 0644]
xmltooling/signature/impl/InlineKeyResolver.cpp
xmltooling/xmltooling.vcproj

index bd5c2d4..cf26b0a 100644 (file)
@@ -55,6 +55,7 @@ ioinclude_HEADERS = \
        io/AbstractXMLObjectUnmarshaller.h
 
 siginclude_HEADERS = \
+       signature/CachingKeyResolver.h \
        signature/ContentReference.h \
        signature/CredentialResolver.h \
        signature/KeyInfo.h \
diff --git a/xmltooling/signature/CachingKeyResolver.h b/xmltooling/signature/CachingKeyResolver.h
new file mode 100644 (file)
index 0000000..361a397
--- /dev/null
@@ -0,0 +1,45 @@
+/*\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
index c34db20..8a4ffcf 100644 (file)
@@ -21,7 +21,7 @@
  */\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
@@ -42,7 +42,7 @@ using namespace log4cpp;
 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
@@ -53,6 +53,14 @@ namespace xmlsignature {
         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
@@ -89,7 +97,7 @@ InlineKeyResolver::InlineKeyResolver(const DOMElement* e) : m_lock(NULL)
 \r
 InlineKeyResolver::~InlineKeyResolver()\r
 {\r
-    m_cache.clear();\r
+    clearCache();\r
     delete m_lock;\r
 }\r
 \r
index 9f6a1ff..9860bce 100644 (file)
                                Name="signature"\r
                                >\r
                                <File\r
+                                       RelativePath=".\signature\CachingKeyResolver.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath=".\signature\ContentReference.h"\r
                                        >\r
                                </File>\r