Expose key resolver caching.
[shibboleth/cpp-xmltooling.git] / xmltooling / signature / impl / InlineKeyResolver.cpp
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