Moved ReplayCache into xmltooling
authorcantor <cantor@fb386ef7-a10c-0410-8ebf-fd3f8e989ab0>
Mon, 9 Oct 2006 16:42:41 +0000 (16:42 +0000)
committercantor <cantor@fb386ef7-a10c-0410-8ebf-fd3f8e989ab0>
Mon, 9 Oct 2006 16:42:41 +0000 (16:42 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-opensaml2/trunk@99 fb386ef7-a10c-0410-8ebf-fd3f8e989ab0

saml/Makefile.am
saml/SAMLConfig.cpp
saml/SAMLConfig.h
saml/binding/ReplayCache.h [deleted file]
saml/binding/impl/ReplayCache.cpp [deleted file]
saml/saml.vcproj
saml/saml1/binding/impl/SAML1ArtifactDecoder.cpp
saml/saml1/binding/impl/SAML1POSTDecoder.cpp
saml/saml2/binding/impl/SAML2POSTDecoder.cpp
samltest/samltest.h
samltest/samltest.vcproj

index ab119fb..c8e1d03 100644 (file)
@@ -34,7 +34,6 @@ samlbindinclude_HEADERS = \
        binding/ArtifactMap.h \
        binding/MessageDecoder.h \
        binding/MessageEncoder.h \
-       binding/ReplayCache.h \
        binding/SAMLArtifact.h \
        binding/URLEncoder.h
 
@@ -95,7 +94,6 @@ libsaml_la_SOURCES = \
        binding/impl/ArtifactMap.cpp \
        binding/impl/MessageDecoder.cpp \
        binding/impl/MessageEncoder.cpp \
-       binding/impl/ReplayCache.cpp \
        binding/impl/SAMLArtifact.cpp \
        binding/impl/URLEncoder.cpp \
        saml1/core/impl/AssertionsImpl.cpp \
index 4e4c7ce..709850e 100644 (file)
@@ -27,7 +27,6 @@
 #include "binding/ArtifactMap.h"
 #include "binding/MessageDecoder.h"
 #include "binding/MessageEncoder.h"
-#include "binding/ReplayCache.h"
 #include "binding/SAMLArtifact.h"
 #include "binding/URLEncoder.h"
 #include "saml1/core/Assertions.h"
@@ -98,12 +97,6 @@ void SAMLConfig::setURLEncoder(URLEncoder* urlEncoder)
     m_urlEncoder = urlEncoder;
 }
 
-void SAMLConfig::setReplayCache(ReplayCache* replayCache)
-{
-    delete m_replayCache;
-    m_replayCache = replayCache;
-}
-
 bool SAMLInternalConfig::init(bool initXMLTooling)
 {
 #ifdef _DEBUG
@@ -157,8 +150,6 @@ void SAMLInternalConfig::term(bool termXMLTooling)
     m_artifactMap = NULL;
     delete m_urlEncoder;
     m_urlEncoder = NULL;
-    delete m_replayCache;
-    m_replayCache = NULL;
 
     if (termXMLTooling) {
         XMLToolingConfig::getConfig().term();
index 8491d0f..6945ab4 100644 (file)
@@ -39,7 +39,6 @@ namespace opensaml {
     class SAML_API ArtifactMap;\r
     class SAML_API MessageEncoder;\r
     class SAML_API MessageDecoder;\r
-    class SAML_API ReplayCache;\r
     class SAML_API SAMLArtifact;\r
     class SAML_API TrustEngine;\r
     class SAML_API URLEncoder;\r
@@ -132,24 +131,6 @@ namespace opensaml {
         }\r
         \r
         /**\r
-         * Sets the global ReplayCache instance.\r
-         * This method must be externally synchronized with any code that uses the object.\r
-         * Any previously set object is destroyed.\r
-         * \r
-         * @param replayCache   new ReplayCache instance to store\r
-         */\r
-        void setReplayCache(ReplayCache* replayCache);\r
-\r
-        /**\r
-         * Returns the global ReplayCache instance.\r
-         * \r
-         * @return  global ReplayCache or NULL\r
-         */\r
-        ReplayCache* getReplayCache() const {\r
-            return m_replayCache;\r
-        }\r
-        \r
-        /**\r
          * Generate random information using the underlying security library\r
          * \r
          * @param buf   buffer for the information\r
@@ -214,16 +195,13 @@ namespace opensaml {
         xmltooling::PluginManager<saml2md::MetadataFilter,const DOMElement*> MetadataFilterManager;\r
 \r
     protected:\r
-        SAMLConfig() : m_artifactMap(NULL), m_urlEncoder(NULL), m_replayCache(NULL) {}\r
+        SAMLConfig() : m_artifactMap(NULL), m_urlEncoder(NULL) {}\r
         \r
         /** Global ArtifactMap instance for use by artifact-related functions. */\r
         ArtifactMap* m_artifactMap;\r
 \r
         /** Global URLEncoder instance for use by URL-related functions. */\r
         URLEncoder* m_urlEncoder;\r
-        \r
-        /** Global ReplayCache instance. */\r
-        ReplayCache* m_replayCache;\r
     };\r
 \r
 #if defined (_MSC_VER)\r
diff --git a/saml/binding/ReplayCache.h b/saml/binding/ReplayCache.h
deleted file mode 100644 (file)
index d5655fd..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*\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 saml/binding/ReplayCache.h\r
- * \r
- * Helper class on top of StorageService for detecting message replay.\r
- */\r
-\r
-#ifndef __saml_replay_h__\r
-#define __saml_replay_h__\r
-\r
-#include <saml/base.h>\r
-#include <xmltooling/util/StorageService.h>\r
-\r
-namespace opensaml {\r
-\r
-    /**\r
-     * Helper class on top of StorageService for detecting message replay.\r
-     */\r
-    class SAML_API ReplayCache\r
-    {\r
-        MAKE_NONCOPYABLE(ReplayCache);\r
-    public:\r
-        \r
-        /**\r
-         * Creates a replay cache on top of a particular StorageService.\r
-         * \r
-         * @param storage       pointer to a StorageService, or NULL to keep cache in memory\r
-         */\r
-        ReplayCache(xmltooling::StorageService* storage=NULL);\r
-\r
-        virtual ~ReplayCache();\r
-        \r
-        /**\r
-         * Returns true iff the check value is not found in the cache, and stores it.\r
-         * \r
-         * @param context   a context label to subdivide the cache\r
-         * @param s         value to check\r
-         * @param expires   time for disposal of value from cache\r
-         */\r
-        virtual bool check(const char* context, const char* s, time_t expires);\r
-    \r
-        bool check(const char* context, const XMLCh* str, time_t expires) {\r
-            xmltooling::auto_ptr_char temp(str);\r
-            return check(context, temp.get(), expires);\r
-        }\r
-        \r
-    private:\r
-        xmltooling::StorageService* m_storage;\r
-    };\r
-};\r
-\r
-#endif /* __saml_replay_h__ */\r
diff --git a/saml/binding/impl/ReplayCache.cpp b/saml/binding/impl/ReplayCache.cpp
deleted file mode 100644 (file)
index 5081bce..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  Copyright 2001-2006 Internet2
- * 
- * Licensed 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.
- */
-
-/**
- * ReplayCache.cpp
- * 
- * Helper class on top of StorageService for detecting message replay. 
- */
-
-#include "internal.h"
-#include "binding/ReplayCache.h"
-
-using namespace opensaml;
-using namespace xmltooling;
-using namespace std;
-
-ReplayCache::ReplayCache(StorageService* storage) : m_storage(storage)
-{
-    if (!m_storage)
-        m_storage = XMLToolingConfig::getConfig().StorageServiceManager.newPlugin(MEMORY_STORAGE_SERVICE, NULL);
-}
-
-ReplayCache::~ReplayCache()
-{
-    delete m_storage;
-}
-
-bool ReplayCache::check(const char* context, const char* s, time_t expires)
-{
-    // In storage already?
-    if (m_storage->readString(context, s))
-        return false;
-    m_storage->createText(context, s, "x", expires);
-    return true;
-}
index 1fe2f1c..25beeeb 100644 (file)
                                                >\r
                                        </File>\r
                                        <File\r
-                                               RelativePath=".\binding\impl\ReplayCache.cpp"\r
-                                               >\r
-                                       </File>\r
-                                       <File\r
                                                RelativePath=".\binding\impl\SAMLArtifact.cpp"\r
                                                >\r
                                        </File>\r
                                        >\r
                                </File>\r
                                <File\r
-                                       RelativePath=".\binding\ReplayCache.h"\r
-                                       >\r
-                               </File>\r
-                               <File\r
                                        RelativePath=".\binding\SAMLArtifact.h"\r
                                        >\r
                                </File>\r
index 2d1b23c..24b8423 100644 (file)
@@ -23,7 +23,6 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "saml/binding/SAMLArtifact.h"
-#include "saml/binding/ReplayCache.h"
 #include "saml1/binding/SAML1ArtifactDecoder.h"
 #include "saml2/metadata/Metadata.h"
 #include "saml2/metadata/MetadataProvider.h"
@@ -31,6 +30,7 @@
 
 #include <log4cpp/Category.hh>
 #include <xmltooling/util/NDC.h>
+#include <xmltooling/util/ReplayCache.h>
 
 using namespace opensaml::saml2md;
 using namespace opensaml::saml1p;
@@ -88,7 +88,7 @@ Response* SAML1ArtifactDecoder::decode(
             log.debug("processing encoded artifact (%s)", *raw);
             
             // Check replay.
-            ReplayCache* replayCache = SAMLConfig::getConfig().getReplayCache();
+            ReplayCache* replayCache = XMLToolingConfig::getConfig().getReplayCache();
             if (replayCache) {
                 if (!replayCache->check("SAML1Artifact", *raw, time(NULL) + (2*XMLToolingConfig::getConfig().clock_skew_secs))) {
                     log.error("replay detected of artifact (%s)", *raw);
index de0deaa..ee458ec 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "internal.h"
 #include "exceptions.h"
-#include "saml/binding/ReplayCache.h"
 #include "saml1/binding/SAML1POSTDecoder.h"
 #include "saml2/metadata/Metadata.h"
 #include "saml2/metadata/MetadataProvider.h"
@@ -31,6 +30,7 @@
 #include <log4cpp/Category.hh>
 #include <xercesc/util/Base64.hpp>
 #include <xmltooling/util/NDC.h>
+#include <xmltooling/util/ReplayCache.h>
 
 using namespace opensaml::saml2md;
 using namespace opensaml::saml1p;
@@ -121,7 +121,7 @@ Response* SAML1POSTDecoder::decode(
             throw BindingException("Detected expired POST profile response.");
         
         // Check replay.
-        ReplayCache* replayCache = SAMLConfig::getConfig().getReplayCache();
+        ReplayCache* replayCache = XMLToolingConfig::getConfig().getReplayCache();
         if (replayCache) {
             auto_ptr_char id(response->getResponseID());
             if (!replayCache->check("SAML1POST", id.get(), response->getIssueInstant()->getEpoch() + (2*XMLToolingConfig::getConfig().clock_skew_secs))) {
index 7fedc01..7da4411 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "internal.h"
 #include "exceptions.h"
-#include "saml/binding/ReplayCache.h"
 #include "saml2/binding/SAML2POSTDecoder.h"
 #include "saml2/core/Protocols.h"
 #include "saml2/metadata/Metadata.h"
@@ -32,6 +31,7 @@
 #include <log4cpp/Category.hh>
 #include <xercesc/util/Base64.hpp>
 #include <xmltooling/util/NDC.h>
+#include <xmltooling/util/ReplayCache.h>
 
 using namespace opensaml::saml2md;
 using namespace opensaml::saml2p;
@@ -149,7 +149,7 @@ XMLObject* SAML2POSTDecoder::decode(
             throw BindingException("Detected expired POST binding message.");
         
         // Check replay.
-        ReplayCache* replayCache = SAMLConfig::getConfig().getReplayCache();
+        ReplayCache* replayCache = XMLToolingConfig::getConfig().getReplayCache();
         if (replayCache) {
             auto_ptr_char id(xmlObject->getXMLID());
             if (!replayCache->check("SAML2POST", id.get(), response->getIssueInstant()->getEpoch() + (2*XMLToolingConfig::getConfig().clock_skew_secs))) {
index 741a9e0..2e6f5a5 100644 (file)
  */\r
 \r
 #include "internal.h"\r
-#include <saml/SAMLConfig.h>\r
-#include <saml/binding/ArtifactMap.h>\r
-#include <saml/binding/ReplayCache.h>\r
-\r
 #include <fstream>\r
 #include <cxxtest/GlobalFixture.h>\r
+#include <saml/SAMLConfig.h>\r
+#include <saml/binding/ArtifactMap.h>\r
+#include <xmltooling/util/ReplayCache.h>\r
 \r
 //#define SAML_LEAKCHECK\r
 \r
@@ -33,7 +32,7 @@ public:
         XMLToolingConfig::getConfig().log_config();\r
         if (!SAMLConfig::getConfig().init())\r
             return false;\r
-        SAMLConfig::getConfig().setReplayCache(new ReplayCache());\r
+        XMLToolingConfig::getConfig().setReplayCache(new ReplayCache());\r
         SAMLConfig::getConfig().setArtifactMap(new ArtifactMap());\r
 \r
         if (getenv("SAMLTEST_DATA"))\r
index 7f6e2c8..f8eea0c 100644 (file)
@@ -46,6 +46,7 @@
                                BasicRuntimeChecks="3"\r
                                RuntimeLibrary="3"\r
                                UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
                                WarningLevel="3"\r
                                Detect64BitPortabilityProblems="true"\r
                                DebugInformationFormat="4"\r
                                                        >\r
                                                        <Tool\r
                                                                Name="VCCustomBuildTool"\r
-                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;&#x0D;&#x0A;"\r
                                                                Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
                                                        />\r
                                                </FileConfiguration>\r
                                                        >\r
                                                        <Tool\r
                                                                Name="VCCustomBuildTool"\r
-                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;&#x0D;&#x0A;"\r
                                                                Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
                                                        />\r
                                                </FileConfiguration>\r
                                                        >\r
                                                        <Tool\r
                                                                Name="VCCustomBuildTool"\r
-                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;&#x0D;&#x0A;"\r
                                                                Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
                                                        />\r
                                                </FileConfiguration>\r
                                                        >\r
                                                        <Tool\r
                                                                Name="VCCustomBuildTool"\r
-                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;&#x0D;&#x0A;"\r
                                                                Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
                                                        />\r
                                                </FileConfiguration>\r
                                                        >\r
                                                        <Tool\r
                                                                Name="VCCustomBuildTool"\r
-                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;&#x0D;&#x0A;"\r
                                                                Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
                                                        />\r
                                                </FileConfiguration>\r
                                                        >\r
                                                        <Tool\r
                                                                Name="VCCustomBuildTool"\r
-                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;"\r
+                                                               CommandLine="\perl\bin\perl.exe -w \cxxtest\cxxtestgen.pl --part --have-eh --have-std --abort-on-fail -o &quot;$(InputDir)$(InputName)&quot;.cpp &quot;$(InputPath)&quot;&#x0D;&#x0A;"\r
                                                                Outputs="&quot;$(InputDir)$(InputName)&quot;.cpp"\r
                                                        />\r
                                                </FileConfiguration>\r